Home | History | Annotate | Line # | Download | only in ic
bwfmreg.h revision 1.5
      1 /* $NetBSD: bwfmreg.h,v 1.5 2019/10/03 14:42:20 jmcneill Exp $ */
      2 /* $OpenBSD: bwfmreg.h,v 1.16 2018/02/07 21:44:09 patrick Exp $ */
      3 /*
      4  * Copyright (c) 2010-2016 Broadcom Corporation
      5  * Copyright (c) 2016,2017 Patrick Wildt <patrick (at) blueri.se>
      6  *
      7  * Permission to use, copy, modify, and/or distribute this software for any
      8  * purpose with or without fee is hereby granted, provided that the above
      9  * copyright notice and this permission notice appear in all copies.
     10  *
     11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     18  */
     19 
     20 /* SDIO registers */
     21 #define BWFM_SDIO_FUNC1_SBADDRLOW		0x1000A
     22 #define BWFM_SDIO_FUNC1_SBADDRMID		0x1000B
     23 #define BWFM_SDIO_FUNC1_SBADDRHIGH		0x1000C
     24 #define BWFM_SDIO_FUNC1_CHIPCLKCSR		0x1000E
     25 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_FORCE_ALP			0x01
     26 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_FORCE_HT			0x02
     27 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_FORCE_ILP			0x04
     28 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_ALP_AVAIL_REQ		0x08
     29 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_HT_AVAIL_REQ		0x10
     30 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_FORCE_HW_CLKREQ_OFF		0x20
     31 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_ALP_AVAIL			0x40
     32 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_HT_AVAIL			0x80
     33 #define  BWFM_SDIO_FUNC1_CHIPCLKCSR_CSR_MASK			0x1F
     34 #define BWFM_SDIO_FUNC1_SDIOPULLUP		0x1000F
     35 
     36 #define BWFM_SDIO_SB_OFT_ADDR_MASK		0x07FFF
     37 #define BWFM_SDIO_SB_ACCESS_2_4B_FLAG		0x08000
     38 
     39 /* Chip registers */
     40 #define BWFM_CHIP_BASE				0x18000000
     41 #define BWFM_CHIP_REG_CHIPID			0x00000000
     42 #define  BWFM_CHIP_CHIPID_ID(x)				(((x) >> 0) & 0xffff)
     43 #define  BWFM_CHIP_CHIPID_REV(x)			(((x) >> 16) & 0xf)
     44 #define  BWFM_CHIP_CHIPID_PKG(x)			(((x) >> 20) & 0xf)
     45 #define  BWFM_CHIP_CHIPID_CC(x)				(((x) >> 24) & 0xf)
     46 #define  BWFM_CHIP_CHIPID_TYPE(x)			(((x) >> 28) & 0xf)
     47 #define  BWFM_CHIP_CHIPID_TYPE_SOCI_SB			0
     48 #define  BWFM_CHIP_CHIPID_TYPE_SOCI_AI			1
     49 #define BWFM_CHIP_REG_CAPABILITIES		0x00000004
     50 #define  BWFM_CHIP_REG_CAPABILITIES_PMU			0x10000000
     51 #define BWFM_CHIP_REG_CAPABILITIES_EXT		0x000000AC
     52 #define  BWFM_CHIP_REG_CAPABILITIES_EXT_AOB_PRESENT	0x00000040
     53 #define BWFM_CHIP_REG_WATCHDOG			0x00000080
     54 #define BWFM_CHIP_REG_EROMPTR			0x000000FC
     55 #define BWFM_CHIP_REG_SR_CAPABILITY		0x00000500
     56 #define BWFM_CHIP_REG_SR_CONTROL0		0x00000504
     57 #define BWFM_CHIP_REG_SR_CONTROL1		0x00000508
     58 #define BWFM_CHIP_REG_PMUCONTROL		0x00000600
     59 #define  BWFM_CHIP_REG_PMUCONTROL_RES_MASK		0x00006000
     60 #define  BWFM_CHIP_REG_PMUCONTROL_RES_SHIFT		13
     61 #define  BWFM_CHIP_REG_PMUCONTROL_RES_RELOAD		0x2
     62 #define BWFM_CHIP_REG_PMUCAPABILITIES		0x00000604
     63 #define  BWFM_CHIP_REG_PMUCAPABILITIES_REV_MASK		0x000000ff
     64 #define BWFM_CHIP_REG_PMUCAPABILITIES_EXT	0x0000064C
     65 #define  BWFM_CHIP_REG_PMUCAPABILITIES_SR_SUPP		(1 << 1)
     66 #define BWFM_CHIP_REG_CHIPCONTROL_ADDR		0x00000650
     67 #define BWFM_CHIP_REG_CHIPCONTROL_DATA		0x00000654
     68 #define BWFM_CHIP_REG_RETENTION_CTL		0x00000670
     69 #define  BWFM_CHIP_REG_RETENTION_CTL_MACPHY_DIS		(1 << 26)
     70 #define  BWFM_CHIP_REG_RETENTION_CTL_LOGIC_DIS		(1 << 27)
     71 
     72 /* Agent registers */
     73 #define BWFM_AGENT_IOCTL			0x0408
     74 #define  BWFM_AGENT_IOCTL_CLK				0x0001
     75 #define  BWFM_AGENT_IOCTL_FGC				0x0002
     76 #define  BWFM_AGENT_IOCTL_CORE_BITS			0x3FFC
     77 #define  BWFM_AGENT_IOCTL_PME_EN			0x4000
     78 #define  BWFM_AGENT_IOCTL_BIST_EN			0x8000
     79 #define  BWFM_AGENT_IOCTL_ARMCR4_CPUHALT		0x0020
     80 #define BWFM_AGENT_RESET_CTL			0x0800
     81 #define  BWFM_AGENT_RESET_CTL_RESET			0x0001
     82 
     83 /* Agent Core-IDs */
     84 #define BWFM_AGENT_CORE_CHIPCOMMON		0x800
     85 #define BWFM_AGENT_INTERNAL_MEM			0x80E
     86 #define BWFM_AGENT_CORE_80211			0x812
     87 #define BWFM_AGENT_CORE_PMU			0x827
     88 #define BWFM_AGENT_CORE_SDIO_DEV		0x829
     89 #define BWFM_AGENT_CORE_ARM_CM3			0x82A
     90 #define BWFM_AGENT_CORE_PCIE2			0x83C
     91 #define BWFM_AGENT_CORE_ARM_CR4			0x83E
     92 #define BWFM_AGENT_CORE_ARM_CA7			0x847
     93 #define BWFM_AGENT_SYS_MEM			0x849
     94 
     95 /* Specific Core Bits */
     96 #define BWFM_AGENT_ARMCR4_IOCTL_CPUHALT		0x0020
     97 #define BWFM_AGENT_D11_IOCTL_PHYCLOCKEN		0x0004
     98 #define BWFM_AGENT_D11_IOCTL_PHYRESET		0x0008
     99 
    100 /* CR4 registers */
    101 #define BWFM_ARMCR4_CAP				0x0004
    102 #define  BWFM_ARMCR4_CAP_TCBANB_MASK			0xf
    103 #define  BWFM_ARMCR4_CAP_TCBANB_SHIFT			0
    104 #define  BWFM_ARMCR4_CAP_TCBBNB_MASK			0xf0
    105 #define  BWFM_ARMCR4_CAP_TCBBNB_SHIFT			4
    106 #define BWFM_ARMCR4_BANKIDX			0x0040
    107 #define BWFM_ARMCR4_BANKINFO			0x0044
    108 #define  BWFM_ARMCR4_BANKINFO_BSZ_MASK			0x3f
    109 #define  BWFM_ARMCR4_BANKINFO_BSZ_MULT			8192
    110 #define BWFM_ARMCR4_BANKPDA			0x004C
    111 
    112 /* SOCRAM registers */
    113 #define BWFM_SOCRAM_COREINFO			0x0000
    114 #define  BWFM_SOCRAM_COREINFO_SRBSZ_BASE		14
    115 #define  BWFM_SOCRAM_COREINFO_SRBSZ_MASK		0xf
    116 #define  BWFM_SOCRAM_COREINFO_SRBSZ_SHIFT		0
    117 #define  BWFM_SOCRAM_COREINFO_SRNB_MASK			0xf0
    118 #define  BWFM_SOCRAM_COREINFO_SRNB_SHIFT		4
    119 #define  BWFM_SOCRAM_COREINFO_LSS_MASK			0xf00000
    120 #define  BWFM_SOCRAM_COREINFO_LSS_SHIFT			20
    121 #define BWFM_SOCRAM_BANKIDX			0x0010
    122 #define  BWFM_SOCRAM_BANKIDX_MEMTYPE_RAM		0
    123 #define  BWFM_SOCRAM_BANKIDX_MEMTYPE_ROM		1
    124 #define  BWFM_SOCRAM_BANKIDX_MEMTYPE_DEVRAM		2
    125 #define  BWFM_SOCRAM_BANKIDX_MEMTYPE_SHIFT		8
    126 #define BWFM_SOCRAM_BANKINFO			0x0040
    127 #define  BWFM_SOCRAM_BANKINFO_SZBASE			8192
    128 #define  BWFM_SOCRAM_BANKINFO_SZMASK			0x7f
    129 #define  BWFM_SOCRAM_BANKINFO_RETNTRAM_MASK		0x10000
    130 #define BWFM_SOCRAM_BANKPDA			0x0044
    131 
    132 /* SDPCMD registers */
    133 #define BWFM_SDPCMD_INTSTATUS			0x0020
    134 
    135 /* DMP descriptor */
    136 #define BWFM_DMP_DESC_MASK			0x0000000F
    137 #define BWFM_DMP_DESC_EMPTY			0x00000000
    138 #define BWFM_DMP_DESC_VALID			0x00000001
    139 #define BWFM_DMP_DESC_COMPONENT			0x00000001
    140 #define BWFM_DMP_DESC_MASTER_PORT		0x00000003
    141 #define BWFM_DMP_DESC_ADDRESS			0x00000005
    142 #define BWFM_DMP_DESC_ADDRSIZE_GT32		0x00000008
    143 #define BWFM_DMP_DESC_EOT			0x0000000F
    144 #define BWFM_DMP_COMP_DESIGNER			0xFFF00000
    145 #define BWFM_DMP_COMP_DESIGNER_S		20
    146 #define BWFM_DMP_COMP_PARTNUM			0x000FFF00
    147 #define BWFM_DMP_COMP_PARTNUM_S			8
    148 #define BWFM_DMP_COMP_CLASS			0x000000F0
    149 #define BWFM_DMP_COMP_CLASS_S			4
    150 #define BWFM_DMP_COMP_REVISION			0xFF000000
    151 #define BWFM_DMP_COMP_REVISION_S		24
    152 #define BWFM_DMP_COMP_NUM_SWRAP			0x00F80000
    153 #define BWFM_DMP_COMP_NUM_SWRAP_S		19
    154 #define BWFM_DMP_COMP_NUM_MWRAP			0x0007C000
    155 #define BWFM_DMP_COMP_NUM_MWRAP_S		14
    156 #define BWFM_DMP_COMP_NUM_SPORT			0x00003E00
    157 #define BWFM_DMP_COMP_NUM_SPORT_S		9
    158 #define BWFM_DMP_COMP_NUM_MPORT			0x000001F0
    159 #define BWFM_DMP_COMP_NUM_MPORT_S		4
    160 #define BWFM_DMP_MASTER_PORT_UID		0x0000FF00
    161 #define BWFM_DMP_MASTER_PORT_UID_S		8
    162 #define BWFM_DMP_MASTER_PORT_NUM		0x000000F0
    163 #define BWFM_DMP_MASTER_PORT_NUM_S		4
    164 #define BWFM_DMP_SLAVE_ADDR_BASE		0xFFFFF000
    165 #define BWFM_DMP_SLAVE_ADDR_BASE_S		12
    166 #define BWFM_DMP_SLAVE_PORT_NUM			0x00000F00
    167 #define BWFM_DMP_SLAVE_PORT_NUM_S		8
    168 #define BWFM_DMP_SLAVE_TYPE			0x000000C0
    169 #define BWFM_DMP_SLAVE_TYPE_S			6
    170 #define  BWFM_DMP_SLAVE_TYPE_SLAVE		0
    171 #define  BWFM_DMP_SLAVE_TYPE_BRIDGE		1
    172 #define  BWFM_DMP_SLAVE_TYPE_SWRAP		2
    173 #define  BWFM_DMP_SLAVE_TYPE_MWRAP		3
    174 #define BWFM_DMP_SLAVE_SIZE_TYPE		0x00000030
    175 #define BWFM_DMP_SLAVE_SIZE_TYPE_S		4
    176 #define  BWFM_DMP_SLAVE_SIZE_4K			0
    177 #define  BWFM_DMP_SLAVE_SIZE_8K			1
    178 #define  BWFM_DMP_SLAVE_SIZE_16K		2
    179 #define  BWFM_DMP_SLAVE_SIZE_DESC		3
    180 
    181 /* Security Parameters */
    182 #define BWFM_AUTH_OPEN				0
    183 #define BWFM_AUTH_SHARED_KEY			1
    184 #define BWFM_AUTH_AUTO				2
    185 #define BWFM_CRYPTO_ALGO_OFF			0
    186 #define BWFM_CRYPTO_ALGO_WEP1			1
    187 #define BWFM_CRYPTO_ALGO_TKIP			2
    188 #define BWFM_CRYPTO_ALGO_WEP128			3
    189 #define BWFM_CRYPTO_ALGO_AES_CCM		4
    190 #define BWFM_CRYPTO_ALGO_AES_RESERVED1		5
    191 #define BWFM_CRYPTO_ALGO_AES_RESERVED2		6
    192 #define BWFM_MFP_NONE				0
    193 #define BWFM_MFP_CAPABLE			1
    194 #define BWFM_MFP_REQUIRED			2
    195 #define BWFM_WPA_AUTH_DISABLED			(0 << 0)
    196 #define BWFM_WPA_AUTH_NONE			(1 << 0)
    197 #define BWFM_WPA_AUTH_WPA_UNSPECIFIED		(1 << 1)
    198 #define BWFM_WPA_AUTH_WPA_PSK			(1 << 2)
    199 #define BWFM_WPA_AUTH_WPA2_UNSPECIFIED		(1 << 6)
    200 #define BWFM_WPA_AUTH_WPA2_PSK			(1 << 7)
    201 #define BWFM_WPA_AUTH_WPA2_1X_SHA256		(1 << 12)
    202 #define BWFM_WPA_AUTH_WPA2_PSK_SHA256		(1 << 15)
    203 #define BWFM_WSEC_NONE				(0 << 0)
    204 #define BWFM_WSEC_WEP				(1 << 0)
    205 #define BWFM_WSEC_TKIP				(1 << 1)
    206 #define BWFM_WSEC_AES				(1 << 2)
    207 
    208 /* Channel Parameters */
    209 #define BWFM_CHANSPEC_CHAN_MASK			0xff
    210 #define BWFM_CHANSPEC_CHAN_SHIFT		0
    211 #define BWFM_CHANSPEC_D11N_SB_L			(0x1 << 8) /* control lower */
    212 #define BWFM_CHANSPEC_D11N_SB_U			(0x2 << 8) /* control lower */
    213 #define BWFM_CHANSPEC_D11N_SB_N			(0x3 << 8) /* none */
    214 #define BWFM_CHANSPEC_D11N_SB_MASK		(0x3 << 8)
    215 #define BWFM_CHANSPEC_D11N_SB_SHIFT		8
    216 #define BWFM_CHANSPEC_D11N_BW_10		(0x1 << 10)
    217 #define BWFM_CHANSPEC_D11N_BW_20		(0x2 << 10)
    218 #define BWFM_CHANSPEC_D11N_BW_40		(0x3 << 10)
    219 #define BWFM_CHANSPEC_D11N_BW_MASK		(0x3 << 10)
    220 #define BWFM_CHANSPEC_D11N_BW_SHIFT		10
    221 #define BWFM_CHANSPEC_D11N_BND_5G		(0x1 << 12)
    222 #define BWFM_CHANSPEC_D11N_BND_2G		(0x2 << 12)
    223 #define BWFM_CHANSPEC_D11N_BND_MASK		(0x3 << 12)
    224 #define BWFM_CHANSPEC_D11N_BND_SHIFT		12
    225 #define BWFM_CHANSPEC_D11AC_SB_LLL		(0x0 << 8)
    226 #define BWFM_CHANSPEC_D11AC_SB_LLU		(0x1 << 8)
    227 #define BWFM_CHANSPEC_D11AC_SB_LUL		(0x2 << 8)
    228 #define BWFM_CHANSPEC_D11AC_SB_LUU		(0x3 << 8)
    229 #define BWFM_CHANSPEC_D11AC_SB_ULL		(0x4 << 8)
    230 #define BWFM_CHANSPEC_D11AC_SB_ULU		(0x5 << 8)
    231 #define BWFM_CHANSPEC_D11AC_SB_UUL		(0x6 << 8)
    232 #define BWFM_CHANSPEC_D11AC_SB_UUU		(0x7 << 8)
    233 #define BWFM_CHANSPEC_D11AC_SB_MASK		(0x7 << 8)
    234 #define BWFM_CHANSPEC_D11AC_SB_SHIFT		8
    235 #define BWFM_CHANSPEC_D11AC_BW_5		(0x0 << 11)
    236 #define BWFM_CHANSPEC_D11AC_BW_10		(0x1 << 11)
    237 #define BWFM_CHANSPEC_D11AC_BW_20		(0x2 << 11)
    238 #define BWFM_CHANSPEC_D11AC_BW_40		(0x3 << 11)
    239 #define BWFM_CHANSPEC_D11AC_BW_80		(0x4 << 11)
    240 #define BWFM_CHANSPEC_D11AC_BW_160		(0x5 << 11)
    241 #define BWFM_CHANSPEC_D11AC_BW_8080		(0x6 << 11)
    242 #define BWFM_CHANSPEC_D11AC_BW_MASK		(0x7 << 11)
    243 #define BWFM_CHANSPEC_D11AC_BW_SHIFT		11
    244 #define BWFM_CHANSPEC_D11AC_BND_2G		(0x0 << 14)
    245 #define BWFM_CHANSPEC_D11AC_BND_3G		(0x1 << 14)
    246 #define BWFM_CHANSPEC_D11AC_BND_4G		(0x2 << 14)
    247 #define BWFM_CHANSPEC_D11AC_BND_5G		(0x3 << 14)
    248 #define BWFM_CHANSPEC_D11AC_BND_MASK		(0x3 << 14)
    249 #define BWFM_CHANSPEC_D11AC_BND_SHIFT		14
    250 
    251 #define BWFM_BAND_AUTO				0
    252 #define BWFM_BAND_5G				1
    253 #define BWFM_BAND_2G				2
    254 #define BWFM_BAND_ALL				3
    255 
    256 /* Power Modes */
    257 #define BWFM_PM_CAM				0
    258 #define BWFM_PM_PS				1
    259 #define BWFM_PM_FAST_PS				2
    260 
    261 /* DCMD commands */
    262 #define BWFM_C_GET_VERSION			1
    263 #define BWFM_C_UP				2
    264 #define BWFM_C_DOWN				3
    265 #define BWFM_C_SET_PROMISC			10
    266 #define BWFM_C_GET_RATE				12
    267 #define BWFM_C_GET_INFRA			19
    268 #define BWFM_C_SET_INFRA			20
    269 #define BWFM_C_GET_AUTH				21
    270 #define BWFM_C_SET_AUTH				22
    271 #define BWFM_C_GET_BSSID			23
    272 #define BWFM_C_GET_SSID				25
    273 #define BWFM_C_SET_SSID				26
    274 #define BWFM_C_TERMINATED			28
    275 #define BWFM_C_GET_CHANNEL			29
    276 #define BWFM_C_SET_CHANNEL			30
    277 #define BWFM_C_GET_SRL				31
    278 #define BWFM_C_SET_SRL				32
    279 #define BWFM_C_GET_LRL				33
    280 #define BWFM_C_SET_LRL				34
    281 #define BWFM_C_GET_RADIO			37
    282 #define BWFM_C_SET_RADIO			38
    283 #define BWFM_C_GET_PHYTYPE			39
    284 #define BWFM_C_SET_KEY				45
    285 #define BWFM_C_GET_REGULATORY			46
    286 #define BWFM_C_SET_REGULATORY			47
    287 #define BWFM_C_SET_PASSIVE_SCAN			49
    288 #define BWFM_C_SCAN				50
    289 #define BWFM_C_SCAN_RESULTS			51
    290 #define BWFM_C_DISASSOC				52
    291 #define BWFM_C_REASSOC				53
    292 #define BWFM_C_SET_ROAM_TRIGGER			55
    293 #define BWFM_C_SET_ROAM_DELTA			57
    294 #define BWFM_C_GET_BCNPRD			75
    295 #define BWFM_C_SET_BCNPRD			76
    296 #define BWFM_C_GET_DTIMPRD			77
    297 #define BWFM_C_SET_DTIMPRD			78
    298 #define BWFM_C_SET_COUNTRY			84
    299 #define BWFM_C_GET_PM				85
    300 #define BWFM_C_SET_PM				86
    301 #define BWFM_C_GET_REVINFO			98
    302 #define BWFM_C_GET_CURR_RATESET			114
    303 #define BWFM_C_GET_AP				117
    304 #define BWFM_C_SET_AP				118
    305 #define BWFM_C_SET_SCB_AUTHORIZE		121
    306 #define BWFM_C_SET_SCB_DEAUTHORIZE		122
    307 #define BWFM_C_GET_RSSI				127
    308 #define BWFM_C_GET_WSEC				133
    309 #define BWFM_C_SET_WSEC				134
    310 #define BWFM_C_GET_PHY_NOISE			135
    311 #define BWFM_C_GET_BSS_INFO			136
    312 #define BWFM_C_GET_GET_PKTCNTS			137
    313 #define BWFM_C_GET_BANDLIST			140
    314 #define BWFM_C_SET_SCB_TIMEOUT			158
    315 #define BWFM_C_GET_ASSOCLIST			159
    316 #define BWFM_C_GET_PHYLIST			180
    317 #define BWFM_C_SET_SCAN_CHANNEL_TIME		185
    318 #define BWFM_C_SET_SCAN_UNASSOC_TIME		187
    319 #define BWFM_C_SCB_DEAUTHENTICATE_FOR_REASON	201
    320 #define BWFM_C_SET_ASSOC_PREFER			205
    321 #define BWFM_C_GET_VALID_CHANNELS		217
    322 #define BWFM_C_GET_KEY_PRIMARY			235
    323 #define BWFM_C_SET_KEY_PRIMARY			236
    324 #define BWFM_C_SET_SCAN_PASSIVE_TIME		258
    325 #define BWFM_C_GET_VAR				262
    326 #define BWFM_C_SET_VAR				263
    327 #define BWFM_C_SET_WSEC_PMK			268
    328 
    329 /* Small, medium, and maximum buffer size for dcmd */
    330 #define	BWFM_DCMD_SMLEN				256
    331 #define	BWFM_DCMD_MEDLEN			1536
    332 #define	BWFM_DCMD_MAXLEN			8192
    333 
    334 struct bwfm_proto_bcdc_dcmd {
    335 	struct {
    336 		uint32_t cmd;
    337 		uint32_t len;
    338 		uint32_t flags;
    339 #define BWFM_BCDC_DCMD_ERROR		(1 << 0)
    340 #define BWFM_BCDC_DCMD_GET		(0 << 1)
    341 #define BWFM_BCDC_DCMD_SET		(1 << 1)
    342 #define BWFM_BCDC_DCMD_IF_GET(x)	(((x) >> 12) & 0xf)
    343 #define BWFM_BCDC_DCMD_IF_SET(x)	(((x) & 0xf) << 12)
    344 #define BWFM_BCDC_DCMD_ID_GET(x)	(((x) >> 16) & 0xffff)
    345 #define BWFM_BCDC_DCMD_ID_SET(x)	(((x) & 0xffff) << 16)
    346 		uint32_t status;
    347 	} hdr;
    348 	char buf[8192];
    349 };
    350 
    351 struct bwfm_proto_bcdc_hdr {
    352 	uint8_t flags;
    353 #define BWFM_BCDC_FLAG_PROTO_VER	2
    354 #define BWFM_BCDC_FLAG_VER(x)		(((x) & 0xf) << 4)
    355 #define BWFM_BCDC_FLAG_SUM_GOOD		(1 << 2) /* rx */
    356 #define BWFM_BCDC_FLAG_SUM_NEEDED	(1 << 3) /* tx */
    357 	uint8_t priority;
    358 #define BWFM_BCDC_PRIORITY_MASK		0x7
    359 	uint8_t flags2;
    360 #define BWFM_BCDC_FLAG2_IF_MASK		0xf
    361 	uint8_t data_offset;
    362 };
    363 
    364 #define BWFM_MCSSET_LEN				16
    365 #define BWFM_MAX_SSID_LEN			32
    366 #define BWFM_BSS_INFO_BUFLEN			2048
    367 struct bwfm_bss_info {
    368 	uint32_t version;
    369 	uint32_t length;
    370 	uint8_t bssid[ETHER_ADDR_LEN];
    371 	uint16_t beacon_period;
    372 	uint16_t capability;
    373 	uint8_t ssid_len;
    374 	uint8_t ssid[BWFM_MAX_SSID_LEN];
    375 	uint32_t nrates;
    376 	uint8_t rates[16];
    377 	uint16_t chanspec;
    378 	uint16_t atim_window;
    379 	uint8_t dtim_period;
    380 	uint16_t rssi;
    381 	uint8_t phy_noise;
    382 	uint8_t n_cap;
    383 	uint32_t nbss_cap;
    384 	uint8_t ctl_ch;
    385 	uint32_t reserved32[1];
    386 	uint8_t flags;
    387 	uint8_t reserved[3];
    388 	uint8_t basic_mcs[BWFM_MCSSET_LEN];
    389 	uint16_t ie_offset;
    390 	uint32_t ie_length;
    391 	uint16_t snr;
    392 };
    393 
    394 #define BWFM_MAXRATES_IN_SET		BWFM_MCSSET_LEN
    395 #define BWFM_ANT_MAX			4
    396 #define BWFM_VHT_CAP_MCS_MAP_NSS_MAX	8
    397 #define BWFM_HE_CAP_MCS_MAP_NSS_MAX	BWFM_VHT_CAP_MCS_MAP_NSS_MAX
    398 
    399 struct bwfm_sta_rateset_v5 {
    400 	uint32_t count;
    401 	/* rates in 500kbps units w/hi bit set if basic */
    402 	uint8_t rates[BWFM_MAXRATES_IN_SET];
    403 	uint8_t mcs[BWFM_MCSSET_LEN];
    404 	uint16_t vht_mcs[BWFM_VHT_CAP_MCS_MAP_NSS_MAX];
    405 };
    406 
    407 struct bwfm_sta_rateset_v7 {
    408 	uint16_t version;
    409 	uint16_t len;
    410 	uint32_t count;
    411 	/* rates in 500kbps units w/hi bit set if basic */
    412 	uint8_t rates[BWFM_MAXRATES_IN_SET];
    413 	uint8_t mcs[BWFM_MCSSET_LEN];
    414 	uint16_t vht_mcs[BWFM_VHT_CAP_MCS_MAP_NSS_MAX];
    415 	uint16_t he_mcs[BWFM_HE_CAP_MCS_MAP_NSS_MAX];
    416 };
    417 
    418 struct bwfm_sta_info {
    419 	uint16_t ver;
    420 	uint16_t len;
    421 	uint16_t cap;		/* sta's advertised capabilities */
    422 
    423 	uint32_t flags;
    424 #define BWFM_STA_BRCM		0x00000001 /* Running a Broadcom driver */
    425 #define BWFM_STA_WME		0x00000002 /* WMM association */
    426 #define BWFM_STA_NONERP		0x00000004 /* No ERP */
    427 #define BWFM_STA_AUTHE		0x00000008 /* Authenticated */
    428 #define BWFM_STA_ASSOC		0x00000010 /* Associated */
    429 #define BWFM_STA_AUTHO		0x00000020 /* Authorized */
    430 #define BWFM_STA_WDS		0x00000040 /* Wireless Distribution System */
    431 #define BWFM_STA_WDS_LINKUP	0x00000080 /* WDS traffic/probes flowing */
    432 #define BWFM_STA_PS		0x00000100 /* STA in power save mode, says AP */
    433 #define BWFM_STA_APSD_BE	0x00000200 /* APSD for AC_BE default enabled */
    434 #define BWFM_STA_APSD_BK	0x00000400 /* APSD for AC_BK default enabled */
    435 #define BWFM_STA_APSD_VI	0x00000800 /* APSD for AC_VI default enabled */
    436 #define BWFM_STA_APSD_VO	0x00001000 /* APSD for AC_VO default enabled */
    437 #define BWFM_STA_N_CAP		0x00002000 /* STA 802.11n capable */
    438 #define BWFM_STA_SCBSTATS	0x00004000 /* Per STA debug stats */
    439 #define BWFM_STA_AMPDU_CAP	0x00008000 /* STA AMPDU capable */
    440 #define BWFM_STA_AMSDU_CAP	0x00010000 /* STA AMSDU capable */
    441 #define BWFM_STA_MIMO_PS	0x00020000 /* mimo ps mode is enabled */
    442 #define BWFM_STA_MIMO_RTS	0x00040000 /* send rts in mimo ps mode */
    443 #define BWFM_STA_RIFS_CAP	0x00080000 /* rifs enabled */
    444 #define BWFM_STA_VHT_CAP	0x00100000 /* STA VHT(11ac) capable */
    445 #define BWFM_STA_WPS		0x00200000 /* WPS state */
    446 #define BWFM_STA_DWDS_CAP	0x01000000 /* DWDS CAP */
    447 #define BWFM_STA_DWDS		0x02000000 /* DWDS active */
    448 
    449 	uint32_t idle;		/* time since data pkt rx'd from sta */
    450 	uint8_t ea[ETHER_ADDR_LEN];
    451 	uint32_t count;			/* # rates in this set */
    452 	uint8_t rates[BWFM_MAXRATES_IN_SET];	/* rates in 500kbps units */
    453 						/* w/hi bit set if basic */
    454 	uint32_t in;		/* seconds elapsed since associated */
    455 	uint32_t listen_interval_inms; /* Min Listen interval in ms for STA */
    456 
    457 	/* Fields valid for ver >= 3 */
    458 	uint32_t tx_pkts;	/* # of packets transmitted */
    459 	uint32_t tx_failures;	/* # of packets failed */
    460 	uint32_t rx_ucast_pkts;	/* # of unicast packets received */
    461 	uint32_t rx_mcast_pkts;	/* # of multicast packets received */
    462 	uint32_t tx_rate;	/* Rate of last successful tx frame, in bps */
    463 	uint32_t rx_rate;	/* Rate of last successful rx frame, in bps */
    464 	uint32_t rx_decrypt_succeeds;	/* # of packet decrypted successfully */
    465 	uint32_t rx_decrypt_failures;	/* # of packet decrypted failed */
    466 
    467 	/* Fields valid for ver >= 4 */
    468 	uint32_t tx_tot_pkts;    /* # of tx pkts (ucast + mcast) */
    469 	uint32_t rx_tot_pkts;    /* # of data packets recvd (uni + mcast) */
    470 	uint32_t tx_mcast_pkts;  /* # of mcast pkts txed */
    471 	uint64_t tx_tot_bytes;   /* data bytes txed (ucast + mcast) */
    472 	uint64_t rx_tot_bytes;   /* data bytes recvd (ucast + mcast) */
    473 	uint64_t tx_ucast_bytes; /* data bytes txed (ucast) */
    474 	uint64_t tx_mcast_bytes; /* # data bytes txed (mcast) */
    475 	uint64_t rx_ucast_bytes; /* data bytes recvd (ucast) */
    476 	uint64_t rx_mcast_bytes; /* data bytes recvd (mcast) */
    477 	int8_t rssi[BWFM_ANT_MAX];   /* per antenna rssi */
    478 	int8_t nf[BWFM_ANT_MAX];     /* per antenna noise floor */
    479 	uint16_t aid;                    /* association ID */
    480 	uint16_t ht_capabilities;        /* advertised ht caps */
    481 	uint16_t vht_flags;              /* converted vht flags */
    482 	uint32_t tx_pkts_retry_cnt;      /* # of frames where a retry was
    483 					 * exhausted.
    484 					 */
    485 	uint32_t tx_pkts_retry_exhausted; /* # of user frames where a retry
    486 					 * was exhausted
    487 					 */
    488 	int8_t rx_lastpkt_rssi[BWFM_ANT_MAX]; /* Per antenna RSSI of last
    489 					    * received data frame.
    490 					    */
    491 	/* TX WLAN retry/failure statistics:
    492 	 * Separated for host requested frames and locally generated frames.
    493 	 * Include unicast frame only where the retries/failures can be counted.
    494 	 */
    495 	uint32_t tx_pkts_total;          /* # user frames sent successfully */
    496 	uint32_t tx_pkts_retries;        /* # user frames retries */
    497 	uint32_t tx_pkts_fw_total;       /* # FW generated sent successfully */
    498 	uint32_t tx_pkts_fw_retries;     /* # retries for FW generated frames */
    499 	uint32_t tx_pkts_fw_retry_exhausted;	/* # FW generated where a retry
    500 						* was exhausted
    501 						*/
    502 	uint32_t rx_pkts_retried;        /* # rx with retry bit set */
    503 	uint32_t tx_rate_fallback;       /* lowest fallback TX rate */
    504 
    505 	union {
    506 		struct {
    507 			struct bwfm_sta_rateset_v5 rateset_adv;
    508 		} v5;
    509 
    510 		struct {
    511 			uint32_t rx_dur_total; /* user RX duration (estimate) */
    512 			uint16_t chanspec;
    513 			uint16_t pad_1;
    514 			struct bwfm_sta_rateset_v7 rateset_adv;
    515 			uint16_t wpauth;	/* authentication type */
    516 			uint8_t algo;		/* crypto alogorithm */
    517 			uint8_t pad_2;
    518 			uint32_t tx_rspec;/* Rate of last successful tx frame */
    519 			uint32_t rx_rspec;/* Rate of last successful rx frame */
    520 			uint32_t wnm_cap;
    521 		} v7;
    522 	};
    523 };
    524 
    525 struct bwfm_ssid {
    526 	uint32_t len;
    527 	uint8_t ssid[BWFM_MAX_SSID_LEN];
    528 };
    529 
    530 struct bwfm_scan_params {
    531 	struct bwfm_ssid ssid;
    532 	uint8_t bssid[ETHER_ADDR_LEN];
    533 	uint8_t bss_type;
    534 #define DOT11_BSSTYPE_ANY		2
    535 	uint8_t scan_type;
    536 #define BWFM_SCANTYPE_ACTIVE		0
    537 #define BWFM_SCANTYPE_PASSIVE		1
    538 #define BWFM_SCANTYPE_DEFAULT		0xff
    539 	uint32_t nprobes;
    540 	uint32_t active_time;
    541 	uint32_t passive_time;
    542 	uint32_t home_time;
    543 	uint32_t channel_num;
    544 	uint16_t channel_list[];
    545 };
    546 
    547 struct bwfm_scan_results {
    548 	uint32_t buflen;
    549 	uint32_t version;
    550 	uint32_t count;
    551 	struct bwfm_bss_info bss_info[];
    552 };
    553 
    554 struct bwfm_escan_params {
    555 	uint32_t version;
    556 #define BWFM_ESCAN_REQ_VERSION		1
    557 	uint16_t action;
    558 #define WL_ESCAN_ACTION_START		1
    559 #define WL_ESCAN_ACTION_CONTINUE	2
    560 #define WL_ESCAN_ACTION_ABORT		3
    561 	uint16_t sync_id;
    562 	struct bwfm_scan_params scan_params;
    563 };
    564 
    565 struct bwfm_escan_results {
    566 	uint32_t buflen;
    567 	uint32_t version;
    568 	uint16_t sync_id;
    569 	uint16_t bss_count;
    570 	struct bwfm_bss_info bss_info[];
    571 };
    572 
    573 struct bwfm_assoc_params {
    574 	uint8_t bssid[ETHER_ADDR_LEN];
    575 	uint32_t chanspec_num;
    576 	uint16_t chanspec_list[];
    577 };
    578 
    579 struct bwfm_join_pref_params {
    580 	uint8_t type;
    581 #define BWFM_JOIN_PREF_RSSI		1
    582 #define BWFM_JOIN_PREF_WPA		2
    583 #define BWFM_JOIN_PREF_BAND		3
    584 #define BWFM_JOIN_PREF_RSSI_DELTA	4
    585 	uint8_t len;
    586 	uint8_t rssi_gain;
    587 #define BWFM_JOIN_PREF_RSSI_BOOST	8
    588 	uint8_t band;
    589 #define BWFM_JOIN_PREF_BAND_AUTO	0
    590 #define BWFM_JOIN_PREF_BAND_5G		1
    591 #define BWFM_JOIN_PREF_BAND_2G		2
    592 #define BWFM_JOIN_PREF_BAND_ALL		3
    593 };
    594 
    595 struct bwfm_join_params {
    596 	struct bwfm_ssid ssid;
    597 	struct bwfm_assoc_params assoc;
    598 };
    599 
    600 struct bwfm_join_scan_params {
    601 	uint8_t scan_type;
    602 	uint32_t nprobes;
    603 	uint32_t active_time;
    604 	uint32_t passive_time;
    605 	uint32_t home_time;
    606 };
    607 
    608 struct bwfm_ext_join_params {
    609 	struct bwfm_ssid ssid;
    610 	struct bwfm_join_scan_params scan;
    611 	struct bwfm_assoc_params assoc;
    612 };
    613 
    614 struct bwfm_wsec_pmk {
    615 	uint16_t key_len;
    616 #define BWFM_WSEC_MAX_PSK_LEN		32
    617 	uint16_t flags;
    618 #define BWFM_WSEC_PASSPHRASE		(1 << 0)
    619 	uint8_t key[2 * BWFM_WSEC_MAX_PSK_LEN + 1];
    620 };
    621 
    622 struct bwfm_wsec_key {
    623 	uint32_t index;
    624 	uint32_t len;
    625 	uint8_t data[32];
    626 	uint32_t pad_1[18];
    627 	uint32_t algo;
    628 #define	BWFM_CRYPTO_ALGO_OFF		0
    629 #define	BWFM_CRYPTO_ALGO_WEP1		1
    630 #define	BWFM_CRYPTO_ALGO_TKIP		2
    631 #define	BWFM_CRYPTO_ALGO_WEP128		3
    632 #define	BWFM_CRYPTO_ALGO_AES_CCM	4
    633 #define	BWFM_CRYPTO_ALGO_AES_RESERVED1	5
    634 #define	BWFM_CRYPTO_ALGO_AES_RESERVED2	6
    635 	uint32_t flags;
    636 #define	BWFM_PRIMARY_KEY		(1 << 1)
    637 	uint32_t pad_2[3];
    638 	uint32_t iv_initialized;
    639 	uint32_t pad_3;
    640 	struct {
    641 		uint32_t hi;
    642 		uint16_t lo;
    643 	} rxiv;
    644 	uint32_t pad_4[2];
    645 	uint8_t ea[IEEE80211_ADDR_LEN];
    646 };
    647 
    648 #define	BWFM_BAND_5G			1
    649 #define	BWFM_BAND_2G			2
    650 
    651 /* Event handling */
    652 enum bwfm_fweh_event_code {
    653 	BWFM_E_SET_SSID = 0,
    654 	BWFM_E_JOIN = 1,
    655 	BWFM_E_START = 2,
    656 	BWFM_E_AUTH = 3,
    657 	BWFM_E_AUTH_IND = 4,
    658 	BWFM_E_DEAUTH = 5,
    659 	BWFM_E_DEAUTH_IND = 6,
    660 	BWFM_E_ASSOC = 7,
    661 	BWFM_E_ASSOC_IND = 8,
    662 	BWFM_E_REASSOC = 9,
    663 	BWFM_E_REASSOC_IND = 10,
    664 	BWFM_E_DISASSOC = 11,
    665 	BWFM_E_DISASSOC_IND = 12,
    666 	BWFM_E_QUIET_START = 13,
    667 	BWFM_E_QUIET_END = 14,
    668 	BWFM_E_BEACON_RX = 15,
    669 	BWFM_E_LINK = 16,
    670 	BWFM_E_MIC_ERROR = 17,
    671 	BWFM_E_NDIS_LINK = 18,
    672 	BWFM_E_ROAM = 19,
    673 	BWFM_E_TXFAIL = 20,
    674 	BWFM_E_PMKID_CACHE = 21,
    675 	BWFM_E_RETROGRADE_TSF = 22,
    676 	BWFM_E_PRUNE = 23,
    677 	BWFM_E_AUTOAUTH = 24,
    678 	BWFM_E_EAPOL_MSG = 25,
    679 	BWFM_E_SCAN_COMPLETE = 26,
    680 	BWFM_E_ADDTS_IND = 27,
    681 	BWFM_E_DELTS_IND = 28,
    682 	BWFM_E_BCNSENT_IND = 29,
    683 	BWFM_E_BCNRX_MSG = 30,
    684 	BWFM_E_BCNLOST_MSG = 31,
    685 	BWFM_E_ROAM_PREP = 32,
    686 	BWFM_E_PFN_NET_FOUND = 33,
    687 	BWFM_E_PFN_NET_LOST = 34,
    688 	BWFM_E_RESET_COMPLETE = 35,
    689 	BWFM_E_JOIN_START = 36,
    690 	BWFM_E_ROAM_START = 37,
    691 	BWFM_E_ASSOC_START = 38,
    692 	BWFM_E_IBSS_ASSOC = 39,
    693 	BWFM_E_RADIO = 40,
    694 	BWFM_E_PSM_WATCHDOG = 41,
    695 	BWFM_E_PROBREQ_MSG = 44,
    696 	BWFM_E_SCAN_CONFIRM_IND = 45,
    697 	BWFM_E_PSK_SUP = 46,
    698 	BWFM_E_COUNTRY_CODE_CHANGED = 47,
    699 	BWFM_E_EXCEEDED_MEDIUM_TIME = 48,
    700 	BWFM_E_ICV_ERROR = 49,
    701 	BWFM_E_UNICAST_DECODE_ERROR = 50,
    702 	BWFM_E_MULTICAST_DECODE_ERROR = 51,
    703 	BWFM_E_TRACE = 52,
    704 	BWFM_E_IF = 54,
    705 	BWFM_E_P2P_DISC_LISTEN_COMPLETE = 55,
    706 	BWFM_E_RSSI = 56,
    707 	BWFM_E_EXTLOG_MSG = 58,
    708 	BWFM_E_ACTION_FRAME = 59,
    709 	BWFM_E_ACTION_FRAME_COMPLETE = 60,
    710 	BWFM_E_PRE_ASSOC_IND = 61,
    711 	BWFM_E_PRE_REASSOC_IND = 62,
    712 	BWFM_E_CHANNEL_ADOPTED = 63,
    713 	BWFM_E_AP_STARTED = 64,
    714 	BWFM_E_DFS_AP_STOP = 65,
    715 	BWFM_E_DFS_AP_RESUME = 66,
    716 	BWFM_E_ESCAN_RESULT = 69,
    717 	BWFM_E_ACTION_FRAME_OFF_CHAN_COMPLETE = 70,
    718 	BWFM_E_PROBERESP_MSG = 71,
    719 	BWFM_E_P2P_PROBEREQ_MSG = 72,
    720 	BWFM_E_DCS_REQUEST = 73,
    721 	BWFM_E_FIFO_CREDIT_MAP = 74,
    722 	BWFM_E_ACTION_FRAME_RX = 75,
    723 	BWFM_E_TDLS_PEER_EVENT = 92,
    724 	BWFM_E_BCMC_CREDIT_SUPPORT = 127,
    725 	BWFM_E_LAST = 139
    726 };
    727 #define BWFM_EVENT_MASK_LEN		(roundup(BWFM_E_LAST, 8) / 8)
    728 
    729 enum bwfm_fweh_event_status {
    730 	BWFM_E_STATUS_SUCCESS = 0,
    731 	BWFM_E_STATUS_FAIL = 1,
    732 	BWFM_E_STATUS_TIMEOUT = 2,
    733 	BWFM_E_STATUS_NO_NETWORKS = 3,
    734 	BWFM_E_STATUS_ABORT = 4,
    735 	BWFM_E_STATUS_NO_ACK = 5,
    736 	BWFM_E_STATUS_UNSOLICITED = 6,
    737 	BWFM_E_STATUS_ATTEMPT = 7,
    738 	BWFM_E_STATUS_PARTIAL = 8,
    739 	BWFM_E_STATUS_NEWSCAN = 9,
    740 	BWFM_E_STATUS_NEWASSOC = 10,
    741 	BWFM_E_STATUS_11HQUIET = 11,
    742 	BWFM_E_STATUS_SUPPRESS = 12,
    743 	BWFM_E_STATUS_NOCHANS = 13,
    744 	BWFM_E_STATUS_CS_ABORT = 15,
    745 	BWFM_E_STATUS_ERROR = 16,
    746 };
    747 
    748 struct bwfm_ethhdr {
    749 	uint16_t subtype;
    750 	uint16_t length;
    751 	uint8_t version;
    752 	uint8_t oui[3];
    753 #define	BWFM_BRCM_OUI			"\x00\x10\x18"
    754 	uint16_t usr_subtype;
    755 #define	BWFM_BRCM_SUBTYPE_EVENT		1
    756 };
    757 
    758 struct bwfm_event_msg {
    759 	uint16_t version;
    760 	uint16_t flags;
    761 	uint32_t event_type;
    762 	uint32_t status;
    763 	uint32_t reason;
    764 	uint32_t auth_type;
    765 	uint32_t datalen;
    766 	struct ether_addr addr;
    767 	char ifname[IFNAMSIZ];
    768 	uint8_t ifidx;
    769 	uint8_t bsscfgidx;
    770 };
    771 
    772 struct bwfm_event {
    773 	struct ether_header ehdr;
    774 #define BWFM_ETHERTYPE_LINK_CTL			0x886c
    775 	struct bwfm_ethhdr hdr;
    776 	struct bwfm_event_msg msg;
    777 } __packed;
    778 
    779