if_wpireg.h revision 278366
1/* $FreeBSD: head/sys/dev/wpi/if_wpireg.h 278366 2015-02-07 23:11:38Z adrian $ */ 2 3/*- 4 * Copyright (c) 2006,2007 5 * Damien Bergamini <damien.bergamini@free.fr> 6 * 7 * Permission to use, copy, modify, and 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#define WPI_TX_RING_COUNT 256 21#define WPI_TX_RING_LOMARK 192 22#define WPI_TX_RING_HIMARK 224 23#define WPI_RX_RING_COUNT_LOG 6 24#define WPI_RX_RING_COUNT (1 << WPI_RX_RING_COUNT_LOG) 25 26#define WPI_NTXQUEUES 8 27#define WPI_NDMACHNLS 6 28 29/* Maximum scatter/gather. */ 30#define WPI_MAX_SCATTER 4 31 32/* 33 * Rings must be aligned on a 16K boundary. 34 */ 35#define WPI_RING_DMA_ALIGN 0x4000 36 37/* Maximum Rx buffer size. */ 38#define WPI_RBUF_SIZE ( 3 * 1024 ) /* XXX 3000 but must be aligned */ 39 40/* 41 * Control and status registers. 42 */ 43#define WPI_HW_IF_CONFIG 0x000 44#define WPI_INT 0x008 45#define WPI_INT_MASK 0x00c 46#define WPI_FH_INT 0x010 47#define WPI_GPIO_IN 0x018 48#define WPI_RESET 0x020 49#define WPI_GP_CNTRL 0x024 50#define WPI_EEPROM 0x02c 51#define WPI_EEPROM_GP 0x030 52#define WPI_GIO 0x03c 53#define WPI_UCODE_GP1 0x054 54#define WPI_UCODE_GP1_SET 0x058 55#define WPI_UCODE_GP1_CLR 0x05c 56#define WPI_UCODE_GP2 0x060 57#define WPI_GIO_CHICKEN 0x100 58#define WPI_ANA_PLL 0x20c 59#define WPI_DBG_HPET_MEM 0x240 60#define WPI_MEM_RADDR 0x40c 61#define WPI_MEM_WADDR 0x410 62#define WPI_MEM_WDATA 0x418 63#define WPI_MEM_RDATA 0x41c 64#define WPI_PRPH_WADDR 0x444 65#define WPI_PRPH_RADDR 0x448 66#define WPI_PRPH_WDATA 0x44c 67#define WPI_PRPH_RDATA 0x450 68#define WPI_HBUS_TARG_WRPTR 0x460 69 70/* 71 * Flow-Handler registers. 72 */ 73#define WPI_FH_CBBC_CTRL(qid) (0x940 + (qid) * 8) 74#define WPI_FH_CBBC_BASE(qid) (0x944 + (qid) * 8) 75#define WPI_FH_RX_CONFIG 0xc00 76#define WPI_FH_RX_BASE 0xc04 77#define WPI_FH_RX_WPTR 0xc20 78#define WPI_FH_RX_RPTR_ADDR 0xc24 79#define WPI_FH_RSSR_TBL 0xcc0 80#define WPI_FH_RX_STATUS 0xcc4 81#define WPI_FH_TX_CONFIG(qid) (0xd00 + (qid) * 32) 82#define WPI_FH_TX_BASE 0xe80 83#define WPI_FH_MSG_CONFIG 0xe88 84#define WPI_FH_TX_STATUS 0xe90 85 86 87/* 88 * NIC internal memory offsets. 89 */ 90#define WPI_ALM_SCHED_MODE 0x2e00 91#define WPI_ALM_SCHED_ARASTAT 0x2e04 92#define WPI_ALM_SCHED_TXFACT 0x2e10 93#define WPI_ALM_SCHED_TXF4MF 0x2e14 94#define WPI_ALM_SCHED_TXF5MF 0x2e20 95#define WPI_ALM_SCHED_SBYPASS_MODE1 0x2e2c 96#define WPI_ALM_SCHED_SBYPASS_MODE2 0x2e30 97#define WPI_APMG_CLK_EN 0x3004 98#define WPI_APMG_CLK_DIS 0x3008 99#define WPI_APMG_PS 0x300c 100#define WPI_APMG_PCI_STT 0x3010 101#define WPI_APMG_RFKILL 0x3014 102#define WPI_BSM_WR_CTRL 0x3400 103#define WPI_BSM_WR_MEM_SRC 0x3404 104#define WPI_BSM_WR_MEM_DST 0x3408 105#define WPI_BSM_WR_DWCOUNT 0x340c 106#define WPI_BSM_DRAM_TEXT_ADDR 0x3490 107#define WPI_BSM_DRAM_TEXT_SIZE 0x3494 108#define WPI_BSM_DRAM_DATA_ADDR 0x3498 109#define WPI_BSM_DRAM_DATA_SIZE 0x349c 110#define WPI_BSM_SRAM_BASE 0x3800 111 112 113/* Possible flags for register WPI_HW_IF_CONFIG. */ 114#define WPI_HW_IF_CONFIG_ALM_MB (1 << 8) 115#define WPI_HW_IF_CONFIG_ALM_MM (1 << 9) 116#define WPI_HW_IF_CONFIG_SKU_MRC (1 << 10) 117#define WPI_HW_IF_CONFIG_REV_D (1 << 11) 118#define WPI_HW_IF_CONFIG_TYPE_B (1 << 12) 119 120/* Possible flags for registers WPI_PRPH_RADDR/WPI_PRPH_WADDR. */ 121#define WPI_PRPH_DWORD ((sizeof (uint32_t) - 1) << 24) 122 123/* Possible values for WPI_BSM_WR_MEM_DST. */ 124#define WPI_FW_TEXT_BASE 0x00000000 125#define WPI_FW_DATA_BASE 0x00800000 126 127/* Possible flags for WPI_GPIO_IN. */ 128#define WPI_GPIO_IN_VMAIN (1 << 9) 129 130/* Possible flags for register WPI_RESET. */ 131#define WPI_RESET_NEVO (1 << 0) 132#define WPI_RESET_SW (1 << 7) 133#define WPI_RESET_MASTER_DISABLED (1 << 8) 134#define WPI_RESET_STOP_MASTER (1 << 9) 135 136/* Possible flags for register WPI_GP_CNTRL. */ 137#define WPI_GP_CNTRL_MAC_ACCESS_ENA (1 << 0) 138#define WPI_GP_CNTRL_MAC_CLOCK_READY (1 << 0) 139#define WPI_GP_CNTRL_INIT_DONE (1 << 2) 140#define WPI_GP_CNTRL_MAC_ACCESS_REQ (1 << 3) 141#define WPI_GP_CNTRL_SLEEP (1 << 4) 142#define WPI_GP_CNTRL_PS_MASK (7 << 24) 143#define WPI_GP_CNTRL_MAC_PS (4 << 24) 144#define WPI_GP_CNTRL_RFKILL (1 << 27) 145 146/* Possible flags for register WPI_GIO_CHICKEN. */ 147#define WPI_GIO_CHICKEN_L1A_NO_L0S_RX (1 << 23) 148#define WPI_GIO_CHICKEN_DIS_L0S_TIMER (1 << 29) 149 150/* Possible flags for register WPI_GIO. */ 151#define WPI_GIO_L0S_ENA (1 << 1) 152 153/* Possible flags for register WPI_FH_RX_CONFIG. */ 154#define WPI_FH_RX_CONFIG_DMA_ENA (1U << 31) 155#define WPI_FH_RX_CONFIG_RDRBD_ENA (1 << 29) 156#define WPI_FH_RX_CONFIG_WRSTATUS_ENA (1 << 27) 157#define WPI_FH_RX_CONFIG_MAXFRAG (1 << 24) 158#define WPI_FH_RX_CONFIG_NRBD(x) ((x) << 20) 159#define WPI_FH_RX_CONFIG_IRQ_DST_HOST (1 << 12) 160#define WPI_FH_RX_CONFIG_IRQ_TIMEOUT(x) ((x) << 4) 161 162/* Possible flags for register WPI_ANA_PLL. */ 163#define WPI_ANA_PLL_INIT (1 << 24) 164 165/* Possible flags for register WPI_UCODE_GP1*. */ 166#define WPI_UCODE_GP1_MAC_SLEEP (1 << 0) 167#define WPI_UCODE_GP1_RFKILL (1 << 1) 168#define WPI_UCODE_GP1_CMD_BLOCKED (1 << 2) 169 170/* Possible flags for register WPI_FH_RX_STATUS. */ 171#define WPI_FH_RX_STATUS_IDLE (1 << 24) 172 173/* Possible flags for register WPI_BSM_WR_CTRL. */ 174#define WPI_BSM_WR_CTRL_START_EN (1 << 30) 175#define WPI_BSM_WR_CTRL_START (1U << 31) 176 177/* Possible flags for register WPI_INT. */ 178#define WPI_INT_ALIVE (1 << 0) 179#define WPI_INT_WAKEUP (1 << 1) 180#define WPI_INT_SW_RX (1 << 3) 181#define WPI_INT_SW_ERR (1 << 25) 182#define WPI_INT_FH_TX (1 << 27) 183#define WPI_INT_HW_ERR (1 << 29) 184#define WPI_INT_FH_RX (1U << 31) 185 186/* Shortcut. */ 187#define WPI_INT_MASK_DEF \ 188 (WPI_INT_SW_ERR | WPI_INT_HW_ERR | WPI_INT_FH_TX | \ 189 WPI_INT_FH_RX | WPI_INT_ALIVE | WPI_INT_WAKEUP | \ 190 WPI_INT_SW_RX) 191 192/* Possible flags for register WPI_FH_INT. */ 193#define WPI_FH_INT_RX_CHNL(x) (1 << ((x) + 16)) 194#define WPI_FH_INT_HI_PRIOR (1 << 30) 195/* Shortcuts for the above. */ 196#define WPI_FH_INT_RX \ 197 (WPI_FH_INT_RX_CHNL(0) | \ 198 WPI_FH_INT_RX_CHNL(1) | \ 199 WPI_FH_INT_RX_CHNL(2) | \ 200 WPI_FH_INT_HI_PRIOR) 201 202/* Possible flags for register WPI_FH_TX_STATUS. */ 203#define WPI_FH_TX_STATUS_IDLE(qid) \ 204 (1 << ((qid) + 24) | 1 << ((qid) + 16)) 205 206/* Possible flags for register WPI_EEPROM. */ 207#define WPI_EEPROM_READ_VALID (1 << 0) 208 209/* Possible flags for register WPI_EEPROM_GP. */ 210#define WPI_EEPROM_VERSION 0x00000007 211#define WPI_EEPROM_GP_IF_OWNER 0x00000180 212 213/* Possible flags for register WPI_APMG_PS. */ 214#define WPI_APMG_PS_PWR_SRC_MASK (3 << 24) 215 216/* Possible flags for registers WPI_APMG_CLK_*. */ 217#define WPI_APMG_CLK_CTRL_DMA_CLK_RQT (1 << 9) 218#define WPI_APMG_CLK_CTRL_BSM_CLK_RQT (1 << 11) 219 220/* Possible flags for register WPI_APMG_PCI_STT. */ 221#define WPI_APMG_PCI_STT_L1A_DIS (1 << 11) 222 223struct wpi_shared { 224 uint32_t txbase[8]; 225 uint32_t next; 226 uint32_t reserved[2]; 227} __packed; 228 229#define WPI_MAX_SEG_LEN 65520 230struct wpi_tx_desc { 231 uint8_t reserved1[3]; 232 uint8_t nsegs; 233#define WPI_PAD32(x) (roundup2(x, 4) - (x)) 234 235 struct { 236 uint32_t addr; 237 uint32_t len; 238 } __packed segs[WPI_MAX_SCATTER]; 239 uint8_t reserved2[28]; 240} __packed; 241 242struct wpi_tx_stat { 243 uint8_t rtsfailcnt; 244 uint8_t ackfailcnt; 245 uint8_t btkillcnt; 246 uint8_t rate; 247 uint32_t duration; 248 uint32_t status; 249} __packed; 250 251struct wpi_rx_desc { 252 uint32_t len; 253 uint8_t type; 254#define WPI_UC_READY 1 255#define WPI_RX_DONE 27 256#define WPI_TX_DONE 28 257#define WPI_START_SCAN 130 258#define WPI_SCAN_RESULTS 131 259#define WPI_STOP_SCAN 132 260#define WPI_BEACON_SENT 144 261#define WPI_RX_STATISTICS 156 262#define WPI_BEACON_STATISTICS 157 263#define WPI_STATE_CHANGED 161 264#define WPI_BEACON_MISSED 162 265 266 uint8_t flags; 267 uint8_t idx; 268 uint8_t qid; 269} __packed; 270 271struct wpi_rx_stat { 272 uint8_t len; 273#define WPI_STAT_MAXLEN 20 274 275 uint8_t id; 276 uint8_t rssi; /* received signal strength */ 277#define WPI_RSSI_OFFSET 95 278 279 uint8_t agc; /* access gain control */ 280 uint16_t signal; 281 uint16_t noise; 282} __packed; 283 284struct wpi_rx_head { 285 uint16_t chan; 286 uint16_t flags; 287#define WPI_STAT_FLAG_SHPREAMBLE (1 << 2) 288 289 uint8_t reserved; 290 uint8_t plcp; 291 uint16_t len; 292} __packed; 293 294struct wpi_rx_tail { 295 uint32_t flags; 296#define WPI_RX_NO_CRC_ERR (1 << 0) 297#define WPI_RX_NO_OVFL_ERR (1 << 1) 298/* shortcut for the above */ 299#define WPI_RX_NOERROR (WPI_RX_NO_CRC_ERR | WPI_RX_NO_OVFL_ERR) 300#define WPI_RX_CIPHER_MASK (7 << 8) 301#define WPI_RX_CIPHER_CCMP (2 << 8) 302#define WPI_RX_DECRYPT_MASK (3 << 11) 303#define WPI_RX_DECRYPT_OK (3 << 11) 304 305 uint64_t tstamp; 306 uint32_t tbeacon; 307} __packed; 308 309struct wpi_tx_cmd { 310 uint8_t code; 311#define WPI_CMD_RXON 16 312#define WPI_CMD_RXON_ASSOC 17 313#define WPI_CMD_EDCA_PARAMS 19 314#define WPI_CMD_TIMING 20 315#define WPI_CMD_ADD_NODE 24 316#define WPI_CMD_DEL_NODE 25 317#define WPI_CMD_TX_DATA 28 318#define WPI_CMD_MRR_SETUP 71 319#define WPI_CMD_SET_LED 72 320#define WPI_CMD_SET_POWER_MODE 119 321#define WPI_CMD_SCAN 128 322#define WPI_CMD_SET_BEACON 145 323#define WPI_CMD_TXPOWER 151 324#define WPI_CMD_BT_COEX 155 325#define WPI_CMD_GET_STATISTICS 156 326 327 uint8_t flags; 328 uint8_t idx; 329 uint8_t qid; 330 uint8_t data[124]; 331} __packed; 332 333/* Structure for command WPI_CMD_RXON. */ 334struct wpi_rxon { 335 uint8_t myaddr[IEEE80211_ADDR_LEN]; 336 uint16_t reserved1; 337 uint8_t bssid[IEEE80211_ADDR_LEN]; 338 uint16_t reserved2; 339 uint8_t wlap[IEEE80211_ADDR_LEN]; 340 uint16_t reserved3; 341 uint8_t mode; 342#define WPI_MODE_HOSTAP 1 343#define WPI_MODE_STA 3 344#define WPI_MODE_IBSS 4 345#define WPI_MODE_MONITOR 6 346 347 uint8_t air; 348 uint16_t reserved4; 349 uint8_t ofdm_mask; 350 uint8_t cck_mask; 351 uint16_t associd; 352 uint32_t flags; 353#define WPI_RXON_24GHZ (1 << 0) 354#define WPI_RXON_CCK (1 << 1) 355#define WPI_RXON_AUTO (1 << 2) 356#define WPI_RXON_SHSLOT (1 << 4) 357#define WPI_RXON_SHPREAMBLE (1 << 5) 358#define WPI_RXON_NODIVERSITY (1 << 7) 359#define WPI_RXON_ANTENNA_A (1 << 8) 360#define WPI_RXON_ANTENNA_B (1 << 9) 361#define WPI_RXON_TSF (1 << 15) 362#define WPI_RXON_CTS_TO_SELF (1 << 30) 363 364 uint32_t filter; 365#define WPI_FILTER_PROMISC (1 << 0) 366#define WPI_FILTER_CTL (1 << 1) 367#define WPI_FILTER_MULTICAST (1 << 2) 368#define WPI_FILTER_NODECRYPT (1 << 3) 369#define WPI_FILTER_BSS (1 << 5) 370#define WPI_FILTER_BEACON (1 << 6) 371 372 uint8_t chan; 373 uint16_t reserved5; 374} __packed; 375 376/* Structure for command WPI_CMD_RXON_ASSOC. */ 377struct wpi_assoc { 378 uint32_t flags; 379 uint32_t filter; 380 uint8_t ofdm_mask; 381 uint8_t cck_mask; 382 uint16_t reserved; 383} __packed; 384 385/* Structure for command WPI_CMD_EDCA_PARAMS. */ 386struct wpi_edca_params { 387 uint32_t flags; 388#define WPI_EDCA_UPDATE (1 << 0) 389 390 struct { 391 uint16_t cwmin; 392 uint16_t cwmax; 393 uint8_t aifsn; 394 uint8_t reserved; 395 uint16_t txoplimit; 396 } __packed ac[WME_NUM_AC]; 397} __packed; 398 399/* Structure for command WPI_CMD_TIMING. */ 400struct wpi_cmd_timing { 401 uint64_t tstamp; 402 uint16_t bintval; 403 uint16_t atim; 404 uint32_t binitval; 405 uint16_t lintval; 406 uint16_t reserved; 407} __packed; 408 409/* Structure for command WPI_CMD_ADD_NODE. */ 410struct wpi_node_info { 411 uint8_t control; 412#define WPI_NODE_UPDATE (1 << 0) 413 414 uint8_t reserved1[3]; 415 uint8_t macaddr[IEEE80211_ADDR_LEN]; 416 uint16_t reserved2; 417 uint8_t id; 418#define WPI_ID_BSS 0 419#define WPI_ID_IBSS_MIN 2 420#define WPI_ID_IBSS_MAX 23 421#define WPI_ID_BROADCAST 24 422#define WPI_ID_UNDEFINED (uint8_t)-1 423 424 uint8_t flags; 425#define WPI_FLAG_KEY_SET (1 << 0) 426 427 uint16_t reserved3; 428 uint16_t kflags; 429#define WPI_KFLAG_CCMP (1 << 1) 430#define WPI_KFLAG_KID(kid) ((kid) << 8) 431#define WPI_KFLAG_MULTICAST (1 << 14) 432 433 uint8_t tsc2; 434 uint8_t reserved4; 435 uint16_t ttak[5]; 436 uint16_t reserved5; 437 uint8_t key[IEEE80211_KEYBUF_SIZE]; 438 uint32_t action; 439#define WPI_ACTION_SET_RATE (1 << 2) 440 441 uint32_t mask; 442 uint16_t tid; 443 uint8_t plcp; 444 uint8_t antenna; 445#define WPI_ANTENNA_A (1 << 6) 446#define WPI_ANTENNA_B (1 << 7) 447#define WPI_ANTENNA_BOTH (WPI_ANTENNA_A | WPI_ANTENNA_B) 448 449 uint8_t add_imm; 450 uint8_t del_imm; 451 uint16_t add_imm_start; 452} __packed; 453 454/* Structure for command WPI_CMD_DEL_NODE. */ 455struct wpi_cmd_del_node { 456 uint8_t count; 457 uint8_t reserved1[3]; 458 uint8_t macaddr[IEEE80211_ADDR_LEN]; 459 uint16_t reserved2; 460} __packed; 461 462/* Structure for command WPI_CMD_TX_DATA. */ 463struct wpi_cmd_data { 464 uint16_t len; 465 uint16_t lnext; 466 uint32_t flags; 467#define WPI_TX_NEED_RTS (1 << 1) 468#define WPI_TX_NEED_CTS (1 << 2) 469#define WPI_TX_NEED_ACK (1 << 3) 470#define WPI_TX_FULL_TXOP (1 << 7) 471#define WPI_TX_BT_DISABLE (1 << 12) /* bluetooth coexistence */ 472#define WPI_TX_AUTO_SEQ (1 << 13) 473#define WPI_TX_INSERT_TSTAMP (1 << 16) 474 475 uint8_t plcp; 476 uint8_t id; 477 uint8_t tid; 478 uint8_t security; 479#define WPI_CIPHER_WEP 1 480#define WPI_CIPHER_CCMP 2 481#define WPI_CIPHER_TKIP 3 482#define WPI_CIPHER_WEP104 9 483 484 uint8_t key[IEEE80211_KEYBUF_SIZE]; 485 uint8_t tkip[IEEE80211_WEP_MICLEN]; 486 uint32_t fnext; 487 uint32_t lifetime; 488#define WPI_LIFETIME_INFINITE 0xffffffff 489 490 uint8_t ofdm_mask; 491 uint8_t cck_mask; 492 uint8_t rts_ntries; 493 uint8_t data_ntries; 494 uint16_t timeout; 495 uint16_t txop; 496} __packed; 497 498/* Structure for command WPI_CMD_SET_BEACON. */ 499struct wpi_cmd_beacon { 500 uint16_t len; 501 uint16_t reserved1; 502 uint32_t flags; /* same as wpi_cmd_data */ 503 uint8_t plcp; 504 uint8_t id; 505 uint8_t reserved2[30]; 506 uint32_t lifetime; 507 uint8_t ofdm_mask; 508 uint8_t cck_mask; 509 uint16_t reserved3[3]; 510 uint16_t tim; 511 uint8_t timsz; 512 uint8_t reserved4; 513} __packed; 514 515/* Structure for notification WPI_BEACON_MISSED. */ 516struct wpi_beacon_missed { 517 uint32_t consecutive; 518 uint32_t total; 519 uint32_t expected; 520 uint32_t received; 521} __packed; 522 523 524/* Structure for command WPI_CMD_MRR_SETUP. */ 525#define WPI_RIDX_MAX 11 526struct wpi_mrr_setup { 527 uint32_t which; 528#define WPI_MRR_CTL 0 529#define WPI_MRR_DATA 1 530 531 struct { 532 uint8_t plcp; 533 uint8_t flags; 534 uint8_t ntries; 535 uint8_t next; 536 } __packed rates[WPI_RIDX_MAX + 1]; 537} __packed; 538 539/* Structure for command WPI_CMD_SET_LED. */ 540struct wpi_cmd_led { 541 uint32_t unit; /* multiplier (in usecs) */ 542 uint8_t which; 543#define WPI_LED_ACTIVITY 1 544#define WPI_LED_LINK 2 545 546 uint8_t off; 547 uint8_t on; 548 uint8_t reserved; 549} __packed; 550 551/* Structure for command WPI_CMD_SET_POWER_MODE. */ 552struct wpi_pmgt_cmd { 553 uint16_t flags; 554#define WPI_PS_ALLOW_SLEEP (1 << 0) 555#define WPI_PS_NOTIFY (1 << 1) 556#define WPI_PS_SLEEP_OVER_DTIM (1 << 2) 557#define WPI_PS_PCI_PMGT (1 << 3) 558 559 uint8_t reserved[2]; 560 uint32_t rxtimeout; 561 uint32_t txtimeout; 562 uint32_t intval[5]; 563} __packed; 564 565/* Structures for command WPI_CMD_SCAN. */ 566#define WPI_SCAN_MAX_ESSIDS 4 567struct wpi_scan_essid { 568 uint8_t id; 569 uint8_t len; 570 uint8_t data[IEEE80211_NWID_LEN]; 571} __packed; 572 573struct wpi_scan_hdr { 574 uint16_t len; 575 uint8_t reserved1; 576 uint8_t nchan; 577 uint16_t quiet_time; 578 uint16_t quiet_threshold; 579 uint16_t crc_threshold; 580 uint16_t reserved2; 581 uint32_t max_svc; /* background scans */ 582 uint32_t pause_svc; /* background scans */ 583 uint32_t flags; 584 uint32_t filter; 585 586 /* Followed by a struct wpi_cmd_data. */ 587 /* Followed by an array of 4 structs wpi_scan_essid. */ 588 /* Followed by probe request body. */ 589 /* Followed by an array of ``nchan'' structs wpi_scan_chan. */ 590} __packed; 591 592struct wpi_scan_chan { 593 uint8_t flags; 594#define WPI_CHAN_ACTIVE (1 << 0) 595#define WPI_CHAN_NPBREQS(x) (((1 << (x)) - 1) << 1) 596 597 uint8_t chan; 598 uint8_t rf_gain; 599 uint8_t dsp_gain; 600 uint16_t active; /* msecs */ 601 uint16_t passive; /* msecs */ 602} __packed; 603 604#define WPI_SCAN_CRC_TH_DEFAULT htole16(1) 605#define WPI_SCAN_CRC_TH_NEVER htole16(0xffff) 606 607/* Maximum size of a scan command. */ 608#define WPI_SCAN_MAXSZ (MCLBYTES - 4) 609 610#define WPI_ACTIVE_DWELL_TIME_2GHZ (30) /* all times in msec */ 611#define WPI_ACTIVE_DWELL_TIME_5GHZ (20) 612#define WPI_ACTIVE_DWELL_FACTOR_2GHZ ( 3) 613#define WPI_ACTIVE_DWELL_FACTOR_5GHZ ( 2) 614 615#define WPI_PASSIVE_DWELL_TIME_2GHZ ( 20) 616#define WPI_PASSIVE_DWELL_TIME_5GHZ ( 10) 617#define WPI_PASSIVE_DWELL_BASE (100) 618 619/* Structure for command WPI_CMD_TXPOWER. */ 620struct wpi_cmd_txpower { 621 uint8_t band; 622#define WPI_BAND_5GHZ 0 623#define WPI_BAND_2GHZ 1 624 625 uint8_t reserved; 626 uint16_t chan; 627 628 struct { 629 uint8_t plcp; 630 uint8_t rf_gain; 631 uint8_t dsp_gain; 632 uint8_t reserved; 633 } __packed rates[WPI_RIDX_MAX + 1]; 634 635} __packed; 636 637/* Structure for command WPI_CMD_BT_COEX. */ 638struct wpi_bluetooth { 639 uint8_t flags; 640#define WPI_BT_COEX_DISABLE 0 641#define WPI_BT_COEX_MODE_2WIRE 1 642#define WPI_BT_COEX_MODE_3WIRE 2 643#define WPI_BT_COEX_MODE_4WIRE 3 644 645 uint8_t lead_time; 646#define WPI_BT_LEAD_TIME_DEF 30 647 648 uint8_t max_kill; 649#define WPI_BT_MAX_KILL_DEF 5 650 651 uint8_t reserved; 652 uint32_t kill_ack; 653 uint32_t kill_cts; 654} __packed; 655 656/* Structure for WPI_UC_READY notification. */ 657struct wpi_ucode_info { 658 uint8_t minor; 659 uint8_t major; 660 uint16_t reserved1; 661 uint8_t revision[8]; 662 uint8_t type; 663 uint8_t subtype; 664 uint16_t reserved2; 665 uint32_t logptr; 666 uint32_t errptr; 667 uint32_t tstamp; 668 uint32_t valid; 669} __packed; 670 671/* Structure for WPI_START_SCAN notification. */ 672struct wpi_start_scan { 673 uint64_t tstamp; 674 uint32_t tbeacon; 675 uint8_t chan; 676 uint8_t band; 677 uint16_t reserved; 678 uint32_t status; 679} __packed; 680 681/* Structure for WPI_STOP_SCAN notification. */ 682struct wpi_stop_scan { 683 uint8_t nchan; 684 uint8_t status; 685 uint8_t reserved; 686 uint8_t chan; 687 uint64_t tsf; 688} __packed; 689 690/* Structures for WPI_{RX,BEACON}_STATISTICS notification. */ 691struct wpi_rx_phy_stats { 692 uint32_t ina; 693 uint32_t fina; 694 uint32_t bad_plcp; 695 uint32_t bad_crc32; 696 uint32_t overrun; 697 uint32_t eoverrun; 698 uint32_t good_crc32; 699 uint32_t fa; 700 uint32_t bad_fina_sync; 701 uint32_t sfd_timeout; 702 uint32_t fina_timeout; 703 uint32_t no_rts_ack; 704 uint32_t rxe_limit; 705 uint32_t ack; 706 uint32_t cts; 707} __packed; 708 709struct wpi_rx_general_stats { 710 uint32_t bad_cts; 711 uint32_t bad_ack; 712 uint32_t not_bss; 713 uint32_t filtered; 714 uint32_t bad_chan; 715} __packed; 716 717struct wpi_rx_stats { 718 struct wpi_rx_phy_stats ofdm; 719 struct wpi_rx_phy_stats cck; 720 struct wpi_rx_general_stats general; 721} __packed; 722 723struct wpi_tx_stats { 724 uint32_t preamble; 725 uint32_t rx_detected; 726 uint32_t bt_defer; 727 uint32_t bt_kill; 728 uint32_t short_len; 729 uint32_t cts_timeout; 730 uint32_t ack_timeout; 731 uint32_t exp_ack; 732 uint32_t ack; 733} __packed; 734 735struct wpi_general_stats { 736 uint32_t temp; 737 uint32_t burst_check; 738 uint32_t burst; 739 uint32_t reserved[4]; 740 uint32_t sleep; 741 uint32_t slot_out; 742 uint32_t slot_idle; 743 uint32_t ttl_tstamp; 744 uint32_t tx_ant_a; 745 uint32_t tx_ant_b; 746 uint32_t exec; 747 uint32_t probe; 748} __packed; 749 750struct wpi_stats { 751 uint32_t flags; 752 struct wpi_rx_stats rx; 753 struct wpi_tx_stats tx; 754 struct wpi_general_stats general; 755} __packed; 756 757/* Possible flags for command WPI_CMD_GET_STATISTICS. */ 758#define WPI_STATISTICS_BEACON_DISABLE (1 << 1) 759 760 761/* Firmware error dump entry. */ 762struct wpi_fw_dump { 763 uint32_t desc; 764 uint32_t time; 765 uint32_t blink[2]; 766 uint32_t ilink[2]; 767 uint32_t data; 768} __packed; 769 770/* Firmware image file header. */ 771struct wpi_firmware_hdr { 772 773#define WPI_FW_MINVERSION 2144 774#define WPI_FW_NAME "wpifw" 775 776 uint16_t driver; 777 uint8_t minor; 778 uint8_t major; 779 uint32_t rtextsz; 780 uint32_t rdatasz; 781 uint32_t itextsz; 782 uint32_t idatasz; 783 uint32_t btextsz; 784} __packed; 785 786#define WPI_FW_TEXT_MAXSZ ( 80 * 1024 ) 787#define WPI_FW_DATA_MAXSZ ( 32 * 1024 ) 788#define WPI_FW_BOOT_TEXT_MAXSZ 1024 789 790#define WPI_FW_UPDATED (1U << 31 ) 791 792/* 793 * Offsets into EEPROM. 794 */ 795#define WPI_EEPROM_MAC 0x015 796#define WPI_EEPROM_REVISION 0x035 797#define WPI_EEPROM_SKU_CAP 0x045 798#define WPI_EEPROM_TYPE 0x04a 799#define WPI_EEPROM_DOMAIN 0x060 800#define WPI_EEPROM_BAND1 0x063 801#define WPI_EEPROM_BAND2 0x072 802#define WPI_EEPROM_BAND3 0x080 803#define WPI_EEPROM_BAND4 0x08d 804#define WPI_EEPROM_BAND5 0x099 805#define WPI_EEPROM_POWER_GRP 0x100 806 807struct wpi_eeprom_chan { 808 uint8_t flags; 809#define WPI_EEPROM_CHAN_VALID (1 << 0) 810#define WPI_EEPROM_CHAN_IBSS (1 << 1) 811#define WPI_EEPROM_CHAN_ACTIVE (1 << 3) 812#define WPI_EEPROM_CHAN_RADAR (1 << 4) 813 814 int8_t maxpwr; 815} __packed; 816 817struct wpi_eeprom_sample { 818 uint8_t index; 819 int8_t power; 820 uint16_t volt; 821} __packed; 822 823#define WPI_POWER_GROUPS_COUNT 5 824struct wpi_eeprom_group { 825 struct wpi_eeprom_sample samples[5]; 826 int32_t coef[5]; 827 int32_t corr[5]; 828 int8_t maxpwr; 829 uint8_t chan; 830 int16_t temp; 831} __packed; 832 833#define WPI_CHAN_BANDS_COUNT 5 834#define WPI_MAX_CHAN_PER_BAND 14 835static const struct wpi_chan_band { 836 uint32_t addr; /* offset in EEPROM */ 837 uint8_t nchan; 838 uint8_t chan[WPI_MAX_CHAN_PER_BAND]; 839} wpi_bands[] = { 840 /* 20MHz channels, 2GHz band. */ 841 { WPI_EEPROM_BAND1, 14, 842 { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 } }, 843 /* 20MHz channels, 5GHz band. */ 844 { WPI_EEPROM_BAND2, 13, 845 { 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 } }, 846 { WPI_EEPROM_BAND3, 12, 847 { 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 } }, 848 { WPI_EEPROM_BAND4, 11, 849 { 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 } }, 850 { WPI_EEPROM_BAND5, 6, 851 { 145, 149, 153, 157, 161, 165 } } 852}; 853 854/* HW rate indices. */ 855#define WPI_RIDX_OFDM6 0 856#define WPI_RIDX_OFDM36 5 857#define WPI_RIDX_OFDM48 6 858#define WPI_RIDX_OFDM54 7 859#define WPI_RIDX_CCK1 8 860#define WPI_RIDX_CCK2 9 861#define WPI_RIDX_CCK11 11 862 863static const uint8_t wpi_ridx_to_plcp[] = { 864 /* OFDM: IEEE Std 802.11a-1999, pp. 14 Table 80 */ 865 /* R1-R4 (ral/ural is R4-R1) */ 866 0xd, 0xf, 0x5, 0x7, 0x9, 0xb, 0x1, 0x3, 867 /* CCK: device-dependent */ 868 10, 20, 55, 110 869}; 870 871#define WPI_MAX_PWR_INDEX 77 872 873/* 874 * RF Tx gain values from highest to lowest power (values obtained from 875 * the reference driver.) 876 */ 877static const uint8_t wpi_rf_gain_2ghz[WPI_MAX_PWR_INDEX + 1] = { 878 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xfb, 0xbb, 0xbb, 0xbb, 879 0xbb, 0xf3, 0xf3, 0xf3, 0xf3, 0xf3, 0xd3, 0xd3, 0xb3, 0xb3, 0xb3, 880 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x73, 0xeb, 0xeb, 0xeb, 881 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xcb, 0xab, 0xab, 0xab, 0x8b, 882 0xe3, 0xe3, 0xe3, 0xe3, 0xe3, 0xe3, 0xc3, 0xc3, 0xc3, 0xc3, 0xa3, 883 0xa3, 0xa3, 0xa3, 0x83, 0x83, 0x83, 0x83, 0x63, 0x63, 0x63, 0x63, 884 0x43, 0x43, 0x43, 0x43, 0x23, 0x23, 0x23, 0x23, 0x03, 0x03, 0x03, 885 0x03 886}; 887 888static const uint8_t wpi_rf_gain_5ghz[WPI_MAX_PWR_INDEX + 1] = { 889 0xfb, 0xfb, 0xfb, 0xdb, 0xdb, 0xbb, 0xbb, 0x9b, 0x9b, 0x7b, 0x7b, 890 0x7b, 0x7b, 0x5b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x1b, 0x1b, 891 0x1b, 0x73, 0x73, 0x73, 0x53, 0x53, 0x53, 0x53, 0x53, 0x33, 0x33, 892 0x33, 0x33, 0x13, 0x13, 0x13, 0x13, 0x13, 0xab, 0xab, 0xab, 0x8b, 893 0x8b, 0x8b, 0x8b, 0x6b, 0x6b, 0x6b, 0x6b, 0x4b, 0x4b, 0x4b, 0x4b, 894 0x2b, 0x2b, 0x2b, 0x2b, 0x0b, 0x0b, 0x0b, 0x0b, 0x83, 0x83, 0x63, 895 0x63, 0x63, 0x63, 0x43, 0x43, 0x43, 0x43, 0x23, 0x23, 0x23, 0x23, 896 0x03 897}; 898 899/* 900 * DSP pre-DAC gain values from highest to lowest power (values obtained 901 * from the reference driver.) 902 */ 903static const uint8_t wpi_dsp_gain_2ghz[WPI_MAX_PWR_INDEX + 1] = { 904 0x7f, 0x7f, 0x7f, 0x7f, 0x7d, 0x6e, 0x69, 0x62, 0x7d, 0x73, 0x6c, 905 0x63, 0x77, 0x6f, 0x69, 0x61, 0x5c, 0x6a, 0x64, 0x78, 0x71, 0x6b, 906 0x7d, 0x77, 0x70, 0x6a, 0x65, 0x61, 0x5b, 0x6b, 0x79, 0x73, 0x6d, 907 0x7f, 0x79, 0x73, 0x6c, 0x66, 0x60, 0x5c, 0x6e, 0x68, 0x62, 0x74, 908 0x7d, 0x77, 0x71, 0x6b, 0x65, 0x60, 0x71, 0x6a, 0x66, 0x5f, 0x71, 909 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 0x5f, 910 0x71, 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 0x5f, 0x71, 0x6a, 0x66, 911 0x5f 912}; 913 914static const uint8_t wpi_dsp_gain_5ghz[WPI_MAX_PWR_INDEX + 1] = { 915 0x7f, 0x78, 0x72, 0x77, 0x65, 0x71, 0x66, 0x72, 0x67, 0x75, 0x6b, 916 0x63, 0x5c, 0x6c, 0x7d, 0x76, 0x6d, 0x66, 0x60, 0x5a, 0x68, 0x62, 917 0x5c, 0x76, 0x6f, 0x68, 0x7e, 0x79, 0x71, 0x69, 0x63, 0x76, 0x6f, 918 0x68, 0x62, 0x74, 0x6d, 0x66, 0x62, 0x5d, 0x71, 0x6b, 0x63, 0x78, 919 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 920 0x78, 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 0x6b, 0x63, 0x78, 921 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 0x78, 0x71, 0x6b, 0x63, 922 0x78 923}; 924 925/* 926 * Power saving settings (values obtained from the reference driver.) 927 */ 928#define WPI_NDTIMRANGES 2 929#define WPI_NPOWERLEVELS 6 930static const struct wpi_pmgt { 931 uint32_t rxtimeout; 932 uint32_t txtimeout; 933 uint32_t intval[5]; 934 int skip_dtim; 935} wpi_pmgt[WPI_NDTIMRANGES][WPI_NPOWERLEVELS] = { 936 /* DTIM <= 10 */ 937 { 938 { 0, 0, { 0, 0, 0, 0, 0 }, 0 }, /* CAM */ 939 { 200, 500, { 1, 2, 3, 4, 4 }, 0 }, /* PS level 1 */ 940 { 200, 300, { 2, 4, 6, 7, 7 }, 0 }, /* PS level 2 */ 941 { 50, 100, { 2, 6, 9, 9, 10 }, 0 }, /* PS level 3 */ 942 { 50, 25, { 2, 7, 9, 9, 10 }, 1 }, /* PS level 4 */ 943 { 25, 25, { 4, 7, 10, 10, 10 }, 1 } /* PS level 5 */ 944 }, 945 /* DTIM >= 11 */ 946 { 947 { 0, 0, { 0, 0, 0, 0, 0 }, 0 }, /* CAM */ 948 { 200, 500, { 1, 2, 3, 4, -1 }, 0 }, /* PS level 1 */ 949 { 200, 300, { 2, 4, 6, 7, -1 }, 0 }, /* PS level 2 */ 950 { 50, 100, { 2, 6, 9, 9, -1 }, 0 }, /* PS level 3 */ 951 { 50, 25, { 2, 7, 9, 9, -1 }, 0 }, /* PS level 4 */ 952 { 25, 25, { 4, 7, 10, 10, -1 }, 0 } /* PS level 5 */ 953 } 954}; 955 956/* Firmware errors. */ 957static const char * const wpi_fw_errmsg[] = { 958 "OK", 959 "FAIL", 960 "BAD_PARAM", 961 "BAD_CHECKSUM", 962 "NMI_INTERRUPT", 963 "SYSASSERT", 964 "FATAL_ERROR" 965}; 966 967/* XXX description for some error codes (error data). */ 968/* 0x00000074 - wrong totlen field */ 969/* 0x000003B3 - powersave error */ 970/* 0x00000447 - wrong channel selected */ 971 972#define WPI_READ(sc, reg) \ 973 bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (reg)) 974 975#define WPI_WRITE(sc, reg, val) \ 976 bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (reg), (val)) 977 978#define WPI_WRITE_REGION_4(sc, offset, datap, count) \ 979 bus_space_write_region_4((sc)->sc_st, (sc)->sc_sh, (offset), \ 980 (datap), (count)) 981 982#define WPI_SETBITS(sc, reg, mask) \ 983 WPI_WRITE(sc, reg, WPI_READ(sc, reg) | (mask)) 984 985#define WPI_CLRBITS(sc, reg, mask) \ 986 WPI_WRITE(sc, reg, WPI_READ(sc, reg) & ~(mask)) 987 988#define WPI_BARRIER_WRITE(sc) \ 989 bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz, \ 990 BUS_SPACE_BARRIER_WRITE) 991 992#define WPI_BARRIER_READ_WRITE(sc) \ 993 bus_space_barrier((sc)->sc_st, (sc)->sc_sh, 0, (sc)->sc_sz, \ 994 BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE) 995