xref: /titanic_51/usr/src/uts/common/io/iwp/iwp_hw.h (revision 67d1a47ad0082689ff0f6a8396a511767fff2f96)
122a84b8dSQuaker Fang /*
2*67d1a47aSQuaker Fang  * Sun elects to have this file available under and governed by the BSD license
3*67d1a47aSQuaker Fang  * (see below for full license text).  However, the following notice
4*67d1a47aSQuaker Fang  * accompanied the original version of this file:
522a84b8dSQuaker Fang  */
622a84b8dSQuaker Fang 
722a84b8dSQuaker Fang /*
822a84b8dSQuaker Fang  * Copyright (c) 2009, Intel Corporation
922a84b8dSQuaker Fang  * All rights reserved.
1022a84b8dSQuaker Fang  */
1122a84b8dSQuaker Fang 
1222a84b8dSQuaker Fang /*
1322a84b8dSQuaker Fang  * This file is provided under a dual BSD/GPLv2 license.  When using or
1422a84b8dSQuaker Fang  * redistributing this file, you may do so under either license.
1522a84b8dSQuaker Fang  *
1622a84b8dSQuaker Fang  * GPL LICENSE SUMMARY
1722a84b8dSQuaker Fang  *
1822a84b8dSQuaker Fang  * Copyright(c) 2005 - 2009 Intel Corporation. All rights reserved.
1922a84b8dSQuaker Fang  *
2022a84b8dSQuaker Fang  * This program is free software; you can redistribute it and/or modify
2122a84b8dSQuaker Fang  * it under the terms of version 2 of the GNU General Public License as
2222a84b8dSQuaker Fang  * published by the Free Software Foundation.
2322a84b8dSQuaker Fang  *
2422a84b8dSQuaker Fang  * This program is distributed in the hope that it will be useful, but
2522a84b8dSQuaker Fang  * WITHOUT ANY WARRANTY; without even the implied warranty of
2622a84b8dSQuaker Fang  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2722a84b8dSQuaker Fang  * General Public License for more details.
2822a84b8dSQuaker Fang  *
2922a84b8dSQuaker Fang  * You should have received a copy of the GNU General Public License
3022a84b8dSQuaker Fang  * along with this program; if not, write to the Free Software
3122a84b8dSQuaker Fang  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
3222a84b8dSQuaker Fang  * USA
3322a84b8dSQuaker Fang  *
3422a84b8dSQuaker Fang  * The full GNU General Public License is included in this distribution
3522a84b8dSQuaker Fang  * in the file called LICENSE.GPL.
3622a84b8dSQuaker Fang  *
3722a84b8dSQuaker Fang  * Contact Information:
3822a84b8dSQuaker Fang  * James P. Ketrenos <ipw2100-admin@linux.intel.com>
3922a84b8dSQuaker Fang  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
4022a84b8dSQuaker Fang  *
4122a84b8dSQuaker Fang  * BSD LICENSE
4222a84b8dSQuaker Fang  *
4322a84b8dSQuaker Fang  * Copyright(c) 2005 - 2009 Intel Corporation. All rights reserved.
4422a84b8dSQuaker Fang  * All rights reserved.
4522a84b8dSQuaker Fang  *
4622a84b8dSQuaker Fang  * Redistribution and use in source and binary forms, with or without
4722a84b8dSQuaker Fang  * modification, are permitted provided that the following conditions
4822a84b8dSQuaker Fang  * are met:
4922a84b8dSQuaker Fang  *
5022a84b8dSQuaker Fang  *  * Redistributions of source code must retain the above copyright
5122a84b8dSQuaker Fang  *    notice, this list of conditions and the following disclaimer.
5222a84b8dSQuaker Fang  *  * Redistributions in binary form must reproduce the above copyright
5322a84b8dSQuaker Fang  *    notice, this list of conditions and the following disclaimer in
5422a84b8dSQuaker Fang  *    the documentation and/or other materials provided with the
5522a84b8dSQuaker Fang  *    distribution.
5622a84b8dSQuaker Fang  *  * Neither the name Intel Corporation nor the names of its
5722a84b8dSQuaker Fang  *    contributors may be used to endorse or promote products derived
5822a84b8dSQuaker Fang  *    from this software without specific prior written permission.
5922a84b8dSQuaker Fang  *
6022a84b8dSQuaker Fang  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6122a84b8dSQuaker Fang  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6222a84b8dSQuaker Fang  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6322a84b8dSQuaker Fang  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
6422a84b8dSQuaker Fang  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
6522a84b8dSQuaker Fang  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
6622a84b8dSQuaker Fang  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
6722a84b8dSQuaker Fang  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
6822a84b8dSQuaker Fang  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
6922a84b8dSQuaker Fang  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
7022a84b8dSQuaker Fang  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7122a84b8dSQuaker Fang  */
7222a84b8dSQuaker Fang 
7322a84b8dSQuaker Fang #ifndef	_IWP_HW_H_
7422a84b8dSQuaker Fang #define	_IWP_HW_H_
7522a84b8dSQuaker Fang 
7622a84b8dSQuaker Fang #ifdef	__cplusplus
7722a84b8dSQuaker Fang extern "C" {
7822a84b8dSQuaker Fang #endif
7922a84b8dSQuaker Fang 
8022a84b8dSQuaker Fang /*
8122a84b8dSQuaker Fang  * maximum scatter/gather
8222a84b8dSQuaker Fang  */
8322a84b8dSQuaker Fang #define	IWP_MAX_SCATTER	(10)
8422a84b8dSQuaker Fang 
8522a84b8dSQuaker Fang /*
8622a84b8dSQuaker Fang  * Flow Handler Definitions
8722a84b8dSQuaker Fang  */
8822a84b8dSQuaker Fang #define	FH_MEM_LOWER_BOUND	(0x1000)
8922a84b8dSQuaker Fang #define	FH_MEM_UPPER_BOUND	(0x1EF0)
9022a84b8dSQuaker Fang 
9122a84b8dSQuaker Fang #define	IWP_FH_REGS_LOWER_BOUND	(0x1000)
9222a84b8dSQuaker Fang #define	IWP_FH_REGS_UPPER_BOUND	(0x2000)
9322a84b8dSQuaker Fang 
9422a84b8dSQuaker Fang /*
9522a84b8dSQuaker Fang  * TFDB  Area - TFDs buffer table
9622a84b8dSQuaker Fang  */
9722a84b8dSQuaker Fang #define	FH_MEM_TFDB_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x000)
9822a84b8dSQuaker Fang #define	FH_MEM_TFDB_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x900)
9922a84b8dSQuaker Fang 
10022a84b8dSQuaker Fang /*
10122a84b8dSQuaker Fang  * channels 0 - 8
10222a84b8dSQuaker Fang  */
10322a84b8dSQuaker Fang #define	FH_MEM_TFDB_CHNL_BUF0(x) (FH_MEM_TFDB_LOWER_BOUND + (x) * 0x100)
10422a84b8dSQuaker Fang #define	FH_MEM_TFDB_CHNL_BUF1(x) (FH_MEM_TFDB_LOWER_BOUND + 0x80 + (x) * 0x100)
10522a84b8dSQuaker Fang 
10622a84b8dSQuaker Fang /*
10722a84b8dSQuaker Fang  * TFDIB Area - TFD Immediate Buffer
10822a84b8dSQuaker Fang  */
10922a84b8dSQuaker Fang #define	FH_MEM_TFDIB_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x900)
11022a84b8dSQuaker Fang #define	FH_MEM_TFDIB_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x958)
11122a84b8dSQuaker Fang 
11222a84b8dSQuaker Fang /*
11322a84b8dSQuaker Fang  * channels 0 - 10
11422a84b8dSQuaker Fang  */
11522a84b8dSQuaker Fang #define	FH_MEM_TFDIB_CHNL(x)	(FH_MEM_TFDIB_LOWER_BOUND + (x) * 0x8)
11622a84b8dSQuaker Fang 
11722a84b8dSQuaker Fang /*
11822a84b8dSQuaker Fang  * TFDIB registers used in Service Mode
11922a84b8dSQuaker Fang  */
12022a84b8dSQuaker Fang #define	FH_MEM_TFDIB_CHNL9_REG0	(FH_MEM_TFDIB_CHNL(9))
12122a84b8dSQuaker Fang #define	FH_MEM_TFDIB_CHNL9_REG1	(FH_MEM_TFDIB_CHNL(9) + 4)
12222a84b8dSQuaker Fang #define	FH_MEM_TFDIB_CHNL10_REG0	(FH_MEM_TFDIB_CHNL(10))
12322a84b8dSQuaker Fang #define	FH_MEM_TFDIB_CHNL10_REG1	(FH_MEM_TFDIB_CHNL(10) + 4)
12422a84b8dSQuaker Fang 
12522a84b8dSQuaker Fang /*
12622a84b8dSQuaker Fang  * Tx service channels
12722a84b8dSQuaker Fang  */
12822a84b8dSQuaker Fang #define	FH_MEM_TFDIB_DRAM_ADDR_MSB_MASK	(0xF00000000)
12922a84b8dSQuaker Fang #define	FH_MEM_TFDIB_TB_LENGTH_MASK	(0x0001FFFF)	/* bits 16:0 */
13022a84b8dSQuaker Fang 
13122a84b8dSQuaker Fang #define	FH_MEM_TFDIB_DRAM_ADDR_LSB_BITSHIFT	(0)
13222a84b8dSQuaker Fang #define	FH_MEM_TFDIB_DRAM_ADDR_MSB_BITSHIFT	(32)
13322a84b8dSQuaker Fang #define	FH_MEM_TFDIB_TB_LENGTH_BITSHIFT		(0)
13422a84b8dSQuaker Fang 
13522a84b8dSQuaker Fang #define	FH_MEM_TFDIB_REG0_ADDR_MASK	(0xFFFFFFFF)
13622a84b8dSQuaker Fang #define	FH_MEM_TFDIB_REG1_ADDR_MASK	(0xF0000000)
13722a84b8dSQuaker Fang #define	FH_MEM_TFDIB_REG1_LENGTH_MASK	(0x0001FFFF)
13822a84b8dSQuaker Fang 
13922a84b8dSQuaker Fang #define	FH_MEM_TFDIB_REG0_ADDR_BITSHIFT	(0)
14022a84b8dSQuaker Fang #define	FH_MEM_TFDIB_REG1_ADDR_BITSHIFT	(28)
14122a84b8dSQuaker Fang #define	FH_MEM_TFDIB_REG1_LENGTH_BITSHIFT	(0)
14222a84b8dSQuaker Fang #define	FH_MEM_TFDIB_DRAM_ADDR_LSB_MASK		(0xFFFFFFFF)
14322a84b8dSQuaker Fang 
14422a84b8dSQuaker Fang /*
14522a84b8dSQuaker Fang  * TRB Area - Transmit Request Buffers
14622a84b8dSQuaker Fang  */
14722a84b8dSQuaker Fang #define	FH_MEM_TRB_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x0958)
14822a84b8dSQuaker Fang #define	FH_MEM_TRB_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x0980)
14922a84b8dSQuaker Fang 
15022a84b8dSQuaker Fang /*
15122a84b8dSQuaker Fang  * channels 0 - 8
15222a84b8dSQuaker Fang  */
15322a84b8dSQuaker Fang #define	FH_MEM_TRB_CHNL(x)	(FH_MEM_TRB_LOWER_BOUND + (x) * 0x4)
15422a84b8dSQuaker Fang 
15522a84b8dSQuaker Fang /*
15622a84b8dSQuaker Fang  * Keep-Warm (KW) buffer base address.
15722a84b8dSQuaker Fang  *
15822a84b8dSQuaker Fang  * Driver must allocate a 4KByte buffer that is used by Shirely Peak(SP) for
15922a84b8dSQuaker Fang  * keeping the
16022a84b8dSQuaker Fang  * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
16122a84b8dSQuaker Fang  * DRAM access when SP is Txing or Rxing.  The dummy accesses prevent host
16222a84b8dSQuaker Fang  * from going into a power-savings mode that would cause higher DRAM latency,
16322a84b8dSQuaker Fang  * and possible data over/under-runs, before all Tx/Rx is complete.
16422a84b8dSQuaker Fang  *
16522a84b8dSQuaker Fang  * Driver loads IWP_FH_KW_MEM_ADDR_REG with the physical address (bits 35:4)
16622a84b8dSQuaker Fang  * of the buffer, which must be 4K aligned.  Once this is set up, the SP
16722a84b8dSQuaker Fang  * automatically invokes keep-warm accesses when normal accesses might not
16822a84b8dSQuaker Fang  * be sufficient to maintain fast DRAM response.
16922a84b8dSQuaker Fang  *
17022a84b8dSQuaker Fang  * Bit fields:
17122a84b8dSQuaker Fang  * 31-0:  Keep-warm buffer physical base address [35:4], must be 4K aligned
17222a84b8dSQuaker Fang  */
17322a84b8dSQuaker Fang #define	IWP_FH_KW_MEM_ADDR_REG	(FH_MEM_LOWER_BOUND + 0x97C)
17422a84b8dSQuaker Fang 
17522a84b8dSQuaker Fang /*
17622a84b8dSQuaker Fang  * STAGB Area - Scheduler TAG Buffer
17722a84b8dSQuaker Fang  */
17822a84b8dSQuaker Fang #define	FH_MEM_STAGB_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x980)
17922a84b8dSQuaker Fang #define	FH_MEM_STAGB_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x9D0)
18022a84b8dSQuaker Fang 
18122a84b8dSQuaker Fang /*
18222a84b8dSQuaker Fang  * channels 0 - 8
18322a84b8dSQuaker Fang  */
18422a84b8dSQuaker Fang #define	FH_MEM_STAGB_0(x)	(FH_MEM_STAGB_LOWER_BOUND + (x) * 0x8)
18522a84b8dSQuaker Fang #define	FH_MEM_STAGB_1(x)	(FH_MEM_STAGB_LOWER_BOUND + 0x4 + (x) * 0x8)
18622a84b8dSQuaker Fang 
18722a84b8dSQuaker Fang /*
18822a84b8dSQuaker Fang  * Tx service channels
18922a84b8dSQuaker Fang  */
19022a84b8dSQuaker Fang #define	FH_MEM_SRAM_ADDR_9	(FH_MEM_STAGB_LOWER_BOUND + 0x048)
19122a84b8dSQuaker Fang #define	FH_MEM_SRAM_ADDR_10	(FH_MEM_STAGB_LOWER_BOUND + 0x04C)
19222a84b8dSQuaker Fang 
19322a84b8dSQuaker Fang #define	FH_MEM_STAGB_SRAM_ADDR_MASK	(0x00FFFFFF)
19422a84b8dSQuaker Fang 
19522a84b8dSQuaker Fang /*
19622a84b8dSQuaker Fang  * TFD Circular Buffers Base (CBBC) addresses
19722a84b8dSQuaker Fang  *
19822a84b8dSQuaker Fang  * SP has 16 base pointer registers, one for each of 16 host-DRAM-resident
19922a84b8dSQuaker Fang  * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
20022a84b8dSQuaker Fang  * (see struct iwp_tfd_frame).  These 16 pointer registers are offset by 0x04
20122a84b8dSQuaker Fang  * bytes from one another.  Each TFD circular buffer in DRAM must be 256-byte
20222a84b8dSQuaker Fang  * aligned (address bits 0-7 must be 0).
20322a84b8dSQuaker Fang  *
20422a84b8dSQuaker Fang  * Bit fields in each pointer register:
20522a84b8dSQuaker Fang  * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned
20622a84b8dSQuaker Fang  */
20722a84b8dSQuaker Fang #define	FH_MEM_CBBC_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x9D0)
20822a84b8dSQuaker Fang #define	FH_MEM_CBBC_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xA10)
20922a84b8dSQuaker Fang 
21022a84b8dSQuaker Fang /*
21122a84b8dSQuaker Fang  * queues 0 - 15
21222a84b8dSQuaker Fang  */
21322a84b8dSQuaker Fang #define	FH_MEM_CBBC_QUEUE(x)	(FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
21422a84b8dSQuaker Fang 
21522a84b8dSQuaker Fang /*
21622a84b8dSQuaker Fang  * TAGR Area - TAG reconstruct table
21722a84b8dSQuaker Fang  */
21822a84b8dSQuaker Fang #define	FH_MEM_TAGR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xA10)
21922a84b8dSQuaker Fang #define	FH_MEM_TAGR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xA70)
22022a84b8dSQuaker Fang 
22122a84b8dSQuaker Fang /*
22222a84b8dSQuaker Fang  * TDBGR Area - Tx Debug Registers
22322a84b8dSQuaker Fang  */
22422a84b8dSQuaker Fang #define	FH_MEM_TDBGR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x0A70)
22522a84b8dSQuaker Fang #define	FH_MEM_TDBGR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x0B20)
22622a84b8dSQuaker Fang 
22722a84b8dSQuaker Fang /*
22822a84b8dSQuaker Fang  * channels 0 - 10
22922a84b8dSQuaker Fang  */
23022a84b8dSQuaker Fang #define	FH_MEM_TDBGR_CHNL(x)	(FH_MEM_TDBGR_LOWER_BOUND + (x) * 0x10)
23122a84b8dSQuaker Fang 
23222a84b8dSQuaker Fang #define	FH_MEM_TDBGR_CHNL_REG_0(x)	(FH_MEM_TDBGR_CHNL(x))
23322a84b8dSQuaker Fang #define	FH_MEM_TDBGR_CHNL_REG_1(x)	(FH_MEM_TDBGR_CHNL_REG_0(x) + 0x4)
23422a84b8dSQuaker Fang 
23522a84b8dSQuaker Fang #define	FH_MEM_TDBGR_CHNL_BYTES_TO_FIFO_MASK	(0x000FFFFF)
23622a84b8dSQuaker Fang #define	FH_MEM_TDBGR_CHNL_BYTES_TO_FIFO_BITSHIFT	(0)
23722a84b8dSQuaker Fang 
23822a84b8dSQuaker Fang /*
23922a84b8dSQuaker Fang  * RDBUF Area
24022a84b8dSQuaker Fang  */
24122a84b8dSQuaker Fang #define	FH_MEM_RDBUF_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xB80)
24222a84b8dSQuaker Fang #define	FH_MEM_RDBUF_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xBC0)
24322a84b8dSQuaker Fang #define	FH_MEM_RDBUF_CHNL0	(FH_MEM_RDBUF_LOWER_BOUND)
24422a84b8dSQuaker Fang 
24522a84b8dSQuaker Fang /*
24622a84b8dSQuaker Fang  * Rx SRAM Control and Status Registers (RSCSR)
24722a84b8dSQuaker Fang  *
24822a84b8dSQuaker Fang  * These registers provide handshake between driver and Shirley Peak for
24922a84b8dSQuaker Fang  * the Rx queue
25022a84b8dSQuaker Fang  * (this queue handles *all* command responses, notifications, Rx data, etc.
25122a84b8dSQuaker Fang  * sent from SP uCode to host driver).  Unlike Tx, there is only one Rx
25222a84b8dSQuaker Fang  * queue, and only one Rx DMA/FIFO channel.  Also unlike Tx, which can
25322a84b8dSQuaker Fang  * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
25422a84b8dSQuaker Fang  * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
25522a84b8dSQuaker Fang  * mapping between RBDs and RBs.
25622a84b8dSQuaker Fang  *
25722a84b8dSQuaker Fang  * Driver must allocate host DRAM memory for the following, and set the
25822a84b8dSQuaker Fang  * physical address of each into SP registers:
25922a84b8dSQuaker Fang  *
26022a84b8dSQuaker Fang  * 1)  Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
26122a84b8dSQuaker Fang  *     entries (although any power of 2, up to 4096, is selectable by driver).
26222a84b8dSQuaker Fang  *     Each entry (1 dword) points to a receive buffer (RB) of consistent size
26322a84b8dSQuaker Fang  *     (typically 4K, although 8K or 16K are also selectable by driver).
26422a84b8dSQuaker Fang  *     Driver sets up RB size and number of RBDs in the CB via Rx config
26522a84b8dSQuaker Fang  *     register FH_MEM_RCSR_CHNL0_CONFIG_REG.
26622a84b8dSQuaker Fang  *
26722a84b8dSQuaker Fang  *     Bit fields within one RBD:
26822a84b8dSQuaker Fang  *     27-0:  Receive Buffer physical address bits [35:8], 256-byte aligned.
26922a84b8dSQuaker Fang  *
27022a84b8dSQuaker Fang  *     Driver sets physical address [35:8] of base of RBD circular buffer
27122a84b8dSQuaker Fang  *     into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
27222a84b8dSQuaker Fang  *
27322a84b8dSQuaker Fang  * 2)  Rx status buffer, 8 bytes, in which SP indicates which Rx Buffers
27422a84b8dSQuaker Fang  *     (RBs) have been filled, via a "write pointer", actually the index of
27522a84b8dSQuaker Fang  *     the RB's corresponding RBD within the circular buffer.  Driver sets
27622a84b8dSQuaker Fang  *     physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
27722a84b8dSQuaker Fang  *
27822a84b8dSQuaker Fang  *     Bit fields in lower dword of Rx status buffer (upper dword not used
27922a84b8dSQuaker Fang  *     by driver; see struct iwp_shared, val0):
28022a84b8dSQuaker Fang  *     31-12:  Not used by driver
28122a84b8dSQuaker Fang  *     11- 0:  Index of last filled Rx buffer descriptor
28222a84b8dSQuaker Fang  *             (SP writes, driver reads this value)
28322a84b8dSQuaker Fang  *
28422a84b8dSQuaker Fang  * As the driver prepares Receive Buffers (RBs) for SP to fill, driver must
28522a84b8dSQuaker Fang  * enter pointers to these RBs into contiguous RBD circular buffer entries,
28622a84b8dSQuaker Fang  * and update the SP's "write" index register, FH_RSCSR_CHNL0_RBDCB_WPTR_REG.
28722a84b8dSQuaker Fang  *
28822a84b8dSQuaker Fang  * This "write" index corresponds to the *next* RBD that the driver will make
28922a84b8dSQuaker Fang  * available, i.e. one RBD past the the tail of the ready-to-fill RBDs within
29022a84b8dSQuaker Fang  * the circular buffer.  This value should initially be 0 (before preparing any
29122a84b8dSQuaker Fang  * RBs), should be 8 after preparing the first 8 RBs (for example), and must
29222a84b8dSQuaker Fang  * wrap back to 0 at the end of the circular buffer (but don't wrap before
29322a84b8dSQuaker Fang  * "read" index has advanced past 1!  See below).
29422a84b8dSQuaker Fang  * NOTE:  SP EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8.
29522a84b8dSQuaker Fang  *
29622a84b8dSQuaker Fang  * As the SP fills RBs (referenced from contiguous RBDs within the circular
29722a84b8dSQuaker Fang  * buffer), it updates the Rx status buffer in DRAM, 2) described above,
29822a84b8dSQuaker Fang  * to tell the driver the index of the latest filled RBD.  The driver must
29922a84b8dSQuaker Fang  * read this "read" index from DRAM after receiving an Rx interrupt from SP.
30022a84b8dSQuaker Fang  *
30122a84b8dSQuaker Fang  * The driver must also internally keep track of a third index, which is the
30222a84b8dSQuaker Fang  * next RBD to process.  When receiving an Rx interrupt, driver should process
30322a84b8dSQuaker Fang  * all filled but unprocessed RBs up to, but not including, the RB
30422a84b8dSQuaker Fang  * corresponding to the "read" index.  For example, if "read" index becomes "1",
30522a84b8dSQuaker Fang  * driver may process the RB pointed to by RBD 0.  Depending on volume of
30622a84b8dSQuaker Fang  * traffic, there may be many RBs to process.
30722a84b8dSQuaker Fang  *
30822a84b8dSQuaker Fang  * If read index == write index, SP thinks there is no room to put new data.
30922a84b8dSQuaker Fang  * Due to this, the maximum number of filled RBs is 255, instead of 256.  To
31022a84b8dSQuaker Fang  * be safe, make sure that there is a gap of at least 2 RBDs between "write"
31122a84b8dSQuaker Fang  * and "read" indexes; that is, make sure that there are no more than 254
31222a84b8dSQuaker Fang  * buffers waiting to be filled.
31322a84b8dSQuaker Fang  */
31422a84b8dSQuaker Fang #define	FH_MEM_RSCSR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xBC0)
31522a84b8dSQuaker Fang #define	FH_MEM_RSCSR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xC00)
31622a84b8dSQuaker Fang #define	FH_MEM_RSCSR_CHNL0	(FH_MEM_RSCSR_LOWER_BOUND)
31722a84b8dSQuaker Fang #define	FH_MEM_RSCSR_CHNL1	(FH_MEM_RSCSR_LOWER_BOUND + 0x020)
31822a84b8dSQuaker Fang 
31922a84b8dSQuaker Fang /*
32022a84b8dSQuaker Fang  * Physical base address of 8-byte Rx Status buffer.
32122a84b8dSQuaker Fang  * Bit fields:
32222a84b8dSQuaker Fang  * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
32322a84b8dSQuaker Fang  */
32422a84b8dSQuaker Fang 
32522a84b8dSQuaker Fang #define	FH_RSCSR_CHNL0_STTS_WPTR_REG	(FH_MEM_RSCSR_CHNL0)
32622a84b8dSQuaker Fang 
32722a84b8dSQuaker Fang /*
32822a84b8dSQuaker Fang  * Physical base address of Rx Buffer Descriptor Circular Buffer.
32922a84b8dSQuaker Fang  * Bit fields:
33022a84b8dSQuaker Fang  * 27-0:  RBD CD physical base address [35:8], must be 256-byte aligned.
33122a84b8dSQuaker Fang  */
33222a84b8dSQuaker Fang #define	FH_RSCSR_CHNL0_RBDCB_BASE_REG	(FH_MEM_RSCSR_CHNL0 + 0x004)
33322a84b8dSQuaker Fang 
33422a84b8dSQuaker Fang /*
33522a84b8dSQuaker Fang  * Rx write pointer (index, really!).
33622a84b8dSQuaker Fang  * Bit fields:
33722a84b8dSQuaker Fang  * 11-0:  Index of driver's most recent prepared-to-be-filled RBD, + 1.
33822a84b8dSQuaker Fang  *        NOTE:  For 256-entry circular buffer, use only bits [7:0].
33922a84b8dSQuaker Fang  */
34022a84b8dSQuaker Fang #define	FH_RSCSR_CHNL0_RBDCB_WPTR_REG	(FH_MEM_RSCSR_CHNL0 + 0x008)
34122a84b8dSQuaker Fang #define	FH_RSCSR_CHNL0_RBDCB_RPTR_REG	(FH_MEM_RSCSR_CHNL0 + 0x00c)
34222a84b8dSQuaker Fang 
34322a84b8dSQuaker Fang 
34422a84b8dSQuaker Fang /*
34522a84b8dSQuaker Fang  * RSCSR registers used in Service mode
34622a84b8dSQuaker Fang  */
34722a84b8dSQuaker Fang #define	FH_RSCSR_CHNL1_RB_WPTR_REG	(FH_MEM_RSCSR_CHNL1)
34822a84b8dSQuaker Fang #define	FH_RSCSR_CHNL1_RB_WPTR_OFFSET_REG	(FH_MEM_RSCSR_CHNL1 + 0x004)
34922a84b8dSQuaker Fang #define	FH_RSCSR_CHNL1_RB_CHUNK_NUM_REG		(FH_MEM_RSCSR_CHNL1 + 0x008)
35022a84b8dSQuaker Fang #define	FH_RSCSR_CHNL1_SRAM_ADDR_REG	(FH_MEM_RSCSR_CHNL1 + 0x00C)
35122a84b8dSQuaker Fang 
35222a84b8dSQuaker Fang /*
35322a84b8dSQuaker Fang  * Rx Config/Status Registers (RCSR)
35422a84b8dSQuaker Fang  * Rx Config Reg for channel 0 (only channel used)
35522a84b8dSQuaker Fang  *
35622a84b8dSQuaker Fang  * Driver must initialize FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for
35722a84b8dSQuaker Fang  * normal operation (see bit fields).
35822a84b8dSQuaker Fang  *
35922a84b8dSQuaker Fang  * Clearing FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
36022a84b8dSQuaker Fang  * Driver should poll FH_MEM_RSSR_RX_STATUS_REG	for
36122a84b8dSQuaker Fang  * FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
36222a84b8dSQuaker Fang  *
36322a84b8dSQuaker Fang  * Bit fields:
36422a84b8dSQuaker Fang  * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
36522a84b8dSQuaker Fang  *        '10' operate normally
36622a84b8dSQuaker Fang  * 29-24: reserved
36722a84b8dSQuaker Fang  * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
36822a84b8dSQuaker Fang  *        min "5" for 32 RBDs, max "12" for 4096 RBDs.
36922a84b8dSQuaker Fang  * 19-18: reserved
37022a84b8dSQuaker Fang  * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
37122a84b8dSQuaker Fang  *        '10' 12K, '11' 16K.
37222a84b8dSQuaker Fang  * 15-14: reserved
37322a84b8dSQuaker Fang  * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
37422a84b8dSQuaker Fang  * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
37522a84b8dSQuaker Fang  *        typical value 0x10 (about 1/2 msec)
37622a84b8dSQuaker Fang  * 3- 0: reserved
37722a84b8dSQuaker Fang  */
37822a84b8dSQuaker Fang #define	FH_MEM_RCSR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xC00)
37922a84b8dSQuaker Fang #define	FH_MEM_RCSR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xCC0)
38022a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL0	(FH_MEM_RCSR_LOWER_BOUND)
38122a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL1	(FH_MEM_RCSR_LOWER_BOUND + 0x020)
38222a84b8dSQuaker Fang 
38322a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL0_CONFIG_REG	(FH_MEM_RCSR_CHNL0)
38422a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL0_CREDIT_REG	(FH_MEM_RCSR_CHNL0 + 0x004)
38522a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL0_RBD_STTS_REG	(FH_MEM_RCSR_CHNL0 + 0x008)
38622a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL0_RB_STTS_REG	(FH_MEM_RCSR_CHNL0 + 0x00C)
38722a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL0_RXPD_STTS_REG	(FH_MEM_RCSR_CHNL0 + 0x010)
38822a84b8dSQuaker Fang 
38922a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL0_RBD_STTS_FRAME_RB_CNT_MASK	(0x7FFFFFF0)
39022a84b8dSQuaker Fang 
39122a84b8dSQuaker Fang /*
39222a84b8dSQuaker Fang  * RCSR registers used in Service mode
39322a84b8dSQuaker Fang  */
39422a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL1_CONFIG_REG	(FH_MEM_RCSR_CHNL1)
39522a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL1_RB_STTS_REG	(FH_MEM_RCSR_CHNL1 + 0x00C)
39622a84b8dSQuaker Fang #define	FH_MEM_RCSR_CHNL1_RX_PD_STTS_REG	(FH_MEM_RCSR_CHNL1 + 0x010)
39722a84b8dSQuaker Fang 
39822a84b8dSQuaker Fang /*
39922a84b8dSQuaker Fang  * Rx Shared Status Registers (RSSR)
40022a84b8dSQuaker Fang  *
40122a84b8dSQuaker Fang  * After stopping Rx DMA channel (writing 0 to FH_MEM_RCSR_CHNL0_CONFIG_REG),
40222a84b8dSQuaker Fang  * driver must poll FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
40322a84b8dSQuaker Fang  *
40422a84b8dSQuaker Fang  * Bit fields:
40522a84b8dSQuaker Fang  * 24:  1 = Channel 0 is idle
40622a84b8dSQuaker Fang  *
40722a84b8dSQuaker Fang  * FH_MEM_RSSR_SHARED_CTRL_REG and FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV contain
40822a84b8dSQuaker Fang  * default values that should not be altered by the driver.
40922a84b8dSQuaker Fang  */
41022a84b8dSQuaker Fang #define	FH_MEM_RSSR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xC40)
41122a84b8dSQuaker Fang #define	FH_MEM_RSSR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xD00)
41222a84b8dSQuaker Fang #define	FH_MEM_RSSR_SHARED_CTRL_REG	(FH_MEM_RSSR_LOWER_BOUND)
41322a84b8dSQuaker Fang #define	FH_MEM_RSSR_RX_STATUS_REG	(FH_MEM_RSSR_LOWER_BOUND + 0x004)
41422a84b8dSQuaker Fang #define	FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV (FH_MEM_RSSR_LOWER_BOUND + 0x008)
41522a84b8dSQuaker Fang 
41622a84b8dSQuaker Fang /*
41722a84b8dSQuaker Fang  * Transmit DMA Channel Control/Status Registers (TCSR)
41822a84b8dSQuaker Fang  *
41922a84b8dSQuaker Fang  * SP has one configuration register for each of 8 Tx DMA/FIFO channels
42022a84b8dSQuaker Fang  * supported in hardware; config regs are separated by 0x20 bytes.
42122a84b8dSQuaker Fang  *
42222a84b8dSQuaker Fang  * To use a Tx DMA channel, driver must initialize its
42322a84b8dSQuaker Fang  *
42422a84b8dSQuaker Fang  *
42522a84b8dSQuaker Fang  * All other bits should be 0.
42622a84b8dSQuaker Fang  *
42722a84b8dSQuaker Fang  * Bit fields:
42822a84b8dSQuaker Fang  * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
42922a84b8dSQuaker Fang  *        '10' operate normally
43022a84b8dSQuaker Fang  * 29- 4: Reserved, set to "0"
43122a84b8dSQuaker Fang  *     3: Enable internal DMA requests (1, normal operation), disable (0)
43222a84b8dSQuaker Fang  *  2- 0: Reserved, set to "0"
43322a84b8dSQuaker Fang  */
43422a84b8dSQuaker Fang #define	IWP_FH_TCSR_UPPER_BOUND	(IWP_FH_REGS_LOWER_BOUND + 0xE60)
43522a84b8dSQuaker Fang 
43622a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_NUM	(7)
43722a84b8dSQuaker Fang 
43822a84b8dSQuaker Fang /*
43922a84b8dSQuaker Fang  * Tx Shared Status Registers (TSSR)
44022a84b8dSQuaker Fang  *
44122a84b8dSQuaker Fang  * After stopping Tx DMA channel (writing 0 to
44222a84b8dSQuaker Fang  * IWP_FH_TSSR_TX_STATUS_REG until selected Tx channel is idle
44322a84b8dSQuaker Fang  * (channel's buffers empty | no pending requests).
44422a84b8dSQuaker Fang  *
44522a84b8dSQuaker Fang  * Bit fields:
44622a84b8dSQuaker Fang  * 31-24:  1 = Channel buffers empty (channel 7:0)
44722a84b8dSQuaker Fang  * 23-16:  1 = No pending requests (channel 7:0)
44822a84b8dSQuaker Fang  */
44922a84b8dSQuaker Fang #define	IWP_FH_TSSR_LOWER_BOUND	(IWP_FH_REGS_LOWER_BOUND + 0xEA0)
45022a84b8dSQuaker Fang #define	IWP_FH_TSSR_UPPER_BOUND	(IWP_FH_REGS_LOWER_BOUND + 0xEC0)
45122a84b8dSQuaker Fang 
45222a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG (IWP_FH_TSSR_LOWER_BOUND + 0x008)
45322a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_STATUS_REG	(IWP_FH_TSSR_LOWER_BOUND + 0x010)
45422a84b8dSQuaker Fang 
45522a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON	(0xFF000000)
45622a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON	(0x00FF0000)
45722a84b8dSQuaker Fang 
45822a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_64B	(0x00000000)
45922a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B	(0x00000400)
46022a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_256B	(0x00000800)
46122a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_512B	(0x00000C00)
46222a84b8dSQuaker Fang 
46322a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON	(0x00000100)
46422a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON	(0x00000080)
46522a84b8dSQuaker Fang 
46622a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH	(0x00000020)
46722a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH	(0x00000005)
46822a84b8dSQuaker Fang 
46922a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl)	\
47022a84b8dSQuaker Fang 	((1 << (_chnl)) << 24)
47122a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) \
47222a84b8dSQuaker Fang 	((1 << (_chnl)) << 16)
47322a84b8dSQuaker Fang 
47422a84b8dSQuaker Fang #define	IWP_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) \
47522a84b8dSQuaker Fang 	(IWP_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \
47622a84b8dSQuaker Fang 	IWP_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl))
47722a84b8dSQuaker Fang 
47822a84b8dSQuaker Fang /*
47922a84b8dSQuaker Fang  * TFDIB
48022a84b8dSQuaker Fang  */
48122a84b8dSQuaker Fang #define	IWP_FH_TFDIB_UPPER_BOUND	(IWP_FH_REGS_LOWER_BOUND + 0x958)
48222a84b8dSQuaker Fang #define	IWP_FH_TFDIB_CTRL1_REG_POS_MSB	(28)
48322a84b8dSQuaker Fang #define	IWP_FH_TFDIB_LOWER_BOUND	(IWP_FH_REGS_LOWER_BOUND + 0x900)
48422a84b8dSQuaker Fang 
48522a84b8dSQuaker Fang #define	IWP_FH_TFDIB_CTRL0_REG(_chnl)\
48622a84b8dSQuaker Fang 	(IWP_FH_TFDIB_LOWER_BOUND + 0x8 * _chnl)
48722a84b8dSQuaker Fang 
48822a84b8dSQuaker Fang #define	IWP_FH_TFDIB_CTRL1_REG(_chnl)\
48922a84b8dSQuaker Fang 	(IWP_FH_TFDIB_LOWER_BOUND + 0x8 * _chnl + 0x4)
49022a84b8dSQuaker Fang 
49122a84b8dSQuaker Fang /*
49222a84b8dSQuaker Fang  * Debug Monitor Area
49322a84b8dSQuaker Fang  */
49422a84b8dSQuaker Fang #define	FH_MEM_DM_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xEE0)
49522a84b8dSQuaker Fang #define	FH_MEM_DM_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xEF0)
49622a84b8dSQuaker Fang #define	FH_MEM_DM_CONTROL_MASK_REG	(FH_MEM_DM_LOWER_BOUND)
49722a84b8dSQuaker Fang #define	FH_MEM_DM_CONTROL_START_REG	(FH_MEM_DM_LOWER_BOUND + 0x004)
49822a84b8dSQuaker Fang #define	FH_MEM_DM_CONTROL_STATUS_REG	(FH_MEM_DM_LOWER_BOUND + 0x008)
49922a84b8dSQuaker Fang #define	FH_MEM_DM_MONITOR_REG	(FH_MEM_DM_LOWER_BOUND + 0x00C)
50022a84b8dSQuaker Fang 
50122a84b8dSQuaker Fang #define	FH_TB1_ADDR_LOW_MASK	(0xFFFFFFFF)	/* bits 31:0 */
50222a84b8dSQuaker Fang #define	FH_TB1_ADDR_HIGH_MASK	(0xF00000000)	/* bits 35:32 */
50322a84b8dSQuaker Fang #define	FH_TB2_ADDR_LOW_MASK	(0x0000FFFF)	/* bits 15:0 */
50422a84b8dSQuaker Fang #define	FH_TB2_ADDR_HIGH_MASK	(0xFFFFF0000)	/* bits 35:16 */
50522a84b8dSQuaker Fang 
50622a84b8dSQuaker Fang #define	FH_TB1_ADDR_LOW_BITSHIFT	(0)
50722a84b8dSQuaker Fang #define	FH_TB1_ADDR_HIGH_BITSHIFT	(32)
50822a84b8dSQuaker Fang #define	FH_TB2_ADDR_LOW_BITSHIFT	(0)
50922a84b8dSQuaker Fang #define	FH_TB2_ADDR_HIGH_BITSHIFT	(16)
51022a84b8dSQuaker Fang 
51122a84b8dSQuaker Fang #define	FH_TB1_LENGTH_MASK	(0x00000FFF)	/* bits 11:0 */
51222a84b8dSQuaker Fang #define	FH_TB2_LENGTH_MASK	(0x00000FFF)	/* bits 11:0 */
51322a84b8dSQuaker Fang 
51422a84b8dSQuaker Fang /*
51522a84b8dSQuaker Fang  * number of FH channels including 2 service mode
51622a84b8dSQuaker Fang  */
51722a84b8dSQuaker Fang #define	NUM_OF_FH_CHANNELS	(10)
51822a84b8dSQuaker Fang 
51922a84b8dSQuaker Fang /*
52022a84b8dSQuaker Fang  * ctrl field bitology
52122a84b8dSQuaker Fang  */
52222a84b8dSQuaker Fang #define	FH_TFD_CTRL_PADDING_MASK	(0xC0000000)	/* bits 31:30 */
52322a84b8dSQuaker Fang #define	FH_TFD_CTRL_NUMTB_MASK		(0x1F000000)	/* bits 28:24 */
52422a84b8dSQuaker Fang 
52522a84b8dSQuaker Fang #define	FH_TFD_CTRL_PADDING_BITSHIFT	(30)
52622a84b8dSQuaker Fang #define	FH_TFD_CTRL_NUMTB_BITSHIFT	(24)
52722a84b8dSQuaker Fang 
52822a84b8dSQuaker Fang #define	FH_TFD_GET_NUM_TBS(ctrl) \
52922a84b8dSQuaker Fang 	((ctrl & FH_TFD_CTRL_NUMTB_MASK) >> FH_TFD_CTRL_NUMTB_BITSHIFT)
53022a84b8dSQuaker Fang #define	FH_TFD_GET_PADDING(ctrl) \
53122a84b8dSQuaker Fang 	((ctrl & FH_TFD_CTRL_PADDING_MASK) >> FH_TFD_CTRL_PADDING_BITSHIFT)
53222a84b8dSQuaker Fang 
53322a84b8dSQuaker Fang /*
53422a84b8dSQuaker Fang  * TCSR: tx_config register values
53522a84b8dSQuaker Fang  */
53622a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF	(0x00000000)
53722a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER	(0x00000001)
53822a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_ARC	(0x00000002)
53922a84b8dSQuaker Fang 
54022a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL	(0x00000008)
54122a84b8dSQuaker Fang 
54222a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT	(0x00000000)
54322a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD	(0x00200000)
54422a84b8dSQuaker Fang 
54522a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT		(0x00000000)
54622a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD	(0x00400000)
54722a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD		(0x00800000)
54822a84b8dSQuaker Fang 
54922a84b8dSQuaker Fang 
55022a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY	(0x00000000)
55122a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT	(0x00002000)
55222a84b8dSQuaker Fang 
55322a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR	(0x00000001)
55422a84b8dSQuaker Fang 
55522a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM	(20)
55622a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX	(12)
55722a84b8dSQuaker Fang 
55822a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID	(0x00000003)
55922a84b8dSQuaker Fang 
56022a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE	(0x80000000)
56122a84b8dSQuaker Fang 
56222a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL	(0x00000000)
56322a84b8dSQuaker Fang 
56422a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD		(0x00100000)
56522a84b8dSQuaker Fang 
56622a84b8dSQuaker Fang #define	IWP_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE	(0x00000000)
56722a84b8dSQuaker Fang 
56822a84b8dSQuaker Fang #define	IWP_FH_TCSR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xD00)
56922a84b8dSQuaker Fang 
57022a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl)\
57122a84b8dSQuaker Fang 	(IWP_FH_TCSR_LOWER_BOUND + 0x20 * _chnl)
57222a84b8dSQuaker Fang 
57322a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_TX_CREDIT_REG(_chnl)\
57422a84b8dSQuaker Fang 	(IWP_FH_TCSR_LOWER_BOUND + 0x20 * _chnl + 0x4)
57522a84b8dSQuaker Fang 
57622a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_TX_BUF_STS_REG(_chnl)\
57722a84b8dSQuaker Fang 	(IWP_FH_TCSR_LOWER_BOUND + 0x20 * _chnl + 0x8)
57822a84b8dSQuaker Fang #define	IWP_FH_TCSR_CHNL_NUM		(7)
57922a84b8dSQuaker Fang 
58022a84b8dSQuaker Fang /*
58122a84b8dSQuaker Fang  * CBB table
58222a84b8dSQuaker Fang  */
58322a84b8dSQuaker Fang #define	FH_CBB_ADDR_MASK	0x0FFFFFFF	/* bits 27:0 */
58422a84b8dSQuaker Fang #define	FH_CBB_ADDR_BIT_SHIFT	(8)
58522a84b8dSQuaker Fang 
58622a84b8dSQuaker Fang /*
58722a84b8dSQuaker Fang  * RCSR:  channel 0 rx_config register defines
58822a84b8dSQuaker Fang  */
58922a84b8dSQuaker Fang #define	FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MASK (0xC0000000) /* bits 30-31 */
59022a84b8dSQuaker Fang #define	FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MASK (0x00F00000) /* bits 20-23 */
59122a84b8dSQuaker Fang #define	FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MASK (0x00030000) /* bits 16-17 */
59222a84b8dSQuaker Fang #define	FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MASK (0x00008000) /* bit 15 */
59322a84b8dSQuaker Fang #define	FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MASK (0x00001000) /* bit 12 */
59422a84b8dSQuaker Fang #define	FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MASK (0x00000FF0) /* bit 4-11 */
59522a84b8dSQuaker Fang 
59622a84b8dSQuaker Fang #define	FH_RCSR_RX_CONFIG_RBDCB_SIZE_BITSHIFT	(20)
59722a84b8dSQuaker Fang #define	FH_RCSR_RX_CONFIG_RB_SIZE_BITSHIFT	(16)
59822a84b8dSQuaker Fang 
59922a84b8dSQuaker Fang #define	FH_RCSR_GET_RDBC_SIZE(reg) \
60022a84b8dSQuaker Fang 	((reg & FH_RCSR_RX_CONFIG_RDBC_SIZE_MASK) >> \
60122a84b8dSQuaker Fang 	FH_RCSR_RX_CONFIG_RDBC_SIZE_BITSHIFT)
60222a84b8dSQuaker Fang 
60322a84b8dSQuaker Fang /*
60422a84b8dSQuaker Fang  * RCSR:  channel 1 rx_config register defines
60522a84b8dSQuaker Fang  */
60622a84b8dSQuaker Fang #define	FH_RCSR_CHNL1_RX_CONFIG_DMA_CHNL_EN_MASK  (0xC0000000) /* bits 30-31 */
60722a84b8dSQuaker Fang #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_MASK	  (0x00003000) /* bits 12-13 */
60822a84b8dSQuaker Fang 
60922a84b8dSQuaker Fang /*
61022a84b8dSQuaker Fang  * RCSR: rx_config register values
61122a84b8dSQuaker Fang  */
61222a84b8dSQuaker Fang #define	FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL	(0x00000000)
61322a84b8dSQuaker Fang #define	FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL	(0x40000000)
61422a84b8dSQuaker Fang #define	FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL	(0x80000000)
61522a84b8dSQuaker Fang #define	FH_RCSR_RX_CONFIG_SINGLE_FRAME_MODE	(0x00008000)
61622a84b8dSQuaker Fang 
61722a84b8dSQuaker Fang #define	FH_RCSR_RX_CONFIG_RDRBD_DISABLE_VAL	(0x00000000)
61822a84b8dSQuaker Fang #define	FH_RCSR_RX_CONFIG_RDRBD_ENABLE_VAL	(0x20000000)
61922a84b8dSQuaker Fang 
62022a84b8dSQuaker Fang #define	IWP_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K	(0x00000000)
62122a84b8dSQuaker Fang #define	IWP_TX_RTS_RETRY_LIMIT		(60)
62222a84b8dSQuaker Fang #define	IWP_TX_DATA_RETRY_LIMIT		(15)
62322a84b8dSQuaker Fang 
62422a84b8dSQuaker Fang #define	IWP_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K	(0x00010000)
62522a84b8dSQuaker Fang #define	IWP_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K	(0x00020000)
62622a84b8dSQuaker Fang #define	IWP_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K	(0x00030000)
62722a84b8dSQuaker Fang 
62822a84b8dSQuaker Fang /*
62922a84b8dSQuaker Fang  * RCSR channel 0 config register values
63022a84b8dSQuaker Fang  */
63122a84b8dSQuaker Fang #define	FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL	(0x00000000)
63222a84b8dSQuaker Fang #define	FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL	(0x00001000)
63322a84b8dSQuaker Fang 
63422a84b8dSQuaker Fang /*
63522a84b8dSQuaker Fang  * RCSR channel 1 config register values
63622a84b8dSQuaker Fang  */
63722a84b8dSQuaker Fang #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_NO_INT_VAL	(0x00000000)
63822a84b8dSQuaker Fang #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_INT_HOST_VAL	(0x00001000)
63922a84b8dSQuaker Fang #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_INT_RTC_VAL	(0x00002000)
64022a84b8dSQuaker Fang #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_INT_HOST_RTC_VAL (0x00003000)
64122a84b8dSQuaker Fang 
64222a84b8dSQuaker Fang /*
64322a84b8dSQuaker Fang  * RCSR: rb status register defines
64422a84b8dSQuaker Fang  */
64522a84b8dSQuaker Fang #define	FH_RCSR_RB_BYTE_TO_SEND_MASK	(0x0001FFFF)	/* bits 0-16 */
64622a84b8dSQuaker Fang 
64722a84b8dSQuaker Fang /*
64822a84b8dSQuaker Fang  * RSCSR: defs used in normal mode
64922a84b8dSQuaker Fang  */
65022a84b8dSQuaker Fang #define	FH_RSCSR_CHNL0_RBDCB_WPTR_MASK	(0x00000FFF)	/* bits 0-11 */
65122a84b8dSQuaker Fang 
65222a84b8dSQuaker Fang /*
65322a84b8dSQuaker Fang  * RSCSR: defs used in service mode
65422a84b8dSQuaker Fang  */
65522a84b8dSQuaker Fang #define	FH_RSCSR_CHNL1_SRAM_ADDR_MASK	(0x00FFFFFF)	/* bits 0-23 */
65622a84b8dSQuaker Fang #define	FH_RSCSR_CHNL1_RB_WPTR_MASK	(0x0FFFFFFF)	/* bits 0-27 */
65722a84b8dSQuaker Fang #define	FH_RSCSR_CHNL1_RB_WPTR_OFFSET_MASK	(0x000000FF)	/* bits 0-7 */
65822a84b8dSQuaker Fang 
65922a84b8dSQuaker Fang /*
66022a84b8dSQuaker Fang  * RSSR: RX Enable Error IRQ to Driver register defines
66122a84b8dSQuaker Fang  */
66222a84b8dSQuaker Fang #define	FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV_NO_RBD (0x00400000)	/* bit 22 */
66322a84b8dSQuaker Fang 
66422a84b8dSQuaker Fang #define	FH_DRAM2SRAM_DRAM_ADDR_HIGH_MASK	(0xFFFFFFF00)	/* bits 8-35 */
66522a84b8dSQuaker Fang #define	FH_DRAM2SRAM_DRAM_ADDR_LOW_MASK		(0x000000FF)	/* bits 0-7 */
66622a84b8dSQuaker Fang 
66722a84b8dSQuaker Fang #define	FH_DRAM2SRAM_DRAM_ADDR_HIGH_BITSHIFT	(8)	/* bits 8-35 */
66822a84b8dSQuaker Fang 
66922a84b8dSQuaker Fang /*
67022a84b8dSQuaker Fang  * RX DRAM status regs definitions
67122a84b8dSQuaker Fang  */
67222a84b8dSQuaker Fang #define	FH_RX_RB_NUM_MASK	(0x00000FFF)	/* bits 0-11 */
67322a84b8dSQuaker Fang #define	FH_RX_FRAME_NUM_MASK	(0x0FFF0000) /* bits 16-27 */
67422a84b8dSQuaker Fang 
67522a84b8dSQuaker Fang #define	FH_RX_RB_NUM_BITSHIFT	(0)
67622a84b8dSQuaker Fang #define	FH_RX_FRAME_NUM_BITSHIFT	(16)
67722a84b8dSQuaker Fang 
67822a84b8dSQuaker Fang /*
67922a84b8dSQuaker Fang  * Tx Scheduler
68022a84b8dSQuaker Fang  *
68122a84b8dSQuaker Fang  * The Tx Scheduler selects the next frame to be transmitted, chosing TFDs
68222a84b8dSQuaker Fang  * (Transmit Frame Descriptors) from up to 16 circular queues resident in
68322a84b8dSQuaker Fang  * host DRAM.  It steers each frame's Tx command (which contains the frame
68422a84b8dSQuaker Fang  * data) through one of up to 7 prioritized Tx DMA FIFO channels within the
68522a84b8dSQuaker Fang  * device.  A queue maps to only one (selectable by driver) Tx DMA channel,
68622a84b8dSQuaker Fang  * but one DMA channel may take input from several queues.
68722a84b8dSQuaker Fang  *
68822a84b8dSQuaker Fang  * Tx DMA channels have dedicated purposes.  For SP, and are used as follows:
68922a84b8dSQuaker Fang  * BMC TODO:  CONFIRM channel assignments, esp for 0/1
69022a84b8dSQuaker Fang  *
69122a84b8dSQuaker Fang  * 0 -- EDCA BK (background) frames, lowest priority
69222a84b8dSQuaker Fang  * 1 -- EDCA BE (best effort) frames, normal priority
69322a84b8dSQuaker Fang  * 2 -- EDCA VI (video) frames, higher priority
69422a84b8dSQuaker Fang  * 3 -- EDCA VO (voice) and management frames, highest priority
69522a84b8dSQuaker Fang  * 4 -- Commands (e.g. RXON, etc.)
69622a84b8dSQuaker Fang  * 5 -- HCCA short frames
69722a84b8dSQuaker Fang  * 6 -- HCCA long frames
69822a84b8dSQuaker Fang  * 7 -- not used by driver (device-internal only)
69922a84b8dSQuaker Fang  *
70022a84b8dSQuaker Fang  * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6.
70122a84b8dSQuaker Fang  * In addition, driver can map queues 7-15 to Tx DMA/FIFO channels 0-3 to
70222a84b8dSQuaker Fang  * support 11n aggregation via EDCA DMA channels. BMC confirm.
70322a84b8dSQuaker Fang  *
70422a84b8dSQuaker Fang  * The driver sets up each queue to work in one of two modes:
70522a84b8dSQuaker Fang  *
70622a84b8dSQuaker Fang  * 1)  Scheduler-Ack, in which the scheduler automatically supports a
70722a84b8dSQuaker Fang  *     block-ack (BA) window of up to 64 TFDs.  In this mode, each queue
70822a84b8dSQuaker Fang  *     contains TFDs for a unique combination of Recipient Address (RA)
70922a84b8dSQuaker Fang  *     and Traffic Identifier (TID), that is, traffic of a given
71022a84b8dSQuaker Fang  *     Quality-Of-Service (QOS) priority, destined for a single station.
71122a84b8dSQuaker Fang  *
71222a84b8dSQuaker Fang  *     In scheduler-ack mode, the scheduler keeps track of the Tx status of
71322a84b8dSQuaker Fang  *     each frame within the BA window, including whether it's been transmitted,
71422a84b8dSQuaker Fang  *     and whether it's been acknowledged by the receiving station.  The device
71522a84b8dSQuaker Fang  *     automatically processes block-acks received from the receiving STA,
71622a84b8dSQuaker Fang  *     and reschedules un-acked frames to be retransmitted (successful
71722a84b8dSQuaker Fang  *     Tx completion may end up being out-of-order).
71822a84b8dSQuaker Fang  *
71922a84b8dSQuaker Fang  *     The driver must maintain the queue's Byte Count table in host DRAM
72022a84b8dSQuaker Fang  *     (struct iwp_sched_queue_byte_cnt_tbl) for this mode.
72122a84b8dSQuaker Fang  *     This mode does not support fragmentation.
72222a84b8dSQuaker Fang  *
72322a84b8dSQuaker Fang  * 2)  FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order.
72422a84b8dSQuaker Fang  *     The device may automatically retry Tx, but will retry only one frame
72522a84b8dSQuaker Fang  *     at a time, until receiving ACK from receiving station, or reaching
72622a84b8dSQuaker Fang  *     retry limit and giving up.
72722a84b8dSQuaker Fang  *
72822a84b8dSQuaker Fang  *     The command queue (#4) must use this mode!
72922a84b8dSQuaker Fang  *     This mode does not require use of the Byte Count table in host DRAM.
73022a84b8dSQuaker Fang  *
73122a84b8dSQuaker Fang  * Driver controls scheduler operation via 3 means:
73222a84b8dSQuaker Fang  * 1)  Scheduler registers
73322a84b8dSQuaker Fang  * 2)  Shared scheduler data base in internal 4956 SRAM
73422a84b8dSQuaker Fang  * 3)  Shared data in host DRAM
73522a84b8dSQuaker Fang  *
73622a84b8dSQuaker Fang  * Initialization:
73722a84b8dSQuaker Fang  *
73822a84b8dSQuaker Fang  * When loading, driver should allocate memory for:
73922a84b8dSQuaker Fang  * 1)  16 TFD circular buffers, each with space for (typically) 256 TFDs.
74022a84b8dSQuaker Fang  * 2)  16 Byte Count circular buffers in 16 KBytes contiguous memory
74122a84b8dSQuaker Fang  *     (1024 bytes for each queue).
74222a84b8dSQuaker Fang  *
74322a84b8dSQuaker Fang  * After receiving "Alive" response from uCode, driver must initialize
74422a84b8dSQuaker Fang  * the following (especially for queue #4, the command queue, otherwise
74522a84b8dSQuaker Fang  * the driver can't issue commands!):
74622a84b8dSQuaker Fang  *
74722a84b8dSQuaker Fang  * 1)  SP's scheduler data base area in SRAM:
74822a84b8dSQuaker Fang  *     a)  Read SRAM address of data base area from SCD_SRAM_BASE_ADDR
74922a84b8dSQuaker Fang  *     b)  Clear and Init SCD_CONTEXT_DATA_OFFSET area (size 128 bytes)
75022a84b8dSQuaker Fang  *     c)  Clear SCD_TX_STTS_BITMAP_OFFSET area (size 256 bytes)
75122a84b8dSQuaker Fang  *     d)  Clear (BMC and init?) SCD_TRANSLATE_TBL_OFFSET (size 32 bytes)
75222a84b8dSQuaker Fang  *
75322a84b8dSQuaker Fang  * 2)  Init SCD_DRAM_BASE_ADDR with physical base of Tx byte count circular
75422a84b8dSQuaker Fang  *     buffer array, allocated by driver in host DRAM.
75522a84b8dSQuaker Fang  *
75622a84b8dSQuaker Fang  * 3)
75722a84b8dSQuaker Fang  */
75822a84b8dSQuaker Fang 
75922a84b8dSQuaker Fang /*
76022a84b8dSQuaker Fang  * Max Tx window size is the max number of contiguous TFDs that the scheduler
76122a84b8dSQuaker Fang  * can keep track of at one time when creating block-ack chains of frames.
76222a84b8dSQuaker Fang  * Note that "64" matches the number of ack bits in a block-ack.
76322a84b8dSQuaker Fang  * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize
76422a84b8dSQuaker Fang  * SCD_CONTEXT_QUEUE_OFFSET(x) values.
76522a84b8dSQuaker Fang  */
76622a84b8dSQuaker Fang #define	SCD_WIN_SIZE	64
76722a84b8dSQuaker Fang #define	SCD_FRAME_LIMIT	64
76822a84b8dSQuaker Fang 
76922a84b8dSQuaker Fang /*
77022a84b8dSQuaker Fang  * Driver may need to update queue-empty bits after changing queue's
77122a84b8dSQuaker Fang  * write and read pointers (indexes) during (re-)initialization (i.e. when
77222a84b8dSQuaker Fang  * scheduler is not tracking what's happening).
77322a84b8dSQuaker Fang  * Bit fields:
77422a84b8dSQuaker Fang  * 31-16:  Write mask -- 1: update empty bit, 0: don't change empty bit
77522a84b8dSQuaker Fang  * 15-00:  Empty state, one for each queue -- 1: empty, 0: non-empty
77622a84b8dSQuaker Fang  * NOTE BMC:  THIS REGISTER NOT USED BY LINUX DRIVER.
77722a84b8dSQuaker Fang  */
77822a84b8dSQuaker Fang #define	SCD_EMPTY_BITS	(SCD_START_OFFSET + 0x4)
77922a84b8dSQuaker Fang 
78022a84b8dSQuaker Fang /*
78122a84b8dSQuaker Fang  * Physical base address of array of byte count (BC) circular buffers (CBs).
78222a84b8dSQuaker Fang  * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode.
78322a84b8dSQuaker Fang  * This register points to BC CB for queue 0, must be on 1024-byte boundary.
78422a84b8dSQuaker Fang  * Others are spaced by 1024 bytes.
78522a84b8dSQuaker Fang  * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad.
78622a84b8dSQuaker Fang  * (Index into a queue's BC CB) = (index into queue's TFD CB) = (SSN & 0xff).
78722a84b8dSQuaker Fang  * Bit fields:
78822a84b8dSQuaker Fang  * 25-00:  Byte Count CB physical address [35:10], must be 1024-byte aligned.
78922a84b8dSQuaker Fang  */
79022a84b8dSQuaker Fang #define	SCD_AIT		(SCD_START_OFFSET + 0x18)
79122a84b8dSQuaker Fang 
79222a84b8dSQuaker Fang /*
79322a84b8dSQuaker Fang  * Queue (x) Write Pointers (indexes, really!), one for each Tx queue.
79422a84b8dSQuaker Fang  * Initialized and updated by driver as new TFDs are added to queue.
79522a84b8dSQuaker Fang  * NOTE:  If using Block Ack, index must correspond to frame's
79622a84b8dSQuaker Fang  *        Start Sequence Number; index = (SSN & 0xff)
79722a84b8dSQuaker Fang  * NOTE BMC:  Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses?
79822a84b8dSQuaker Fang  */
79922a84b8dSQuaker Fang #define	SCD_QUEUE_WRPTR(x)	(SCD_START_OFFSET + 0x24 + (x) * 4)
80022a84b8dSQuaker Fang 
80122a84b8dSQuaker Fang /*
80222a84b8dSQuaker Fang  * Queue (x) Read Pointers (indexes, really!), one for each Tx queue.
80322a84b8dSQuaker Fang  * For FIFO mode, index indicates next frame to transmit.
80422a84b8dSQuaker Fang  * For Scheduler-ACK mode, index indicates first frame in Tx window.
80522a84b8dSQuaker Fang  * Initialized by driver, updated by scheduler.
80622a84b8dSQuaker Fang  */
80722a84b8dSQuaker Fang #define	SCD_QUEUE_RDPTR(x)	(SCD_START_OFFSET + 0x64 + (x) * 4)
80822a84b8dSQuaker Fang #define	SCD_SETQUEUENUM		(SCD_START_OFFSET + 0xa4)
80922a84b8dSQuaker Fang #define	SCD_SET_TXSTAT_TXED	(SCD_START_OFFSET + 0xa8)
81022a84b8dSQuaker Fang #define	SCD_SET_TXSTAT_DONE	(SCD_START_OFFSET + 0xac)
81122a84b8dSQuaker Fang #define	SCD_SET_TXSTAT_NOT_SCHD	(SCD_START_OFFSET + 0xb0)
81222a84b8dSQuaker Fang #define	SCD_DECREASE_CREDIT	(SCD_START_OFFSET + 0xb4)
81322a84b8dSQuaker Fang #define	SCD_DECREASE_SCREDIT	(SCD_START_OFFSET + 0xb8)
81422a84b8dSQuaker Fang #define	SCD_LOAD_CREDIT		(SCD_START_OFFSET + 0xbc)
81522a84b8dSQuaker Fang #define	SCD_LOAD_SCREDIT	(SCD_START_OFFSET + 0xc0)
81622a84b8dSQuaker Fang #define	SCD_BAR			(SCD_START_OFFSET + 0xc4)
81722a84b8dSQuaker Fang #define	SCD_BAR_DW0		(SCD_START_OFFSET + 0xc8)
81822a84b8dSQuaker Fang #define	SCD_BAR_DW1		(SCD_START_OFFSET + 0xcc)
81922a84b8dSQuaker Fang 
82022a84b8dSQuaker Fang /*
82122a84b8dSQuaker Fang  * Select which queues work in chain mode (1) vs. not (0).
82222a84b8dSQuaker Fang  * Use chain mode to build chains of aggregated frames.
82322a84b8dSQuaker Fang  * Bit fields:
82422a84b8dSQuaker Fang  * 31-16:  Reserved
82522a84b8dSQuaker Fang  * 15-00:  Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time
82622a84b8dSQuaker Fang  * NOTE:  If driver sets up queue for chain mode, it should be also set up
82722a84b8dSQuaker Fang  *        Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x).
82822a84b8dSQuaker Fang  */
82922a84b8dSQuaker Fang #define	SCD_QUERY_REQ		(SCD_START_OFFSET + 0xd8)
83022a84b8dSQuaker Fang #define	SCD_QUERY_RES		(SCD_START_OFFSET + 0xdc)
83122a84b8dSQuaker Fang #define	SCD_PENDING_FRAMES	(SCD_START_OFFSET + 0xe0)
83222a84b8dSQuaker Fang 
83322a84b8dSQuaker Fang /*
83422a84b8dSQuaker Fang  * Select which queues interrupt driver when read pointer (index) increments.
83522a84b8dSQuaker Fang  * Bit fields:
83622a84b8dSQuaker Fang  * 31-16:  Reserved
83722a84b8dSQuaker Fang  * 15-00:  Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled
83822a84b8dSQuaker Fang  * NOTE BMC:  THIS FUNCTIONALITY IS APPARENTLY A NO-OP.
83922a84b8dSQuaker Fang  */
84022a84b8dSQuaker Fang #define	SCD_INTERRUPT_THRESHOLD	(SCD_START_OFFSET + 0xe8)
84122a84b8dSQuaker Fang #define	SCD_QUERY_MIN_FRAME_SIZE	(SCD_START_OFFSET + 0x100)
84222a84b8dSQuaker Fang 
84322a84b8dSQuaker Fang 
84422a84b8dSQuaker Fang /*
84522a84b8dSQuaker Fang  * SP internal SRAM structures for scheduler, shared with driver ...
84622a84b8dSQuaker Fang  * Driver should clear and initialize the following areas after receiving
84722a84b8dSQuaker Fang  * "Alive" response from SP uCode, i.e. after initial
84822a84b8dSQuaker Fang  * uCode load, or after a uCode load done for error recovery:
84922a84b8dSQuaker Fang  *
85022a84b8dSQuaker Fang  * SCD_CONTEXT_DATA_OFFSET (size 128 bytes)
85122a84b8dSQuaker Fang  * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes)
85222a84b8dSQuaker Fang  * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes)
85322a84b8dSQuaker Fang  *
85422a84b8dSQuaker Fang  * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR.
85522a84b8dSQuaker Fang  * All OFFSET values must be added to this base address.
85622a84b8dSQuaker Fang  * Use HBUS_TARG_MEM_* registers to access SRAM.
85722a84b8dSQuaker Fang  */
85822a84b8dSQuaker Fang 
85922a84b8dSQuaker Fang /*
86022a84b8dSQuaker Fang  * Queue context.  One 8-byte entry for each of 16 queues.
86122a84b8dSQuaker Fang  *
86222a84b8dSQuaker Fang  * Driver should clear this entire area (size 0x80) to 0 after receiving
86322a84b8dSQuaker Fang  * "Alive" notification from uCode.  Additionally, driver should init
86422a84b8dSQuaker Fang  * each queue's entry as follows:
86522a84b8dSQuaker Fang  *
86622a84b8dSQuaker Fang  * LS Dword bit fields:
86722a84b8dSQuaker Fang  *  0-06:  Max Tx window size for Scheduler-ACK.  Driver should init to 64.
86822a84b8dSQuaker Fang  *
86922a84b8dSQuaker Fang  * MS Dword bit fields:
87022a84b8dSQuaker Fang  * 16-22:  Frame limit.  Driver should init to 10 (0xa).
87122a84b8dSQuaker Fang  *
87222a84b8dSQuaker Fang  * Driver should init all other bits to 0.
87322a84b8dSQuaker Fang  *
87422a84b8dSQuaker Fang  * Init must be done after driver receives "Alive" response from SP uCode,
87522a84b8dSQuaker Fang  * and when setting up queue for aggregation.
87622a84b8dSQuaker Fang  */
87722a84b8dSQuaker Fang #define	SCD_CONTEXT_DATA_OFFSET		0x380
87822a84b8dSQuaker Fang 
87922a84b8dSQuaker Fang /*
88022a84b8dSQuaker Fang  * Tx Status Bitmap
88122a84b8dSQuaker Fang  *
88222a84b8dSQuaker Fang  * Driver should clear this entire area (size 0x100) to 0 after receiving
88322a84b8dSQuaker Fang  * "Alive" notification from uCode.  Area is used only by device itself;
88422a84b8dSQuaker Fang  * no other support (besides clearing) is required from driver.
88522a84b8dSQuaker Fang  */
88622a84b8dSQuaker Fang #define	SCD_TX_STTS_BITMAP_OFFSET	0x400
88722a84b8dSQuaker Fang 
88822a84b8dSQuaker Fang /*
88922a84b8dSQuaker Fang  * RAxTID to queue translation mapping.
89022a84b8dSQuaker Fang  *
89122a84b8dSQuaker Fang  * When queue is in Scheduler-ACK mode, frames placed in a that queue must be
89222a84b8dSQuaker Fang  * for only one combination of receiver address (RA) and traffic ID (TID), i.e.
89322a84b8dSQuaker Fang  * one QOS priority level destined for one station (for this link, not final
89422a84b8dSQuaker Fang  * destination).  The SCD_TRANSLATE_TABLE area provides 16 16-bit mappings,
89522a84b8dSQuaker Fang  * one for each of the 16 queues.  If queue is not in Scheduler-ACK mode, the
89622a84b8dSQuaker Fang  * device ignores the mapping value.
89722a84b8dSQuaker Fang  *
89822a84b8dSQuaker Fang  * Bit fields, for each 16-bit map:
89922a84b8dSQuaker Fang  * 15-9:  Reserved, set to 0
90022a84b8dSQuaker Fang  *  8-4:  Index into device's station table for recipient station
90122a84b8dSQuaker Fang  *  3-0:  Traffic ID (tid), range 0-15
90222a84b8dSQuaker Fang  *
90322a84b8dSQuaker Fang  * Driver should clear this entire area (size 32 bytes) to 0 after receiving
90422a84b8dSQuaker Fang  * "Alive" notification from uCode.  To update a 16-bit map value, driver
90522a84b8dSQuaker Fang  * must read a dword-aligned value from device SRAM, replace the 16-bit map
90622a84b8dSQuaker Fang  * value of interest, and write the dword value back into device SRAM.
90722a84b8dSQuaker Fang  */
90822a84b8dSQuaker Fang #define	SCD_TRANSLATE_TBL_OFFSET	0x500
90922a84b8dSQuaker Fang #define	SCD_CONTEXT_QUEUE_OFFSET(x)	(SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
91022a84b8dSQuaker Fang #define	SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
91122a84b8dSQuaker Fang 	((SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
91222a84b8dSQuaker Fang 
91322a84b8dSQuaker Fang /*
91422a84b8dSQuaker Fang  * Mask to enable contiguous Tx DMA/FIFO channels between "lo" and "hi".
91522a84b8dSQuaker Fang  */
91622a84b8dSQuaker Fang #define	SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \
91722a84b8dSQuaker Fang 	((1<<(hi))|((1<<(hi))-(1<<(lo))))
91822a84b8dSQuaker Fang 
91922a84b8dSQuaker Fang #define	SCD_MODE_REG_BIT_SEARCH_MODE		(1<<0)
92022a84b8dSQuaker Fang #define	SCD_MODE_REG_BIT_SBYP_MODE		(1<<1)
92122a84b8dSQuaker Fang 
92222a84b8dSQuaker Fang #define	SCD_TXFIFO_POS_TID			(0)
92322a84b8dSQuaker Fang #define	SCD_TXFIFO_POS_RA			(4)
92422a84b8dSQuaker Fang #define	SCD_QUEUE_STTS_REG_POS_SCD_ACK		(8)
92522a84b8dSQuaker Fang #define	SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN	(10)
92622a84b8dSQuaker Fang 
92722a84b8dSQuaker Fang #define	SCD_QUEUE_RA_TID_MAP_RATID_MSK		(0x01FF)
92822a84b8dSQuaker Fang 
92922a84b8dSQuaker Fang #define	SCD_QUEUE_CTX_REG1_WIN_SIZE_POS		(0)
93022a84b8dSQuaker Fang #define	SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK		(0x0000007F)
93122a84b8dSQuaker Fang #define	SCD_QUEUE_CTX_REG1_CREDIT_POS		(8)
93222a84b8dSQuaker Fang #define	SCD_QUEUE_CTX_REG1_CREDIT_MSK		(0x00FFFF00)
93322a84b8dSQuaker Fang #define	SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS	(24)
93422a84b8dSQuaker Fang #define	SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK	(0xFF000000)
93522a84b8dSQuaker Fang #define	SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS	(16)
93622a84b8dSQuaker Fang #define	SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK	(0x007F0000)
93722a84b8dSQuaker Fang 
93822a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_BIT_KEDRON_R	(0x00000010)
93922a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER	(0x00000C00)
94022a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_BIT_MAC_SI		(0x00000100)
94122a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI	(0x00000200)
94222a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_EEP_SEM		(0x00200000)
94322a84b8dSQuaker Fang #define	IWP_CSR_ANA_PLL_CFG			(0x00880300)
94422a84b8dSQuaker Fang 
94522a84b8dSQuaker Fang /* IWP-END */
94622a84b8dSQuaker Fang 
94722a84b8dSQuaker Fang 
94822a84b8dSQuaker Fang #define	STATISTICS_FLG_CLEAR				(0x1)
94922a84b8dSQuaker Fang #define	STATISTICS_FLG_DISABLE_NOTIFICATION		(0x2)
95022a84b8dSQuaker Fang 
95122a84b8dSQuaker Fang #define	STATISTICS_REPLY_FLG_CLEAR			(0x1)
95222a84b8dSQuaker Fang #define	STATISTICS_REPLY_FLG_BAND_24G_MSK		(0x2)
95322a84b8dSQuaker Fang #define	STATISTICS_REPLY_FLG_TGJ_NARROW_BAND_MSK	(0x4)
95422a84b8dSQuaker Fang #define	STATISTICS_REPLY_FLG_FAT_MODE_MSK		(0x8)
95522a84b8dSQuaker Fang #define	RX_PHY_FLAGS_ANTENNAE_OFFSET			(4)
95622a84b8dSQuaker Fang #define	RX_PHY_FLAGS_ANTENNAE_MASK			(0x70)
95722a84b8dSQuaker Fang 
95822a84b8dSQuaker Fang /*
95922a84b8dSQuaker Fang  * Register and values
96022a84b8dSQuaker Fang  */
96122a84b8dSQuaker Fang #define	CSR_BASE	(0x0)
96222a84b8dSQuaker Fang #define	HBUS_BASE	(0x400)
96322a84b8dSQuaker Fang 
96422a84b8dSQuaker Fang #define	HBUS_TARG_MBX_C	(HBUS_BASE+0x030)
96522a84b8dSQuaker Fang 
96622a84b8dSQuaker Fang /*
96722a84b8dSQuaker Fang  * CSR (control and status registers)
96822a84b8dSQuaker Fang  */
96922a84b8dSQuaker Fang #define	CSR_SW_VER		(CSR_BASE+0x000)
97022a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG	(CSR_BASE+0x000) /* hardware interface config */
97122a84b8dSQuaker Fang #define	CSR_INT_COALESCING	(CSR_BASE+0x004) /* accum ints, 32-usec units */
97222a84b8dSQuaker Fang #define	CSR_INT		(CSR_BASE+0x008) /* host interrupt status/ack */
97322a84b8dSQuaker Fang #define	CSR_INT_MASK	(CSR_BASE+0x00c) /* host interrupt enable */
97422a84b8dSQuaker Fang #define	CSR_FH_INT_STATUS	(CSR_BASE+0x010) /* busmaster int status/ack */
97522a84b8dSQuaker Fang #define	CSR_GPIO_IN	(CSR_BASE+0x018) /* read external chip pins */
97622a84b8dSQuaker Fang #define	CSR_RESET	(CSR_BASE+0x020) /* busmaster enable, NMI, etc */
97722a84b8dSQuaker Fang #define	CSR_GP_CNTRL	(CSR_BASE+0x024)
97822a84b8dSQuaker Fang #define	CSR_HW_REV	(CSR_BASE+0x028)
97922a84b8dSQuaker Fang #define	CSR_EEPROM_REG	(CSR_BASE+0x02c)
98022a84b8dSQuaker Fang #define	CSR_EEPROM_GP	(CSR_BASE+0x030)
98122a84b8dSQuaker Fang #define	CSR_GP_DRIVER_REG	(CSR_BASE+0x050)
98222a84b8dSQuaker Fang #define	CSR_UCODE_DRV_GP1	(CSR_BASE+0x054)
98322a84b8dSQuaker Fang #define	CSR_UCODE_DRV_GP1_SET	(CSR_BASE+0x058)
98422a84b8dSQuaker Fang #define	CSR_UCODE_DRV_GP1_CLR	(CSR_BASE+0x05c)
98522a84b8dSQuaker Fang #define	CSR_UCODE_DRV_GP2	(CSR_BASE+0x060)
98622a84b8dSQuaker Fang #define	CSR_GIO_CHICKEN_BITS	(CSR_BASE+0x100)
98722a84b8dSQuaker Fang #define	CSR_ANA_PLL_CFG		(CSR_BASE+0x20c)
98822a84b8dSQuaker Fang #define	CSR_HW_REV_WA_REG	(CSR_BASE+0x22C)
98922a84b8dSQuaker Fang 
99022a84b8dSQuaker Fang /*
99122a84b8dSQuaker Fang  * BSM (Bootstrap State Machine)
99222a84b8dSQuaker Fang  */
99322a84b8dSQuaker Fang #define	BSM_BASE		(CSR_BASE + 0x3400)
99422a84b8dSQuaker Fang 
99522a84b8dSQuaker Fang #define	BSM_WR_CTRL_REG  	(BSM_BASE + 0x000) /* ctl and status */
99622a84b8dSQuaker Fang #define	BSM_WR_MEM_SRC_REG 	(BSM_BASE + 0x004) /* source in BSM mem */
99722a84b8dSQuaker Fang #define	BSM_WR_MEM_DST_REG 	(BSM_BASE + 0x008) /* dest in SRAM mem */
99822a84b8dSQuaker Fang #define	BSM_WR_DWCOUNT_REG 	(BSM_BASE + 0x00C) /* bytes */
99922a84b8dSQuaker Fang #define	BSM_WR_STATUS_REG	(BSM_BASE + 0x010) /* bit 0:  1 == done */
100022a84b8dSQuaker Fang 
100122a84b8dSQuaker Fang /*
100222a84b8dSQuaker Fang  * BSM special memory, stays powered during power-save sleeps
100322a84b8dSQuaker Fang  */
100422a84b8dSQuaker Fang #define	BSM_SRAM_LOWER_BOUND	(CSR_BASE + 0x3800)
100522a84b8dSQuaker Fang #define	BSM_SRAM_SIZE		(1024)
100622a84b8dSQuaker Fang 
100722a84b8dSQuaker Fang 
100822a84b8dSQuaker Fang /*
100922a84b8dSQuaker Fang  * card static random access memory (SRAM) for processor data and instructs
101022a84b8dSQuaker Fang  */
101122a84b8dSQuaker Fang #define	RTC_INST_LOWER_BOUND		(0x000000)
101222a84b8dSQuaker Fang #define	RTC_INST_UPPER_BOUND 		(0x040000)
101322a84b8dSQuaker Fang 
101422a84b8dSQuaker Fang #define	RTC_DATA_LOWER_BOUND		(0x800000)
101522a84b8dSQuaker Fang #define	RTC_DATA_UPPER_BOUND		(0x814000)
101622a84b8dSQuaker Fang 
101722a84b8dSQuaker Fang #define	RTC_INST_SIZE\
101822a84b8dSQuaker Fang 	(RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
101922a84b8dSQuaker Fang #define	RTC_DATA_SIZE\
102022a84b8dSQuaker Fang 	(RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
102122a84b8dSQuaker Fang 
102222a84b8dSQuaker Fang /*
102322a84b8dSQuaker Fang  * HBUS (Host-side bus)
102422a84b8dSQuaker Fang  */
102522a84b8dSQuaker Fang #define	HBUS_TARG_MEM_RADDR 	(HBUS_BASE+0x00c)
102622a84b8dSQuaker Fang #define	HBUS_TARG_MEM_WADDR 	(HBUS_BASE+0x010)
102722a84b8dSQuaker Fang #define	HBUS_TARG_MEM_WDAT	(HBUS_BASE+0x018)
102822a84b8dSQuaker Fang #define	HBUS_TARG_MEM_RDAT	(HBUS_BASE+0x01c)
102922a84b8dSQuaker Fang #define	HBUS_TARG_PRPH_WADDR	(HBUS_BASE+0x044)
103022a84b8dSQuaker Fang #define	HBUS_TARG_PRPH_RADDR	(HBUS_BASE+0x048)
103122a84b8dSQuaker Fang #define	HBUS_TARG_PRPH_WDAT 	(HBUS_BASE+0x04c)
103222a84b8dSQuaker Fang #define	HBUS_TARG_PRPH_RDAT 	(HBUS_BASE+0x050)
103322a84b8dSQuaker Fang #define	HBUS_TARG_WRPTR		(HBUS_BASE+0x060)
103422a84b8dSQuaker Fang 
103522a84b8dSQuaker Fang /*
103622a84b8dSQuaker Fang  * HW I/F configuration
103722a84b8dSQuaker Fang  */
103822a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MB	(0x00000100)
103922a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MM	(0x00000200)
104022a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_BIT_SKU_MRC	(0x00000400)
104122a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_BIT_BOARD_TYPE	(0x00000800)
104222a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A	(0x00000000)
104322a84b8dSQuaker Fang #define	CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B	(0x00001000)
104422a84b8dSQuaker Fang 
104522a84b8dSQuaker Fang #define	CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP    	(0x00000001)
104622a84b8dSQuaker Fang #define	CSR_UCODE_SW_BIT_RFKILL			(0x00000002)
104722a84b8dSQuaker Fang #define	CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED   	(0x00000004)
104822a84b8dSQuaker Fang #define	CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT	(0x00000008)
104922a84b8dSQuaker Fang 
105022a84b8dSQuaker Fang #define	CSR_GPIO_IN_BIT_AUX_POWER	(0x00000200)
105122a84b8dSQuaker Fang #define	CSR_GPIO_IN_VAL_VAUX_PWR_SRC	(0x00000000)
105222a84b8dSQuaker Fang #define	CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX  (0x00800000)
105322a84b8dSQuaker Fang #define	CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER  (0x20000000)
105422a84b8dSQuaker Fang #define	CSR_GPIO_IN_VAL_VMAIN_PWR_SRC	CSR_GPIO_IN_BIT_AUX_POWER
105522a84b8dSQuaker Fang 
105622a84b8dSQuaker Fang #define	CSR_GP_DRIVER_REG_BIT_RADIO_SKU_MSK	(0x00000003)
105722a84b8dSQuaker Fang #define	CSR_GP_DRIVER_REG_BIT_RADIO_SKU_3x3_MIX	(0x00000000)
105822a84b8dSQuaker Fang #define	CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_MIX	(0x00000001)
105922a84b8dSQuaker Fang #define	CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA	(0x00000002)
106022a84b8dSQuaker Fang 
106122a84b8dSQuaker Fang /*
106222a84b8dSQuaker Fang  * interrupt flags in INTA, set by uCode or hardware (e.g. dma),
106322a84b8dSQuaker Fang  * acknowledged (reset) by host writing "1" to flagged bits.
106422a84b8dSQuaker Fang  */
106522a84b8dSQuaker Fang #define	BIT_INT_FH_RX \
106622a84b8dSQuaker Fang 	(((uint32_t)1) << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
106722a84b8dSQuaker Fang #define	BIT_INT_ERR	(1<<29) /* DMA hardware error FH_INT[31] */
106822a84b8dSQuaker Fang #define	BIT_INT_FH_TX	(1<<27) /* Tx DMA FH_INT[1:0] */
106922a84b8dSQuaker Fang #define	BIT_INT_MAC_CLK_ACTV (1<<26) /* NIC controller's clock toggled on/off */
107022a84b8dSQuaker Fang #define	BIT_INT_SWERROR	(1<<25) /* uCode error */
107122a84b8dSQuaker Fang #define	BIT_INT_RF_KILL	(1<<7)  /* HW RFKILL switch GP_CNTRL[27] toggled */
107222a84b8dSQuaker Fang #define	BIT_INT_CT_KILL	(1<<6)  /* Critical temp (chip too hot) rfkill */
107322a84b8dSQuaker Fang #define	BIT_INT_SW_RX 	(1<<3)  /* Rx, command responses, 3945 */
107422a84b8dSQuaker Fang #define	BIT_INT_WAKEUP 	(1<<1)  /* NIC controller waking up (pwr mgmt) */
107522a84b8dSQuaker Fang #define	BIT_INT_ALIVE 	(1<<0)  /* uCode interrupts once it initializes */
107622a84b8dSQuaker Fang 
107722a84b8dSQuaker Fang #define	CSR_INI_SET_MASK	(BIT_INT_FH_RX   |  \
107822a84b8dSQuaker Fang 				BIT_INT_ERR |      \
107922a84b8dSQuaker Fang 				BIT_INT_FH_TX   |  \
108022a84b8dSQuaker Fang 				BIT_INT_SWERROR |  \
108122a84b8dSQuaker Fang 				BIT_INT_RF_KILL |  \
108222a84b8dSQuaker Fang 				BIT_INT_SW_RX   |  \
108322a84b8dSQuaker Fang 				BIT_INT_WAKEUP  |  \
108422a84b8dSQuaker Fang 				BIT_INT_ALIVE)
108522a84b8dSQuaker Fang 
108622a84b8dSQuaker Fang /*
108722a84b8dSQuaker Fang  * interrupt flags in FH (flow handler) (PCI busmaster DMA)
108822a84b8dSQuaker Fang  */
108922a84b8dSQuaker Fang #define	BIT_FH_INT_ERR		(((uint32_t)1) << 31) /* Error */
109022a84b8dSQuaker Fang #define	BIT_FH_INT_HI_PRIOR	(1<<30) /* High priority Rx,bypass coalescing */
109122a84b8dSQuaker Fang #define	BIT_FH_INT_RX_CHNL2	(1<<18) /* Rx channel 2 (3945 only) */
109222a84b8dSQuaker Fang #define	BIT_FH_INT_RX_CHNL1	(1<<17) /* Rx channel 1 */
109322a84b8dSQuaker Fang #define	BIT_FH_INT_RX_CHNL0	(1<<16) /* Rx channel 0 */
109422a84b8dSQuaker Fang #define	BIT_FH_INT_TX_CHNL6	(1<<6)  /* Tx channel 6 (3945 only) */
109522a84b8dSQuaker Fang #define	BIT_FH_INT_TX_CHNL1	(1<<1)  /* Tx channel 1 */
109622a84b8dSQuaker Fang #define	BIT_FH_INT_TX_CHNL0	(1<<0)  /* Tx channel 0 */
109722a84b8dSQuaker Fang 
109822a84b8dSQuaker Fang #define	FH_INT_RX_MASK		(BIT_FH_INT_HI_PRIOR |  \
109922a84b8dSQuaker Fang 				BIT_FH_INT_RX_CHNL1 |  \
110022a84b8dSQuaker Fang 				BIT_FH_INT_RX_CHNL0)
110122a84b8dSQuaker Fang 
110222a84b8dSQuaker Fang #define	FH_INT_TX_MASK		(BIT_FH_INT_TX_CHNL6 |  \
110322a84b8dSQuaker Fang 				BIT_FH_INT_TX_CHNL1 |  \
110422a84b8dSQuaker Fang 				BIT_FH_INT_TX_CHNL0)
110522a84b8dSQuaker Fang 
110622a84b8dSQuaker Fang /*
110722a84b8dSQuaker Fang  * RESET
110822a84b8dSQuaker Fang  */
110922a84b8dSQuaker Fang #define	CSR_RESET_REG_FLAG_NEVO_RESET		(0x00000001)
111022a84b8dSQuaker Fang #define	CSR_RESET_REG_FLAG_FORCE_NMI		(0x00000002)
111122a84b8dSQuaker Fang #define	CSR_RESET_REG_FLAG_SW_RESET		(0x00000080)
111222a84b8dSQuaker Fang #define	CSR_RESET_REG_FLAG_MASTER_DISABLED	(0x00000100)
111322a84b8dSQuaker Fang #define	CSR_RESET_REG_FLAG_STOP_MASTER  	(0x00000200)
111422a84b8dSQuaker Fang 
111522a84b8dSQuaker Fang /*
111622a84b8dSQuaker Fang  * GP (general purpose) CONTROL
111722a84b8dSQuaker Fang  */
111822a84b8dSQuaker Fang #define	CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY	(0x00000001)
111922a84b8dSQuaker Fang #define	CSR_GP_CNTRL_REG_FLAG_INIT_DONE   	(0x00000004)
112022a84b8dSQuaker Fang #define	CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ 	(0x00000008)
112122a84b8dSQuaker Fang #define	CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP 	(0x00000010)
112222a84b8dSQuaker Fang 
112322a84b8dSQuaker Fang #define	CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN	(0x00000001)
112422a84b8dSQuaker Fang 
112522a84b8dSQuaker Fang #define	CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE	(0x07000000)
112622a84b8dSQuaker Fang #define	CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE	(0x04000000)
112722a84b8dSQuaker Fang #define	CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW 	(0x08000000)
112822a84b8dSQuaker Fang 
112922a84b8dSQuaker Fang /*
113022a84b8dSQuaker Fang  * APMG (power management) constants
113122a84b8dSQuaker Fang  */
113222a84b8dSQuaker Fang #define	APMG_CLK_CTRL_REG  	(0x003000)
113322a84b8dSQuaker Fang #define	ALM_APMG_CLK_EN  	(0x003004)
113422a84b8dSQuaker Fang #define	ALM_APMG_CLK_DIS   	(0x003008)
113522a84b8dSQuaker Fang #define	ALM_APMG_PS_CTL    	(0x00300c)
113622a84b8dSQuaker Fang #define	ALM_APMG_PCIDEV_STT	(0x003010)
113722a84b8dSQuaker Fang #define	ALM_APMG_RFKILL    	(0x003014)
113822a84b8dSQuaker Fang #define	ALM_APMG_LARC_INT 	(0x00301c)
113922a84b8dSQuaker Fang #define	ALM_APMG_LARC_INT_MSK	(0x003020)
114022a84b8dSQuaker Fang 
114122a84b8dSQuaker Fang #define	APMG_CLK_REG_VAL_DMA_CLK_RQT	(0x00000200)
114222a84b8dSQuaker Fang #define	APMG_CLK_REG_VAL_BSM_CLK_RQT	(0x00000800)
114322a84b8dSQuaker Fang 
114422a84b8dSQuaker Fang #define	APMG_PS_CTRL_REG_VAL_ALM_R_RESET_REQ	(0x04000000)
114522a84b8dSQuaker Fang 
114622a84b8dSQuaker Fang #define	APMG_DEV_STATE_REG_VAL_L1_ACTIVE_DISABLE	(0x00000800)
114722a84b8dSQuaker Fang 
114822a84b8dSQuaker Fang #define	APMG_PS_CTRL_REG_MSK_POWER_SRC		(0x03000000)
114922a84b8dSQuaker Fang #define	APMG_PS_CTRL_REG_VAL_POWER_SRC_VMAIN	(0x00000000)
115022a84b8dSQuaker Fang #define	APMG_PS_CTRL_REG_VAL_POWER_SRC_VAUX	(0x01000000)
115122a84b8dSQuaker Fang 
115222a84b8dSQuaker Fang /*
115322a84b8dSQuaker Fang  * BSM (bootstrap state machine)
115422a84b8dSQuaker Fang  */
115522a84b8dSQuaker Fang /*
115622a84b8dSQuaker Fang  * start boot load now
115722a84b8dSQuaker Fang  */
115822a84b8dSQuaker Fang #define	BSM_WR_CTRL_REG_BIT_START	(0x80000000)
115922a84b8dSQuaker Fang /*
116022a84b8dSQuaker Fang  * enable boot after power up
116122a84b8dSQuaker Fang  */
116222a84b8dSQuaker Fang #define	BSM_WR_CTRL_REG_BIT_START_EN	(0x40000000)
116322a84b8dSQuaker Fang 
116422a84b8dSQuaker Fang /*
116522a84b8dSQuaker Fang  * DBM
116622a84b8dSQuaker Fang  */
116722a84b8dSQuaker Fang #define	ALM_FH_SRVC_CHNL				(6)
116822a84b8dSQuaker Fang #define	IWP_FH_SRVC_LOWER_BOUND		(IWP_FH_REGS_LOWER_BOUND + 0x9C8)
116922a84b8dSQuaker Fang #define	IWP_FH_SRVC_CHNL		(9)
117022a84b8dSQuaker Fang 
117122a84b8dSQuaker Fang 
117222a84b8dSQuaker Fang #define	IWP_FH_SRVC_CHNL_SRAM_ADDR_REG(_chnl)\
117322a84b8dSQuaker Fang 	(IWP_FH_SRVC_LOWER_BOUND + (_chnl - 9) * 0x4)
117422a84b8dSQuaker Fang 
117522a84b8dSQuaker Fang #define	ALM_FH_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE		(20)
117622a84b8dSQuaker Fang #define	ALM_FH_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH		(4)
117722a84b8dSQuaker Fang 
117822a84b8dSQuaker Fang #define	ALM_FH_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN		(0x08000000)
117922a84b8dSQuaker Fang #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE	(0x80000000)
118022a84b8dSQuaker Fang #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE		(0x20000000)
118122a84b8dSQuaker Fang #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128		(0x01000000)
118222a84b8dSQuaker Fang #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST		(0x00001000)
118322a84b8dSQuaker Fang #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH		(0x00000000)
118422a84b8dSQuaker Fang #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF		(0x00000000)
118522a84b8dSQuaker Fang #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER		(0x00000001)
118622a84b8dSQuaker Fang #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL	(0x00000000)
118722a84b8dSQuaker Fang #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL	(0x00000008)
118822a84b8dSQuaker Fang #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD		(0x00200000)
118922a84b8dSQuaker Fang #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT		(0x00000000)
119022a84b8dSQuaker Fang #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE		(0x00000000)
119122a84b8dSQuaker Fang #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE		(0x80000000)
119222a84b8dSQuaker Fang #define	ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID		(0x00004000)
119322a84b8dSQuaker Fang #define	ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR		(0x00000001)
119422a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON	(0xFF000000)
119522a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON	(0x00FF0000)
119622a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B	(0x00000400)
119722a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON	(0x00000100)
119822a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON	(0x00000080)
119922a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH	(0x00000020)
120022a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH		(0x00000005)
120122a84b8dSQuaker Fang 
120222a84b8dSQuaker Fang #define	ALM_TB_MAX_BYTES_COUNT	(0xFFF0)
120322a84b8dSQuaker Fang 
120422a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) \
120522a84b8dSQuaker Fang 	((1LU << _channel) << 24)
120622a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel) \
120722a84b8dSQuaker Fang 	((1LU << _channel) << 16)
120822a84b8dSQuaker Fang 
120922a84b8dSQuaker Fang #define	ALM_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_channel) \
121022a84b8dSQuaker Fang 	(ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) | \
121122a84b8dSQuaker Fang 	ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel))
121222a84b8dSQuaker Fang #define	PCI_CFG_REV_ID_BIT_BASIC_SKU	(0x40)	/* bit 6 */
121322a84b8dSQuaker Fang #define	PCI_CFG_REV_ID_BIT_RTP		(0x80)	/* bit 7 */
121422a84b8dSQuaker Fang #define	PCI_CFG_RETRY_TIMEOUT		(0x41)
121522a84b8dSQuaker Fang 
121622a84b8dSQuaker Fang #define	HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED	(0x00000004)
121722a84b8dSQuaker Fang 
121822a84b8dSQuaker Fang #define	TFD_QUEUE_MIN		0
121922a84b8dSQuaker Fang #define	TFD_QUEUE_MAX		6
122022a84b8dSQuaker Fang #define	TFD_QUEUE_SIZE_MAX	(256)
122122a84b8dSQuaker Fang 
122222a84b8dSQuaker Fang /*
122322a84b8dSQuaker Fang  * spectrum and channel data structures
122422a84b8dSQuaker Fang  */
122522a84b8dSQuaker Fang #define	IWP_NUM_SCAN_RATES	(2)
122622a84b8dSQuaker Fang 
122722a84b8dSQuaker Fang #define	IWP_SCAN_FLAG_24GHZ  (1<<0)
122822a84b8dSQuaker Fang #define	IWP_SCAN_FLAG_52GHZ  (1<<1)
122922a84b8dSQuaker Fang #define	IWP_SCAN_FLAG_ACTIVE (1<<2)
123022a84b8dSQuaker Fang #define	IWP_SCAN_FLAG_DIRECT (1<<3)
123122a84b8dSQuaker Fang 
123222a84b8dSQuaker Fang #define	IWP_MAX_CMD_SIZE 1024
123322a84b8dSQuaker Fang 
123422a84b8dSQuaker Fang #define	IWP_DEFAULT_TX_RETRY	15
123522a84b8dSQuaker Fang #define	IWP_MAX_TX_RETRY	16
123622a84b8dSQuaker Fang 
123722a84b8dSQuaker Fang #define	RFD_SIZE	4
123822a84b8dSQuaker Fang #define	NUM_TFD_CHUNKS	4
123922a84b8dSQuaker Fang 
124022a84b8dSQuaker Fang #define	RX_QUEUE_SIZE		256
124122a84b8dSQuaker Fang #define	RX_QUEUE_SIZE_LOG	8
124222a84b8dSQuaker Fang 
124322a84b8dSQuaker Fang /*
124422a84b8dSQuaker Fang  * TX Queue Flag Definitions
124522a84b8dSQuaker Fang  */
124622a84b8dSQuaker Fang /*
124722a84b8dSQuaker Fang  * use short preamble
124822a84b8dSQuaker Fang  */
124922a84b8dSQuaker Fang #define	DCT_FLAG_LONG_PREAMBLE	0x00
125022a84b8dSQuaker Fang #define	DCT_FLAG_SHORT_PREAMBLE	0x04
125122a84b8dSQuaker Fang 
125222a84b8dSQuaker Fang /*
125322a84b8dSQuaker Fang  * ACK rx is expected to follow
125422a84b8dSQuaker Fang  */
125522a84b8dSQuaker Fang #define	DCT_FLAG_ACK_REQD		0x80
125622a84b8dSQuaker Fang 
125722a84b8dSQuaker Fang #define	IWP_MB_DISASSOCIATE_THRESHOLD_DEFAULT	24
125822a84b8dSQuaker Fang #define	IWP_MB_ROAMING_THRESHOLD_DEFAULT		8
125922a84b8dSQuaker Fang #define	IWP_REAL_RATE_RX_PACKET_THRESHOLD		300
126022a84b8dSQuaker Fang 
126122a84b8dSQuaker Fang /*
126222a84b8dSQuaker Fang  * QoS  definitions
126322a84b8dSQuaker Fang  */
126422a84b8dSQuaker Fang 
126522a84b8dSQuaker Fang #define	AC_NUM		(4)	/* the number of access category */
126622a84b8dSQuaker Fang 
126722a84b8dSQuaker Fang /*
126822a84b8dSQuaker Fang  * index of every AC in firmware
126922a84b8dSQuaker Fang  */
127022a84b8dSQuaker Fang #define	QOS_AC_BK	(0)
127122a84b8dSQuaker Fang #define	QOS_AC_BE	(1)
127222a84b8dSQuaker Fang #define	QOS_AC_VI	(2)
127322a84b8dSQuaker Fang #define	QOS_AC_VO	(3)
127422a84b8dSQuaker Fang #define	QOS_AC_INVALID	(-1)
127522a84b8dSQuaker Fang 
127622a84b8dSQuaker Fang #define	QOS_CW_RANGE_MIN	(0)	/* exponential of 2 */
127722a84b8dSQuaker Fang #define	QOS_CW_RANGE_MAX	(15)	/* exponential of 2 */
127822a84b8dSQuaker Fang #define	QOS_TXOP_MIN		(0)	/* unit of 32 microsecond */
127922a84b8dSQuaker Fang #define	QOS_TXOP_MAX		(255)	/* unit of 32 microsecond */
128022a84b8dSQuaker Fang #define	QOS_AIFSN_MIN		(2)
128122a84b8dSQuaker Fang #define	QOS_AIFSN_MAX		(15)	/* undefined */
128222a84b8dSQuaker Fang 
128322a84b8dSQuaker Fang /*
128422a84b8dSQuaker Fang  * masks for flags of QoS parameter command
128522a84b8dSQuaker Fang  */
128622a84b8dSQuaker Fang #define	QOS_PARAM_FLG_UPDATE_EDCA	(0x01)
128722a84b8dSQuaker Fang #define	QOS_PARAM_FLG_TGN		(0x02)
128822a84b8dSQuaker Fang 
128922a84b8dSQuaker Fang /*
129022a84b8dSQuaker Fang  * index of TX queue for every AC
129122a84b8dSQuaker Fang  */
129222a84b8dSQuaker Fang #define	QOS_AC_BK_TO_TXQ	(3)
129322a84b8dSQuaker Fang #define	QOS_AC_BE_TO_TXQ	(2)
129422a84b8dSQuaker Fang #define	QOS_AC_VI_TO_TXQ	(1)
129522a84b8dSQuaker Fang #define	QOS_AC_VO_TO_TXQ	(0)
129622a84b8dSQuaker Fang #define	TXQ_FOR_AC_MIN		(0)
129722a84b8dSQuaker Fang #define	TXQ_FOR_AC_MAX		(3)
129822a84b8dSQuaker Fang #define	TXQ_FOR_AC_INVALID	(-1)
129922a84b8dSQuaker Fang #define	NON_QOS_TXQ		QOS_AC_BE_TO_TXQ
130022a84b8dSQuaker Fang #define	QOS_TXQ_FOR_MGT		QOS_AC_VO_TO_TXQ
130122a84b8dSQuaker Fang 
130222a84b8dSQuaker Fang #define	WME_TID_MIN	(0)
130322a84b8dSQuaker Fang #define	WME_TID_MAX	(7)
130422a84b8dSQuaker Fang #define	WME_TID_INVALID	(-1)
130522a84b8dSQuaker Fang 
130622a84b8dSQuaker Fang /*
130722a84b8dSQuaker Fang  * HT definitions
130822a84b8dSQuaker Fang  */
130922a84b8dSQuaker Fang 
131022a84b8dSQuaker Fang /*
131122a84b8dSQuaker Fang  * HT capabilities masks
131222a84b8dSQuaker Fang  */
131322a84b8dSQuaker Fang #define	HT_CAP_SUP_WIDTH	(0x0002)
131422a84b8dSQuaker Fang #define	HT_CAP_MIMO_PS		(0x000c)
131522a84b8dSQuaker Fang #define	HT_CAP_GRN_FLD		(0x0010)
131622a84b8dSQuaker Fang #define	HT_CAP_SGI_20		(0x0020)
131722a84b8dSQuaker Fang #define	HT_CAP_SGI_40		(0x0040)
131822a84b8dSQuaker Fang #define	HT_CAP_DELAY_BA		(0x0400)
131922a84b8dSQuaker Fang #define	HT_CAP_MAX_AMSDU	(0x0800)
132022a84b8dSQuaker Fang #define	HT_CAP_MCS_TX_DEFINED	(0x01)
132122a84b8dSQuaker Fang #define	HT_CAP_MCS_TX_RX_DIFF	(0x02)
132222a84b8dSQuaker Fang #define	HT_CAP_MCS_TX_STREAMS	(0x0c)
132322a84b8dSQuaker Fang #define	HT_CAP_MCS_TX_UEQM	(0x10)
132422a84b8dSQuaker Fang 
132522a84b8dSQuaker Fang #define	HT_CAP_MIMO_PS_STATIC	(0)
132622a84b8dSQuaker Fang #define	HT_CAP_MIMO_PS_DYNAMIC	(1)
132722a84b8dSQuaker Fang #define	HT_CAP_MIMO_PS_INVALID	(2)
132822a84b8dSQuaker Fang #define	HT_CAP_MIMO_PS_NONE	(3)
132922a84b8dSQuaker Fang 
133022a84b8dSQuaker Fang #define	HT_RX_AMPDU_FACTOR_8K	(0x0)
133122a84b8dSQuaker Fang #define	HT_RX_AMPDU_FACTOR_16K	(0x1)
133222a84b8dSQuaker Fang #define	HT_RX_AMPDU_FACTOR_32K	(0x2)
133322a84b8dSQuaker Fang #define	HT_RX_AMPDU_FACTOR_64K	(0x3)
133422a84b8dSQuaker Fang #define	HT_RX_AMPDU_FACTOR	HT_RX_AMPDU_FACTOR_8K
133522a84b8dSQuaker Fang #define	HT_RX_AMPDU_FACTOR_MSK	(0x3)
133622a84b8dSQuaker Fang 
133722a84b8dSQuaker Fang #define	HT_MPDU_DENSITY_4USEC	(0x5)
133822a84b8dSQuaker Fang #define	HT_MPDU_DENSITY_8USEC	(0x6)
133922a84b8dSQuaker Fang #define	HT_MPDU_DENSITY		HT_MPDU_DENSITY_4USEC
134022a84b8dSQuaker Fang #define	HT_MPDU_DENSITY_MSK	(0x1c)
134122a84b8dSQuaker Fang #define	HT_MPDU_DENSITY_POS	(2)
134222a84b8dSQuaker Fang 
134322a84b8dSQuaker Fang #define	HT_RATESET_NUM		(16)
134422a84b8dSQuaker Fang #define	HT_1CHAIN_RATE_MIN_IDX	(0x0)
134522a84b8dSQuaker Fang #define	HT_1CHAIN_RATE_MAX_IDX	(0x7)
134622a84b8dSQuaker Fang #define	HT_2CHAIN_RATE_MIN_IDX	(0x8)
134722a84b8dSQuaker Fang #define	HT_2CHAIN_RATE_MAX_IDX	(0xf)
134822a84b8dSQuaker Fang 
134922a84b8dSQuaker Fang struct iwp_ampdu_param {
135022a84b8dSQuaker Fang 	uint8_t	factor;
135122a84b8dSQuaker Fang 	uint8_t	density;
135222a84b8dSQuaker Fang };
135322a84b8dSQuaker Fang 
135422a84b8dSQuaker Fang typedef	struct iwp_ht_conf {
135522a84b8dSQuaker Fang 	uint8_t			ht_support;
135622a84b8dSQuaker Fang 	uint16_t		cap;
135722a84b8dSQuaker Fang 	struct iwp_ampdu_param	ampdu_p;
135822a84b8dSQuaker Fang 	uint8_t			tx_support_mcs[HT_RATESET_NUM];
135922a84b8dSQuaker Fang 	uint8_t			rx_support_mcs[HT_RATESET_NUM];
136022a84b8dSQuaker Fang 	uint8_t			valid_chains;
136122a84b8dSQuaker Fang 	uint8_t			tx_stream_count;
136222a84b8dSQuaker Fang 	uint8_t			rx_stream_count;
136322a84b8dSQuaker Fang 	uint8_t			ht_protection;
136422a84b8dSQuaker Fang } iwp_ht_conf_t;
136522a84b8dSQuaker Fang 
136622a84b8dSQuaker Fang #define	NO_HT_PROT		(0)
136722a84b8dSQuaker Fang #define	HT_PROT_CHAN_NON_HT	(1)
136822a84b8dSQuaker Fang #define	HT_PROT_FAT		(2)
136922a84b8dSQuaker Fang #define	HT_PROT_ASSOC_NON_HT	(3)
137022a84b8dSQuaker Fang 
137122a84b8dSQuaker Fang /*
137222a84b8dSQuaker Fang  * HT flags for RXON command.
137322a84b8dSQuaker Fang  */
137422a84b8dSQuaker Fang #define	RXON_FLG_CONTROL_CHANNEL_LOCATION_MSK	0x400000
137522a84b8dSQuaker Fang #define	RXON_FLG_CONTROL_CHANNEL_LOC_LOW_MSK	0x000000
137622a84b8dSQuaker Fang #define	RXON_FLG_CONTROL_CHANNEL_LOC_HIGH_MSK	0x400000
137722a84b8dSQuaker Fang 
137822a84b8dSQuaker Fang #define	RXON_FLG_HT_OPERATING_MODE_POS		(23)
137922a84b8dSQuaker Fang #define	RXON_FLG_HT_PROT_MSK			0x800000
138022a84b8dSQuaker Fang #define	RXON_FLG_FAT_PROT_MSK			0x1000000
138122a84b8dSQuaker Fang 
138222a84b8dSQuaker Fang #define	RXON_FLG_CHANNEL_MODE_POS		(25)
138322a84b8dSQuaker Fang #define	RXON_FLG_CHANNEL_MODE_MSK		0x06000000
138422a84b8dSQuaker Fang #define	RXON_FLG_CHANNEL_MODE_LEGACY_MSK	0x00000000
138522a84b8dSQuaker Fang #define	RXON_FLG_CHANNEL_MODE_PURE_40_MSK	0x02000000
138622a84b8dSQuaker Fang #define	RXON_FLG_CHANNEL_MODE_MIXED_MSK		0x04000000
138722a84b8dSQuaker Fang 
138822a84b8dSQuaker Fang #define	RXON_RX_CHAIN_DRIVER_FORCE_MSK		(0x1<<0)
138922a84b8dSQuaker Fang #define	RXON_RX_CHAIN_VALID_MSK			(0x7<<1)
139022a84b8dSQuaker Fang #define	RXON_RX_CHAIN_VALID_POS			(1)
139122a84b8dSQuaker Fang #define	RXON_RX_CHAIN_FORCE_SEL_MSK		(0x7<<4)
139222a84b8dSQuaker Fang #define	RXON_RX_CHAIN_FORCE_SEL_POS		(4)
139322a84b8dSQuaker Fang #define	RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK	(0x7<<7)
139422a84b8dSQuaker Fang #define	RXON_RX_CHAIN_FORCE_MIMO_SEL_POS	(7)
139522a84b8dSQuaker Fang #define	RXON_RX_CHAIN_CNT_MSK			(0x3<<10)
139622a84b8dSQuaker Fang #define	RXON_RX_CHAIN_CNT_POS			(10)
139722a84b8dSQuaker Fang #define	RXON_RX_CHAIN_MIMO_CNT_MSK		(0x3<<12)
139822a84b8dSQuaker Fang #define	RXON_RX_CHAIN_MIMO_CNT_POS		(12)
139922a84b8dSQuaker Fang #define	RXON_RX_CHAIN_MIMO_FORCE_MSK		(0x1<<14)
140022a84b8dSQuaker Fang #define	RXON_RX_CHAIN_MIMO_FORCE_POS		(14)
140122a84b8dSQuaker Fang #define	RXON_RX_CHAIN_A_MSK			(1)
140222a84b8dSQuaker Fang #define	RXON_RX_CHAIN_B_MSK			(2)
140322a84b8dSQuaker Fang #define	RXON_RX_CHAIN_C_MSK			(4)
140422a84b8dSQuaker Fang 
140522a84b8dSQuaker Fang /*
140622a84b8dSQuaker Fang  * Generic queue structure
140722a84b8dSQuaker Fang  *
140822a84b8dSQuaker Fang  * Contains common data for Rx and Tx queues
140922a84b8dSQuaker Fang  */
141022a84b8dSQuaker Fang #define	TFD_CTL_COUNT_SET(n)	(n<<24)
141122a84b8dSQuaker Fang #define	TFD_CTL_COUNT_GET(ctl)	((ctl>>24) & 7)
141222a84b8dSQuaker Fang #define	TFD_CTL_PAD_SET(n)	(n<<28)
141322a84b8dSQuaker Fang #define	TFD_CTL_PAD_GET(ctl)	(ctl>>28)
141422a84b8dSQuaker Fang 
141522a84b8dSQuaker Fang #define	TFD_TX_CMD_SLOTS 64
141622a84b8dSQuaker Fang #define	TFD_CMD_SLOTS 32
141722a84b8dSQuaker Fang 
141822a84b8dSQuaker Fang /*
141922a84b8dSQuaker Fang  * Tx/Rx Queues
142022a84b8dSQuaker Fang  *
142122a84b8dSQuaker Fang  * Most communication between driver and SP is via queues of data buffers.
142222a84b8dSQuaker Fang  * For example, all commands that the driver issues to device's embedded
142322a84b8dSQuaker Fang  * controller (uCode) are via the command queue (one of the Tx queues).  All
142422a84b8dSQuaker Fang  * uCode command responses/replies/notifications, including Rx frames, are
142522a84b8dSQuaker Fang  * conveyed from uCode to driver via the Rx queue.
142622a84b8dSQuaker Fang  *
142722a84b8dSQuaker Fang  * Most support for these queues, including handshake support, resides in
142822a84b8dSQuaker Fang  * structures in host DRAM, shared between the driver and the device.  When
142922a84b8dSQuaker Fang  * allocating this memory, the driver must make sure that data written by
143022a84b8dSQuaker Fang  * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's
143122a84b8dSQuaker Fang  * cache memory), so DRAM and cache are consistent, and the device can
143222a84b8dSQuaker Fang  * immediately see changes made by the driver.
143322a84b8dSQuaker Fang  *
143422a84b8dSQuaker Fang  * SP supports up to 16 DRAM-based Tx queues, and services these queues via
143522a84b8dSQuaker Fang  * up to 7 DMA channels (FIFOs).  Each Tx queue is supported by a circular array
143622a84b8dSQuaker Fang  * in DRAM containing 256 Transmit Frame Descriptors (TFDs).
143722a84b8dSQuaker Fang  */
143822a84b8dSQuaker Fang #define	IWP_MAX_WIN_SIZE	64
143922a84b8dSQuaker Fang #define	IWP_QUEUE_SIZE	256
144022a84b8dSQuaker Fang #define	IWP_NUM_FIFOS	7
144122a84b8dSQuaker Fang #define	IWP_NUM_QUEUES	20
144222a84b8dSQuaker Fang #define	IWP_CMD_QUEUE_NUM	4
144322a84b8dSQuaker Fang #define	IWP_KW_SIZE 0x1000	/* 4k */
144422a84b8dSQuaker Fang #define	IWP_CMD_FIFO_NUM	7
144522a84b8dSQuaker Fang 
144622a84b8dSQuaker Fang struct iwp_rate {
144722a84b8dSQuaker Fang 	union {
144822a84b8dSQuaker Fang 		struct {
144922a84b8dSQuaker Fang 			uint8_t rate;
145022a84b8dSQuaker Fang 			uint8_t flags;
145122a84b8dSQuaker Fang 			uint16_t ext_flags;
145222a84b8dSQuaker Fang 		} s;
145322a84b8dSQuaker Fang 		uint32_t rate_n_flags;
145422a84b8dSQuaker Fang 	} r;
145522a84b8dSQuaker Fang };
145622a84b8dSQuaker Fang 
145722a84b8dSQuaker Fang struct iwp_dram_scratch {
145822a84b8dSQuaker Fang 	uint8_t try_cnt;
145922a84b8dSQuaker Fang 	uint8_t bt_kill_cnt;
146022a84b8dSQuaker Fang 	uint16_t reserved;
146122a84b8dSQuaker Fang };
146222a84b8dSQuaker Fang 
146322a84b8dSQuaker Fang 
146422a84b8dSQuaker Fang struct iwp_tx_power {
146522a84b8dSQuaker Fang 	uint8_t tx_gain;	/* gain for analog radio */
146622a84b8dSQuaker Fang 	uint8_t dsp_atten;	/* gain for DSP */
146722a84b8dSQuaker Fang };
146822a84b8dSQuaker Fang 
146922a84b8dSQuaker Fang 
147022a84b8dSQuaker Fang union iwp_tx_power_triple_stream {
147122a84b8dSQuaker Fang 	struct {
147222a84b8dSQuaker Fang 		uint8_t radio_tx_gain[3];
147322a84b8dSQuaker Fang 		uint8_t reserved1;
147422a84b8dSQuaker Fang 		uint8_t dsp_predis_atten[3];
147522a84b8dSQuaker Fang 		uint8_t reserved2;
147622a84b8dSQuaker Fang 	}s;
147722a84b8dSQuaker Fang 	uint32_t val1;
147822a84b8dSQuaker Fang 	uint32_t val2;
147922a84b8dSQuaker Fang };
148022a84b8dSQuaker Fang 
148122a84b8dSQuaker Fang struct iwp_tx_power_db {
148222a84b8dSQuaker Fang 	union	iwp_tx_power_triple_stream ht_ofdm_power[24];
148322a84b8dSQuaker Fang 	union	iwp_tx_power_triple_stream cck_power[2];
148422a84b8dSQuaker Fang };
148522a84b8dSQuaker Fang 
148622a84b8dSQuaker Fang typedef struct iwp_tx_power_table_cmd {
148722a84b8dSQuaker Fang 	uint8_t band;
148822a84b8dSQuaker Fang 	uint8_t pa_measurements;
148922a84b8dSQuaker Fang 	uint8_t channel;
149022a84b8dSQuaker Fang 	uint8_t max_mcs;
149122a84b8dSQuaker Fang 	struct iwp_tx_power_db	db;
149222a84b8dSQuaker Fang } iwp_tx_power_table_cmd_t;
149322a84b8dSQuaker Fang 
149422a84b8dSQuaker Fang /*
149522a84b8dSQuaker Fang  * Hardware rate scaling set by iwp_ap_lq function.
149622a84b8dSQuaker Fang  * Given a particular initial rate and mode, the driver uses the
149722a84b8dSQuaker Fang  * following formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM]
149822a84b8dSQuaker Fang  * rate table in the Link Quality command:
149922a84b8dSQuaker Fang  *
150022a84b8dSQuaker Fang  * 1) If using High-throughput(HT)(SISO or MIMO) initial rate:
150122a84b8dSQuaker Fang  *    a) Use this same initial rate for first 3 entries.
150222a84b8dSQuaker Fang  *    b) Find next lower available rate using same mode(SISO or MIMO),
150322a84b8dSQuaker Fang  *	 use for next 3 entries. If no lower rate available, switch to
150422a84b8dSQuaker Fang  *	 legacy mode(no FAT channel, no MIMO, no short guard interval).
150522a84b8dSQuaker Fang  *    c) If using MIMO, set command's mimo_delimeter to number of
150622a84b8dSQuaker Fang  *	 entries using MIMO(3 or 6).
150722a84b8dSQuaker Fang  *    d) After trying 2 HT rates, switch to legacy mode(no FAT channel,
150822a84b8dSQuaker Fang  *	 no MIMO, no short qguard interval), at the next lower bit rate
150922a84b8dSQuaker Fang  *	 (e.g. if second HT bit rate was 54, try 48 legacy),and follow
151022a84b8dSQuaker Fang  *   legacy procedure for remaining table entries.
151122a84b8dSQuaker Fang  *
151222a84b8dSQuaker Fang  * 2) If using legacy initial rate:
151322a84b8dSQuaker Fang  *    a) Use the initial rate for only one entry.
151422a84b8dSQuaker Fang  *    b) For each following entry, reduce the rate to next lower available
151522a84b8dSQuaker Fang  *	 rate, until reaching the lowest available rate.
151622a84b8dSQuaker Fang  *    c) When reducing rate, also switch antenna selection.
151722a84b8dSQuaker Fang  *    b) Once lowest available rate is reached, repreat this rate until
151822a84b8dSQuaker Fang  *   rate table is filled(16 entries),switching antenna each entry.
151922a84b8dSQuaker Fang  */
152022a84b8dSQuaker Fang 
152122a84b8dSQuaker Fang /*
152222a84b8dSQuaker Fang  * OFDM HT rate masks
152322a84b8dSQuaker Fang  */
152422a84b8dSQuaker Fang #define	R_MCS_6M_MSK 0x1
152522a84b8dSQuaker Fang #define	R_MCS_12M_MSK 0x2
152622a84b8dSQuaker Fang #define	R_MCS_18M_MSK 0x4
152722a84b8dSQuaker Fang #define	R_MCS_24M_MSK 0x8
152822a84b8dSQuaker Fang #define	R_MCS_36M_MSK 0x10
152922a84b8dSQuaker Fang #define	R_MCS_48M_MSK 0x20
153022a84b8dSQuaker Fang #define	R_MCS_54M_MSK 0x40
153122a84b8dSQuaker Fang #define	R_MCS_60M_MSK 0x80
153222a84b8dSQuaker Fang #define	R_MCS_12M_DUAL_MSK 0x100
153322a84b8dSQuaker Fang #define	R_MCS_24M_DUAL_MSK 0x200
153422a84b8dSQuaker Fang #define	R_MCS_36M_DUAL_MSK 0x400
153522a84b8dSQuaker Fang #define	R_MCS_48M_DUAL_MSK 0x800
153622a84b8dSQuaker Fang 
153722a84b8dSQuaker Fang #define	RATE_MCS_CODE_MSK 0x7
153822a84b8dSQuaker Fang #define	RATE_MCS_MIMO_POS 3
153922a84b8dSQuaker Fang #define	RATE_MCS_MIMO_MSK 0x8
154022a84b8dSQuaker Fang #define	RATE_MCS_HT_DUP_POS 5
154122a84b8dSQuaker Fang #define	RATE_MCS_HT_DUP_MSK 0x20
154222a84b8dSQuaker Fang #define	RATE_MCS_FLAGS_POS 8
154322a84b8dSQuaker Fang #define	RATE_MCS_HT_POS 8
154422a84b8dSQuaker Fang #define	RATE_MCS_HT_MSK 0x100
154522a84b8dSQuaker Fang #define	RATE_MCS_CCK_POS 9
154622a84b8dSQuaker Fang #define	RATE_MCS_CCK_MSK 0x200
154722a84b8dSQuaker Fang #define	RATE_MCS_GF_POS 10
154822a84b8dSQuaker Fang #define	RATE_MCS_GF_MSK 0x400
154922a84b8dSQuaker Fang 
155022a84b8dSQuaker Fang #define	RATE_MCS_FAT_POS 11
155122a84b8dSQuaker Fang #define	RATE_MCS_FAT_MSK 0x800
155222a84b8dSQuaker Fang #define	RATE_MCS_DUP_POS 12
155322a84b8dSQuaker Fang #define	RATE_MCS_DUP_MSK 0x1000
155422a84b8dSQuaker Fang #define	RATE_MCS_SGI_POS 13
155522a84b8dSQuaker Fang #define	RATE_MCS_SGI_MSK 0x2000
155622a84b8dSQuaker Fang 
155722a84b8dSQuaker Fang #define	EEPROM_SEM_TIMEOUT 10
155822a84b8dSQuaker Fang #define	EEPROM_SEM_RETRY_LIMIT 1000
155922a84b8dSQuaker Fang 
156022a84b8dSQuaker Fang /*
156122a84b8dSQuaker Fang  * Antenna masks:
156222a84b8dSQuaker Fang  * bit14:15 01 B inactive, A active
156322a84b8dSQuaker Fang  *          10 B active, A inactive
156422a84b8dSQuaker Fang  *          11 Both active
156522a84b8dSQuaker Fang  */
156622a84b8dSQuaker Fang #define	RATE_MCS_ANT_A_POS	14
156722a84b8dSQuaker Fang #define	RATE_MCS_ANT_B_POS	15
156822a84b8dSQuaker Fang #define	RATE_MCS_ANT_A_MSK	0x4000
156922a84b8dSQuaker Fang #define	RATE_MCS_ANT_B_MSK	0x8000
157022a84b8dSQuaker Fang #define	RATE_MCS_ANT_AB_MSK	0xc000
157122a84b8dSQuaker Fang 
157222a84b8dSQuaker Fang #define	is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A))
157322a84b8dSQuaker Fang #define	is_siso(tbl) (((tbl) == LQ_SISO))
157422a84b8dSQuaker Fang #define	is_mimo(tbl) (((tbl) == LQ_MIMO))
157522a84b8dSQuaker Fang #define	is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl))
157622a84b8dSQuaker Fang #define	is_a_band(tbl) (((tbl) == LQ_A))
157722a84b8dSQuaker Fang #define	is_g_and(tbl) (((tbl) == LQ_G))
157822a84b8dSQuaker Fang 
157922a84b8dSQuaker Fang /*
158022a84b8dSQuaker Fang  * RS_NEW_API: only TLC_RTS remains and moved to bit 0
158122a84b8dSQuaker Fang  */
158222a84b8dSQuaker Fang #define	LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK	(1<<0)
158322a84b8dSQuaker Fang 
158422a84b8dSQuaker Fang #define	LINK_QUAL_AC_NUM 4
158522a84b8dSQuaker Fang #define	LINK_QUAL_MAX_RETRY_NUM 16
158622a84b8dSQuaker Fang 
158722a84b8dSQuaker Fang #define	LINK_QUAL_ANT_A_MSK (1<<0)
158822a84b8dSQuaker Fang #define	LINK_QUAL_ANT_B_MSK (1<<1)
158922a84b8dSQuaker Fang #define	LINK_QUAL_ANT_MSK   (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
159022a84b8dSQuaker Fang 
159122a84b8dSQuaker Fang struct iwp_link_qual_general_params {
159222a84b8dSQuaker Fang 	uint8_t flags;
159322a84b8dSQuaker Fang 	uint8_t mimo_delimiter;
159422a84b8dSQuaker Fang 	uint8_t single_stream_ant_msk;
159522a84b8dSQuaker Fang 	uint8_t dual_stream_ant_msk;
159622a84b8dSQuaker Fang 	uint8_t start_rate_index[LINK_QUAL_AC_NUM];
159722a84b8dSQuaker Fang };
159822a84b8dSQuaker Fang 
159922a84b8dSQuaker Fang struct iwp_link_qual_agg_params {
160022a84b8dSQuaker Fang 	uint16_t agg_time_limit;
160122a84b8dSQuaker Fang 	uint8_t agg_dis_start_th;
160222a84b8dSQuaker Fang 	uint8_t agg_frame_cnt_limit;
160322a84b8dSQuaker Fang 	uint32_t reserved;
160422a84b8dSQuaker Fang };
160522a84b8dSQuaker Fang 
160622a84b8dSQuaker Fang typedef struct iwp_link_quality_cmd {
160722a84b8dSQuaker Fang 	uint8_t sta_id;
160822a84b8dSQuaker Fang 	uint8_t reserved1;
160922a84b8dSQuaker Fang 	uint16_t control;
161022a84b8dSQuaker Fang 	struct iwp_link_qual_general_params general_params;
161122a84b8dSQuaker Fang 	struct iwp_link_qual_agg_params agg_params;
161222a84b8dSQuaker Fang 	uint32_t rate_n_flags[LINK_QUAL_MAX_RETRY_NUM];
161322a84b8dSQuaker Fang 	uint32_t reserved2;
161422a84b8dSQuaker Fang } iwp_link_quality_cmd_t;
161522a84b8dSQuaker Fang 
161622a84b8dSQuaker Fang struct	iwp_rx_mpdu_body_size {
161722a84b8dSQuaker Fang 	uint16_t	byte_count;
161822a84b8dSQuaker Fang 	uint16_t	reserved;
161922a84b8dSQuaker Fang };
162022a84b8dSQuaker Fang 
162122a84b8dSQuaker Fang typedef struct iwp_rx_phy_res {
162222a84b8dSQuaker Fang 	uint8_t non_cfg_phy_cnt;  /* non configurable DSP phy data byte count */
162322a84b8dSQuaker Fang 	uint8_t cfg_phy_cnt;	/* configurable DSP phy data byte count */
162422a84b8dSQuaker Fang 	uint8_t stat_id;	/* configurable DSP phy data set ID */
162522a84b8dSQuaker Fang 	uint8_t reserved1;
162622a84b8dSQuaker Fang 	uint32_t timestampl; /* TSF at on air rise */
162722a84b8dSQuaker Fang 	uint32_t timestamph;
162822a84b8dSQuaker Fang 	uint32_t beacon_time_stamp; /* beacon at on-air rise */
162922a84b8dSQuaker Fang 	uint16_t phy_flags;	/* general phy flags: band, modulation, ... */
163022a84b8dSQuaker Fang 	uint16_t channel;		/* channel number */
163122a84b8dSQuaker Fang 	/* for various implementations of non_cfg_phy */
163222a84b8dSQuaker Fang 	uint8_t	 non_cfg_phy[32];
163322a84b8dSQuaker Fang 	struct iwp_rate rate;	/* rate in ucode internal format */
163422a84b8dSQuaker Fang 	uint16_t byte_count;		/* frame's byte-count */
163522a84b8dSQuaker Fang 	uint16_t reserved3;
163622a84b8dSQuaker Fang } iwp_rx_phy_res_t;
163722a84b8dSQuaker Fang 
163822a84b8dSQuaker Fang struct iwp_rx_mpdu_res_start {
163922a84b8dSQuaker Fang 	uint16_t byte_count;
164022a84b8dSQuaker Fang 	uint16_t reserved;
164122a84b8dSQuaker Fang };
164222a84b8dSQuaker Fang 
164322a84b8dSQuaker Fang #define	IWP_AGC_DB_MASK 	(0x3f80)	/* MASK(7,13) */
164422a84b8dSQuaker Fang #define	IWP_AGC_DB_POS	(7)
164522a84b8dSQuaker Fang 
164622a84b8dSQuaker Fang #define	IWP_RX_RES_PHY_CNT	(8)
164722a84b8dSQuaker Fang #define	IWP_RX_RES_AGC_IDX	(1)
164822a84b8dSQuaker Fang #define	IWP_RX_RES_RSSI_AB_IDX	(2)
164922a84b8dSQuaker Fang #define	IWP_RX_RES_RSSI_C_IDX	(3)
165022a84b8dSQuaker Fang #define	IWP_OFDM_AGC_MSK	(0xFE00)
165122a84b8dSQuaker Fang #define	IWP_OFDM_AGC_BIT_POS	(9)
165222a84b8dSQuaker Fang #define	IWP_OFDM_RSSI_A_MSK	(0x00FF)
165322a84b8dSQuaker Fang #define	IWP_OFDM_RSSI_A_BIT_POS	(0)
165422a84b8dSQuaker Fang #define	IWP_OFDM_RSSI_B_MSK	(0xFF0000)
165522a84b8dSQuaker Fang #define	IWP_OFDM_RSSI_B_BIT_POS	(16)
165622a84b8dSQuaker Fang #define	IWP_OFDM_RSSI_C_MSK	(0x00FF)
165722a84b8dSQuaker Fang #define	IWP_OFDM_RSSI_C_BIT_POS	(0)
165822a84b8dSQuaker Fang #define	IWP_RSSI_OFFSET		(44)
165922a84b8dSQuaker Fang 
166022a84b8dSQuaker Fang /*
166122a84b8dSQuaker Fang  * Fixed (non-configurable) rx data from phy
166222a84b8dSQuaker Fang  */
166322a84b8dSQuaker Fang struct iwp_rx_non_cfg_phy {
166422a84b8dSQuaker Fang 	uint32_t non_cfg_phy[IWP_RX_RES_PHY_CNT];	/* upto 8 phy entries */
166522a84b8dSQuaker Fang };
166622a84b8dSQuaker Fang 
166722a84b8dSQuaker Fang /*
166822a84b8dSQuaker Fang  * Byte Count Table Entry
166922a84b8dSQuaker Fang  *
167022a84b8dSQuaker Fang  * Bit fields:
167122a84b8dSQuaker Fang  * 15-12: reserved
167222a84b8dSQuaker Fang  * 11- 0: total to-be-transmitted byte count of frame (does not include command)
167322a84b8dSQuaker Fang  */
167422a84b8dSQuaker Fang struct iwp_queue_byte_cnt_entry {
167522a84b8dSQuaker Fang 	uint16_t val;
167622a84b8dSQuaker Fang };
167722a84b8dSQuaker Fang 
167822a84b8dSQuaker Fang /*
167922a84b8dSQuaker Fang  * Byte Count table
168022a84b8dSQuaker Fang  *
168122a84b8dSQuaker Fang  * Each Tx queue uses a byte-count table containing 320 entries:
168222a84b8dSQuaker Fang  * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that
168322a84b8dSQuaker Fang  * duplicate the first 64 entries (to avoid wrap-around within a Tx window;
168422a84b8dSQuaker Fang  * max Tx window is 64 TFDs).
168522a84b8dSQuaker Fang  *
168622a84b8dSQuaker Fang  * When driver sets up a new TFD, it must also enter the total byte count
168722a84b8dSQuaker Fang  * of the frame to be transmitted into the corresponding entry in the byte
168822a84b8dSQuaker Fang  * count table for the chosen Tx queue.  If the TFD index is 0-63, the driver
168922a84b8dSQuaker Fang  * must duplicate the byte count entry in corresponding index 256-319.
169022a84b8dSQuaker Fang  *
169122a84b8dSQuaker Fang  * "dont_care" padding puts each byte count table on a 1024-byte boundary;
169222a84b8dSQuaker Fang  * SP assumes tables are separated by 1024 bytes.
169322a84b8dSQuaker Fang  */
169422a84b8dSQuaker Fang struct iwp_sched_queue_byte_cnt_tbl {
169522a84b8dSQuaker Fang 	struct iwp_queue_byte_cnt_entry tfd_offset[IWP_QUEUE_SIZE +
169622a84b8dSQuaker Fang 	    IWP_MAX_WIN_SIZE];
169722a84b8dSQuaker Fang };
169822a84b8dSQuaker Fang 
169922a84b8dSQuaker Fang /*
170022a84b8dSQuaker Fang  * struct iwp_shared, handshake area for Tx and Rx
170122a84b8dSQuaker Fang  *
170222a84b8dSQuaker Fang  * For convenience in allocating memory, this structure combines 2 areas of
170322a84b8dSQuaker Fang  * DRAM which must be shared between driver and SP.  These do not need to
170422a84b8dSQuaker Fang  * be combined, if better allocation would result from keeping them separate:
170522a84b8dSQuaker Fang  * TODO:  Split these; carried over from 3945, doesn't work well for SP.
170622a84b8dSQuaker Fang  *
170722a84b8dSQuaker Fang  * 1)  The Tx byte count tables occupy 1024 bytes each (16 KBytes total for
170822a84b8dSQuaker Fang  *     16 queues).  Driver uses SCD_DRAM_BASE_ADDR to tell SP where to find
170922a84b8dSQuaker Fang  *     the first of these tables.  SP assumes tables are 1024 bytes apart.
171022a84b8dSQuaker Fang  *
171122a84b8dSQuaker Fang  * 2)  The Rx status (val0 and val1) occupies only 8 bytes.  Driver uses
171222a84b8dSQuaker Fang  *     FH_RSCSR_CHNL0_STTS_WPTR_REG to tell SP where to find this area.
171322a84b8dSQuaker Fang  *     Driver reads val0 to determine the latest Receive Buffer Descriptor (RBD)
171422a84b8dSQuaker Fang  *     that has been filled by the SP.
171522a84b8dSQuaker Fang  *
171622a84b8dSQuaker Fang  * Bit fields val0:
171722a84b8dSQuaker Fang  * 31-12:  Not used
171822a84b8dSQuaker Fang  * 11- 0:  Index of last filled Rx buffer descriptor (SP writes, driver reads)
171922a84b8dSQuaker Fang  *
172022a84b8dSQuaker Fang  * Bit fields val1:
172122a84b8dSQuaker Fang  * 31- 0:  Not used
172222a84b8dSQuaker Fang  */
172322a84b8dSQuaker Fang typedef struct iwp_shared {
172422a84b8dSQuaker Fang 	struct iwp_sched_queue_byte_cnt_tbl
172522a84b8dSQuaker Fang 	    queues_byte_cnt_tbls[IWP_NUM_QUEUES];
172622a84b8dSQuaker Fang 	uint32_t val0;
172722a84b8dSQuaker Fang 	uint32_t val1;
172822a84b8dSQuaker Fang 	uint32_t padding1;  /* so that allocation will be aligned to 16B */
172922a84b8dSQuaker Fang 	uint32_t padding2;
173022a84b8dSQuaker Fang } iwp_shared_t;
173122a84b8dSQuaker Fang 
173222a84b8dSQuaker Fang 
173322a84b8dSQuaker Fang /*
173422a84b8dSQuaker Fang  * struct iwp_tfd_frame_data
173522a84b8dSQuaker Fang  *
173622a84b8dSQuaker Fang  * Describes up to 2 buffers containing (contiguous) portions of a Tx frame.
173722a84b8dSQuaker Fang  * Each buffer must be on dword boundary.
173822a84b8dSQuaker Fang  * Up to 10 iwp_tfd_frame_data structures, describing up to 20 buffers,
173922a84b8dSQuaker Fang  * may be filled within a TFD (iwp_tfd_frame).
174022a84b8dSQuaker Fang  *
174122a84b8dSQuaker Fang  * Bit fields in tb1_addr:
174222a84b8dSQuaker Fang  * 31- 0: Tx buffer 1 address bits [31:0]
174322a84b8dSQuaker Fang  *
174422a84b8dSQuaker Fang  * Bit fields in val1:
174522a84b8dSQuaker Fang  * 31-16: Tx buffer 2 address bits [15:0]
174622a84b8dSQuaker Fang  * 15- 4: Tx buffer 1 length (bytes)
174722a84b8dSQuaker Fang  *  3- 0: Tx buffer 1 address bits [32:32]
174822a84b8dSQuaker Fang  *
174922a84b8dSQuaker Fang  * Bit fields in val2:
175022a84b8dSQuaker Fang  * 31-20: Tx buffer 2 length (bytes)
175122a84b8dSQuaker Fang  * 19- 0: Tx buffer 2 address bits [35:16]
175222a84b8dSQuaker Fang  */
175322a84b8dSQuaker Fang struct iwp_tfd_frame_data {
175422a84b8dSQuaker Fang 		uint32_t tb1_addr;
175522a84b8dSQuaker Fang 		uint32_t val1;
175622a84b8dSQuaker Fang 		uint32_t val2;
175722a84b8dSQuaker Fang };
175822a84b8dSQuaker Fang 
175922a84b8dSQuaker Fang typedef struct iwp_tx_desc {
176022a84b8dSQuaker Fang 	uint32_t	val0;
176122a84b8dSQuaker Fang 	struct iwp_tfd_frame_data pa[10];
176222a84b8dSQuaker Fang 	uint32_t reserved;
176322a84b8dSQuaker Fang } iwp_tx_desc_t;
176422a84b8dSQuaker Fang 
176522a84b8dSQuaker Fang struct	agg_tx_status {
176622a84b8dSQuaker Fang 	uint16_t	status;
176722a84b8dSQuaker Fang 	uint16_t	sequence;
176822a84b8dSQuaker Fang };
176922a84b8dSQuaker Fang 
177022a84b8dSQuaker Fang typedef struct iwp_tx_stat {
177122a84b8dSQuaker Fang 	uint8_t		frame_count;
177222a84b8dSQuaker Fang 	uint8_t		bt_kill_count;
177322a84b8dSQuaker Fang 	uint8_t		nrts;
177422a84b8dSQuaker Fang 	uint8_t		ntries;
177522a84b8dSQuaker Fang 	struct iwp_rate rate;
177622a84b8dSQuaker Fang 	uint16_t	duration;
177722a84b8dSQuaker Fang 	uint16_t	reserved;
177822a84b8dSQuaker Fang 	uint32_t	pa_power1;
177922a84b8dSQuaker Fang 	uint32_t	pa_power2;
178022a84b8dSQuaker Fang 	uint32_t	tfd_info;
178122a84b8dSQuaker Fang 	uint16_t	seq_ctl;
178222a84b8dSQuaker Fang 	uint16_t	byte_cnt;
178322a84b8dSQuaker Fang 	uint32_t	tlc_info;
178422a84b8dSQuaker Fang 	struct	agg_tx_status	status;
178522a84b8dSQuaker Fang } iwp_tx_stat_t;
178622a84b8dSQuaker Fang 
178722a84b8dSQuaker Fang struct iwp_cmd_header {
178822a84b8dSQuaker Fang 	uint8_t		type;
178922a84b8dSQuaker Fang 	uint8_t		flags;
179022a84b8dSQuaker Fang 	uint8_t		idx;
179122a84b8dSQuaker Fang 	uint8_t		qid;
179222a84b8dSQuaker Fang };
179322a84b8dSQuaker Fang 
179422a84b8dSQuaker Fang typedef struct iwp_rx_desc {
179522a84b8dSQuaker Fang 	uint32_t	len;
179622a84b8dSQuaker Fang 	struct iwp_cmd_header hdr;
179722a84b8dSQuaker Fang } iwp_rx_desc_t;
179822a84b8dSQuaker Fang 
179922a84b8dSQuaker Fang typedef struct iwp_rx_stat {
180022a84b8dSQuaker Fang 	uint8_t		len;
180122a84b8dSQuaker Fang 	uint8_t		id;
180222a84b8dSQuaker Fang 	uint8_t		rssi;	/* received signal strength */
180322a84b8dSQuaker Fang 	uint8_t		agc;	/* access gain control */
180422a84b8dSQuaker Fang 	uint16_t	signal;
180522a84b8dSQuaker Fang 	uint16_t	noise;
180622a84b8dSQuaker Fang } iwp_rx_stat_t;
180722a84b8dSQuaker Fang 
180822a84b8dSQuaker Fang typedef struct iwp_rx_head {
180922a84b8dSQuaker Fang 	uint16_t	chan;
181022a84b8dSQuaker Fang 	uint16_t	flags;
181122a84b8dSQuaker Fang 	uint8_t		reserved;
181222a84b8dSQuaker Fang 	uint8_t		rate;
181322a84b8dSQuaker Fang 	uint16_t	len;
181422a84b8dSQuaker Fang } iwp_rx_head_t;
181522a84b8dSQuaker Fang 
181622a84b8dSQuaker Fang typedef struct iwp_rx_tail {
181722a84b8dSQuaker Fang 	uint32_t	flags;
181822a84b8dSQuaker Fang 	uint32_t	timestampl;
181922a84b8dSQuaker Fang 	uint32_t	timestamph;
182022a84b8dSQuaker Fang 	uint32_t	tbeacon;
182122a84b8dSQuaker Fang } iwp_rx_tail_t;
182222a84b8dSQuaker Fang 
182322a84b8dSQuaker Fang enum {
182422a84b8dSQuaker Fang 	IWP_AP_ID = 0,
182522a84b8dSQuaker Fang 	IWP_MULTICAST_ID,
182622a84b8dSQuaker Fang 	IWP_STA_ID,
182722a84b8dSQuaker Fang 	IWP_BROADCAST_ID = 15,
182822a84b8dSQuaker Fang 	IWP_STATION_COUNT = 16,
182922a84b8dSQuaker Fang 	IWP_INVALID_STATION
183022a84b8dSQuaker Fang };
183122a84b8dSQuaker Fang 
183222a84b8dSQuaker Fang /*
183322a84b8dSQuaker Fang  * key flags
183422a84b8dSQuaker Fang  */
183522a84b8dSQuaker Fang enum {
183622a84b8dSQuaker Fang 	STA_KEY_FLG_ENCRYPT_MSK = 0x7,
183722a84b8dSQuaker Fang 	STA_KEY_FLG_NO_ENC = 0x0,
183822a84b8dSQuaker Fang 	STA_KEY_FLG_WEP = 0x1,
183922a84b8dSQuaker Fang 	STA_KEY_FLG_CCMP = 0x2,
184022a84b8dSQuaker Fang 	STA_KEY_FLG_TKIP = 0x3,
184122a84b8dSQuaker Fang 
184222a84b8dSQuaker Fang 	STA_KEY_FLG_KEYID_POS = 8,
184322a84b8dSQuaker Fang 	STA_KEY_FLG_INVALID = 0x0800,
184422a84b8dSQuaker Fang };
184522a84b8dSQuaker Fang 
184622a84b8dSQuaker Fang /*
184722a84b8dSQuaker Fang  * modify flags
184822a84b8dSQuaker Fang  */
184922a84b8dSQuaker Fang enum {
185022a84b8dSQuaker Fang 	STA_MODIFY_KEY_MASK = 0x01,
185122a84b8dSQuaker Fang 	STA_MODIFY_TID_DISABLE_TX = 0x02,
185222a84b8dSQuaker Fang 	STA_MODIFY_TX_RATE_MSK = 0x04
185322a84b8dSQuaker Fang };
185422a84b8dSQuaker Fang 
185522a84b8dSQuaker Fang enum {
185622a84b8dSQuaker Fang 	RX_RES_STATUS_NO_CRC32_ERROR = (1 << 0),
185722a84b8dSQuaker Fang 	RX_RES_STATUS_NO_RXE_OVERFLOW = (1 << 1),
185822a84b8dSQuaker Fang };
185922a84b8dSQuaker Fang 
186022a84b8dSQuaker Fang enum {
186122a84b8dSQuaker Fang 	RX_RES_PHY_FLAGS_BAND_24_MSK = (1 << 0),
186222a84b8dSQuaker Fang 	RX_RES_PHY_FLAGS_MOD_CCK_MSK = (1 << 1),
186322a84b8dSQuaker Fang 	RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK = (1 << 2),
186422a84b8dSQuaker Fang 	RX_RES_PHY_FLAGS_NARROW_BAND_MSK = (1 << 3),
186522a84b8dSQuaker Fang 	RX_RES_PHY_FLAGS_ANTENNA_MSK = 0xf0,
186622a84b8dSQuaker Fang 
186722a84b8dSQuaker Fang 	RX_RES_STATUS_SEC_TYPE_MSK = (0x7 << 8),
186822a84b8dSQuaker Fang 	RX_RES_STATUS_SEC_TYPE_NONE = (STA_KEY_FLG_NO_ENC << 8),
186922a84b8dSQuaker Fang 	RX_RES_STATUS_SEC_TYPE_WEP = (STA_KEY_FLG_WEP << 8),
187022a84b8dSQuaker Fang 	RX_RES_STATUS_SEC_TYPE_TKIP = (STA_KEY_FLG_TKIP << 8),
187122a84b8dSQuaker Fang 	RX_RES_STATUS_SEC_TYPE_CCMP = (STA_KEY_FLG_CCMP << 8),
187222a84b8dSQuaker Fang 
187322a84b8dSQuaker Fang 	RX_RES_STATUS_DECRYPT_TYPE_MSK = (0x3 << 11),
187422a84b8dSQuaker Fang 	RX_RES_STATUS_NOT_DECRYPT = (0x0 << 11),
187522a84b8dSQuaker Fang 	RX_RES_STATUS_DECRYPT_OK = (0x3 << 11),
187622a84b8dSQuaker Fang 	RX_RES_STATUS_BAD_ICV_MIC = (0x1 << 11),
187722a84b8dSQuaker Fang 	RX_RES_STATUS_BAD_KEY_TTAK = (0x2 << 11),
187822a84b8dSQuaker Fang };
187922a84b8dSQuaker Fang 
188022a84b8dSQuaker Fang enum {
188122a84b8dSQuaker Fang 	REPLY_ALIVE = 0x1,
188222a84b8dSQuaker Fang 	REPLY_ERROR = 0x2,
188322a84b8dSQuaker Fang 
188422a84b8dSQuaker Fang 	/* RXON state commands */
188522a84b8dSQuaker Fang 	REPLY_RXON = 0x10,
188622a84b8dSQuaker Fang 	REPLY_RXON_ASSOC = 0x11,
188722a84b8dSQuaker Fang 	REPLY_QOS_PARAM = 0x13,
188822a84b8dSQuaker Fang 	REPLY_RXON_TIMING = 0x14,
188922a84b8dSQuaker Fang 
189022a84b8dSQuaker Fang 	/* Multi-Station support */
189122a84b8dSQuaker Fang 	REPLY_ADD_STA = 0x18,
189222a84b8dSQuaker Fang 	REPLY_REMOVE_STA = 0x19,
189322a84b8dSQuaker Fang 	REPLY_REMOVE_ALL_STA = 0x1a,
189422a84b8dSQuaker Fang 
189522a84b8dSQuaker Fang 	/* RX, TX */
189622a84b8dSQuaker Fang 
189722a84b8dSQuaker Fang 	REPLY_TX = 0x1c,
189822a84b8dSQuaker Fang 
189922a84b8dSQuaker Fang 	/* timers commands */
190022a84b8dSQuaker Fang 	REPLY_BCON = 0x27,
190122a84b8dSQuaker Fang 
190222a84b8dSQuaker Fang 	REPLY_SHUTDOWN = 0x40,
190322a84b8dSQuaker Fang 
190422a84b8dSQuaker Fang 	/* MISC commands */
190522a84b8dSQuaker Fang 	REPLY_RATE_SCALE = 0x47,
190622a84b8dSQuaker Fang 	REPLY_LEDS_CMD = 0x48,
190722a84b8dSQuaker Fang 	REPLY_TX_LINK_QUALITY_CMD = 0x4e,
190822a84b8dSQuaker Fang 
190922a84b8dSQuaker Fang 	COEX_PRIORITY_TABLE_CMD = 0x5a,
191022a84b8dSQuaker Fang 	CALIBRATION_CFG_CMD = 0x65,
191122a84b8dSQuaker Fang 	CALIBRATION_RES_NOTIFICATION = 0x66,
191222a84b8dSQuaker Fang 	CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
191322a84b8dSQuaker Fang 
191422a84b8dSQuaker Fang 	/* 802.11h related */
191522a84b8dSQuaker Fang 	RADAR_NOTIFICATION = 0x70,
191622a84b8dSQuaker Fang 	REPLY_QUIET_CMD = 0x71,
191722a84b8dSQuaker Fang 	REPLY_CHANNEL_SWITCH = 0x72,
191822a84b8dSQuaker Fang 	CHANNEL_SWITCH_NOTIFICATION = 0x73,
191922a84b8dSQuaker Fang 	REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
192022a84b8dSQuaker Fang 	SPECTRUM_MEASURE_NOTIFICATION = 0x75,
192122a84b8dSQuaker Fang 
192222a84b8dSQuaker Fang 	/* Power Management *** */
192322a84b8dSQuaker Fang 	POWER_TABLE_CMD = 0x77,
192422a84b8dSQuaker Fang 	PM_SLEEP_NOTIFICATION = 0x7A,
192522a84b8dSQuaker Fang 	PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
192622a84b8dSQuaker Fang 
192722a84b8dSQuaker Fang 	/* Scan commands and notifications */
192822a84b8dSQuaker Fang 	REPLY_SCAN_CMD = 0x80,
192922a84b8dSQuaker Fang 	REPLY_SCAN_ABORT_CMD = 0x81,
193022a84b8dSQuaker Fang 
193122a84b8dSQuaker Fang 	SCAN_START_NOTIFICATION = 0x82,
193222a84b8dSQuaker Fang 	SCAN_RESULTS_NOTIFICATION = 0x83,
193322a84b8dSQuaker Fang 	SCAN_COMPLETE_NOTIFICATION = 0x84,
193422a84b8dSQuaker Fang 
193522a84b8dSQuaker Fang 	/* IBSS/AP commands */
193622a84b8dSQuaker Fang 	BEACON_NOTIFICATION = 0x90,
193722a84b8dSQuaker Fang 	REPLY_TX_BEACON = 0x91,
193822a84b8dSQuaker Fang 	WHO_IS_AWAKE_NOTIFICATION = 0x94,
193922a84b8dSQuaker Fang 
194022a84b8dSQuaker Fang 	QUIET_NOTIFICATION = 0x96,
194122a84b8dSQuaker Fang 	REPLY_TX_PWR_TABLE_CMD = 0x97,
194222a84b8dSQuaker Fang 	MEASURE_ABORT_NOTIFICATION = 0x99,
194322a84b8dSQuaker Fang 
194422a84b8dSQuaker Fang 	REPLY_CALIBRATION_TUNE = 0x9a,
194522a84b8dSQuaker Fang 
194622a84b8dSQuaker Fang 	/* BT config command */
194722a84b8dSQuaker Fang 	REPLY_BT_CONFIG = 0x9b,
194822a84b8dSQuaker Fang 	REPLY_STATISTICS_CMD = 0x9c,
194922a84b8dSQuaker Fang 	STATISTICS_NOTIFICATION = 0x9d,
195022a84b8dSQuaker Fang 
195122a84b8dSQuaker Fang 	/* RF-KILL commands and notifications *** */
195222a84b8dSQuaker Fang 	REPLY_CARD_STATE_CMD = 0xa0,
195322a84b8dSQuaker Fang 	CARD_STATE_NOTIFICATION = 0xa1,
195422a84b8dSQuaker Fang 
195522a84b8dSQuaker Fang 	/* Missed beacons notification */
195622a84b8dSQuaker Fang 	MISSED_BEACONS_NOTIFICATION = 0xa2,
195722a84b8dSQuaker Fang 	MISSED_BEACONS_NOTIFICATION_TH_CMD = 0xa3,
195822a84b8dSQuaker Fang 
195922a84b8dSQuaker Fang 	REPLY_CT_KILL_CONFIG_CMD = 0xa4,
196022a84b8dSQuaker Fang 	SENSITIVITY_CMD = 0xa8,
196122a84b8dSQuaker Fang 	REPLY_PHY_CALIBRATION_CMD = 0xb0,
196222a84b8dSQuaker Fang 	REPLY_RX_PHY_CMD = 0xc0,
196322a84b8dSQuaker Fang 	REPLY_RX_MPDU_CMD = 0xc1,
196422a84b8dSQuaker Fang 	REPLY_SP_RX = 0xc3,
196522a84b8dSQuaker Fang 	REPLY_COMPRESSED_BA = 0xc5,
196622a84b8dSQuaker Fang 	REPLY_MAX = 0xff
196722a84b8dSQuaker Fang };
196822a84b8dSQuaker Fang 
196922a84b8dSQuaker Fang typedef struct iwp_cmd {
197022a84b8dSQuaker Fang 	struct iwp_cmd_header hdr;
197122a84b8dSQuaker Fang 	uint8_t	data[1024];
197222a84b8dSQuaker Fang } iwp_cmd_t;
197322a84b8dSQuaker Fang 
197422a84b8dSQuaker Fang /*
197522a84b8dSQuaker Fang  * Alive Command & Response
197622a84b8dSQuaker Fang  */
197722a84b8dSQuaker Fang #define	UCODE_VALID_OK		(0x1)
197822a84b8dSQuaker Fang #define	INITIALIZE_SUBTYPE	(9)
197922a84b8dSQuaker Fang 
198022a84b8dSQuaker Fang struct iwp_alive_resp {
198122a84b8dSQuaker Fang 	uint8_t ucode_minor;
198222a84b8dSQuaker Fang 	uint8_t ucode_major;
198322a84b8dSQuaker Fang 	uint16_t reserved1;
198422a84b8dSQuaker Fang 	uint8_t sw_rev[8];
198522a84b8dSQuaker Fang 	uint8_t ver_type;
198622a84b8dSQuaker Fang 	uint8_t ver_subtype;
198722a84b8dSQuaker Fang 	uint16_t reserved2;
198822a84b8dSQuaker Fang 	uint32_t log_event_table_ptr;
198922a84b8dSQuaker Fang 	uint32_t error_event_table_ptr;
199022a84b8dSQuaker Fang 	uint32_t timestamp;
199122a84b8dSQuaker Fang 	uint32_t is_valid;
199222a84b8dSQuaker Fang };
199322a84b8dSQuaker Fang 
199422a84b8dSQuaker Fang struct iwp_init_alive_resp {
199522a84b8dSQuaker Fang 	struct iwp_alive_resp s;
199622a84b8dSQuaker Fang 	/* calibration values from "initialize" uCode */
199722a84b8dSQuaker Fang 	uint32_t voltage;	/* signed */
199822a84b8dSQuaker Fang 	uint32_t therm_r1[2];	/* signed 1st for normal, 2nd for FAT channel */
199922a84b8dSQuaker Fang 	uint32_t therm_r2[2];	/* signed */
200022a84b8dSQuaker Fang 	uint32_t therm_r3[2];	/* signed */
200122a84b8dSQuaker Fang 	uint32_t therm_r4[2];	/* signed */
200222a84b8dSQuaker Fang 		/*
200322a84b8dSQuaker Fang 		 * signed MIMO gain comp, 5 freq groups, 2 Tx chains
200422a84b8dSQuaker Fang 		 */
200522a84b8dSQuaker Fang 	uint32_t tx_atten[5][2];
200622a84b8dSQuaker Fang };
200722a84b8dSQuaker Fang 
200822a84b8dSQuaker Fang /*
200922a84b8dSQuaker Fang  * Rx config defines & structure
201022a84b8dSQuaker Fang  */
201122a84b8dSQuaker Fang /*
201222a84b8dSQuaker Fang  * rx_config device types
201322a84b8dSQuaker Fang  */
201422a84b8dSQuaker Fang enum {
201522a84b8dSQuaker Fang 	RXON_DEV_TYPE_AP = 1,
201622a84b8dSQuaker Fang 	RXON_DEV_TYPE_ESS = 3,
201722a84b8dSQuaker Fang 	RXON_DEV_TYPE_IBSS = 4,
201822a84b8dSQuaker Fang 	RXON_DEV_TYPE_SNIFFER = 6,
201922a84b8dSQuaker Fang };
202022a84b8dSQuaker Fang 
202122a84b8dSQuaker Fang /*
202222a84b8dSQuaker Fang  * rx_config flags
202322a84b8dSQuaker Fang  */
202422a84b8dSQuaker Fang enum {
202522a84b8dSQuaker Fang 	/* band & modulation selection */
202622a84b8dSQuaker Fang 	RXON_FLG_BAND_24G_MSK = (1 << 0),
202722a84b8dSQuaker Fang 	RXON_FLG_CCK_MSK = (1 << 1),
202822a84b8dSQuaker Fang 	/* auto detection enable */
202922a84b8dSQuaker Fang 	RXON_FLG_AUTO_DETECT_MSK = (1 << 2),
203022a84b8dSQuaker Fang 	/* TGg protection when tx */
203122a84b8dSQuaker Fang 	RXON_FLG_TGG_PROTECT_MSK = (1 << 3),
203222a84b8dSQuaker Fang 	/* cck short slot & preamble */
203322a84b8dSQuaker Fang 	RXON_FLG_SHORT_SLOT_MSK = (1 << 4),
203422a84b8dSQuaker Fang 	RXON_FLG_SHORT_PREAMBLE_MSK = (1 << 5),
203522a84b8dSQuaker Fang 	/* antenna selection */
203622a84b8dSQuaker Fang 	RXON_FLG_DIS_DIV_MSK = (1 << 7),
203722a84b8dSQuaker Fang 	RXON_FLG_ANT_SEL_MSK = 0x0f00,
203822a84b8dSQuaker Fang 	RXON_FLG_ANT_A_MSK = (1 << 8),
203922a84b8dSQuaker Fang 	RXON_FLG_ANT_B_MSK = (1 << 9),
204022a84b8dSQuaker Fang 	/* radar detection enable */
204122a84b8dSQuaker Fang 	RXON_FLG_RADAR_DETECT_MSK = (1 << 12),
204222a84b8dSQuaker Fang 	RXON_FLG_TGJ_NARROW_BAND_MSK = (1 << 13),
204322a84b8dSQuaker Fang 	/*
204422a84b8dSQuaker Fang 	 * rx response to host with 8-byte TSF
204522a84b8dSQuaker Fang 	 * (according to ON_AIR deassertion)
204622a84b8dSQuaker Fang 	 */
204722a84b8dSQuaker Fang 	RXON_FLG_TSF2HOST_MSK = (1 << 15),
204822a84b8dSQuaker Fang 	RXON_FLG_DIS_ACQUISITION = (1 << 27),
204922a84b8dSQuaker Fang 	RXON_FLG_DIS_RE_ACQUISITION = (1 << 28),
205022a84b8dSQuaker Fang 	RXON_FLG_DIS_BEAMFORM = (1 << 29)
205122a84b8dSQuaker Fang };
205222a84b8dSQuaker Fang 
205322a84b8dSQuaker Fang /*
205422a84b8dSQuaker Fang  * rx_config filter flags
205522a84b8dSQuaker Fang  */
205622a84b8dSQuaker Fang enum {
205722a84b8dSQuaker Fang 	/* accept all data frames */
205822a84b8dSQuaker Fang 	RXON_FILTER_PROMISC_MSK = (1 << 0),
205922a84b8dSQuaker Fang 	/* pass control & management to host */
206022a84b8dSQuaker Fang 	RXON_FILTER_CTL2HOST_MSK = (1 << 1),
206122a84b8dSQuaker Fang 	/* accept multi-cast */
206222a84b8dSQuaker Fang 	RXON_FILTER_ACCEPT_GRP_MSK = (1 << 2),
206322a84b8dSQuaker Fang 	/* don't decrypt uni-cast frames */
206422a84b8dSQuaker Fang 	RXON_FILTER_DIS_DECRYPT_MSK = (1 << 3),
206522a84b8dSQuaker Fang 	/* don't decrypt multi-cast frames */
206622a84b8dSQuaker Fang 	RXON_FILTER_DIS_GRP_DECRYPT_MSK = (1 << 4),
206722a84b8dSQuaker Fang 	/* STA is associated */
206822a84b8dSQuaker Fang 	RXON_FILTER_ASSOC_MSK = (1 << 5),
206922a84b8dSQuaker Fang 	/* transfer to host non bssid beacons in associated state */
207022a84b8dSQuaker Fang 	RXON_FILTER_BCON_AWARE_MSK = (1 << 6)
207122a84b8dSQuaker Fang };
207222a84b8dSQuaker Fang 
207322a84b8dSQuaker Fang 
207422a84b8dSQuaker Fang /*
207522a84b8dSQuaker Fang  * structure for RXON Command & Response
207622a84b8dSQuaker Fang  */
207722a84b8dSQuaker Fang typedef struct iwp_rxon_cmd {
207822a84b8dSQuaker Fang 	uint8_t		node_addr[IEEE80211_ADDR_LEN];
207922a84b8dSQuaker Fang 	uint16_t	reserved1;
208022a84b8dSQuaker Fang 	uint8_t		bssid[IEEE80211_ADDR_LEN];
208122a84b8dSQuaker Fang 	uint16_t	reserved2;
208222a84b8dSQuaker Fang 	uint8_t		wlap_bssid[IEEE80211_ADDR_LEN];
208322a84b8dSQuaker Fang 	uint16_t	reserved3;
208422a84b8dSQuaker Fang 	uint8_t		dev_type;
208522a84b8dSQuaker Fang 	uint8_t		air_propagation;
208622a84b8dSQuaker Fang 	uint16_t	rx_chain;
208722a84b8dSQuaker Fang 	uint8_t		ofdm_basic_rates;
208822a84b8dSQuaker Fang 	uint8_t		cck_basic_rates;
208922a84b8dSQuaker Fang 	uint16_t	assoc_id;
209022a84b8dSQuaker Fang 	uint32_t	flags;
209122a84b8dSQuaker Fang 	uint32_t	filter_flags;
209222a84b8dSQuaker Fang 	uint16_t	chan;
209322a84b8dSQuaker Fang 	uint8_t		ofdm_ht_single_stream_basic_rates;
209422a84b8dSQuaker Fang 	uint8_t		ofdm_ht_dual_stream_basic_rates;
209522a84b8dSQuaker Fang 	uint8_t		ofdm_ht_triple_stream_basic_rates;
209622a84b8dSQuaker Fang 	uint8_t		reserved4;
209722a84b8dSQuaker Fang 	uint16_t	acquisition_data;
209822a84b8dSQuaker Fang 	uint16_t	reserved5;
209922a84b8dSQuaker Fang } iwp_rxon_cmd_t;
210022a84b8dSQuaker Fang 
210122a84b8dSQuaker Fang typedef struct iwp_compressed_ba_resp {
210222a84b8dSQuaker Fang 	uint32_t sta_addr_lo32;
210322a84b8dSQuaker Fang 	uint16_t sta_addr_hi16;
210422a84b8dSQuaker Fang 	uint16_t reserved;
210522a84b8dSQuaker Fang 	uint8_t sta_id;
210622a84b8dSQuaker Fang 	uint8_t tid;
210722a84b8dSQuaker Fang 	uint16_t ba_seq_ctl;
210822a84b8dSQuaker Fang 	uint32_t ba_bitmap0;
210922a84b8dSQuaker Fang 	uint32_t ba_bitmap1;
211022a84b8dSQuaker Fang 	uint16_t scd_flow;
211122a84b8dSQuaker Fang 	uint16_t scd_ssn;
211222a84b8dSQuaker Fang } iwp_compressed_ba_resp_t;
211322a84b8dSQuaker Fang 
211422a84b8dSQuaker Fang #define	PHY_CALIBRATE_DIFF_GAIN_CMD	(7)
211522a84b8dSQuaker Fang #define	PHY_CALIBRATE_LO_CMD		(9)
211622a84b8dSQuaker Fang #define	PHY_CALIBRATE_TX_IQ_CMD		(11)
211722a84b8dSQuaker Fang #define	PHY_CALIBRATE_CRYSTAL_FRQ_CMD	(15)
211822a84b8dSQuaker Fang #define	PHY_CALIBRATE_BASE_BAND_CMD	(16)
211922a84b8dSQuaker Fang #define	PHY_CALIBRATE_TX_IQ_PERD_CMD	(17)
212022a84b8dSQuaker Fang #define	HD_TABLE_SIZE	(11)
212122a84b8dSQuaker Fang 
212222a84b8dSQuaker Fang /*
212322a84b8dSQuaker Fang  * Param table within SENSITIVITY_CMD
212422a84b8dSQuaker Fang  */
212522a84b8dSQuaker Fang #define	HD_MIN_ENERGY_CCK_DET_INDEX		(0)
212622a84b8dSQuaker Fang #define	HD_MIN_ENERGY_OFDM_DET_INDEX		(1)
212722a84b8dSQuaker Fang #define	HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX	(2)
212822a84b8dSQuaker Fang #define	HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX	(3)
212922a84b8dSQuaker Fang #define	HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX	(4)
213022a84b8dSQuaker Fang #define	HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX	(5)
213122a84b8dSQuaker Fang #define	HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX	(6)
213222a84b8dSQuaker Fang #define	HD_BARKER_CORR_TH_ADD_MIN_INDEX		(7)
213322a84b8dSQuaker Fang #define	HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX	(8)
213422a84b8dSQuaker Fang #define	HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX	(9)
213522a84b8dSQuaker Fang #define	HD_OFDM_ENERGY_TH_IN_INDEX		(10)
213622a84b8dSQuaker Fang 
213722a84b8dSQuaker Fang typedef struct iwp_sensitivity_cmd {
213822a84b8dSQuaker Fang 	uint16_t control;
213922a84b8dSQuaker Fang 	uint16_t table[HD_TABLE_SIZE];
214022a84b8dSQuaker Fang } iwp_sensitivity_cmd_t;
214122a84b8dSQuaker Fang 
214222a84b8dSQuaker Fang typedef struct iwp_calibration_cmd {
214322a84b8dSQuaker Fang 	uint8_t opCode;
214422a84b8dSQuaker Fang 	uint8_t flags;
214522a84b8dSQuaker Fang 	uint16_t reserved;
214622a84b8dSQuaker Fang 	char diff_gain_a;
214722a84b8dSQuaker Fang 	char diff_gain_b;
214822a84b8dSQuaker Fang 	char diff_gain_c;
214922a84b8dSQuaker Fang 	uint8_t reserved1;
215022a84b8dSQuaker Fang } iwp_calibation_cmd_t;
215122a84b8dSQuaker Fang 
215222a84b8dSQuaker Fang 
215322a84b8dSQuaker Fang struct	iwp_calib_hdr {
215422a84b8dSQuaker Fang 	uint8_t	op_code;
215522a84b8dSQuaker Fang 	uint8_t	first_group;
215622a84b8dSQuaker Fang 	uint8_t	groups_num;
215722a84b8dSQuaker Fang 	uint8_t	data_valid;
215822a84b8dSQuaker Fang };
215922a84b8dSQuaker Fang 
216022a84b8dSQuaker Fang #define	FH_RSCSR_FRAME_SIZE_MASK	(0x00003FFF)
216122a84b8dSQuaker Fang 
216222a84b8dSQuaker Fang struct	iwp_calib_results {
216322a84b8dSQuaker Fang 	void		*tx_iq_res;
216422a84b8dSQuaker Fang 	uint32_t	tx_iq_res_len;
216522a84b8dSQuaker Fang 	void		*tx_iq_perd_res;
216622a84b8dSQuaker Fang 	uint32_t	tx_iq_perd_res_len;
216722a84b8dSQuaker Fang 	void		*lo_res;
216822a84b8dSQuaker Fang 	uint32_t	lo_res_len;
216922a84b8dSQuaker Fang 	void		*base_band_res;
217022a84b8dSQuaker Fang 	uint32_t	base_band_res_len;
217122a84b8dSQuaker Fang };
217222a84b8dSQuaker Fang 
217322a84b8dSQuaker Fang #define	IWP_CALIB_INIT_CFG_ALL	(0xFFFFFFFF)
217422a84b8dSQuaker Fang 
217522a84b8dSQuaker Fang struct	iwp_calib_cfg_elmnt_s {
217622a84b8dSQuaker Fang 	uint32_t	is_enable;
217722a84b8dSQuaker Fang 	uint32_t	start;
217822a84b8dSQuaker Fang 	uint32_t	send_res;
217922a84b8dSQuaker Fang 	uint32_t	apply_res;
218022a84b8dSQuaker Fang 	uint32_t	resered;
218122a84b8dSQuaker Fang };
218222a84b8dSQuaker Fang 
218322a84b8dSQuaker Fang struct	iwp_calib_cfg_status_s {
218422a84b8dSQuaker Fang 	struct	iwp_calib_cfg_elmnt_s	once;
218522a84b8dSQuaker Fang 	struct	iwp_calib_cfg_elmnt_s	perd;
218622a84b8dSQuaker Fang 	uint32_t	flags;
218722a84b8dSQuaker Fang };
218822a84b8dSQuaker Fang 
218922a84b8dSQuaker Fang struct	iwp_calib_cfg_cmd {
219022a84b8dSQuaker Fang 	struct	iwp_calib_cfg_status_s	ucd_calib_cfg;
219122a84b8dSQuaker Fang 	struct	iwp_calib_cfg_status_s	drv_calib_cfg;
219222a84b8dSQuaker Fang 	uint32_t	reserved1;
219322a84b8dSQuaker Fang };
219422a84b8dSQuaker Fang 
219522a84b8dSQuaker Fang struct	iwp_cal_crystal_freq {
219622a84b8dSQuaker Fang 	uint8_t	cap_pin1;
219722a84b8dSQuaker Fang 	uint8_t	cap_pin2;
219822a84b8dSQuaker Fang };
219922a84b8dSQuaker Fang 
220022a84b8dSQuaker Fang typedef	struct	iwp_calibration_crystal_cmd {
220122a84b8dSQuaker Fang 	uint8_t	opCode;
220222a84b8dSQuaker Fang 	uint8_t	first_group;
220322a84b8dSQuaker Fang 	uint8_t	num_group;
220422a84b8dSQuaker Fang 	uint8_t	all_data_valid;
220522a84b8dSQuaker Fang 	struct	iwp_cal_crystal_freq	data;
220622a84b8dSQuaker Fang } iwp_calibration_crystal_cmd_t;
220722a84b8dSQuaker Fang 
220822a84b8dSQuaker Fang #define	COEX_NUM_OF_EVENTS	(16)
220922a84b8dSQuaker Fang 
221022a84b8dSQuaker Fang struct	iwp_wimax_coex_event_entry {
221122a84b8dSQuaker Fang 	uint8_t	request_prio;
221222a84b8dSQuaker Fang 	uint8_t	win_medium_prio;
221322a84b8dSQuaker Fang 	uint8_t	reserved;
221422a84b8dSQuaker Fang 	uint8_t	flags;
221522a84b8dSQuaker Fang };
221622a84b8dSQuaker Fang 
221722a84b8dSQuaker Fang typedef	struct	iwp_wimax_coex_cmd {
221822a84b8dSQuaker Fang 	uint8_t	flags;
221922a84b8dSQuaker Fang 	uint8_t	reserved[3];
222022a84b8dSQuaker Fang 	struct iwp_wimax_coex_event_entry	sta_prio[COEX_NUM_OF_EVENTS];
222122a84b8dSQuaker Fang } iwp_wimax_coex_cmd_t;
222222a84b8dSQuaker Fang 
222322a84b8dSQuaker Fang typedef struct iwp_missed_beacon_notif {
222422a84b8dSQuaker Fang 	uint32_t consequtive_missed_beacons;
222522a84b8dSQuaker Fang 	uint32_t total_missed_becons;
222622a84b8dSQuaker Fang 	uint32_t num_expected_beacons;
222722a84b8dSQuaker Fang 	uint32_t num_recvd_beacons;
222822a84b8dSQuaker Fang } iwp_missed_beacon_notif_t;
222922a84b8dSQuaker Fang 
223022a84b8dSQuaker Fang typedef struct iwp_ct_kill_config {
223122a84b8dSQuaker Fang 	uint32_t   reserved;
223222a84b8dSQuaker Fang 	uint32_t   critical_temperature_M;
223322a84b8dSQuaker Fang 	uint32_t   critical_temperature_R;
223422a84b8dSQuaker Fang } iwp_ct_kill_config_t;
223522a84b8dSQuaker Fang 
223622a84b8dSQuaker Fang /*
223722a84b8dSQuaker Fang  * structure for command IWP_CMD_ASSOCIATE
223822a84b8dSQuaker Fang  */
223922a84b8dSQuaker Fang typedef struct iwp_assoc {
224022a84b8dSQuaker Fang 	uint32_t	flags;
224122a84b8dSQuaker Fang 	uint32_t	filter;
224222a84b8dSQuaker Fang 	uint8_t		ofdm_mask;
224322a84b8dSQuaker Fang 	uint8_t		cck_mask;
224422a84b8dSQuaker Fang 	uint8_t		ofdm_ht_single_stream_basic_rates;
224522a84b8dSQuaker Fang 	uint8_t		ofdm_ht_dual_stream_basic_rates;
224622a84b8dSQuaker Fang 	uint16_t	rx_chain_select_flags;
224722a84b8dSQuaker Fang 	uint16_t	reserved;
224822a84b8dSQuaker Fang } iwp_assoc_t;
224922a84b8dSQuaker Fang 
225022a84b8dSQuaker Fang /*
225122a84b8dSQuaker Fang  * structure for command IWP_CMD_TSF
225222a84b8dSQuaker Fang  */
225322a84b8dSQuaker Fang typedef struct iwp_cmd_tsf {
225422a84b8dSQuaker Fang 	uint32_t	timestampl;
225522a84b8dSQuaker Fang 	uint32_t	timestamph;
225622a84b8dSQuaker Fang 	uint16_t	bintval;
225722a84b8dSQuaker Fang 	uint16_t	atim;
225822a84b8dSQuaker Fang 	uint32_t	binitval;
225922a84b8dSQuaker Fang 	uint16_t	lintval;
226022a84b8dSQuaker Fang 	uint16_t	reserved;
226122a84b8dSQuaker Fang } iwp_cmd_tsf_t;
226222a84b8dSQuaker Fang 
226322a84b8dSQuaker Fang /*
226422a84b8dSQuaker Fang  * structure for IWP_CMD_ADD_NODE
226522a84b8dSQuaker Fang  */
226622a84b8dSQuaker Fang #define	STA_MODE_ADD_MSK		(0)
226722a84b8dSQuaker Fang #define	STA_MODE_MODIFY_MSK		(1)
226822a84b8dSQuaker Fang 
226922a84b8dSQuaker Fang #define	STA_FLG_RTS_MIMO_PROT		(1 << 17)
227022a84b8dSQuaker Fang #define	STA_FLG_MAX_AMPDU_POS		(19)
227122a84b8dSQuaker Fang #define	STA_FLG_AMPDU_DENSITY_POS	(23)
227222a84b8dSQuaker Fang #define	STA_FLG_FAT_EN			(1 << 21)
227322a84b8dSQuaker Fang 
227422a84b8dSQuaker Fang #define	STA_MODIFY_KEY_MASK		(0x01)
227522a84b8dSQuaker Fang #define	STA_MODIFY_TID_DISABLE_TX	(0x02)
227622a84b8dSQuaker Fang #define	STA_MODIFY_TX_RATE_MSK		(0x04)
227722a84b8dSQuaker Fang #define	STA_MODIFY_ADDBA_TID_MSK	(0x08)
227822a84b8dSQuaker Fang #define	STA_MODIFY_DELBA_TID_MSK	(0x10)
227922a84b8dSQuaker Fang 
228022a84b8dSQuaker Fang struct	sta_id_modify {
228122a84b8dSQuaker Fang 	uint8_t		addr[6];
228222a84b8dSQuaker Fang 	uint16_t	reserved1;
228322a84b8dSQuaker Fang 	uint8_t		sta_id;
228422a84b8dSQuaker Fang 	uint8_t		modify_mask;
228522a84b8dSQuaker Fang 	uint16_t	reserved2;
228622a84b8dSQuaker Fang };
228722a84b8dSQuaker Fang 
228822a84b8dSQuaker Fang struct	iwp_keyinfo {
228922a84b8dSQuaker Fang 	uint16_t	key_flags;
229022a84b8dSQuaker Fang 	uint8_t		tkip_rx_tsc_byte2;
229122a84b8dSQuaker Fang 	uint8_t		reserved1;
229222a84b8dSQuaker Fang 	uint16_t	tkip_rx_ttak[5];
229322a84b8dSQuaker Fang 	uint8_t		key_offset;
229422a84b8dSQuaker Fang 	uint8_t		reserved2;
229522a84b8dSQuaker Fang 	uint8_t		key[16];
229622a84b8dSQuaker Fang 	uint32_t	tx_secur_seq_cnt1;
229722a84b8dSQuaker Fang 	uint32_t	tx_secur_seq_cnt2;
229822a84b8dSQuaker Fang 	uint32_t	hw_tkip_mic_rx_key1;
229922a84b8dSQuaker Fang 	uint32_t	hw_tkip_mic_rx_key2;
230022a84b8dSQuaker Fang 	uint32_t	hw_tkip_mic_tx_key1;
230122a84b8dSQuaker Fang 	uint32_t	hw_tkip_mic_tx_key2;
230222a84b8dSQuaker Fang };
230322a84b8dSQuaker Fang typedef struct iwp_add_sta {
230422a84b8dSQuaker Fang 	uint8_t		mode;
230522a84b8dSQuaker Fang 	uint8_t		reserved[3];
230622a84b8dSQuaker Fang 	struct sta_id_modify	sta;
230722a84b8dSQuaker Fang 	struct iwp_keyinfo	key;
230822a84b8dSQuaker Fang 	uint32_t	station_flags;
230922a84b8dSQuaker Fang 	uint32_t	station_flags_msk;
231022a84b8dSQuaker Fang 	uint16_t	disable_tx;
231122a84b8dSQuaker Fang 	uint16_t	reserved1;
231222a84b8dSQuaker Fang 	uint8_t		add_immediate_ba_tid;
231322a84b8dSQuaker Fang 	uint8_t		remove_immediate_ba_tid;
231422a84b8dSQuaker Fang 	uint16_t	add_immediate_ba_ssn;
231522a84b8dSQuaker Fang 	uint32_t	reserved2;
231622a84b8dSQuaker Fang } iwp_add_sta_t;
231722a84b8dSQuaker Fang 
231822a84b8dSQuaker Fang typedef	struct iwp_rem_sta {
231922a84b8dSQuaker Fang 	uint8_t	num_sta;	/* number of removed stations */
232022a84b8dSQuaker Fang 	uint8_t	reserved1[3];
232122a84b8dSQuaker Fang 	uint8_t	addr[6];	/* MAC address of the first station */
232222a84b8dSQuaker Fang 	uint8_t	reserved2[2];
232322a84b8dSQuaker Fang } iwp_rem_sta_t;
232422a84b8dSQuaker Fang 
232522a84b8dSQuaker Fang /*
232622a84b8dSQuaker Fang  * Tx flags
232722a84b8dSQuaker Fang  */
232822a84b8dSQuaker Fang enum {
232922a84b8dSQuaker Fang 	TX_CMD_FLG_RTS_MSK = (1 << 1),
233022a84b8dSQuaker Fang 	TX_CMD_FLG_CTS_MSK = (1 << 2),
233122a84b8dSQuaker Fang 	TX_CMD_FLG_ACK_MSK = (1 << 3),
233222a84b8dSQuaker Fang 	TX_CMD_FLG_STA_RATE_MSK = (1 << 4),
233322a84b8dSQuaker Fang 	TX_CMD_FLG_IMM_BA_RSP_MASK = (1 << 6),
233422a84b8dSQuaker Fang 	TX_CMD_FLG_FULL_TXOP_PROT_MSK = (1 << 7),
233522a84b8dSQuaker Fang 	TX_CMD_FLG_ANT_SEL_MSK = 0xf00,
233622a84b8dSQuaker Fang 	TX_CMD_FLG_ANT_A_MSK = (1 << 8),
233722a84b8dSQuaker Fang 	TX_CMD_FLG_ANT_B_MSK = (1 << 9),
233822a84b8dSQuaker Fang 
233922a84b8dSQuaker Fang 	/* ucode ignores BT priority for this frame */
234022a84b8dSQuaker Fang 	TX_CMD_FLG_BT_DIS_MSK = (1 << 12),
234122a84b8dSQuaker Fang 
234222a84b8dSQuaker Fang 	/* ucode overrides sequence control */
234322a84b8dSQuaker Fang 	TX_CMD_FLG_SEQ_CTL_MSK = (1 << 13),
234422a84b8dSQuaker Fang 
234522a84b8dSQuaker Fang 	/* signal that this frame is non-last MPDU */
234622a84b8dSQuaker Fang 	TX_CMD_FLG_MORE_FRAG_MSK = (1 << 14),
234722a84b8dSQuaker Fang 
234822a84b8dSQuaker Fang 	/* calculate TSF in outgoing frame */
234922a84b8dSQuaker Fang 	TX_CMD_FLG_TSF_MSK = (1 << 16),
235022a84b8dSQuaker Fang 
235122a84b8dSQuaker Fang 	/* activate TX calibration. */
235222a84b8dSQuaker Fang 	TX_CMD_FLG_CALIB_MSK = (1 << 17),
235322a84b8dSQuaker Fang 
235422a84b8dSQuaker Fang 	/*
235522a84b8dSQuaker Fang 	 * signals that 2 bytes pad was inserted
235622a84b8dSQuaker Fang 	 * after the MAC header
235722a84b8dSQuaker Fang 	 */
235822a84b8dSQuaker Fang 	TX_CMD_FLG_MH_PAD_MSK = (1 << 20),
235922a84b8dSQuaker Fang 
236022a84b8dSQuaker Fang 	/* HCCA-AP - disable duration overwriting. */
236122a84b8dSQuaker Fang 	TX_CMD_FLG_DUR_MSK = (1 << 25),
236222a84b8dSQuaker Fang };
236322a84b8dSQuaker Fang 
236422a84b8dSQuaker Fang 
236522a84b8dSQuaker Fang /*
236622a84b8dSQuaker Fang  * structure for command IWP_CMD_TX_DATA
236722a84b8dSQuaker Fang  */
236822a84b8dSQuaker Fang typedef struct iwp_tx_cmd {
236922a84b8dSQuaker Fang 	uint16_t len;
237022a84b8dSQuaker Fang 	uint16_t next_frame_len;
237122a84b8dSQuaker Fang 	uint32_t tx_flags;
237222a84b8dSQuaker Fang 	struct iwp_dram_scratch scratch;
237322a84b8dSQuaker Fang 	struct iwp_rate rate;
237422a84b8dSQuaker Fang 	uint8_t sta_id;
237522a84b8dSQuaker Fang 	uint8_t sec_ctl;
237622a84b8dSQuaker Fang 	uint8_t initial_rate_index;
237722a84b8dSQuaker Fang 	uint8_t reserved;
237822a84b8dSQuaker Fang 	uint8_t key[16];
237922a84b8dSQuaker Fang 	uint16_t next_frame_flags;
238022a84b8dSQuaker Fang 	uint16_t reserved2;
238122a84b8dSQuaker Fang 	union {
238222a84b8dSQuaker Fang 		uint32_t life_time;
238322a84b8dSQuaker Fang 		uint32_t attempt;
238422a84b8dSQuaker Fang 	} stop_time;
238522a84b8dSQuaker Fang 	uint32_t dram_lsb_ptr;
238622a84b8dSQuaker Fang 	uint8_t dram_msb_ptr;
238722a84b8dSQuaker Fang 	uint8_t rts_retry_limit;
238822a84b8dSQuaker Fang 	uint8_t data_retry_limit;
238922a84b8dSQuaker Fang 	uint8_t tid_tspec;
239022a84b8dSQuaker Fang 	union {
239122a84b8dSQuaker Fang 		uint16_t pm_frame_timeout;
239222a84b8dSQuaker Fang 		uint16_t attempt_duration;
239322a84b8dSQuaker Fang 	} timeout;
239422a84b8dSQuaker Fang 	uint16_t driver_txop;
239522a84b8dSQuaker Fang } iwp_tx_cmd_t;
239622a84b8dSQuaker Fang 
239722a84b8dSQuaker Fang 
239822a84b8dSQuaker Fang /*
239922a84b8dSQuaker Fang  * structure for command "TX beacon"
240022a84b8dSQuaker Fang  */
240122a84b8dSQuaker Fang 
240222a84b8dSQuaker Fang typedef struct iwp_tx_beacon_cmd {
240322a84b8dSQuaker Fang 	iwp_tx_cmd_t	config;
240422a84b8dSQuaker Fang 	uint16_t	tim_idx;
240522a84b8dSQuaker Fang 	uint8_t		tim_size;
240622a84b8dSQuaker Fang 	uint8_t		reserved;
240722a84b8dSQuaker Fang 	uint8_t		bcon_frame[2342];
240822a84b8dSQuaker Fang } iwp_tx_beacon_cmd_t;
240922a84b8dSQuaker Fang 
241022a84b8dSQuaker Fang 
241122a84b8dSQuaker Fang /*
241222a84b8dSQuaker Fang  * LEDs Command & Response
241322a84b8dSQuaker Fang  * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
241422a84b8dSQuaker Fang  *
241522a84b8dSQuaker Fang  * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
241622a84b8dSQuaker Fang  * this command turns it on or off, or sets up a periodic blinking cycle.
241722a84b8dSQuaker Fang  */
241822a84b8dSQuaker Fang typedef struct iwp_led_cmd {
241922a84b8dSQuaker Fang 	uint32_t interval;	/* "interval" in uSec */
242022a84b8dSQuaker Fang 	uint8_t id;		/* 1: Activity, 2: Link, 3: Tech */
242122a84b8dSQuaker Fang 		/*
242222a84b8dSQuaker Fang 		 * # intervals off while blinking;
242322a84b8dSQuaker Fang 		 * "0", with > 0 "on" value, turns LED on
242422a84b8dSQuaker Fang 		 */
242522a84b8dSQuaker Fang 	uint8_t off;
242622a84b8dSQuaker Fang 		/*
242722a84b8dSQuaker Fang 		 * # intervals on while blinking;
242822a84b8dSQuaker Fang 		 * "0", regardless of "off", turns LED off
242922a84b8dSQuaker Fang 		 */
243022a84b8dSQuaker Fang 	uint8_t on;
243122a84b8dSQuaker Fang 	uint8_t reserved;
243222a84b8dSQuaker Fang } iwp_led_cmd_t;
243322a84b8dSQuaker Fang 
243422a84b8dSQuaker Fang /*
243522a84b8dSQuaker Fang  * structure for IWP_CMD_SET_POWER_MODE
243622a84b8dSQuaker Fang  */
243722a84b8dSQuaker Fang typedef struct iwp_powertable_cmd {
243822a84b8dSQuaker Fang 	uint16_t	flags;
243922a84b8dSQuaker Fang 	uint8_t		keep_alive_seconds;
244022a84b8dSQuaker Fang 	uint8_t		debug_flags;
244122a84b8dSQuaker Fang 	uint32_t	rx_timeout;
244222a84b8dSQuaker Fang 	uint32_t	tx_timeout;
244322a84b8dSQuaker Fang 	uint32_t	sleep[5];
244422a84b8dSQuaker Fang 	uint32_t	keep_alive_beacons;
244522a84b8dSQuaker Fang } iwp_powertable_cmd_t;
244622a84b8dSQuaker Fang 
244722a84b8dSQuaker Fang struct iwp_ssid_ie {
244822a84b8dSQuaker Fang 	uint8_t id;
244922a84b8dSQuaker Fang 	uint8_t len;
245022a84b8dSQuaker Fang 	uint8_t ssid[32];
245122a84b8dSQuaker Fang };
245222a84b8dSQuaker Fang /*
245322a84b8dSQuaker Fang  * structure for command IWP_CMD_SCAN
245422a84b8dSQuaker Fang  */
245522a84b8dSQuaker Fang typedef struct iwp_scan_hdr {
245622a84b8dSQuaker Fang 	uint16_t len;
245722a84b8dSQuaker Fang 	uint8_t	 reserved1;
245822a84b8dSQuaker Fang 	uint8_t	 nchan;
245922a84b8dSQuaker Fang 		/*
246022a84b8dSQuaker Fang 		 * dwell only this long on quiet chnl
246122a84b8dSQuaker Fang 		 * (active scan)
246222a84b8dSQuaker Fang 		 */
246322a84b8dSQuaker Fang 	uint16_t quiet_time;
246422a84b8dSQuaker Fang 	uint16_t quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
246522a84b8dSQuaker Fang 	uint16_t good_crc_th; /* passive -> active promotion threshold */
246622a84b8dSQuaker Fang 	uint16_t rx_chain;
246722a84b8dSQuaker Fang 		/*
246822a84b8dSQuaker Fang 		 * max usec to be out of associated (service)
246922a84b8dSQuaker Fang 		 * chnl
247022a84b8dSQuaker Fang 		 */
247122a84b8dSQuaker Fang 	uint32_t max_out_time;
247222a84b8dSQuaker Fang 		/*
247322a84b8dSQuaker Fang 		 * pause scan this long when returning to svc
247422a84b8dSQuaker Fang 		 * chnl.
247522a84b8dSQuaker Fang 		 * SP -- 31:22 # beacons, 21:0 additional usec.
247622a84b8dSQuaker Fang 		 */
247722a84b8dSQuaker Fang 	uint32_t suspend_time;
247822a84b8dSQuaker Fang 	uint32_t flags;
247922a84b8dSQuaker Fang 	uint32_t filter_flags;
248022a84b8dSQuaker Fang 	struct	 iwp_tx_cmd tx_cmd;
248122a84b8dSQuaker Fang 	struct	 iwp_ssid_ie direct_scan[20];
248222a84b8dSQuaker Fang 	/* followed by probe request body */
248322a84b8dSQuaker Fang 	/* followed by nchan x iwp_scan_chan */
248422a84b8dSQuaker Fang } iwp_scan_hdr_t;
248522a84b8dSQuaker Fang 
248622a84b8dSQuaker Fang typedef struct iwp_scan_chan {
248722a84b8dSQuaker Fang 	uint32_t	type;
248822a84b8dSQuaker Fang 	uint16_t	chan;
248922a84b8dSQuaker Fang 	struct iwp_tx_power	tpc;
249022a84b8dSQuaker Fang 	uint16_t	active_dwell;	/* dwell time */
249122a84b8dSQuaker Fang 	uint16_t	passive_dwell;	/* dwell time */
249222a84b8dSQuaker Fang } iwp_scan_chan_t;
249322a84b8dSQuaker Fang 
249422a84b8dSQuaker Fang /*
249522a84b8dSQuaker Fang  * structure for IWP_CMD_BLUETOOTH
249622a84b8dSQuaker Fang  */
249722a84b8dSQuaker Fang typedef struct iwp_bt_cmd {
249822a84b8dSQuaker Fang 	uint8_t		flags;
249922a84b8dSQuaker Fang 	uint8_t		lead_time;
250022a84b8dSQuaker Fang 	uint8_t		max_kill;
250122a84b8dSQuaker Fang 	uint8_t		reserved;
250222a84b8dSQuaker Fang 	uint32_t	kill_ack_mask;
250322a84b8dSQuaker Fang 	uint32_t	kill_cts_mask;
250422a84b8dSQuaker Fang } iwp_bt_cmd_t;
250522a84b8dSQuaker Fang 
250622a84b8dSQuaker Fang typedef struct iwp_wme_param {
250722a84b8dSQuaker Fang 	uint8_t		aifsn;
250822a84b8dSQuaker Fang 	uint8_t		cwmin_e;
250922a84b8dSQuaker Fang 	uint8_t		cwmax_e;
251022a84b8dSQuaker Fang 	uint16_t	txop;
251122a84b8dSQuaker Fang } iwp_wme_param_t;
251222a84b8dSQuaker Fang /*
251322a84b8dSQuaker Fang  * QoS parameter command (REPLY_QOS_PARAM = 0x13)
251422a84b8dSQuaker Fang  * FIFO0-background, FIFO1-best effort, FIFO2-video, FIFO3-voice
251522a84b8dSQuaker Fang  */
251622a84b8dSQuaker Fang 
251722a84b8dSQuaker Fang struct iwp_edca_param {
251822a84b8dSQuaker Fang 	uint16_t	cw_min;
251922a84b8dSQuaker Fang 	uint16_t	cw_max;
252022a84b8dSQuaker Fang 	uint8_t		aifsn;
252122a84b8dSQuaker Fang 	uint8_t		reserved;
252222a84b8dSQuaker Fang 	uint16_t	txop;
252322a84b8dSQuaker Fang };
252422a84b8dSQuaker Fang 
252522a84b8dSQuaker Fang typedef struct iwp_qos_param_cmd {
252622a84b8dSQuaker Fang 	uint32_t	flags;
252722a84b8dSQuaker Fang 	struct iwp_edca_param	ac[AC_NUM];
252822a84b8dSQuaker Fang } iwp_qos_param_cmd_t;
252922a84b8dSQuaker Fang 
253022a84b8dSQuaker Fang /*
253122a84b8dSQuaker Fang  * firmware image header
253222a84b8dSQuaker Fang  */
253322a84b8dSQuaker Fang typedef struct iwp_firmware_hdr {
253422a84b8dSQuaker Fang 	uint32_t	version;
253522a84b8dSQuaker Fang 	uint32_t	bld_nu;
253622a84b8dSQuaker Fang 	uint32_t	textsz;
253722a84b8dSQuaker Fang 	uint32_t	datasz;
253822a84b8dSQuaker Fang 	uint32_t	init_textsz;
253922a84b8dSQuaker Fang 	uint32_t	init_datasz;
254022a84b8dSQuaker Fang 	uint32_t	bootsz;
254122a84b8dSQuaker Fang } iwp_firmware_hdr_t;
254222a84b8dSQuaker Fang 
254322a84b8dSQuaker Fang /*
254422a84b8dSQuaker Fang  * structure for IWP_START_SCAN notification
254522a84b8dSQuaker Fang  */
254622a84b8dSQuaker Fang typedef struct iwp_start_scan {
254722a84b8dSQuaker Fang 	uint32_t	timestampl;
254822a84b8dSQuaker Fang 	uint32_t	timestamph;
254922a84b8dSQuaker Fang 	uint32_t	tbeacon;
255022a84b8dSQuaker Fang 	uint8_t		chan;
255122a84b8dSQuaker Fang 	uint8_t		band;
255222a84b8dSQuaker Fang 	uint16_t	reserved;
255322a84b8dSQuaker Fang 	uint32_t	status;
255422a84b8dSQuaker Fang } iwp_start_scan_t;
255522a84b8dSQuaker Fang 
255622a84b8dSQuaker Fang /*
255722a84b8dSQuaker Fang  * structure for IWK_SCAN_COMPLETE notification
255822a84b8dSQuaker Fang  */
255922a84b8dSQuaker Fang typedef struct iwp_stop_scan {
256022a84b8dSQuaker Fang 	uint8_t		nchan;
256122a84b8dSQuaker Fang 	uint8_t		status;
256222a84b8dSQuaker Fang 	uint8_t		reserved;
256322a84b8dSQuaker Fang 	uint8_t		chan;
256422a84b8dSQuaker Fang 	uint8_t		tsf;
256522a84b8dSQuaker Fang } iwp_stop_scan_t;
256622a84b8dSQuaker Fang 
256722a84b8dSQuaker Fang 
256822a84b8dSQuaker Fang #define	IWP_READ(sc, reg)						\
256922a84b8dSQuaker Fang 	ddi_get32((sc)->sc_handle, (uint32_t *)((sc)->sc_base + (reg)))
257022a84b8dSQuaker Fang 
257122a84b8dSQuaker Fang #define	IWP_WRITE(sc, reg, val)					\
257222a84b8dSQuaker Fang 	ddi_put32((sc)->sc_handle, (uint32_t *)((sc)->sc_base + (reg)), (val))
257322a84b8dSQuaker Fang 
257422a84b8dSQuaker Fang /*
257522a84b8dSQuaker Fang  * Driver can access peripheral registers
257622a84b8dSQuaker Fang  * and ram via HBUS_TARG_PRPH_* registers.
257722a84b8dSQuaker Fang  */
257822a84b8dSQuaker Fang 
257922a84b8dSQuaker Fang #define	PRPH_BASE	(0x00000)
258022a84b8dSQuaker Fang #define	PRPH_END	(0xFFFFF)
258122a84b8dSQuaker Fang 
258222a84b8dSQuaker Fang #define	IWP_SCD_BASE	(PRPH_BASE + 0xA02C00)
258322a84b8dSQuaker Fang 
258422a84b8dSQuaker Fang #define	IWP_SCD_SRAM_BASE_ADDR	(IWP_SCD_BASE + 0x0)
258522a84b8dSQuaker Fang #define	IWP_SCD_DRAM_BASE_ADDR	(IWP_SCD_BASE + 0x8)
258622a84b8dSQuaker Fang #define	IWP_SCD_QUEUECHAIN_SEL	(IWP_SCD_BASE + 0xE8)
258722a84b8dSQuaker Fang #define	IWP_SCD_AGGR_SEL	(IWP_SCD_BASE + 0x248)
258822a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_RDPTR(x)	(IWP_SCD_BASE + 0x68 + (x) * 4)
258922a84b8dSQuaker Fang #define	IWP_SCD_INTERRUPT_MASK	(IWP_SCD_BASE + 0x108)
259022a84b8dSQuaker Fang #define	IWP_SCD_TXFACT		(IWP_SCD_BASE + 0x1C)
259122a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_STATUS_BITS(x)	(IWP_SCD_BASE + 0x10C + (x) * 4)
259222a84b8dSQuaker Fang 
259322a84b8dSQuaker Fang #define	IWP_SCD_CONTEXT_DATA_OFFSET	(0x600)
259422a84b8dSQuaker Fang #define	IWP_SCD_TX_STTS_BITMAP_OFFSET	(0x7B1)
259522a84b8dSQuaker Fang #define	IWP_SCD_TRANSLATE_TBL_OFFSET	(0x7E0)
259622a84b8dSQuaker Fang 
259722a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS	(0)
259822a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK	(0x0000007F)
259922a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS	(16)
260022a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK	(0x007F0000)
260122a84b8dSQuaker Fang 
260222a84b8dSQuaker Fang #define	IWP_SCD_QUEUECHAIN_SEL_ALL(x)	(((1 << (x)) - 1) &\
260322a84b8dSQuaker Fang 				(~(1 << IWP_CMD_QUEUE_NUM)))
260422a84b8dSQuaker Fang 
260522a84b8dSQuaker Fang #define	IWP_SCD_CONTEXT_QUEUE_OFFSET(x)\
260622a84b8dSQuaker Fang 		(IWP_SCD_CONTEXT_DATA_OFFSET + (x) * 8)
260722a84b8dSQuaker Fang 
260822a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_STTS_REG_POS_TXF		(0)
260922a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_STTS_REG_POS_ACTIVE	(3)
261022a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_STTS_REG_POS_WSL		(4)
261122a84b8dSQuaker Fang #define	IWP_SCD_QUEUE_STTS_REG_MSK		(0x00FF0000)
261222a84b8dSQuaker Fang 
261322a84b8dSQuaker Fang /* TX command security control */
261422a84b8dSQuaker Fang #define	TX_CMD_SEC_WEP		(0x01)
261522a84b8dSQuaker Fang #define	TX_CMD_SEC_CCM		(0x02)
261622a84b8dSQuaker Fang #define	TX_CMD_SEC_TKIP		(0x03)
261722a84b8dSQuaker Fang #define	TX_CMD_SEC_MSK		(0x03)
261822a84b8dSQuaker Fang #define	TX_CMD_SEC_SHIFT	(6)
261922a84b8dSQuaker Fang #define	TX_CMD_SEC_KEY128	(0x08)
262022a84b8dSQuaker Fang 
262122a84b8dSQuaker Fang #define	WEP_IV_LEN	(4)
262222a84b8dSQuaker Fang #define	WEP_ICV_LEN	(4)
262322a84b8dSQuaker Fang #define	CCMP_MIC_LEN	(8)
262422a84b8dSQuaker Fang #define	TKIP_ICV_LEN	(4)
262522a84b8dSQuaker Fang 
262622a84b8dSQuaker Fang #ifdef __cplusplus
262722a84b8dSQuaker Fang }
262822a84b8dSQuaker Fang #endif
262922a84b8dSQuaker Fang 
263022a84b8dSQuaker Fang #endif /* _IWP_HW_H_ */
2631