Home | History | Annotate | Line # | Download | only in pci
if_iwnreg.h revision 1.6.2.1
      1  1.6.2.1  uebayasi /*	$NetBSD: if_iwnreg.h,v 1.6.2.1 2010/04/30 14:43:35 uebayasi Exp $	*/
      2  1.6.2.1  uebayasi /*	$OpenBSD: if_iwnreg.h,v 1.38 2010/04/10 08:37:36 damien Exp $	*/
      3      1.1      ober 
      4      1.1      ober /*-
      5      1.6  christos  * Copyright (c) 2007, 2008
      6      1.1      ober  *	Damien Bergamini <damien.bergamini (at) free.fr>
      7      1.1      ober  *
      8      1.1      ober  * Permission to use, copy, modify, and distribute this software for any
      9      1.1      ober  * purpose with or without fee is hereby granted, provided that the above
     10      1.1      ober  * copyright notice and this permission notice appear in all copies.
     11      1.1      ober  *
     12      1.1      ober  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     13      1.1      ober  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     14      1.1      ober  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     15      1.1      ober  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     16      1.1      ober  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     17      1.1      ober  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     18      1.1      ober  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     19      1.1      ober  */
     20      1.1      ober 
     21  1.6.2.1  uebayasi /* XXX Added for NetBSD */
     22  1.6.2.1  uebayasi #define EDCA_NUM_AC		4
     23  1.6.2.1  uebayasi #define IEEE80211_TKIP_MICLEN	8
     24      1.6  christos 
     25      1.1      ober #define IWN_TX_RING_COUNT	256
     26      1.6  christos #define IWN_TX_RING_LOMARK	192
     27      1.6  christos #define IWN_TX_RING_HIMARK	224
     28  1.6.2.1  uebayasi #define IWN_RX_RING_COUNT_LOG	6
     29      1.6  christos #define IWN_RX_RING_COUNT	(1 << IWN_RX_RING_COUNT_LOG)
     30      1.6  christos 
     31      1.6  christos #define IWN4965_NTXQUEUES	16
     32      1.6  christos #define IWN5000_NTXQUEUES	20
     33  1.6.2.1  uebayasi 
     34  1.6.2.1  uebayasi #define IWN4965_NDMACHNLS	7
     35  1.6.2.1  uebayasi #define IWN5000_NDMACHNLS	8
     36  1.6.2.1  uebayasi 
     37  1.6.2.1  uebayasi #define IWN_SRVC_DMACHNL	9
     38  1.6.2.1  uebayasi 
     39  1.6.2.1  uebayasi #define IWN_ICT_SIZE		4096
     40  1.6.2.1  uebayasi #define IWN_ICT_COUNT		(IWN_ICT_SIZE / sizeof (uint32_t))
     41      1.1      ober 
     42      1.6  christos /* Maximum number of DMA segments for TX. */
     43      1.6  christos #define IWN_MAX_SCATTER	20
     44      1.1      ober 
     45      1.6  christos /* RX buffers must be large enough to hold a full 4K A-MPDU. */
     46      1.6  christos #define IWN_RBUF_SIZE	(4 * 1024)
     47      1.1      ober 
     48      1.6  christos #if defined(__LP64__)
     49      1.6  christos /* HW supports 36-bit DMA addresses. */
     50      1.6  christos #define IWN_LOADDR(paddr)	((uint32_t)(paddr))
     51      1.6  christos #define IWN_HIADDR(paddr)	(((paddr) >> 32) & 0xf)
     52      1.6  christos #else
     53      1.6  christos #define IWN_LOADDR(paddr)	(paddr)
     54      1.6  christos #define IWN_HIADDR(paddr)	(0)
     55      1.6  christos #endif
     56      1.1      ober 
     57      1.6  christos /* Base Address Register. */
     58      1.6  christos #define IWN_PCI_BAR0	PCI_MAPREG_START
     59      1.1      ober 
     60      1.1      ober /*
     61      1.1      ober  * Control and status registers.
     62      1.1      ober  */
     63      1.6  christos #define IWN_HW_IF_CONFIG	0x000
     64      1.6  christos #define IWN_INT_COALESCING	0x004
     65  1.6.2.1  uebayasi #define IWN_INT_PERIODIC	0x005	/* use IWN_WRITE_1 */
     66      1.6  christos #define IWN_INT			0x008
     67  1.6.2.1  uebayasi #define IWN_INT_MASK		0x00c
     68      1.6  christos #define IWN_FH_INT		0x010
     69      1.1      ober #define IWN_RESET		0x020
     70      1.6  christos #define IWN_GP_CNTRL		0x024
     71      1.6  christos #define IWN_HW_REV		0x028
     72      1.6  christos #define IWN_EEPROM		0x02c
     73      1.6  christos #define IWN_EEPROM_GP		0x030
     74  1.6.2.1  uebayasi #define IWN_OTP_GP		0x034
     75      1.6  christos #define IWN_GIO			0x03c
     76  1.6.2.1  uebayasi #define IWN_GP_DRIVER		0x050
     77      1.6  christos #define IWN_UCODE_GP1_CLR	0x05c
     78      1.6  christos #define IWN_LED			0x094
     79  1.6.2.1  uebayasi #define IWN_DRAM_INT_TBL	0x0a0
     80      1.6  christos #define IWN_GIO_CHICKEN		0x100
     81      1.6  christos #define IWN_ANA_PLL		0x20c
     82  1.6.2.1  uebayasi #define IWN_HW_REV_WA		0x22c
     83      1.6  christos #define IWN_DBG_HPET_MEM	0x240
     84  1.6.2.1  uebayasi #define IWN_DBG_LINK_PWR_MGMT	0x250
     85      1.6  christos #define IWN_MEM_RADDR		0x40c
     86      1.1      ober #define IWN_MEM_WADDR		0x410
     87      1.1      ober #define IWN_MEM_WDATA		0x418
     88      1.6  christos #define IWN_MEM_RDATA		0x41c
     89      1.6  christos #define IWN_PRPH_WADDR  	0x444
     90      1.6  christos #define IWN_PRPH_RADDR   	0x448
     91      1.6  christos #define IWN_PRPH_WDATA  	0x44c
     92      1.6  christos #define IWN_PRPH_RDATA   	0x450
     93      1.6  christos #define IWN_HBUS_TARG_WRPTR	0x460
     94      1.6  christos 
     95      1.6  christos /*
     96      1.6  christos  * Flow-Handler registers.
     97      1.6  christos  */
     98      1.6  christos #define IWN_FH_TFBD_CTRL0(qid)		(0x1900 + (qid) * 8)
     99      1.6  christos #define IWN_FH_TFBD_CTRL1(qid)		(0x1904 + (qid) * 8)
    100      1.6  christos #define IWN_FH_KW_ADDR			0x197c
    101      1.6  christos #define IWN_FH_SRAM_ADDR(qid)		(0x19a4 + (qid) * 4)
    102      1.6  christos #define IWN_FH_CBBC_QUEUE(qid)		(0x19d0 + (qid) * 4)
    103      1.6  christos #define IWN_FH_STATUS_WPTR		0x1bc0
    104      1.6  christos #define IWN_FH_RX_BASE			0x1bc4
    105      1.6  christos #define IWN_FH_RX_WPTR			0x1bc8
    106      1.6  christos #define IWN_FH_RX_CONFIG		0x1c00
    107      1.6  christos #define IWN_FH_RX_STATUS		0x1c44
    108      1.6  christos #define IWN_FH_TX_CONFIG(qid)		(0x1d00 + (qid) * 32)
    109      1.6  christos #define IWN_FH_TXBUF_STATUS(qid)	(0x1d08 + (qid) * 32)
    110      1.6  christos #define IWN_FH_TX_CHICKEN		0x1e98
    111      1.6  christos #define IWN_FH_TX_STATUS		0x1eb0
    112      1.6  christos 
    113      1.6  christos /*
    114      1.6  christos  * TX scheduler registers.
    115      1.6  christos  */
    116      1.6  christos #define IWN_SCHED_BASE			0xa02c00
    117      1.6  christos #define IWN_SCHED_SRAM_ADDR		(IWN_SCHED_BASE + 0x000)
    118      1.6  christos #define IWN5000_SCHED_DRAM_ADDR		(IWN_SCHED_BASE + 0x008)
    119      1.6  christos #define IWN4965_SCHED_DRAM_ADDR		(IWN_SCHED_BASE + 0x010)
    120      1.6  christos #define IWN5000_SCHED_TXFACT		(IWN_SCHED_BASE + 0x010)
    121      1.6  christos #define IWN4965_SCHED_TXFACT		(IWN_SCHED_BASE + 0x01c)
    122      1.6  christos #define IWN4965_SCHED_QUEUE_RDPTR(qid)	(IWN_SCHED_BASE + 0x064 + (qid) * 4)
    123      1.6  christos #define IWN5000_SCHED_QUEUE_RDPTR(qid)	(IWN_SCHED_BASE + 0x068 + (qid) * 4)
    124      1.6  christos #define IWN4965_SCHED_QCHAIN_SEL	(IWN_SCHED_BASE + 0x0d0)
    125      1.6  christos #define IWN4965_SCHED_INTR_MASK		(IWN_SCHED_BASE + 0x0e4)
    126      1.6  christos #define IWN5000_SCHED_QCHAIN_SEL	(IWN_SCHED_BASE + 0x0e8)
    127      1.6  christos #define IWN4965_SCHED_QUEUE_STATUS(qid)	(IWN_SCHED_BASE + 0x104 + (qid) * 4)
    128      1.6  christos #define IWN5000_SCHED_INTR_MASK		(IWN_SCHED_BASE + 0x108)
    129      1.6  christos #define IWN5000_SCHED_QUEUE_STATUS(qid)	(IWN_SCHED_BASE + 0x10c + (qid) * 4)
    130      1.6  christos #define IWN5000_SCHED_AGGR_SEL		(IWN_SCHED_BASE + 0x248)
    131      1.6  christos 
    132      1.6  christos /*
    133      1.6  christos  * Offsets in TX scheduler's SRAM.
    134      1.6  christos  */
    135      1.6  christos #define IWN4965_SCHED_CTX_OFF		0x380
    136      1.6  christos #define IWN4965_SCHED_CTX_LEN		416
    137      1.6  christos #define IWN4965_SCHED_QUEUE_OFFSET(qid)	(0x380 + (qid) * 8)
    138      1.6  christos #define IWN4965_SCHED_TRANS_TBL(qid)	(0x500 + (qid) * 2)
    139      1.6  christos #define IWN5000_SCHED_CTX_OFF		0x600
    140      1.6  christos #define IWN5000_SCHED_CTX_LEN		520
    141      1.6  christos #define IWN5000_SCHED_QUEUE_OFFSET(qid)	(0x600 + (qid) * 8)
    142      1.6  christos #define IWN5000_SCHED_TRANS_TBL(qid)	(0x7e0 + (qid) * 2)
    143      1.1      ober 
    144      1.1      ober /*
    145      1.1      ober  * NIC internal memory offsets.
    146      1.1      ober  */
    147  1.6.2.1  uebayasi #define IWN_APMG_CLK_CTRL	0x3000
    148  1.6.2.1  uebayasi #define IWN_APMG_CLK_EN		0x3004
    149      1.6  christos #define IWN_APMG_CLK_DIS	0x3008
    150      1.6  christos #define IWN_APMG_PS		0x300c
    151  1.6.2.1  uebayasi #define IWN_APMG_DIGITAL_SVR	0x3058
    152  1.6.2.1  uebayasi #define IWN_APMG_ANALOG_SVR	0x306c
    153      1.6  christos #define IWN_APMG_PCI_STT	0x3010
    154      1.6  christos #define IWN_BSM_WR_CTRL		0x3400
    155      1.6  christos #define IWN_BSM_WR_MEM_SRC	0x3404
    156      1.6  christos #define IWN_BSM_WR_MEM_DST	0x3408
    157      1.6  christos #define IWN_BSM_WR_DWCOUNT	0x340c
    158      1.6  christos #define IWN_BSM_DRAM_TEXT_ADDR	0x3490
    159      1.6  christos #define IWN_BSM_DRAM_TEXT_SIZE	0x3494
    160      1.6  christos #define IWN_BSM_DRAM_DATA_ADDR	0x3498
    161      1.6  christos #define IWN_BSM_DRAM_DATA_SIZE	0x349c
    162      1.6  christos #define IWN_BSM_SRAM_BASE	0x3800
    163      1.6  christos 
    164      1.6  christos /* Possible flags for register IWN_HW_IF_CONFIG. */
    165      1.6  christos #define IWN_HW_IF_CONFIG_4965_R		(1 <<  4)
    166      1.6  christos #define IWN_HW_IF_CONFIG_MAC_SI		(1 <<  8)
    167      1.6  christos #define IWN_HW_IF_CONFIG_RADIO_SI	(1 <<  9)
    168      1.6  christos #define IWN_HW_IF_CONFIG_EEPROM_LOCKED	(1 << 21)
    169  1.6.2.1  uebayasi #define IWN_HW_IF_CONFIG_NIC_READY	(1 << 22)
    170      1.6  christos #define IWN_HW_IF_CONFIG_HAP_WAKE_L1A	(1 << 23)
    171  1.6.2.1  uebayasi #define IWN_HW_IF_CONFIG_PREPARE_DONE	(1 << 25)
    172  1.6.2.1  uebayasi #define IWN_HW_IF_CONFIG_PREPARE	(1 << 27)
    173  1.6.2.1  uebayasi 
    174  1.6.2.1  uebayasi /* Possible values for register IWN_INT_PERIODIC. */
    175  1.6.2.1  uebayasi #define IWN_INT_PERIODIC_DIS	0x00
    176  1.6.2.1  uebayasi #define IWN_INT_PERIODIC_ENA	0xff
    177      1.6  christos 
    178      1.6  christos /* Possible flags for registers IWN_PRPH_RADDR/IWN_PRPH_WADDR. */
    179      1.6  christos #define IWN_PRPH_DWORD	((sizeof (uint32_t) - 1) << 24)
    180      1.6  christos 
    181      1.6  christos /* Possible values for IWN_BSM_WR_MEM_DST. */
    182      1.6  christos #define IWN_FW_TEXT_BASE	0x00000000
    183      1.6  christos #define IWN_FW_DATA_BASE	0x00800000
    184      1.6  christos 
    185      1.6  christos /* Possible flags for register IWN_RESET. */
    186      1.6  christos #define IWN_RESET_NEVO			(1 << 0)
    187      1.6  christos #define IWN_RESET_SW			(1 << 7)
    188      1.6  christos #define IWN_RESET_MASTER_DISABLED	(1 << 8)
    189      1.6  christos #define IWN_RESET_STOP_MASTER		(1 << 9)
    190  1.6.2.1  uebayasi #define IWN_RESET_LINK_PWR_MGMT_DIS	(1 << 31)
    191      1.6  christos 
    192      1.6  christos /* Possible flags for register IWN_GP_CNTRL. */
    193      1.6  christos #define IWN_GP_CNTRL_MAC_ACCESS_ENA	(1 << 0)
    194      1.6  christos #define IWN_GP_CNTRL_MAC_CLOCK_READY	(1 << 0)
    195      1.6  christos #define IWN_GP_CNTRL_INIT_DONE		(1 << 2)
    196      1.6  christos #define IWN_GP_CNTRL_MAC_ACCESS_REQ	(1 << 3)
    197      1.6  christos #define IWN_GP_CNTRL_SLEEP		(1 << 4)
    198      1.6  christos #define IWN_GP_CNTRL_RFKILL		(1 << 27)
    199      1.6  christos 
    200      1.6  christos /* Possible flags for register IWN_HW_REV. */
    201      1.6  christos #define IWN_HW_REV_TYPE_SHIFT	4
    202      1.6  christos #define IWN_HW_REV_TYPE_MASK	0x000000f0
    203      1.6  christos #define IWN_HW_REV_TYPE_4965	0
    204      1.6  christos #define IWN_HW_REV_TYPE_5300	2
    205      1.6  christos #define IWN_HW_REV_TYPE_5350	3
    206      1.6  christos #define IWN_HW_REV_TYPE_5150	4
    207      1.6  christos #define IWN_HW_REV_TYPE_5100	5
    208      1.6  christos #define IWN_HW_REV_TYPE_1000	6
    209      1.6  christos #define IWN_HW_REV_TYPE_6000	7
    210      1.6  christos #define IWN_HW_REV_TYPE_6050	8
    211  1.6.2.1  uebayasi #define IWN_HW_REV_TYPE_6005	11
    212      1.6  christos 
    213      1.6  christos /* Possible flags for register IWN_GIO_CHICKEN. */
    214      1.6  christos #define IWN_GIO_CHICKEN_L1A_NO_L0S_RX	(1 << 23)
    215      1.6  christos #define IWN_GIO_CHICKEN_DIS_L0S_TIMER	(1 << 29)
    216      1.6  christos 
    217      1.6  christos /* Possible flags for register IWN_GIO. */
    218      1.6  christos #define IWN_GIO_L0S_ENA		(1 << 1)
    219      1.6  christos 
    220  1.6.2.1  uebayasi /* Possible flags for register IWN_GP_DRIVER. */
    221  1.6.2.1  uebayasi #define IWN_GP_DRIVER_RADIO_3X3_HYB	(0 << 0)
    222  1.6.2.1  uebayasi #define IWN_GP_DRIVER_RADIO_2X2_HYB	(1 << 0)
    223  1.6.2.1  uebayasi #define IWN_GP_DRIVER_RADIO_2X2_IPA	(2 << 0)
    224  1.6.2.1  uebayasi #define IWN_GP_DRIVER_CALIB_VER6	(1 << 2)
    225  1.6.2.1  uebayasi 
    226      1.6  christos /* Possible flags for register IWN_UCODE_GP1_CLR. */
    227      1.6  christos #define IWN_UCODE_GP1_RFKILL		(1 << 1)
    228      1.6  christos #define IWN_UCODE_GP1_CMD_BLOCKED	(1 << 2)
    229      1.6  christos #define IWN_UCODE_GP1_CTEMP_STOP_RF	(1 << 3)
    230      1.6  christos 
    231      1.6  christos /* Possible flags/values for register IWN_LED. */
    232      1.6  christos #define IWN_LED_BSM_CTRL	(1 << 5)
    233      1.6  christos #define IWN_LED_OFF		0x00000038
    234      1.6  christos #define IWN_LED_ON		0x00000078
    235      1.6  christos 
    236  1.6.2.1  uebayasi /* Possible flags for register IWN_DRAM_INT_TBL. */
    237  1.6.2.1  uebayasi #define IWN_DRAM_INT_TBL_WRAP_CHECK	(1 << 27)
    238  1.6.2.1  uebayasi #define IWN_DRAM_INT_TBL_ENABLE		(1 << 31)
    239  1.6.2.1  uebayasi 
    240      1.6  christos /* Possible values for register IWN_ANA_PLL. */
    241      1.6  christos #define IWN_ANA_PLL_INIT	0x00880300
    242      1.6  christos 
    243      1.6  christos /* Possible flags for register IWN_FH_RX_STATUS. */
    244      1.6  christos #define	IWN_FH_RX_STATUS_IDLE	(1 << 24)
    245      1.6  christos 
    246      1.6  christos /* Possible flags for register IWN_BSM_WR_CTRL. */
    247      1.6  christos #define IWN_BSM_WR_CTRL_START_EN	(1 << 30)
    248      1.6  christos #define IWN_BSM_WR_CTRL_START		(1 << 31)
    249      1.6  christos 
    250      1.6  christos /* Possible flags for register IWN_INT. */
    251      1.6  christos #define IWN_INT_ALIVE		(1 <<  0)
    252      1.6  christos #define IWN_INT_WAKEUP		(1 <<  1)
    253      1.6  christos #define IWN_INT_SW_RX		(1 <<  3)
    254      1.6  christos #define IWN_INT_CT_REACHED	(1 <<  6)
    255      1.6  christos #define IWN_INT_RF_TOGGLED	(1 <<  7)
    256      1.6  christos #define IWN_INT_SW_ERR		(1 << 25)
    257  1.6.2.1  uebayasi #define IWN_INT_SCHED		(1 << 26)
    258      1.6  christos #define IWN_INT_FH_TX		(1 << 27)
    259  1.6.2.1  uebayasi #define IWN_INT_RX_PERIODIC	(1 << 28)
    260      1.6  christos #define IWN_INT_HW_ERR		(1 << 29)
    261      1.6  christos #define IWN_INT_FH_RX		(1 << 31)
    262      1.6  christos 
    263      1.6  christos /* Shortcut. */
    264  1.6.2.1  uebayasi #define IWN_INT_MASK_DEF						\
    265      1.6  christos 	(IWN_INT_SW_ERR | IWN_INT_HW_ERR | IWN_INT_FH_TX |		\
    266      1.6  christos 	 IWN_INT_FH_RX | IWN_INT_ALIVE | IWN_INT_WAKEUP |		\
    267      1.6  christos 	 IWN_INT_SW_RX | IWN_INT_CT_REACHED | IWN_INT_RF_TOGGLED)
    268      1.6  christos 
    269      1.6  christos /* Possible flags for register IWN_FH_INT. */
    270      1.6  christos #define IWN_FH_INT_TX_CHNL(x)	(1 << (x))
    271      1.6  christos #define IWN_FH_INT_RX_CHNL(x)	(1 << ((x) + 16))
    272      1.6  christos #define IWN_FH_INT_HI_PRIOR	(1 << 30)
    273      1.6  christos /* Shortcuts for the above. */
    274      1.6  christos #define IWN_FH_INT_TX							\
    275      1.6  christos 	(IWN_FH_INT_TX_CHNL(0) | IWN_FH_INT_TX_CHNL(1))
    276      1.6  christos #define IWN_FH_INT_RX							\
    277      1.6  christos 	(IWN_FH_INT_RX_CHNL(0) | IWN_FH_INT_RX_CHNL(1) | IWN_FH_INT_HI_PRIOR)
    278      1.6  christos 
    279      1.6  christos /* Possible flags/values for register IWN_FH_TX_CONFIG. */
    280      1.6  christos #define IWN_FH_TX_CONFIG_DMA_PAUSE		0
    281      1.6  christos #define IWN_FH_TX_CONFIG_DMA_ENA		(1 << 31)
    282      1.6  christos #define IWN_FH_TX_CONFIG_CIRQ_HOST_ENDTFD	(1 << 20)
    283      1.6  christos 
    284      1.6  christos /* Possible flags/values for register IWN_FH_TXBUF_STATUS. */
    285      1.6  christos #define IWN_FH_TXBUF_STATUS_TBNUM(x)	((x) << 20)
    286      1.6  christos #define IWN_FH_TXBUF_STATUS_TBIDX(x)	((x) << 12)
    287      1.6  christos #define IWN_FH_TXBUF_STATUS_TFBD_VALID	3
    288      1.6  christos 
    289      1.6  christos /* Possible flags for register IWN_FH_TX_CHICKEN. */
    290      1.6  christos #define IWN_FH_TX_CHICKEN_SCHED_RETRY	(1 << 1)
    291      1.6  christos 
    292      1.6  christos /* Possible flags for register IWN_FH_TX_STATUS. */
    293      1.6  christos #define IWN_FH_TX_STATUS_IDLE(chnl)					\
    294      1.6  christos 	(1 << ((chnl) + 24) | 1 << ((chnl) + 16))
    295      1.6  christos 
    296      1.6  christos /* Possible flags for register IWN_FH_RX_CONFIG. */
    297      1.6  christos #define IWN_FH_RX_CONFIG_ENA		(1 << 31)
    298      1.6  christos #define IWN_FH_RX_CONFIG_NRBD(x)	((x) << 20)
    299      1.6  christos #define IWN_FH_RX_CONFIG_RB_SIZE_8K	(1 << 16)
    300      1.6  christos #define IWN_FH_RX_CONFIG_SINGLE_FRAME	(1 << 15)
    301      1.6  christos #define IWN_FH_RX_CONFIG_IRQ_DST_HOST	(1 << 12)
    302      1.6  christos #define IWN_FH_RX_CONFIG_RB_TIMEOUT(x)	((x) << 4)
    303      1.6  christos #define IWN_FH_RX_CONFIG_IGN_RXF_EMPTY	(1 <<  2)
    304      1.6  christos 
    305      1.6  christos /* Possible flags for register IWN_FH_TX_CONFIG. */
    306      1.6  christos #define IWN_FH_TX_CONFIG_DMA_ENA	(1 << 31)
    307      1.6  christos #define IWN_FH_TX_CONFIG_DMA_CREDIT_ENA	(1 <<  3)
    308      1.1      ober 
    309      1.6  christos /* Possible flags for register IWN_EEPROM. */
    310      1.6  christos #define IWN_EEPROM_READ_VALID	(1 << 0)
    311      1.1      ober #define IWN_EEPROM_CMD		(1 << 1)
    312      1.1      ober 
    313  1.6.2.1  uebayasi /* Possible flags for register IWN_EEPROM_GP. */
    314  1.6.2.1  uebayasi #define IWN_EEPROM_GP_IF_OWNER	0x00000180
    315  1.6.2.1  uebayasi 
    316  1.6.2.1  uebayasi /* Possible flags for register IWN_OTP_GP. */
    317  1.6.2.1  uebayasi #define IWN_OTP_GP_DEV_SEL_OTP		(1 << 16)
    318  1.6.2.1  uebayasi #define IWN_OTP_GP_RELATIVE_ACCESS	(1 << 17)
    319  1.6.2.1  uebayasi #define IWN_OTP_GP_ECC_CORR_STTS	(1 << 20)
    320  1.6.2.1  uebayasi #define IWN_OTP_GP_ECC_UNCORR_STTS	(1 << 21)
    321  1.6.2.1  uebayasi 
    322      1.6  christos /* Possible flags for register IWN_SCHED_QUEUE_STATUS. */
    323      1.6  christos #define IWN4965_TXQ_STATUS_ACTIVE	0x0007fc01
    324      1.6  christos #define IWN4965_TXQ_STATUS_INACTIVE	0x0007fc00
    325      1.6  christos #define IWN4965_TXQ_STATUS_AGGR_ENA	(1 << 5 | 1 << 8)
    326      1.6  christos #define IWN4965_TXQ_STATUS_CHGACT	(1 << 10)
    327      1.6  christos #define IWN5000_TXQ_STATUS_ACTIVE	0x00ff0018
    328      1.6  christos #define IWN5000_TXQ_STATUS_INACTIVE	0x00ff0010
    329      1.6  christos #define IWN5000_TXQ_STATUS_CHGACT	(1 << 19)
    330      1.6  christos 
    331  1.6.2.1  uebayasi /* Possible flags for registers IWN_APMG_CLK_*. */
    332      1.6  christos #define IWN_APMG_CLK_CTRL_DMA_CLK_RQT	(1 <<  9)
    333      1.6  christos #define IWN_APMG_CLK_CTRL_BSM_CLK_RQT	(1 << 11)
    334      1.6  christos 
    335      1.6  christos /* Possible flags for register IWN_APMG_PS. */
    336      1.6  christos #define IWN_APMG_PS_EARLY_PWROFF_DIS	(1 << 22)
    337      1.6  christos #define IWN_APMG_PS_PWR_SRC(x)		((x) << 24)
    338      1.6  christos #define IWN_APMG_PS_PWR_SRC_VMAIN	0
    339  1.6.2.1  uebayasi #define IWN_APMG_PS_PWR_SRC_VAUX	2
    340  1.6.2.1  uebayasi #define IWN_APMG_PS_PWR_SRC_MASK	IWN_APMG_PS_PWR_SRC(3)
    341  1.6.2.1  uebayasi #define IWN_APMG_PS_RESET_REQ		(1 << 26)
    342  1.6.2.1  uebayasi 
    343  1.6.2.1  uebayasi /* Possible flags for register IWN_APMG_DIGITAL_SVR. */
    344  1.6.2.1  uebayasi #define IWN_APMG_DIGITAL_SVR_VOLTAGE(x)		(((x) & 0xf) << 5)
    345  1.6.2.1  uebayasi #define IWN_APMG_DIGITAL_SVR_VOLTAGE_MASK	\
    346  1.6.2.1  uebayasi 	IWN_APMG_DIGITAL_SVR_VOLTAGE(0xf)
    347  1.6.2.1  uebayasi #define IWN_APMG_DIGITAL_SVR_VOLTAGE_1_32	\
    348  1.6.2.1  uebayasi 	IWN_APMG_DIGITAL_SVR_VOLTAGE(3)
    349      1.1      ober 
    350      1.6  christos /* Possible flags for IWN_APMG_PCI_STT. */
    351      1.6  christos #define IWN_APMG_PCI_STT_L1A_DIS	(1 << 11)
    352      1.1      ober 
    353      1.6  christos /* Possible flags for register IWN_BSM_DRAM_TEXT_SIZE. */
    354      1.1      ober #define IWN_FW_UPDATED	(1 << 31)
    355      1.1      ober 
    356      1.6  christos #define IWN_SCHED_WINSZ		64
    357      1.6  christos #define IWN_SCHED_LIMIT		64
    358      1.6  christos #define IWN4965_SCHED_COUNT	512
    359      1.6  christos #define IWN5000_SCHED_COUNT	(IWN_TX_RING_COUNT + IWN_SCHED_WINSZ)
    360      1.6  christos #define IWN4965_SCHEDSZ		(IWN4965_NTXQUEUES * IWN4965_SCHED_COUNT * 2)
    361      1.6  christos #define IWN5000_SCHEDSZ		(IWN5000_NTXQUEUES * IWN5000_SCHED_COUNT * 2)
    362      1.1      ober 
    363      1.6  christos struct iwn_tx_desc {
    364      1.6  christos 	uint8_t		reserved1[3];
    365      1.6  christos 	uint8_t		nsegs;
    366      1.6  christos 	struct {
    367      1.6  christos 		uint32_t	addr;
    368      1.6  christos 		uint16_t	len;
    369      1.6  christos 	} __packed	segs[IWN_MAX_SCATTER];
    370      1.6  christos 	/* Pad to 128 bytes. */
    371      1.6  christos 	uint32_t	reserved2;
    372      1.6  christos } __packed;
    373      1.1      ober 
    374      1.6  christos struct iwn_rx_status {
    375      1.1      ober 	uint16_t	closed_count;
    376      1.1      ober 	uint16_t	closed_rx_count;
    377      1.1      ober 	uint16_t	finished_count;
    378      1.1      ober 	uint16_t	finished_rx_count;
    379      1.1      ober 	uint32_t	reserved[2];
    380      1.1      ober } __packed;
    381      1.1      ober 
    382      1.1      ober struct iwn_rx_desc {
    383      1.1      ober 	uint32_t	len;
    384      1.1      ober 	uint8_t		type;
    385      1.6  christos #define IWN_UC_READY			  1
    386      1.6  christos #define IWN_ADD_NODE_DONE		 24
    387      1.6  christos #define IWN_TX_DONE			 28
    388      1.6  christos #define IWN5000_CALIBRATION_RESULT	102
    389      1.6  christos #define IWN5000_CALIBRATION_DONE	103
    390      1.6  christos #define IWN_START_SCAN			130
    391      1.6  christos #define IWN_STOP_SCAN			132
    392      1.6  christos #define IWN_RX_STATISTICS		156
    393      1.6  christos #define IWN_BEACON_STATISTICS		157
    394      1.6  christos #define IWN_STATE_CHANGED		161
    395      1.6  christos #define IWN_BEACON_MISSED		162
    396      1.6  christos #define IWN_RX_PHY			192
    397      1.6  christos #define IWN_MPDU_RX_DONE		193
    398      1.6  christos #define IWN_RX_DONE			195
    399  1.6.2.1  uebayasi #define IWN_RX_COMPRESSED_BA		197
    400      1.1      ober 
    401      1.1      ober 	uint8_t		flags;
    402      1.1      ober 	uint8_t		idx;
    403      1.1      ober 	uint8_t		qid;
    404      1.1      ober } __packed;
    405      1.1      ober 
    406      1.6  christos /* Possible RX status flags. */
    407      1.6  christos #define IWN_RX_NO_CRC_ERR	(1 <<  0)
    408      1.6  christos #define IWN_RX_NO_OVFL_ERR	(1 <<  1)
    409      1.6  christos /* Shortcut for the above. */
    410      1.1      ober #define IWN_RX_NOERROR	(IWN_RX_NO_CRC_ERR | IWN_RX_NO_OVFL_ERR)
    411      1.6  christos #define IWN_RX_MPDU_MIC_OK	(1 <<  6)
    412      1.6  christos #define IWN_RX_CIPHER_MASK	(7 <<  8)
    413      1.6  christos #define IWN_RX_CIPHER_CCMP	(2 <<  8)
    414      1.6  christos #define IWN_RX_MPDU_DEC		(1 << 11)
    415      1.6  christos #define IWN_RX_DECRYPT_MASK	(3 << 11)
    416      1.6  christos #define IWN_RX_DECRYPT_OK	(3 << 11)
    417      1.1      ober 
    418      1.1      ober struct iwn_tx_cmd {
    419      1.1      ober 	uint8_t	code;
    420  1.6.2.1  uebayasi #define IWN_CMD_RXON			 16
    421  1.6.2.1  uebayasi #define IWN_CMD_RXON_ASSOC		 17
    422      1.6  christos #define IWN_CMD_EDCA_PARAMS		 19
    423      1.6  christos #define IWN_CMD_TIMING			 20
    424      1.1      ober #define IWN_CMD_ADD_NODE		 24
    425      1.1      ober #define IWN_CMD_TX_DATA			 28
    426      1.6  christos #define IWN_CMD_LINK_QUALITY		 78
    427      1.1      ober #define IWN_CMD_SET_LED			 72
    428      1.6  christos #define IWN5000_CMD_WIMAX_COEX		 90
    429      1.6  christos #define IWN5000_CMD_CALIB_CONFIG	101
    430      1.1      ober #define IWN_CMD_SET_POWER_MODE		119
    431      1.1      ober #define IWN_CMD_SCAN			128
    432  1.6.2.1  uebayasi #define IWN_CMD_TXPOWER_DBM		149
    433      1.1      ober #define IWN_CMD_TXPOWER			151
    434  1.6.2.1  uebayasi #define IWN5000_CMD_TX_ANT_CONFIG	152
    435      1.6  christos #define IWN_CMD_BT_COEX			155
    436      1.1      ober #define IWN_CMD_GET_STATISTICS		156
    437      1.1      ober #define IWN_CMD_SET_CRITICAL_TEMP	164
    438      1.6  christos #define IWN_CMD_SET_SENSITIVITY		168
    439      1.6  christos #define IWN_CMD_PHY_CALIB		176
    440      1.1      ober 
    441      1.1      ober 	uint8_t	flags;
    442      1.1      ober 	uint8_t	idx;
    443      1.1      ober 	uint8_t	qid;
    444      1.1      ober 	uint8_t	data[136];
    445      1.1      ober } __packed;
    446      1.1      ober 
    447      1.6  christos /* Antenna flags, used in various commands. */
    448      1.6  christos #define IWN_ANT_A	(1 << 0)
    449      1.6  christos #define IWN_ANT_B	(1 << 1)
    450      1.6  christos #define IWN_ANT_C	(1 << 2)
    451  1.6.2.1  uebayasi /* Shortcuts. */
    452  1.6.2.1  uebayasi #define IWN_ANT_AB	(IWN_ANT_A | IWN_ANT_B)
    453  1.6.2.1  uebayasi #define IWN_ANT_BC	(IWN_ANT_B | IWN_ANT_C)
    454      1.6  christos #define IWN_ANT_ABC	(IWN_ANT_A | IWN_ANT_B | IWN_ANT_C)
    455      1.6  christos 
    456  1.6.2.1  uebayasi /* Structure for command IWN_CMD_RXON. */
    457      1.6  christos struct iwn_rxon {
    458      1.1      ober 	uint8_t		myaddr[IEEE80211_ADDR_LEN];
    459      1.1      ober 	uint16_t	reserved1;
    460      1.1      ober 	uint8_t		bssid[IEEE80211_ADDR_LEN];
    461      1.1      ober 	uint16_t	reserved2;
    462      1.1      ober 	uint8_t		wlap[IEEE80211_ADDR_LEN];
    463      1.1      ober 	uint16_t	reserved3;
    464      1.1      ober 	uint8_t		mode;
    465      1.1      ober #define IWN_MODE_HOSTAP		1
    466      1.1      ober #define IWN_MODE_STA		3
    467      1.1      ober #define IWN_MODE_IBSS		4
    468      1.1      ober #define IWN_MODE_MONITOR	6
    469      1.1      ober 
    470      1.6  christos 	uint8_t		air;
    471      1.1      ober 	uint16_t	rxchain;
    472  1.6.2.1  uebayasi #define IWN_RXCHAIN_DRIVER_FORCE	(1 << 0)
    473  1.6.2.1  uebayasi #define IWN_RXCHAIN_VALID(x)		(((x) & IWN_ANT_ABC) << 1)
    474  1.6.2.1  uebayasi #define IWN_RXCHAIN_FORCE_SEL(x)	(((x) & IWN_ANT_ABC) << 4)
    475  1.6.2.1  uebayasi #define IWN_RXCHAIN_FORCE_MIMO_SEL(x)	(((x) & IWN_ANT_ABC) << 7)
    476      1.6  christos #define IWN_RXCHAIN_IDLE_COUNT(x)	((x) << 10)
    477      1.6  christos #define IWN_RXCHAIN_MIMO_COUNT(x)	((x) << 12)
    478      1.6  christos #define IWN_RXCHAIN_MIMO_FORCE		(1 << 14)
    479      1.1      ober 
    480      1.1      ober 	uint8_t		ofdm_mask;
    481      1.1      ober 	uint8_t		cck_mask;
    482      1.1      ober 	uint16_t	associd;
    483      1.1      ober 	uint32_t	flags;
    484  1.6.2.1  uebayasi #define IWN_RXON_24GHZ		(1 <<  0)
    485      1.6  christos #define IWN_RXON_CCK		(1 <<  1)
    486      1.6  christos #define IWN_RXON_AUTO		(1 <<  2)
    487      1.6  christos #define IWN_RXON_SHSLOT		(1 <<  4)
    488      1.6  christos #define IWN_RXON_SHPREAMBLE	(1 <<  5)
    489      1.6  christos #define IWN_RXON_NODIVERSITY	(1 <<  7)
    490      1.6  christos #define IWN_RXON_ANTENNA_A	(1 <<  8)
    491      1.6  christos #define IWN_RXON_ANTENNA_B	(1 <<  9)
    492      1.6  christos #define IWN_RXON_TSF		(1 << 15)
    493      1.6  christos #define IWN_RXON_CTS_TO_SELF	(1 << 30)
    494      1.1      ober 
    495      1.1      ober 	uint32_t	filter;
    496      1.1      ober #define IWN_FILTER_PROMISC	(1 << 0)
    497      1.1      ober #define IWN_FILTER_CTL		(1 << 1)
    498      1.1      ober #define IWN_FILTER_MULTICAST	(1 << 2)
    499      1.1      ober #define IWN_FILTER_NODECRYPT	(1 << 3)
    500      1.1      ober #define IWN_FILTER_BSS		(1 << 5)
    501      1.6  christos #define IWN_FILTER_BEACON	(1 << 6)
    502      1.1      ober 
    503      1.6  christos 	uint8_t		chan;
    504      1.6  christos 	uint8_t		reserved4;
    505      1.1      ober 	uint8_t		ht_single_mask;
    506      1.1      ober 	uint8_t		ht_dual_mask;
    507  1.6.2.1  uebayasi 	/* The following fields are for >=5000 Series only. */
    508      1.6  christos 	uint8_t		ht_triple_mask;
    509      1.6  christos 	uint8_t		reserved5;
    510      1.6  christos 	uint16_t	acquisition;
    511      1.6  christos 	uint16_t	reserved6;
    512      1.1      ober } __packed;
    513      1.1      ober 
    514      1.6  christos #define IWN4965_RXONSZ	(sizeof (struct iwn_rxon) - 6)
    515      1.6  christos #define IWN5000_RXONSZ	(sizeof (struct iwn_rxon))
    516      1.6  christos 
    517      1.6  christos /* Structure for command IWN_CMD_ASSOCIATE. */
    518      1.1      ober struct iwn_assoc {
    519      1.1      ober 	uint32_t	flags;
    520      1.1      ober 	uint32_t	filter;
    521      1.1      ober 	uint8_t		ofdm_mask;
    522      1.1      ober 	uint8_t		cck_mask;
    523      1.1      ober 	uint16_t	reserved;
    524      1.1      ober } __packed;
    525      1.1      ober 
    526      1.6  christos /* Structure for command IWN_CMD_EDCA_PARAMS. */
    527      1.6  christos struct iwn_edca_params {
    528      1.1      ober 	uint32_t	flags;
    529      1.1      ober #define IWN_EDCA_UPDATE	(1 << 0)
    530      1.1      ober #define IWN_EDCA_TXOP	(1 << 4)
    531      1.1      ober 
    532      1.1      ober 	struct {
    533      1.1      ober 		uint16_t	cwmin;
    534      1.1      ober 		uint16_t	cwmax;
    535      1.1      ober 		uint8_t		aifsn;
    536      1.1      ober 		uint8_t		reserved;
    537      1.6  christos 		uint16_t	txoplimit;
    538  1.6.2.1  uebayasi 	} __packed	ac[EDCA_NUM_AC];
    539      1.1      ober } __packed;
    540      1.1      ober 
    541      1.6  christos /* Structure for command IWN_CMD_TIMING. */
    542      1.6  christos struct iwn_cmd_timing {
    543      1.1      ober 	uint64_t	tstamp;
    544      1.1      ober 	uint16_t	bintval;
    545      1.1      ober 	uint16_t	atim;
    546      1.1      ober 	uint32_t	binitval;
    547      1.1      ober 	uint16_t	lintval;
    548      1.1      ober 	uint16_t	reserved;
    549      1.1      ober } __packed;
    550      1.1      ober 
    551      1.6  christos /* Structure for command IWN_CMD_ADD_NODE. */
    552      1.1      ober struct iwn_node_info {
    553      1.1      ober 	uint8_t		control;
    554      1.1      ober #define IWN_NODE_UPDATE		(1 << 0)
    555      1.1      ober 
    556      1.1      ober 	uint8_t		reserved1[3];
    557      1.6  christos 
    558      1.1      ober 	uint8_t		macaddr[IEEE80211_ADDR_LEN];
    559      1.1      ober 	uint16_t	reserved2;
    560      1.1      ober 	uint8_t		id;
    561      1.1      ober #define IWN_ID_BSS		 0
    562      1.6  christos #define IWN5000_ID_BROADCAST	15
    563      1.6  christos #define IWN4965_ID_BROADCAST	31
    564      1.1      ober 
    565      1.1      ober 	uint8_t		flags;
    566      1.6  christos #define IWN_FLAG_SET_KEY		(1 << 0)
    567      1.6  christos #define IWN_FLAG_SET_DISABLE_TID	(1 << 1)
    568      1.6  christos #define IWN_FLAG_SET_TXRATE		(1 << 2)
    569      1.6  christos #define IWN_FLAG_SET_ADDBA		(1 << 3)
    570      1.6  christos #define IWN_FLAG_SET_DELBA		(1 << 4)
    571      1.1      ober 
    572      1.1      ober 	uint16_t	reserved3;
    573      1.6  christos 	uint16_t	kflags;
    574      1.6  christos #define IWN_KFLAG_CCMP		(1 <<  1)
    575      1.6  christos #define IWN_KFLAG_MAP		(1 <<  3)
    576      1.6  christos #define IWN_KFLAG_KID(kid)	((kid) << 8)
    577      1.6  christos #define IWN_KFLAG_INVALID	(1 << 11)
    578      1.6  christos #define IWN_KFLAG_GROUP		(1 << 14)
    579      1.6  christos 
    580      1.1      ober 	uint8_t		tsc2;	/* TKIP TSC2 */
    581      1.1      ober 	uint8_t		reserved4;
    582      1.1      ober 	uint16_t	ttak[5];
    583      1.6  christos 	uint8_t		kid;
    584      1.6  christos 	uint8_t		reserved5;
    585      1.6  christos 	uint8_t		key[16];
    586      1.6  christos 	/* The following 3 fields are for 5000 Series only. */
    587      1.6  christos 	uint64_t	tsc;
    588  1.6.2.1  uebayasi 	uint8_t		rxmic[IEEE80211_TKIP_MICLEN];
    589  1.6.2.1  uebayasi 	uint8_t		txmic[IEEE80211_TKIP_MICLEN];
    590      1.6  christos 
    591      1.1      ober 	uint32_t	htflags;
    592      1.6  christos #define IWN_AMDPU_SIZE_FACTOR(x)	((x) << 19)
    593      1.6  christos #define IWN_AMDPU_DENSITY(x)		((x) << 23)
    594      1.1      ober 
    595      1.1      ober 	uint32_t	mask;
    596      1.6  christos 	uint16_t	disable_tid;
    597      1.6  christos 	uint16_t	reserved6;
    598      1.6  christos 	uint8_t		addba_tid;
    599      1.6  christos 	uint8_t		delba_tid;
    600      1.6  christos 	uint16_t	addba_ssn;
    601      1.6  christos 	uint32_t	reserved7;
    602      1.6  christos } __packed;
    603      1.1      ober 
    604      1.6  christos struct iwn4965_node_info {
    605      1.6  christos 	uint8_t		control;
    606      1.6  christos 	uint8_t		reserved1[3];
    607      1.6  christos 	uint8_t		macaddr[IEEE80211_ADDR_LEN];
    608      1.6  christos 	uint16_t	reserved2;
    609      1.6  christos 	uint8_t		id;
    610      1.6  christos 	uint8_t		flags;
    611      1.6  christos 	uint16_t	reserved3;
    612      1.6  christos 	uint16_t	kflags;
    613      1.6  christos 	uint8_t		tsc2;	/* TKIP TSC2 */
    614      1.6  christos 	uint8_t		reserved4;
    615      1.6  christos 	uint16_t	ttak[5];
    616      1.6  christos 	uint8_t		kid;
    617      1.6  christos 	uint8_t		reserved5;
    618      1.6  christos 	uint8_t		key[16];
    619      1.6  christos 	uint32_t	htflags;
    620      1.6  christos 	uint32_t	mask;
    621      1.6  christos 	uint16_t	disable_tid;
    622      1.6  christos 	uint16_t	reserved6;
    623      1.6  christos 	uint8_t		addba_tid;
    624      1.6  christos 	uint8_t		delba_tid;
    625      1.6  christos 	uint16_t	addba_ssn;
    626      1.6  christos 	uint32_t	reserved7;
    627      1.1      ober } __packed;
    628      1.1      ober 
    629      1.6  christos #define IWN_RFLAG_CCK		(1 << 1)
    630      1.6  christos #define IWN_RFLAG_ANT(x)	((x) << 6)
    631      1.6  christos 
    632      1.6  christos /* Structure for command IWN_CMD_TX_DATA. */
    633      1.1      ober struct iwn_cmd_data {
    634      1.1      ober 	uint16_t	len;
    635      1.1      ober 	uint16_t	lnext;
    636      1.1      ober 	uint32_t	flags;
    637      1.6  christos #define IWN_TX_NEED_PROTECTION	(1 <<  0)	/* 5000 only */
    638      1.1      ober #define IWN_TX_NEED_RTS		(1 <<  1)
    639      1.1      ober #define IWN_TX_NEED_CTS		(1 <<  2)
    640      1.1      ober #define IWN_TX_NEED_ACK		(1 <<  3)
    641      1.6  christos #define IWN_TX_LINKQ		(1 <<  4)
    642      1.6  christos #define IWN_TX_IMM_BA		(1 <<  6)
    643      1.1      ober #define IWN_TX_FULL_TXOP	(1 <<  7)
    644      1.1      ober #define IWN_TX_BT_DISABLE	(1 << 12)	/* bluetooth coexistence */
    645      1.1      ober #define IWN_TX_AUTO_SEQ		(1 << 13)
    646      1.6  christos #define IWN_TX_MORE_FRAG	(1 << 14)
    647      1.1      ober #define IWN_TX_INSERT_TSTAMP	(1 << 16)
    648      1.1      ober #define IWN_TX_NEED_PADDING	(1 << 20)
    649      1.1      ober 
    650      1.6  christos 	uint32_t	scratch;
    651      1.6  christos 	uint8_t		plcp;
    652      1.1      ober 	uint8_t		rflags;
    653      1.1      ober 	uint16_t	xrflags;
    654      1.6  christos 
    655      1.1      ober 	uint8_t		id;
    656      1.1      ober 	uint8_t		security;
    657      1.1      ober #define IWN_CIPHER_WEP40	1
    658      1.1      ober #define IWN_CIPHER_CCMP		2
    659      1.1      ober #define IWN_CIPHER_TKIP		3
    660      1.1      ober #define IWN_CIPHER_WEP104	9
    661      1.1      ober 
    662      1.6  christos 	uint8_t		linkq;
    663      1.1      ober 	uint8_t		reserved2;
    664      1.6  christos 	uint8_t		key[16];
    665      1.1      ober 	uint16_t	fnext;
    666      1.1      ober 	uint16_t	reserved3;
    667      1.1      ober 	uint32_t	lifetime;
    668      1.1      ober #define IWN_LIFETIME_INFINITE	0xffffffff
    669      1.1      ober 
    670      1.1      ober 	uint32_t	loaddr;
    671      1.1      ober 	uint8_t		hiaddr;
    672      1.1      ober 	uint8_t		rts_ntries;
    673      1.1      ober 	uint8_t		data_ntries;
    674      1.1      ober 	uint8_t		tid;
    675      1.1      ober 	uint16_t	timeout;
    676      1.1      ober 	uint16_t	txop;
    677      1.1      ober } __packed;
    678      1.1      ober 
    679      1.6  christos /* Structure for command IWN_CMD_LINK_QUALITY. */
    680      1.1      ober #define IWN_MAX_TX_RETRIES	16
    681      1.6  christos struct iwn_cmd_link_quality {
    682      1.1      ober 	uint8_t		id;
    683      1.1      ober 	uint8_t		reserved1;
    684      1.1      ober 	uint16_t	ctl;
    685      1.1      ober 	uint8_t		flags;
    686      1.1      ober 	uint8_t		mimo;
    687      1.6  christos 	uint8_t		antmsk_1stream;
    688      1.6  christos 	uint8_t		antmsk_2stream;
    689  1.6.2.1  uebayasi 	uint8_t		ridx[EDCA_NUM_AC];
    690      1.1      ober 	uint16_t	ampdu_limit;
    691      1.6  christos 	uint8_t		ampdu_threshold;
    692      1.1      ober 	uint8_t		ampdu_max;
    693      1.1      ober 	uint32_t	reserved2;
    694      1.1      ober 	struct {
    695      1.6  christos 		uint8_t		plcp;
    696      1.1      ober 		uint8_t		rflags;
    697      1.1      ober 		uint16_t	xrflags;
    698      1.6  christos 	} __packed	retry[IWN_MAX_TX_RETRIES];
    699      1.1      ober 	uint32_t	reserved3;
    700      1.1      ober } __packed;
    701      1.1      ober 
    702      1.6  christos /* Structure for command IWN_CMD_SET_LED. */
    703      1.1      ober struct iwn_cmd_led {
    704      1.1      ober 	uint32_t	unit;	/* multiplier (in usecs) */
    705      1.1      ober 	uint8_t		which;
    706      1.1      ober #define IWN_LED_ACTIVITY	1
    707      1.1      ober #define IWN_LED_LINK		2
    708      1.1      ober 
    709      1.1      ober 	uint8_t		off;
    710      1.1      ober 	uint8_t		on;
    711      1.1      ober 	uint8_t		reserved;
    712      1.1      ober } __packed;
    713      1.1      ober 
    714      1.6  christos /* Structure for command IWN5000_CMD_WIMAX_COEX. */
    715      1.6  christos struct iwn5000_wimax_coex {
    716      1.6  christos 	uint32_t	flags;
    717  1.6.2.1  uebayasi #define IWN_WIMAX_COEX_STA_TABLE_VALID		(1 << 0)
    718  1.6.2.1  uebayasi #define IWN_WIMAX_COEX_UNASSOC_WA_UNMASK	(1 << 2)
    719  1.6.2.1  uebayasi #define IWN_WIMAX_COEX_ASSOC_WA_UNMASK		(1 << 3)
    720  1.6.2.1  uebayasi #define IWN_WIMAX_COEX_ENABLE			(1 << 7)
    721  1.6.2.1  uebayasi 
    722  1.6.2.1  uebayasi 	struct iwn5000_wimax_event {
    723      1.6  christos 		uint8_t	request;
    724      1.6  christos 		uint8_t	window;
    725      1.6  christos 		uint8_t	reserved;
    726      1.6  christos 		uint8_t	flags;
    727      1.6  christos 	} __packed	events[16];
    728      1.6  christos } __packed;
    729      1.6  christos 
    730      1.6  christos /* Structures for command IWN5000_CMD_CALIB_CONFIG. */
    731      1.6  christos struct iwn5000_calib_elem {
    732      1.6  christos 	uint32_t	enable;
    733      1.6  christos 	uint32_t	start;
    734      1.6  christos 	uint32_t	send;
    735      1.6  christos 	uint32_t	apply;
    736      1.6  christos 	uint32_t	reserved;
    737      1.6  christos } __packed;
    738      1.6  christos 
    739      1.6  christos struct iwn5000_calib_status {
    740      1.6  christos 	struct iwn5000_calib_elem	once;
    741      1.6  christos 	struct iwn5000_calib_elem	perd;
    742      1.6  christos 	uint32_t			flags;
    743      1.6  christos } __packed;
    744      1.6  christos 
    745      1.6  christos struct iwn5000_calib_config {
    746      1.6  christos 	struct iwn5000_calib_status	ucode;
    747      1.6  christos 	struct iwn5000_calib_status	driver;
    748      1.6  christos 	uint32_t			reserved;
    749      1.6  christos } __packed;
    750      1.6  christos 
    751      1.6  christos /* Structure for command IWN_CMD_SET_POWER_MODE. */
    752      1.6  christos struct iwn_pmgt_cmd {
    753      1.1      ober 	uint16_t	flags;
    754      1.6  christos #define IWN_PS_ALLOW_SLEEP	(1 << 0)
    755      1.6  christos #define IWN_PS_NOTIFY		(1 << 1)
    756      1.6  christos #define IWN_PS_SLEEP_OVER_DTIM	(1 << 2)
    757      1.6  christos #define IWN_PS_PCI_PMGT		(1 << 3)
    758      1.6  christos #define IWN_PS_FAST_PD		(1 << 4)
    759      1.1      ober 
    760      1.6  christos 	uint8_t		keepalive;
    761      1.1      ober 	uint8_t		debug;
    762      1.6  christos 	uint32_t	rxtimeout;
    763      1.6  christos 	uint32_t	txtimeout;
    764      1.6  christos 	uint32_t	intval[5];
    765      1.1      ober 	uint32_t	beacons;
    766      1.1      ober } __packed;
    767      1.1      ober 
    768      1.6  christos /* Structures for command IWN_CMD_SCAN. */
    769      1.1      ober struct iwn_scan_essid {
    770      1.1      ober 	uint8_t	id;
    771      1.1      ober 	uint8_t	len;
    772      1.1      ober 	uint8_t	data[IEEE80211_NWID_LEN];
    773      1.1      ober } __packed;
    774      1.1      ober 
    775      1.1      ober struct iwn_scan_hdr {
    776      1.6  christos 	uint16_t	len;
    777      1.6  christos 	uint8_t		reserved1;
    778      1.6  christos 	uint8_t		nchan;
    779      1.6  christos 	uint16_t	quiet_time;
    780      1.6  christos 	uint16_t	quiet_threshold;
    781      1.6  christos 	uint16_t	crc_threshold;
    782      1.6  christos 	uint16_t	rxchain;
    783      1.6  christos 	uint32_t	max_svc;	/* background scans */
    784      1.6  christos 	uint32_t	pause_svc;	/* background scans */
    785      1.6  christos 	uint32_t	flags;
    786      1.6  christos 	uint32_t	filter;
    787  1.6.2.1  uebayasi 
    788  1.6.2.1  uebayasi 	/* Followed by a struct iwn_cmd_data. */
    789  1.6.2.1  uebayasi 	/* Followed by an array of 20 structs iwn_scan_essid. */
    790  1.6.2.1  uebayasi 	/* Followed by probe request body. */
    791  1.6.2.1  uebayasi 	/* Followed by an array of ``nchan'' structs iwn_scan_chan. */
    792      1.1      ober } __packed;
    793      1.1      ober 
    794      1.1      ober struct iwn_scan_chan {
    795      1.6  christos 	uint32_t	flags;
    796      1.6  christos #define IWN_CHAN_ACTIVE		(1 << 0)
    797      1.6  christos #define IWN_CHAN_NPBREQS(x)	(((1 << (x)) - 1) << 1)
    798      1.1      ober 
    799      1.6  christos 	uint16_t	chan;
    800      1.1      ober 	uint8_t		rf_gain;
    801      1.1      ober 	uint8_t		dsp_gain;
    802      1.1      ober 	uint16_t	active;		/* msecs */
    803      1.1      ober 	uint16_t	passive;	/* msecs */
    804      1.1      ober } __packed;
    805      1.1      ober 
    806      1.6  christos /* Maximum size of a scan command. */
    807      1.6  christos #define IWN_SCAN_MAXSZ	(MCLBYTES - 4)
    808      1.6  christos 
    809      1.6  christos /* Structure for command IWN_CMD_TXPOWER (4965AGN only.) */
    810      1.1      ober #define IWN_RIDX_MAX	32
    811      1.6  christos struct iwn4965_cmd_txpower {
    812      1.6  christos 	uint8_t		band;
    813      1.6  christos 	uint8_t		reserved1;
    814      1.6  christos 	uint8_t		chan;
    815      1.6  christos 	uint8_t		reserved2;
    816      1.1      ober 	struct {
    817      1.6  christos 		uint8_t	rf_gain[2];
    818      1.6  christos 		uint8_t	dsp_gain[2];
    819      1.6  christos 	} __packed	power[IWN_RIDX_MAX + 1];
    820      1.1      ober } __packed;
    821      1.1      ober 
    822      1.6  christos /* Structure for command IWN_CMD_TXPOWER_DBM (5000 Series only.) */
    823      1.6  christos struct iwn5000_cmd_txpower {
    824      1.6  christos 	int8_t	global_limit;	/* in half-dBm */
    825      1.6  christos #define IWN5000_TXPOWER_AUTO		0x7f
    826      1.6  christos #define IWN5000_TXPOWER_MAX_DBM		16
    827      1.6  christos 
    828      1.6  christos 	uint8_t	flags;
    829      1.6  christos #define IWN5000_TXPOWER_NO_CLOSED	(1 << 6)
    830      1.6  christos 
    831      1.6  christos 	int8_t	srv_limit;	/* in half-dBm */
    832      1.6  christos 	uint8_t	reserved;
    833      1.6  christos } __packed;
    834      1.6  christos 
    835      1.6  christos /* Structure for command IWN_CMD_BLUETOOTH. */
    836      1.1      ober struct iwn_bluetooth {
    837      1.1      ober 	uint8_t		flags;
    838  1.6.2.1  uebayasi #define IWN_BT_COEX_CHAN_ANN	(1 << 0)
    839  1.6.2.1  uebayasi #define IWN_BT_COEX_BT_PRIO	(1 << 1)
    840  1.6.2.1  uebayasi #define IWN_BT_COEX_2_WIRE	(1 << 2)
    841  1.6.2.1  uebayasi 
    842  1.6.2.1  uebayasi 	uint8_t		lead_time;
    843  1.6.2.1  uebayasi #define IWN_BT_LEAD_TIME_DEF	30
    844  1.6.2.1  uebayasi 
    845  1.6.2.1  uebayasi 	uint8_t		max_kill;
    846  1.6.2.1  uebayasi #define IWN_BT_MAX_KILL_DEF	5
    847  1.6.2.1  uebayasi 
    848      1.1      ober 	uint8_t		reserved;
    849  1.6.2.1  uebayasi 	uint32_t	kill_ack;
    850  1.6.2.1  uebayasi 	uint32_t	kill_cts;
    851      1.1      ober } __packed;
    852      1.1      ober 
    853      1.6  christos /* Structure for command IWN_CMD_SET_CRITICAL_TEMP. */
    854      1.1      ober struct iwn_critical_temp {
    855      1.1      ober 	uint32_t	reserved;
    856      1.1      ober 	uint32_t	tempM;
    857      1.1      ober 	uint32_t	tempR;
    858      1.6  christos /* degK <-> degC conversion macros. */
    859      1.1      ober #define IWN_CTOK(c)	((c) + 273)
    860      1.1      ober #define IWN_KTOC(k)	((k) - 273)
    861      1.1      ober #define IWN_CTOMUK(c)	(((c) * 1000000) + 273150000)
    862      1.1      ober } __packed;
    863      1.1      ober 
    864      1.6  christos /* Structure for command IWN_CMD_SET_SENSITIVITY. */
    865      1.1      ober struct iwn_sensitivity_cmd {
    866      1.1      ober 	uint16_t	which;
    867      1.1      ober #define IWN_SENSITIVITY_DEFAULTTBL	0
    868      1.1      ober #define IWN_SENSITIVITY_WORKTBL		1
    869      1.1      ober 
    870      1.1      ober 	uint16_t	energy_cck;
    871      1.1      ober 	uint16_t	energy_ofdm;
    872      1.1      ober 	uint16_t	corr_ofdm_x1;
    873      1.1      ober 	uint16_t	corr_ofdm_mrc_x1;
    874      1.1      ober 	uint16_t	corr_cck_mrc_x4;
    875      1.1      ober 	uint16_t	corr_ofdm_x4;
    876      1.1      ober 	uint16_t	corr_ofdm_mrc_x4;
    877      1.1      ober 	uint16_t	corr_barker;
    878      1.1      ober 	uint16_t	corr_barker_mrc;
    879      1.1      ober 	uint16_t	corr_cck_x4;
    880      1.1      ober 	uint16_t	energy_ofdm_th;
    881      1.1      ober } __packed;
    882      1.1      ober 
    883      1.6  christos /* Structures for command IWN_CMD_PHY_CALIB. */
    884      1.6  christos struct iwn_phy_calib {
    885      1.6  christos 	uint8_t	code;
    886      1.6  christos #define IWN4965_PHY_CALIB_DIFF_GAIN		 7
    887      1.6  christos #define IWN5000_PHY_CALIB_DC			 8
    888      1.6  christos #define IWN5000_PHY_CALIB_LO			 9
    889      1.6  christos #define IWN5000_PHY_CALIB_TX_IQ			11
    890      1.6  christos #define IWN5000_PHY_CALIB_CRYSTAL		15
    891      1.6  christos #define IWN5000_PHY_CALIB_BASE_BAND		16
    892  1.6.2.1  uebayasi #define IWN5000_PHY_CALIB_TX_IQ_PERIODIC	17
    893      1.6  christos #define IWN5000_PHY_CALIB_RESET_NOISE_GAIN	18
    894      1.6  christos #define IWN5000_PHY_CALIB_NOISE_GAIN		19
    895      1.6  christos 
    896      1.6  christos 	uint8_t	group;
    897      1.6  christos 	uint8_t	ngroups;
    898      1.6  christos 	uint8_t	isvalid;
    899      1.6  christos } __packed;
    900      1.1      ober 
    901      1.6  christos struct iwn5000_phy_calib_crystal {
    902      1.6  christos 	uint8_t	code;
    903      1.6  christos 	uint8_t	group;
    904      1.6  christos 	uint8_t	ngroups;
    905      1.6  christos 	uint8_t	isvalid;
    906      1.6  christos 
    907      1.6  christos 	uint8_t	cap_pin[2];
    908      1.6  christos 	uint8_t	reserved[2];
    909      1.6  christos } __packed;
    910      1.6  christos 
    911      1.6  christos struct iwn_phy_calib_gain {
    912      1.6  christos 	uint8_t	code;
    913      1.6  christos 	uint8_t	group;
    914      1.6  christos 	uint8_t	ngroups;
    915      1.6  christos 	uint8_t	isvalid;
    916      1.1      ober 
    917      1.6  christos 	int8_t	gain[3];
    918      1.6  christos 	uint8_t	reserved;
    919      1.1      ober } __packed;
    920      1.1      ober 
    921      1.6  christos /* Structure for command IWN_CMD_SPECTRUM_MEASUREMENT. */
    922      1.6  christos struct iwn_spectrum_cmd {
    923      1.6  christos 	uint16_t	len;
    924      1.6  christos 	uint8_t		token;
    925      1.6  christos 	uint8_t		id;
    926      1.6  christos 	uint8_t		origin;
    927      1.6  christos 	uint8_t		periodic;
    928      1.6  christos 	uint16_t	timeout;
    929      1.6  christos 	uint32_t	start;
    930      1.6  christos 	uint32_t	reserved1;
    931      1.6  christos 	uint32_t	flags;
    932      1.6  christos 	uint32_t	filter;
    933      1.6  christos 	uint16_t	nchan;
    934      1.6  christos 	uint16_t	reserved2;
    935      1.6  christos 	struct {
    936      1.6  christos 		uint32_t	duration;
    937      1.6  christos 		uint8_t		chan;
    938      1.6  christos 		uint8_t		type;
    939      1.6  christos #define IWN_MEASUREMENT_BASIC		(1 << 0)
    940      1.6  christos #define IWN_MEASUREMENT_CCA		(1 << 1)
    941      1.6  christos #define IWN_MEASUREMENT_RPI_HISTOGRAM	(1 << 2)
    942      1.6  christos #define IWN_MEASUREMENT_NOISE_HISTOGRAM	(1 << 3)
    943      1.6  christos #define IWN_MEASUREMENT_FRAME		(1 << 4)
    944      1.6  christos #define IWN_MEASUREMENT_IDLE		(1 << 7)
    945      1.6  christos 
    946      1.6  christos 		uint16_t	reserved;
    947      1.6  christos 	} __packed	chan[10];
    948      1.6  christos } __packed;
    949      1.1      ober 
    950      1.6  christos /* Structure for IWN_UC_READY notification. */
    951      1.1      ober #define IWN_NATTEN_GROUPS	5
    952      1.1      ober struct iwn_ucode_info {
    953      1.1      ober 	uint8_t		minor;
    954      1.1      ober 	uint8_t		major;
    955      1.1      ober 	uint16_t	reserved1;
    956      1.1      ober 	uint8_t		revision[8];
    957      1.1      ober 	uint8_t		type;
    958      1.1      ober 	uint8_t		subtype;
    959      1.1      ober #define IWN_UCODE_RUNTIME	0
    960      1.1      ober #define IWN_UCODE_INIT		9
    961      1.1      ober 
    962      1.1      ober 	uint16_t	reserved2;
    963      1.1      ober 	uint32_t	logptr;
    964      1.6  christos 	uint32_t	errptr;
    965      1.1      ober 	uint32_t	tstamp;
    966      1.1      ober 	uint32_t	valid;
    967      1.1      ober 
    968      1.6  christos 	/* The following fields are for UCODE_INIT only. */
    969      1.1      ober 	int32_t		volt;
    970      1.1      ober 	struct {
    971      1.1      ober 		int32_t	chan20MHz;
    972      1.1      ober 		int32_t	chan40MHz;
    973      1.1      ober 	} __packed	temp[4];
    974      1.6  christos 	int32_t		atten[IWN_NATTEN_GROUPS][2];
    975      1.1      ober } __packed;
    976      1.1      ober 
    977      1.6  christos /* Structures for IWN_TX_DONE notification. */
    978      1.6  christos struct iwn4965_tx_stat {
    979      1.1      ober 	uint8_t		nframes;
    980  1.6.2.1  uebayasi 	uint8_t		btkillcnt;
    981  1.6.2.1  uebayasi 	uint8_t		rtsfailcnt;
    982  1.6.2.1  uebayasi 	uint8_t		ackfailcnt;
    983      1.1      ober 	uint8_t		rate;
    984      1.1      ober 	uint8_t		rflags;
    985      1.1      ober 	uint16_t	xrflags;
    986      1.1      ober 	uint16_t	duration;
    987      1.1      ober 	uint16_t	reserved;
    988      1.1      ober 	uint32_t	power[2];
    989      1.1      ober 	uint32_t	status;
    990      1.1      ober } __packed;
    991      1.1      ober 
    992      1.6  christos struct iwn5000_tx_stat {
    993      1.6  christos 	uint8_t		nframes;
    994  1.6.2.1  uebayasi 	uint8_t		btkillcnt;
    995  1.6.2.1  uebayasi 	uint8_t		rtsfailcnt;
    996  1.6.2.1  uebayasi 	uint8_t		ackfailcnt;
    997      1.6  christos 	uint8_t		rate;
    998      1.6  christos 	uint8_t		rflags;
    999      1.6  christos 	uint16_t	xrflags;
   1000      1.6  christos 	uint16_t	duration;
   1001      1.6  christos 	uint16_t	reserved;
   1002      1.6  christos 	uint32_t	power[2];
   1003      1.6  christos 	uint32_t	info;
   1004      1.6  christos 	uint16_t	seq;
   1005      1.6  christos 	uint16_t	len;
   1006  1.6.2.1  uebayasi 	uint8_t		tlc;
   1007  1.6.2.1  uebayasi 	uint8_t		ratid;
   1008  1.6.2.1  uebayasi 	uint8_t		fc[2];
   1009      1.6  christos 	uint16_t	status;
   1010      1.6  christos 	uint16_t	sequence;
   1011      1.6  christos } __packed;
   1012      1.6  christos 
   1013      1.6  christos /* Structure for IWN_BEACON_MISSED notification. */
   1014      1.1      ober struct iwn_beacon_missed {
   1015      1.1      ober 	uint32_t	consecutive;
   1016      1.1      ober 	uint32_t	total;
   1017      1.1      ober 	uint32_t	expected;
   1018      1.1      ober 	uint32_t	received;
   1019      1.1      ober } __packed;
   1020      1.1      ober 
   1021      1.6  christos /* Structure for IWN_MPDU_RX_DONE notification. */
   1022      1.6  christos struct iwn_rx_mpdu {
   1023      1.1      ober 	uint16_t	len;
   1024      1.1      ober 	uint16_t	reserved;
   1025      1.1      ober } __packed;
   1026      1.1      ober 
   1027      1.6  christos /* Structures for IWN_RX_DONE and IWN_MPDU_RX_DONE notifications. */
   1028      1.6  christos struct iwn4965_rx_phystat {
   1029      1.6  christos 	uint16_t	antenna;
   1030      1.6  christos 	uint16_t	agc;
   1031      1.6  christos 	uint8_t		rssi[6];
   1032      1.6  christos } __packed;
   1033      1.6  christos 
   1034      1.6  christos struct iwn5000_rx_phystat {
   1035      1.6  christos 	uint32_t	reserved1;
   1036      1.6  christos 	uint32_t	agc;
   1037      1.6  christos 	uint16_t	rssi[3];
   1038      1.6  christos } __packed;
   1039      1.6  christos 
   1040      1.1      ober struct iwn_rx_stat {
   1041      1.1      ober 	uint8_t		phy_len;
   1042      1.1      ober 	uint8_t		cfg_phy_len;
   1043      1.1      ober #define IWN_STAT_MAXLEN	20
   1044      1.1      ober 
   1045      1.1      ober 	uint8_t		id;
   1046      1.1      ober 	uint8_t		reserved1;
   1047      1.1      ober 	uint64_t	tstamp;
   1048      1.1      ober 	uint32_t	beacon;
   1049      1.1      ober 	uint16_t	flags;
   1050      1.6  christos #define IWN_STAT_FLAG_SHPREAMBLE	(1 << 2)
   1051      1.6  christos 
   1052      1.1      ober 	uint16_t	chan;
   1053      1.6  christos 	uint8_t		phybuf[32];
   1054      1.1      ober 	uint8_t		rate;
   1055      1.1      ober 	uint8_t		rflags;
   1056      1.1      ober 	uint16_t	xrflags;
   1057      1.1      ober 	uint16_t	len;
   1058      1.1      ober 	uint16_t	reserve3;
   1059      1.1      ober } __packed;
   1060      1.1      ober 
   1061      1.6  christos #define IWN_RSSI_TO_DBM	44
   1062      1.6  christos 
   1063  1.6.2.1  uebayasi /* Structure for IWN_RX_COMPRESSED_BA notification. */
   1064  1.6.2.1  uebayasi struct iwn_compressed_ba {
   1065  1.6.2.1  uebayasi 	uint8_t		macaddr[IEEE80211_ADDR_LEN];
   1066  1.6.2.1  uebayasi 	uint16_t	reserved;
   1067  1.6.2.1  uebayasi 	uint8_t		id;
   1068  1.6.2.1  uebayasi 	uint8_t		tid;
   1069  1.6.2.1  uebayasi 	uint16_t	seq;
   1070  1.6.2.1  uebayasi 	uint64_t	bitmap;
   1071  1.6.2.1  uebayasi 	uint16_t	qid;
   1072  1.6.2.1  uebayasi 	uint16_t	ssn;
   1073  1.6.2.1  uebayasi } __packed;
   1074  1.6.2.1  uebayasi 
   1075      1.6  christos /* Structure for IWN_START_SCAN notification. */
   1076      1.1      ober struct iwn_start_scan {
   1077      1.1      ober 	uint64_t	tstamp;
   1078      1.1      ober 	uint32_t	tbeacon;
   1079      1.1      ober 	uint8_t		chan;
   1080      1.1      ober 	uint8_t		band;
   1081      1.1      ober 	uint16_t	reserved;
   1082      1.1      ober 	uint32_t	status;
   1083      1.1      ober } __packed;
   1084      1.1      ober 
   1085      1.6  christos /* Structure for IWN_STOP_SCAN notification. */
   1086      1.1      ober struct iwn_stop_scan {
   1087      1.1      ober 	uint8_t		nchan;
   1088      1.1      ober 	uint8_t		status;
   1089      1.1      ober 	uint8_t		reserved;
   1090      1.1      ober 	uint8_t		chan;
   1091      1.1      ober 	uint64_t	tsf;
   1092      1.1      ober } __packed;
   1093      1.1      ober 
   1094      1.6  christos /* Structure for IWN_SPECTRUM_MEASUREMENT notification. */
   1095      1.6  christos struct iwn_spectrum_notif {
   1096      1.6  christos 	uint8_t		id;
   1097      1.6  christos 	uint8_t		token;
   1098      1.6  christos 	uint8_t		idx;
   1099      1.6  christos 	uint8_t		state;
   1100      1.6  christos #define IWN_MEASUREMENT_START	0
   1101      1.6  christos #define IWN_MEASUREMENT_STOP	1
   1102      1.6  christos 
   1103      1.6  christos 	uint32_t	start;
   1104      1.6  christos 	uint8_t		band;
   1105      1.6  christos 	uint8_t		chan;
   1106      1.6  christos 	uint8_t		type;
   1107      1.6  christos 	uint8_t		reserved1;
   1108      1.6  christos 	uint32_t	cca_ofdm;
   1109      1.6  christos 	uint32_t	cca_cck;
   1110      1.6  christos 	uint32_t	cca_time;
   1111      1.6  christos 	uint8_t		basic;
   1112      1.6  christos 	uint8_t		reserved2[3];
   1113      1.6  christos 	uint32_t	ofdm[8];
   1114      1.6  christos 	uint32_t	cck[8];
   1115      1.6  christos 	uint32_t	stop;
   1116      1.6  christos 	uint32_t	status;
   1117      1.6  christos #define IWN_MEASUREMENT_OK		0
   1118      1.6  christos #define IWN_MEASUREMENT_CONCURRENT	1
   1119      1.6  christos #define IWN_MEASUREMENT_CSA_CONFLICT	2
   1120      1.6  christos #define IWN_MEASUREMENT_TGH_CONFLICT	3
   1121      1.6  christos #define IWN_MEASUREMENT_STOPPED		6
   1122      1.6  christos #define IWN_MEASUREMENT_TIMEOUT		7
   1123      1.6  christos #define IWN_MEASUREMENT_FAILED		8
   1124      1.6  christos } __packed;
   1125      1.6  christos 
   1126  1.6.2.1  uebayasi /* Structures for IWN_{RX,BEACON}_STATISTICS notification. */
   1127      1.1      ober struct iwn_rx_phy_stats {
   1128      1.1      ober 	uint32_t	ina;
   1129      1.1      ober 	uint32_t	fina;
   1130      1.1      ober 	uint32_t	bad_plcp;
   1131      1.1      ober 	uint32_t	bad_crc32;
   1132      1.1      ober 	uint32_t	overrun;
   1133      1.1      ober 	uint32_t	eoverrun;
   1134      1.1      ober 	uint32_t	good_crc32;
   1135      1.1      ober 	uint32_t	fa;
   1136      1.1      ober 	uint32_t	bad_fina_sync;
   1137      1.1      ober 	uint32_t	sfd_timeout;
   1138      1.1      ober 	uint32_t	fina_timeout;
   1139      1.1      ober 	uint32_t	no_rts_ack;
   1140      1.1      ober 	uint32_t	rxe_limit;
   1141      1.1      ober 	uint32_t	ack;
   1142      1.1      ober 	uint32_t	cts;
   1143      1.1      ober 	uint32_t	ba_resp;
   1144      1.1      ober 	uint32_t	dsp_kill;
   1145      1.1      ober 	uint32_t	bad_mh;
   1146      1.1      ober 	uint32_t	rssi_sum;
   1147      1.1      ober 	uint32_t	reserved;
   1148      1.1      ober } __packed;
   1149      1.1      ober 
   1150      1.1      ober struct iwn_rx_general_stats {
   1151      1.1      ober 	uint32_t	bad_cts;
   1152      1.1      ober 	uint32_t	bad_ack;
   1153      1.1      ober 	uint32_t	not_bss;
   1154      1.1      ober 	uint32_t	filtered;
   1155      1.1      ober 	uint32_t	bad_chan;
   1156      1.1      ober 	uint32_t	beacons;
   1157      1.1      ober 	uint32_t	missed_beacons;
   1158      1.1      ober 	uint32_t	adc_saturated;	/* time in 0.8us */
   1159      1.1      ober 	uint32_t	ina_searched;	/* time in 0.8us */
   1160      1.1      ober 	uint32_t	noise[3];
   1161      1.1      ober 	uint32_t	flags;
   1162      1.1      ober 	uint32_t	load;
   1163      1.1      ober 	uint32_t	fa;
   1164      1.1      ober 	uint32_t	rssi[3];
   1165      1.1      ober 	uint32_t	energy[3];
   1166      1.1      ober } __packed;
   1167      1.1      ober 
   1168      1.1      ober struct iwn_rx_ht_phy_stats {
   1169      1.1      ober 	uint32_t	bad_plcp;
   1170      1.1      ober 	uint32_t	overrun;
   1171      1.1      ober 	uint32_t	eoverrun;
   1172      1.1      ober 	uint32_t	good_crc32;
   1173      1.1      ober 	uint32_t	bad_crc32;
   1174      1.1      ober 	uint32_t	bad_mh;
   1175      1.1      ober 	uint32_t	good_ampdu_crc32;
   1176      1.1      ober 	uint32_t	ampdu;
   1177      1.1      ober 	uint32_t	fragment;
   1178      1.1      ober 	uint32_t	reserved;
   1179      1.1      ober } __packed;
   1180      1.1      ober 
   1181      1.1      ober struct iwn_rx_stats {
   1182      1.1      ober 	struct iwn_rx_phy_stats		ofdm;
   1183      1.1      ober 	struct iwn_rx_phy_stats		cck;
   1184      1.1      ober 	struct iwn_rx_general_stats	general;
   1185      1.1      ober 	struct iwn_rx_ht_phy_stats	ht;
   1186      1.1      ober } __packed;
   1187      1.1      ober 
   1188      1.1      ober struct iwn_tx_stats {
   1189      1.1      ober 	uint32_t	preamble;
   1190      1.1      ober 	uint32_t	rx_detected;
   1191      1.1      ober 	uint32_t	bt_defer;
   1192      1.1      ober 	uint32_t	bt_kill;
   1193      1.1      ober 	uint32_t	short_len;
   1194      1.1      ober 	uint32_t	cts_timeout;
   1195      1.1      ober 	uint32_t	ack_timeout;
   1196      1.1      ober 	uint32_t	exp_ack;
   1197      1.1      ober 	uint32_t	ack;
   1198      1.1      ober 	uint32_t	msdu;
   1199      1.1      ober 	uint32_t	busrt_err1;
   1200      1.1      ober 	uint32_t	burst_err2;
   1201      1.1      ober 	uint32_t	cts_collision;
   1202      1.1      ober 	uint32_t	ack_collision;
   1203      1.1      ober 	uint32_t	ba_timeout;
   1204      1.1      ober 	uint32_t	ba_resched;
   1205      1.1      ober 	uint32_t	query_ampdu;
   1206      1.1      ober 	uint32_t	query;
   1207      1.1      ober 	uint32_t	query_ampdu_frag;
   1208      1.1      ober 	uint32_t	query_mismatch;
   1209      1.1      ober 	uint32_t	not_ready;
   1210      1.1      ober 	uint32_t	underrun;
   1211      1.1      ober 	uint32_t	bt_ht_kill;
   1212      1.1      ober 	uint32_t	rx_ba_resp;
   1213      1.1      ober 	uint32_t	reserved[2];
   1214      1.1      ober } __packed;
   1215      1.1      ober 
   1216      1.1      ober struct iwn_general_stats {
   1217      1.1      ober 	uint32_t	temp;
   1218      1.1      ober 	uint32_t	temp_m;
   1219      1.1      ober 	uint32_t	burst_check;
   1220      1.1      ober 	uint32_t	burst;
   1221      1.1      ober 	uint32_t	reserved1[4];
   1222      1.1      ober 	uint32_t	sleep;
   1223      1.1      ober 	uint32_t	slot_out;
   1224      1.1      ober 	uint32_t	slot_idle;
   1225      1.1      ober 	uint32_t	ttl_tstamp;
   1226      1.1      ober 	uint32_t	tx_ant_a;
   1227      1.1      ober 	uint32_t	tx_ant_b;
   1228      1.1      ober 	uint32_t	exec;
   1229      1.1      ober 	uint32_t	probe;
   1230      1.1      ober 	uint32_t	reserved2[2];
   1231      1.1      ober 	uint32_t	rx_enabled;
   1232      1.1      ober 	uint32_t	reserved3[3];
   1233      1.1      ober } __packed;
   1234      1.1      ober 
   1235      1.1      ober struct iwn_stats {
   1236      1.1      ober 	uint32_t			flags;
   1237      1.1      ober 	struct iwn_rx_stats		rx;
   1238      1.1      ober 	struct iwn_tx_stats		tx;
   1239      1.1      ober 	struct iwn_general_stats	general;
   1240      1.1      ober } __packed;
   1241      1.1      ober 
   1242      1.1      ober 
   1243      1.6  christos /* Firmware error dump. */
   1244      1.6  christos struct iwn_fw_dump {
   1245      1.6  christos 	uint32_t	valid;
   1246      1.6  christos 	uint32_t	id;
   1247      1.6  christos 	uint32_t	pc;
   1248      1.6  christos 	uint32_t	branch_link[2];
   1249      1.6  christos 	uint32_t	interrupt_link[2];
   1250      1.6  christos 	uint32_t	error_data[2];
   1251      1.6  christos 	uint32_t	src_line;
   1252      1.6  christos 	uint32_t	tsf;
   1253      1.6  christos 	uint32_t	time[2];
   1254      1.6  christos } __packed;
   1255      1.6  christos 
   1256      1.6  christos #define IWN4965_FW_TEXT_MAXSZ	( 96 * 1024)
   1257      1.6  christos #define IWN4965_FW_DATA_MAXSZ	( 40 * 1024)
   1258      1.6  christos #define IWN5000_FW_TEXT_MAXSZ	(256 * 1024)
   1259      1.6  christos #define IWN5000_FW_DATA_MAXSZ	( 80 * 1024)
   1260      1.1      ober #define IWN_FW_BOOT_TEXT_MAXSZ	1024
   1261      1.6  christos #define IWN4965_FWSZ		(IWN4965_FW_TEXT_MAXSZ + IWN4965_FW_DATA_MAXSZ)
   1262      1.6  christos #define IWN5000_FWSZ		IWN5000_FW_TEXT_MAXSZ
   1263      1.1      ober 
   1264  1.6.2.1  uebayasi #define IWN_FW_API(x)	(((x) >> 8) & 0xff)
   1265  1.6.2.1  uebayasi 
   1266      1.1      ober /*
   1267      1.1      ober  * Offsets into EEPROM.
   1268      1.1      ober  */
   1269      1.1      ober #define IWN_EEPROM_MAC		0x015
   1270      1.6  christos #define IWN_EEPROM_RFCFG	0x048
   1271      1.6  christos #define IWN4965_EEPROM_DOMAIN	0x060
   1272      1.6  christos #define IWN4965_EEPROM_BAND1	0x063
   1273      1.6  christos #define IWN5000_EEPROM_REG	0x066
   1274      1.6  christos #define IWN5000_EEPROM_CAL	0x067
   1275      1.6  christos #define IWN4965_EEPROM_BAND2	0x072
   1276      1.6  christos #define IWN4965_EEPROM_BAND3	0x080
   1277      1.6  christos #define IWN4965_EEPROM_BAND4	0x08d
   1278      1.6  christos #define IWN4965_EEPROM_BAND5	0x099
   1279      1.6  christos #define IWN4965_EEPROM_BAND6	0x0a0
   1280      1.6  christos #define IWN4965_EEPROM_BAND7	0x0a8
   1281      1.6  christos #define IWN4965_EEPROM_MAXPOW	0x0e8
   1282      1.6  christos #define IWN4965_EEPROM_VOLTAGE	0x0e9
   1283      1.6  christos #define IWN4965_EEPROM_BANDS	0x0ea
   1284      1.6  christos /* Indirect offsets. */
   1285      1.6  christos #define IWN5000_EEPROM_DOMAIN	0x001
   1286      1.6  christos #define IWN5000_EEPROM_BAND1	0x004
   1287      1.6  christos #define IWN5000_EEPROM_BAND2	0x013
   1288      1.6  christos #define IWN5000_EEPROM_BAND3	0x021
   1289      1.6  christos #define IWN5000_EEPROM_BAND4	0x02e
   1290      1.6  christos #define IWN5000_EEPROM_BAND5	0x03a
   1291      1.6  christos #define IWN5000_EEPROM_BAND6	0x041
   1292      1.6  christos #define IWN5000_EEPROM_BAND7	0x049
   1293  1.6.2.1  uebayasi #define IWN6000_EEPROM_ENHINFO	0x054
   1294      1.6  christos #define IWN5000_EEPROM_CRYSTAL	0x128
   1295      1.6  christos #define IWN5000_EEPROM_TEMP	0x12a
   1296      1.6  christos #define IWN5000_EEPROM_VOLT	0x12b
   1297      1.6  christos 
   1298      1.6  christos /* Possible flags for IWN_EEPROM_RFCFG. */
   1299      1.6  christos #define IWN_RFCFG_TYPE(x)	(((x) >>  0) & 0x3)
   1300      1.6  christos #define IWN_RFCFG_STEP(x)	(((x) >>  2) & 0x3)
   1301      1.6  christos #define IWN_RFCFG_DASH(x)	(((x) >>  4) & 0x3)
   1302      1.6  christos #define IWN_RFCFG_TXANTMSK(x)	(((x) >>  8) & 0xf)
   1303      1.6  christos #define IWN_RFCFG_RXANTMSK(x)	(((x) >> 12) & 0xf)
   1304      1.1      ober 
   1305      1.1      ober struct iwn_eeprom_chan {
   1306      1.1      ober 	uint8_t	flags;
   1307      1.1      ober #define IWN_EEPROM_CHAN_VALID	(1 << 0)
   1308      1.1      ober #define IWN_EEPROM_CHAN_IBSS	(1 << 1)
   1309      1.1      ober #define IWN_EEPROM_CHAN_ACTIVE	(1 << 3)
   1310      1.1      ober #define IWN_EEPROM_CHAN_RADAR	(1 << 4)
   1311      1.1      ober 
   1312      1.1      ober 	int8_t	maxpwr;
   1313      1.1      ober } __packed;
   1314      1.1      ober 
   1315  1.6.2.1  uebayasi struct iwn_eeprom_enhinfo {
   1316  1.6.2.1  uebayasi 	uint16_t	chan;
   1317  1.6.2.1  uebayasi 	int8_t		chain[3];	/* max power in half-dBm */
   1318  1.6.2.1  uebayasi 	uint8_t		reserved;
   1319  1.6.2.1  uebayasi 	int8_t		mimo2;		/* max power in half-dBm */
   1320  1.6.2.1  uebayasi 	int8_t		mimo3;		/* max power in half-dBm */
   1321  1.6.2.1  uebayasi } __packed;
   1322  1.6.2.1  uebayasi 
   1323  1.6.2.1  uebayasi struct iwn5000_eeprom_calib_hdr {
   1324  1.6.2.1  uebayasi 	uint8_t		version;
   1325  1.6.2.1  uebayasi 	uint8_t		pa_type;
   1326  1.6.2.1  uebayasi 	uint16_t	volt;
   1327  1.6.2.1  uebayasi } __packed;
   1328  1.6.2.1  uebayasi 
   1329      1.1      ober #define IWN_NSAMPLES	3
   1330      1.6  christos struct iwn4965_eeprom_chan_samples {
   1331      1.1      ober 	uint8_t	num;
   1332      1.1      ober 	struct {
   1333      1.1      ober 		uint8_t temp;
   1334      1.1      ober 		uint8_t	gain;
   1335      1.1      ober 		uint8_t	power;
   1336      1.1      ober 		int8_t	pa_det;
   1337      1.6  christos 	}	samples[2][IWN_NSAMPLES];
   1338      1.1      ober } __packed;
   1339      1.1      ober 
   1340      1.1      ober #define IWN_NBANDS	8
   1341      1.6  christos struct iwn4965_eeprom_band {
   1342      1.1      ober 	uint8_t	lo;	/* low channel number */
   1343      1.1      ober 	uint8_t	hi;	/* high channel number */
   1344      1.6  christos 	struct	iwn4965_eeprom_chan_samples chans[2];
   1345      1.1      ober } __packed;
   1346      1.1      ober 
   1347      1.6  christos /*
   1348      1.6  christos  * Offsets of channels descriptions in EEPROM.
   1349      1.6  christos  */
   1350      1.6  christos static const uint32_t iwn4965_regulatory_bands[IWN_NBANDS] = {
   1351      1.6  christos 	IWN4965_EEPROM_BAND1,
   1352      1.6  christos 	IWN4965_EEPROM_BAND2,
   1353      1.6  christos 	IWN4965_EEPROM_BAND3,
   1354      1.6  christos 	IWN4965_EEPROM_BAND4,
   1355      1.6  christos 	IWN4965_EEPROM_BAND5,
   1356      1.6  christos 	IWN4965_EEPROM_BAND6,
   1357      1.6  christos 	IWN4965_EEPROM_BAND7
   1358      1.6  christos };
   1359      1.6  christos 
   1360      1.6  christos static const uint32_t iwn5000_regulatory_bands[IWN_NBANDS] = {
   1361      1.6  christos 	IWN5000_EEPROM_BAND1,
   1362      1.6  christos 	IWN5000_EEPROM_BAND2,
   1363      1.6  christos 	IWN5000_EEPROM_BAND3,
   1364      1.6  christos 	IWN5000_EEPROM_BAND4,
   1365      1.6  christos 	IWN5000_EEPROM_BAND5,
   1366      1.6  christos 	IWN5000_EEPROM_BAND6,
   1367      1.6  christos 	IWN5000_EEPROM_BAND7
   1368      1.6  christos };
   1369      1.6  christos 
   1370      1.1      ober #define IWN_CHAN_BANDS_COUNT	 7
   1371      1.1      ober #define IWN_MAX_CHAN_PER_BAND	14
   1372      1.1      ober static const struct iwn_chan_band {
   1373      1.6  christos 	uint8_t	nchan;
   1374      1.6  christos 	uint8_t	chan[IWN_MAX_CHAN_PER_BAND];
   1375      1.1      ober } iwn_bands[] = {
   1376      1.6  christos 	/* 20MHz channels, 2GHz band. */
   1377      1.6  christos 	{ 14, { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 } },
   1378      1.6  christos 	/* 20MHz channels, 5GHz band. */
   1379      1.6  christos 	{ 13, { 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 } },
   1380      1.6  christos 	{ 12, { 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 } },
   1381      1.6  christos 	{ 11, { 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 } },
   1382      1.6  christos 	{  6, { 145, 149, 153, 157, 161, 165 } },
   1383      1.6  christos 	/* 40MHz channels (primary channels), 2GHz band. */
   1384      1.6  christos 	{  7, { 1, 2, 3, 4, 5, 6, 7 } },
   1385      1.6  christos 	/* 40MHz channels (primary channels), 5GHz band. */
   1386      1.6  christos 	{ 11, { 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 } }
   1387      1.1      ober };
   1388      1.1      ober 
   1389  1.6.2.1  uebayasi #define IWN1000_OTP_NBLOCKS	3
   1390  1.6.2.1  uebayasi #define IWN6000_OTP_NBLOCKS	4
   1391  1.6.2.1  uebayasi #define IWN6050_OTP_NBLOCKS	7
   1392  1.6.2.1  uebayasi 
   1393      1.6  christos /* HW rate indices. */
   1394      1.6  christos #define IWN_RIDX_CCK1	0
   1395      1.6  christos #define IWN_RIDX_OFDM6	4
   1396      1.6  christos 
   1397      1.6  christos static const struct iwn_rate {
   1398      1.6  christos 	uint8_t	rate;
   1399      1.6  christos 	uint8_t	plcp;
   1400      1.6  christos 	uint8_t	flags;
   1401      1.6  christos } iwn_rates[IWN_RIDX_MAX + 1] = {
   1402      1.6  christos 	{   2,  10, IWN_RFLAG_CCK },
   1403      1.6  christos 	{   4,  20, IWN_RFLAG_CCK },
   1404      1.6  christos 	{  11,  55, IWN_RFLAG_CCK },
   1405      1.6  christos 	{  22, 110, IWN_RFLAG_CCK },
   1406      1.6  christos 	{  12, 0xd, 0 },
   1407      1.6  christos 	{  18, 0xf, 0 },
   1408      1.6  christos 	{  24, 0x5, 0 },
   1409      1.6  christos 	{  36, 0x7, 0 },
   1410      1.6  christos 	{  48, 0x9, 0 },
   1411      1.6  christos 	{  72, 0xb, 0 },
   1412      1.6  christos 	{  96, 0x1, 0 },
   1413      1.6  christos 	{ 108, 0x3, 0 },
   1414      1.6  christos 	{ 120, 0x3, 0 }
   1415      1.6  christos };
   1416      1.6  christos 
   1417      1.6  christos #define IWN4965_MAX_PWR_INDEX	107
   1418      1.1      ober 
   1419      1.1      ober /*
   1420      1.1      ober  * RF Tx gain values from highest to lowest power (values obtained from
   1421      1.1      ober  * the reference driver.)
   1422      1.1      ober  */
   1423      1.6  christos static const uint8_t iwn4965_rf_gain_2ghz[IWN4965_MAX_PWR_INDEX + 1] = {
   1424      1.1      ober 	0x3f, 0x3f, 0x3f, 0x3e, 0x3e, 0x3e, 0x3d, 0x3d, 0x3d, 0x3c, 0x3c,
   1425      1.6  christos 	0x3c, 0x3b, 0x3b, 0x3b, 0x3a, 0x3a, 0x3a, 0x39, 0x39, 0x39, 0x38,
   1426      1.6  christos 	0x38, 0x38, 0x37, 0x37, 0x37, 0x36, 0x36, 0x36, 0x35, 0x35, 0x35,
   1427      1.6  christos 	0x34, 0x34, 0x34, 0x33, 0x33, 0x33, 0x32, 0x32, 0x32, 0x31, 0x31,
   1428      1.6  christos 	0x31, 0x30, 0x30, 0x30, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x04,
   1429      1.6  christos 	0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01,
   1430      1.6  christos 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   1431      1.6  christos 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   1432      1.6  christos 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   1433      1.6  christos 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
   1434      1.1      ober };
   1435      1.1      ober 
   1436      1.6  christos static const uint8_t iwn4965_rf_gain_5ghz[IWN4965_MAX_PWR_INDEX + 1] = {
   1437      1.1      ober 	0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3e, 0x3e, 0x3e, 0x3d, 0x3d, 0x3d,
   1438      1.6  christos 	0x3c, 0x3c, 0x3c, 0x3b, 0x3b, 0x3b, 0x3a, 0x3a, 0x3a, 0x39, 0x39,
   1439      1.6  christos 	0x39, 0x38, 0x38, 0x38, 0x37, 0x37, 0x37, 0x36, 0x36, 0x36, 0x35,
   1440      1.6  christos 	0x35, 0x35, 0x34, 0x34, 0x34, 0x33, 0x33, 0x33, 0x32, 0x32, 0x32,
   1441      1.6  christos 	0x31, 0x31, 0x31, 0x30, 0x30, 0x30, 0x25, 0x25, 0x25, 0x24, 0x24,
   1442      1.6  christos 	0x24, 0x23, 0x23, 0x23, 0x22, 0x18, 0x18, 0x17, 0x17, 0x17, 0x16,
   1443      1.6  christos 	0x16, 0x16, 0x15, 0x15, 0x15, 0x14, 0x14, 0x14, 0x13, 0x13, 0x13,
   1444      1.6  christos 	0x12, 0x08, 0x08, 0x07, 0x07, 0x07, 0x06, 0x06, 0x06, 0x05, 0x05,
   1445      1.6  christos 	0x05, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x01,
   1446      1.6  christos 	0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
   1447      1.1      ober };
   1448      1.1      ober 
   1449      1.1      ober /*
   1450      1.1      ober  * DSP pre-DAC gain values from highest to lowest power (values obtained
   1451      1.1      ober  * from the reference driver.)
   1452      1.1      ober  */
   1453      1.6  christos static const uint8_t iwn4965_dsp_gain_2ghz[IWN4965_MAX_PWR_INDEX + 1] = {
   1454      1.6  christos 	0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68,
   1455      1.6  christos 	0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e,
   1456      1.6  christos 	0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62,
   1457      1.1      ober 	0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68,
   1458      1.6  christos 	0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e,
   1459      1.6  christos 	0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62,
   1460      1.6  christos 	0x6e, 0x68, 0x62, 0x61, 0x60, 0x5f, 0x5e, 0x5d, 0x5c, 0x5b, 0x5a,
   1461      1.6  christos 	0x59, 0x58, 0x57, 0x56, 0x55, 0x54, 0x53, 0x52, 0x51, 0x50, 0x4f,
   1462      1.6  christos 	0x4e, 0x4d, 0x4c, 0x4b, 0x4a, 0x49, 0x48, 0x47, 0x46, 0x45, 0x44,
   1463      1.6  christos 	0x43, 0x42, 0x41, 0x40, 0x3f, 0x3e, 0x3d, 0x3c, 0x3b
   1464      1.1      ober };
   1465      1.1      ober 
   1466      1.6  christos static const uint8_t iwn4965_dsp_gain_5ghz[IWN4965_MAX_PWR_INDEX + 1] = {
   1467      1.1      ober 	0x7b, 0x75, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62,
   1468      1.6  christos 	0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68,
   1469      1.6  christos 	0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e,
   1470      1.6  christos 	0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62,
   1471      1.6  christos 	0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68,
   1472      1.6  christos 	0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e,
   1473      1.6  christos 	0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62,
   1474      1.6  christos 	0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68,
   1475      1.6  christos 	0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e, 0x68, 0x62, 0x6e,
   1476      1.6  christos 	0x68, 0x62, 0x6e, 0x68, 0x62, 0x5d, 0x58, 0x53, 0x4e
   1477      1.6  christos };
   1478      1.6  christos 
   1479      1.6  christos /*
   1480      1.6  christos  * Power saving settings (values obtained from the reference driver.)
   1481      1.6  christos  */
   1482      1.6  christos #define IWN_NDTIMRANGES		3
   1483      1.6  christos #define IWN_NPOWERLEVELS	6
   1484      1.6  christos static const struct iwn_pmgt {
   1485      1.6  christos 	uint32_t	rxtimeout;
   1486      1.6  christos 	uint32_t	txtimeout;
   1487      1.6  christos 	uint32_t	intval[5];
   1488      1.6  christos 	int		skip_dtim;
   1489      1.6  christos } iwn_pmgt[IWN_NDTIMRANGES][IWN_NPOWERLEVELS] = {
   1490      1.6  christos 	/* DTIM <= 2 */
   1491      1.6  christos 	{
   1492      1.6  christos 	{   0,   0, {  0,  0,  0,  0,  0 }, 0 },	/* CAM */
   1493      1.6  christos 	{ 200, 500, {  1,  2,  2,  2, -1 }, 0 },	/* PS level 1 */
   1494      1.6  christos 	{ 200, 300, {  1,  2,  2,  2, -1 }, 0 },	/* PS level 2 */
   1495      1.6  christos 	{  50, 100, {  2,  2,  2,  2, -1 }, 0 },	/* PS level 3 */
   1496      1.6  christos 	{  50,  25, {  2,  2,  4,  4, -1 }, 1 },	/* PS level 4 */
   1497      1.6  christos 	{  25,  25, {  2,  2,  4,  6, -1 }, 2 }		/* PS level 5 */
   1498      1.6  christos 	},
   1499      1.6  christos 	/* 3 <= DTIM <= 10 */
   1500      1.6  christos 	{
   1501      1.6  christos 	{   0,   0, {  0,  0,  0,  0,  0 }, 0 },	/* CAM */
   1502      1.6  christos 	{ 200, 500, {  1,  2,  3,  4,  4 }, 0 },	/* PS level 1 */
   1503      1.6  christos 	{ 200, 300, {  1,  2,  3,  4,  7 }, 0 },	/* PS level 2 */
   1504      1.6  christos 	{  50, 100, {  2,  4,  6,  7,  9 }, 0 },	/* PS level 3 */
   1505      1.6  christos 	{  50,  25, {  2,  4,  6,  9, 10 }, 1 },	/* PS level 4 */
   1506      1.6  christos 	{  25,  25, {  2,  4,  7, 10, 10 }, 2 }		/* PS level 5 */
   1507      1.6  christos 	},
   1508      1.6  christos 	/* DTIM >= 11 */
   1509      1.6  christos 	{
   1510      1.6  christos 	{   0,   0, {  0,  0,  0,  0,  0 }, 0 },	/* CAM */
   1511      1.6  christos 	{ 200, 500, {  1,  2,  3,  4, -1 }, 0 },	/* PS level 1 */
   1512      1.6  christos 	{ 200, 300, {  2,  4,  6,  7, -1 }, 0 },	/* PS level 2 */
   1513      1.6  christos 	{  50, 100, {  2,  7,  9,  9, -1 }, 0 },	/* PS level 3 */
   1514      1.6  christos 	{  50,  25, {  2,  7,  9,  9, -1 }, 0 },	/* PS level 4 */
   1515      1.6  christos 	{  25,  25, {  4,  7, 10, 10, -1 }, 0 }		/* PS level 5 */
   1516      1.6  christos 	}
   1517      1.6  christos };
   1518      1.6  christos 
   1519      1.6  christos struct iwn_sensitivity_limits {
   1520      1.6  christos 	uint32_t	min_ofdm_x1;
   1521      1.6  christos 	uint32_t	max_ofdm_x1;
   1522      1.6  christos 	uint32_t	min_ofdm_mrc_x1;
   1523      1.6  christos 	uint32_t	max_ofdm_mrc_x1;
   1524      1.6  christos 	uint32_t	min_ofdm_x4;
   1525      1.6  christos 	uint32_t	max_ofdm_x4;
   1526      1.6  christos 	uint32_t	min_ofdm_mrc_x4;
   1527      1.6  christos 	uint32_t	max_ofdm_mrc_x4;
   1528      1.6  christos 	uint32_t	min_cck_x4;
   1529      1.6  christos 	uint32_t	max_cck_x4;
   1530      1.6  christos 	uint32_t	min_cck_mrc_x4;
   1531      1.6  christos 	uint32_t	max_cck_mrc_x4;
   1532      1.6  christos 	uint32_t	min_energy_cck;
   1533      1.6  christos 	uint32_t	energy_cck;
   1534      1.6  christos 	uint32_t	energy_ofdm;
   1535      1.1      ober };
   1536      1.1      ober 
   1537      1.6  christos /*
   1538      1.6  christos  * RX sensitivity limits (values obtained from the reference driver.)
   1539      1.6  christos  */
   1540      1.6  christos static const struct iwn_sensitivity_limits iwn4965_sensitivity_limits = {
   1541      1.6  christos 	105, 140,
   1542  1.6.2.1  uebayasi 	220, 270,
   1543      1.6  christos 	 85, 120,
   1544      1.6  christos 	170, 210,
   1545      1.6  christos 	125, 200,
   1546      1.6  christos 	200, 400,
   1547      1.6  christos 	 97,
   1548      1.6  christos 	100,
   1549      1.6  christos 	100
   1550      1.6  christos };
   1551      1.6  christos 
   1552      1.6  christos static const struct iwn_sensitivity_limits iwn5000_sensitivity_limits = {
   1553  1.6.2.1  uebayasi 	120, 120,	/* min = max for performance bug in DSP. */
   1554  1.6.2.1  uebayasi 	240, 240,	/* min = max for performance bug in DSP. */
   1555  1.6.2.1  uebayasi 	 90, 120,
   1556  1.6.2.1  uebayasi 	170, 210,
   1557  1.6.2.1  uebayasi 	125, 200,
   1558  1.6.2.1  uebayasi 	170, 400,
   1559  1.6.2.1  uebayasi 	 95,
   1560  1.6.2.1  uebayasi 	 95,
   1561  1.6.2.1  uebayasi 	 95
   1562  1.6.2.1  uebayasi };
   1563  1.6.2.1  uebayasi 
   1564  1.6.2.1  uebayasi static const struct iwn_sensitivity_limits iwn5150_sensitivity_limits = {
   1565  1.6.2.1  uebayasi 	105, 105,	/* min = max for performance bug in DSP. */
   1566  1.6.2.1  uebayasi 	220, 220,	/* min = max for performance bug in DSP. */
   1567  1.6.2.1  uebayasi 	 90, 120,
   1568  1.6.2.1  uebayasi 	170, 210,
   1569  1.6.2.1  uebayasi 	125, 200,
   1570  1.6.2.1  uebayasi 	170, 400,
   1571  1.6.2.1  uebayasi 	 95,
   1572  1.6.2.1  uebayasi 	 95,
   1573  1.6.2.1  uebayasi 	 95
   1574  1.6.2.1  uebayasi };
   1575  1.6.2.1  uebayasi 
   1576  1.6.2.1  uebayasi static const struct iwn_sensitivity_limits iwn1000_sensitivity_limits = {
   1577      1.6  christos 	120, 155,
   1578      1.6  christos 	240, 290,
   1579      1.6  christos 	 90, 120,
   1580      1.6  christos 	170, 210,
   1581      1.6  christos 	125, 200,
   1582      1.6  christos 	170, 400,
   1583      1.6  christos 	 95,
   1584      1.6  christos 	 95,
   1585      1.6  christos 	 95
   1586      1.6  christos };
   1587      1.6  christos 
   1588  1.6.2.1  uebayasi static const struct iwn_sensitivity_limits iwn6000_sensitivity_limits = {
   1589  1.6.2.1  uebayasi 	105, 110,
   1590  1.6.2.1  uebayasi 	192, 232,
   1591  1.6.2.1  uebayasi 	 80, 145,
   1592  1.6.2.1  uebayasi 	128, 232,
   1593  1.6.2.1  uebayasi 	125, 175,
   1594  1.6.2.1  uebayasi 	160, 310,
   1595  1.6.2.1  uebayasi 	 97,
   1596  1.6.2.1  uebayasi 	 97,
   1597  1.6.2.1  uebayasi 	100
   1598  1.6.2.1  uebayasi };
   1599  1.6.2.1  uebayasi 
   1600      1.6  christos /* Map TID to TX scheduler's FIFO. */
   1601      1.6  christos static const uint8_t iwn_tid2fifo[] = {
   1602      1.6  christos 	1, 0, 0, 1, 2, 2, 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 3
   1603      1.6  christos };
   1604      1.6  christos 
   1605  1.6.2.1  uebayasi /* WiFi/WiMAX coexist event priority table for 6050. */
   1606  1.6.2.1  uebayasi static const struct iwn5000_wimax_event iwn6050_wimax_events[] = {
   1607  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x00 },
   1608  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x03 },
   1609  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x03 },
   1610  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x03 },
   1611  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x00 },
   1612  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x07 },
   1613  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x00 },
   1614  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x03 },
   1615  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x03 },
   1616  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x00 },
   1617  1.6.2.1  uebayasi 	{ 0x06, 0x03, 0x00, 0x07 },
   1618  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x00 },
   1619  1.6.2.1  uebayasi 	{ 0x06, 0x06, 0x00, 0x03 },
   1620  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x07 },
   1621  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x00 },
   1622  1.6.2.1  uebayasi 	{ 0x04, 0x03, 0x00, 0x00 }
   1623  1.6.2.1  uebayasi };
   1624  1.6.2.1  uebayasi 
   1625      1.6  christos /* Firmware errors. */
   1626      1.6  christos static const char * const iwn_fw_errmsg[] = {
   1627      1.6  christos 	"OK",
   1628      1.6  christos 	"FAIL",
   1629      1.6  christos 	"BAD_PARAM",
   1630      1.6  christos 	"BAD_CHECKSUM",
   1631      1.6  christos 	"NMI_INTERRUPT_WDG",
   1632      1.6  christos 	"SYSASSERT",
   1633      1.6  christos 	"FATAL_ERROR",
   1634      1.6  christos 	"BAD_COMMAND",
   1635      1.6  christos 	"HW_ERROR_TUNE_LOCK",
   1636      1.6  christos 	"HW_ERROR_TEMPERATURE",
   1637      1.6  christos 	"ILLEGAL_CHAN_FREQ",
   1638      1.6  christos 	"VCC_NOT_STABLE",
   1639      1.6  christos 	"FH_ERROR",
   1640      1.6  christos 	"NMI_INTERRUPT_HOST",
   1641      1.6  christos 	"NMI_INTERRUPT_ACTION_PT",
   1642      1.6  christos 	"NMI_INTERRUPT_UNKNOWN",
   1643      1.6  christos 	"UCODE_VERSION_MISMATCH",
   1644      1.6  christos 	"HW_ERROR_ABS_LOCK",
   1645      1.6  christos 	"HW_ERROR_CAL_LOCK_FAIL",
   1646      1.6  christos 	"NMI_INTERRUPT_INST_ACTION_PT",
   1647      1.6  christos 	"NMI_INTERRUPT_DATA_ACTION_PT",
   1648      1.6  christos 	"NMI_TRM_HW_ER",
   1649      1.6  christos 	"NMI_INTERRUPT_TRM",
   1650      1.6  christos 	"NMI_INTERRUPT_BREAKPOINT"
   1651      1.6  christos 	"DEBUG_0",
   1652      1.6  christos 	"DEBUG_1",
   1653      1.6  christos 	"DEBUG_2",
   1654      1.6  christos 	"DEBUG_3",
   1655  1.6.2.1  uebayasi 	"ADVANCED_SYSASSERT"
   1656      1.6  christos };
   1657      1.6  christos 
   1658      1.6  christos /* Find least significant bit that is set. */
   1659      1.6  christos #define IWN_LSB(x)	((((x) - 1) & (x)) ^ (x))
   1660      1.6  christos 
   1661      1.1      ober #define IWN_READ(sc, reg)						\
   1662      1.1      ober 	bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg))
   1663      1.1      ober 
   1664      1.1      ober #define IWN_WRITE(sc, reg, val)						\
   1665      1.1      ober 	bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val))
   1666      1.1      ober 
   1667  1.6.2.1  uebayasi #define IWN_WRITE_1(sc, reg, val)					\
   1668  1.6.2.1  uebayasi 	bus_space_write_1((sc)->sc_st, (sc)->sc_sh, (reg), (val))
   1669  1.6.2.1  uebayasi 
   1670      1.6  christos #define IWN_SETBITS(sc, reg, mask)					\
   1671      1.6  christos 	IWN_WRITE(sc, reg, IWN_READ(sc, reg) | (mask))
   1672      1.6  christos 
   1673      1.6  christos #define IWN_CLRBITS(sc, reg, mask)					\
   1674      1.6  christos 	IWN_WRITE(sc, reg, IWN_READ(sc, reg) & ~(mask))
   1675  1.6.2.1  uebayasi 
   1676  1.6.2.1  uebayasi #define IWN_BARRIER_WRITE(sc)						\
   1677  1.6.2.1  uebayasi 	bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz,	\
   1678  1.6.2.1  uebayasi 	    BUS_SPACE_BARRIER_WRITE)
   1679  1.6.2.1  uebayasi 
   1680  1.6.2.1  uebayasi #define IWN_BARRIER_READ_WRITE(sc)					\
   1681  1.6.2.1  uebayasi 	bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz,	\
   1682  1.6.2.1  uebayasi 	    BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE)
   1683  1.6.2.1  uebayasi 
   1684