xref: /onnv-gate/usr/src/uts/common/io/iwh/iwh_hw.h (revision 11531:6655d38bf7cf)
17555SFei.Feng@Sun.COM /*
2*11531SFei.Feng@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
37555SFei.Feng@Sun.COM  * Use is subject to license terms.
47555SFei.Feng@Sun.COM  */
57555SFei.Feng@Sun.COM 
67555SFei.Feng@Sun.COM /*
710266SQuaker.Fang@Sun.COM  * Copyright (c) 2009, Intel Corporation
87555SFei.Feng@Sun.COM  * All rights reserved.
97555SFei.Feng@Sun.COM  */
107555SFei.Feng@Sun.COM 
117555SFei.Feng@Sun.COM /*
127555SFei.Feng@Sun.COM  * Sun elects to use this software under the BSD license.
137555SFei.Feng@Sun.COM  */
147555SFei.Feng@Sun.COM 
157555SFei.Feng@Sun.COM /*
167555SFei.Feng@Sun.COM  * This file is provided under a dual BSD/GPLv2 license.  When using or
177555SFei.Feng@Sun.COM  * redistributing this file, you may do so under either license.
187555SFei.Feng@Sun.COM  *
197555SFei.Feng@Sun.COM  * GPL LICENSE SUMMARY
207555SFei.Feng@Sun.COM  *
2110266SQuaker.Fang@Sun.COM  * Copyright(c) 2005 - 2009 Intel Corporation. All rights reserved.
227555SFei.Feng@Sun.COM  *
237555SFei.Feng@Sun.COM  * This program is free software; you can redistribute it and/or modify
2411152SFei.Feng@Sun.COM  * it under the terms of version 2 of the GNU General Public License as
257555SFei.Feng@Sun.COM  * published by the Free Software Foundation.
267555SFei.Feng@Sun.COM  *
277555SFei.Feng@Sun.COM  * This program is distributed in the hope that it will be useful, but
287555SFei.Feng@Sun.COM  * WITHOUT ANY WARRANTY; without even the implied warranty of
297555SFei.Feng@Sun.COM  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
307555SFei.Feng@Sun.COM  * General Public License for more details.
317555SFei.Feng@Sun.COM  *
327555SFei.Feng@Sun.COM  * You should have received a copy of the GNU General Public License
337555SFei.Feng@Sun.COM  * along with this program; if not, write to the Free Software
347555SFei.Feng@Sun.COM  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
357555SFei.Feng@Sun.COM  * USA
367555SFei.Feng@Sun.COM  *
377555SFei.Feng@Sun.COM  * The full GNU General Public License is included in this distribution
387555SFei.Feng@Sun.COM  * in the file called LICENSE.GPL.
397555SFei.Feng@Sun.COM  *
407555SFei.Feng@Sun.COM  * Contact Information:
417555SFei.Feng@Sun.COM  * James P. Ketrenos <ipw2100-admin@linux.intel.com>
427555SFei.Feng@Sun.COM  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
437555SFei.Feng@Sun.COM  *
447555SFei.Feng@Sun.COM  * BSD LICENSE
457555SFei.Feng@Sun.COM  *
4610266SQuaker.Fang@Sun.COM  * Copyright(c) 2005 - 2009 Intel Corporation. All rights reserved.
477555SFei.Feng@Sun.COM  * All rights reserved.
487555SFei.Feng@Sun.COM  *
497555SFei.Feng@Sun.COM  * Redistribution and use in source and binary forms, with or without
507555SFei.Feng@Sun.COM  * modification, are permitted provided that the following conditions
517555SFei.Feng@Sun.COM  * are met:
527555SFei.Feng@Sun.COM  *
537555SFei.Feng@Sun.COM  *  * Redistributions of source code must retain the above copyright
547555SFei.Feng@Sun.COM  *    notice, this list of conditions and the following disclaimer.
557555SFei.Feng@Sun.COM  *  * Redistributions in binary form must reproduce the above copyright
567555SFei.Feng@Sun.COM  *    notice, this list of conditions and the following disclaimer in
577555SFei.Feng@Sun.COM  *    the documentation and/or other materials provided with the
587555SFei.Feng@Sun.COM  *    distribution.
597555SFei.Feng@Sun.COM  *  * Neither the name Intel Corporation nor the names of its
607555SFei.Feng@Sun.COM  *    contributors may be used to endorse or promote products derived
617555SFei.Feng@Sun.COM  *    from this software without specific prior written permission.
627555SFei.Feng@Sun.COM  *
637555SFei.Feng@Sun.COM  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
647555SFei.Feng@Sun.COM  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
657555SFei.Feng@Sun.COM  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
667555SFei.Feng@Sun.COM  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
677555SFei.Feng@Sun.COM  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
687555SFei.Feng@Sun.COM  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
697555SFei.Feng@Sun.COM  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
707555SFei.Feng@Sun.COM  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
717555SFei.Feng@Sun.COM  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
727555SFei.Feng@Sun.COM  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
737555SFei.Feng@Sun.COM  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
747555SFei.Feng@Sun.COM  */
757555SFei.Feng@Sun.COM 
767555SFei.Feng@Sun.COM #ifndef	_IWH_HW_H_
777555SFei.Feng@Sun.COM #define	_IWH_HW_H_
787555SFei.Feng@Sun.COM 
797555SFei.Feng@Sun.COM #ifdef	__cplusplus
807555SFei.Feng@Sun.COM extern "C" {
817555SFei.Feng@Sun.COM #endif
827555SFei.Feng@Sun.COM 
837555SFei.Feng@Sun.COM /*
847555SFei.Feng@Sun.COM  * maximum scatter/gather
857555SFei.Feng@Sun.COM  */
867555SFei.Feng@Sun.COM #define	IWH_MAX_SCATTER	(10)
877555SFei.Feng@Sun.COM 
887555SFei.Feng@Sun.COM /*
897555SFei.Feng@Sun.COM  * Flow Handler Definitions
907555SFei.Feng@Sun.COM  */
917555SFei.Feng@Sun.COM #define	FH_MEM_LOWER_BOUND	(0x1000)
927555SFei.Feng@Sun.COM #define	FH_MEM_UPPER_BOUND	(0x1EF0)
937555SFei.Feng@Sun.COM 
947555SFei.Feng@Sun.COM #define	IWH_FH_REGS_LOWER_BOUND	(0x1000)
957555SFei.Feng@Sun.COM #define	IWH_FH_REGS_UPPER_BOUND	(0x2000)
967555SFei.Feng@Sun.COM 
977555SFei.Feng@Sun.COM /*
987555SFei.Feng@Sun.COM  * TFDB  Area - TFDs buffer table
997555SFei.Feng@Sun.COM  */
1007555SFei.Feng@Sun.COM #define	FH_MEM_TFDB_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x000)
1017555SFei.Feng@Sun.COM #define	FH_MEM_TFDB_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x900)
1027555SFei.Feng@Sun.COM 
1037555SFei.Feng@Sun.COM /*
1047555SFei.Feng@Sun.COM  * channels 0 - 8
1057555SFei.Feng@Sun.COM  */
1067555SFei.Feng@Sun.COM #define	FH_MEM_TFDB_CHNL_BUF0(x) (FH_MEM_TFDB_LOWER_BOUND + (x) * 0x100)
1077555SFei.Feng@Sun.COM #define	FH_MEM_TFDB_CHNL_BUF1(x) (FH_MEM_TFDB_LOWER_BOUND + 0x80 + (x) * 0x100)
1087555SFei.Feng@Sun.COM 
1097555SFei.Feng@Sun.COM /*
1107555SFei.Feng@Sun.COM  * TFDIB Area - TFD Immediate Buffer
1117555SFei.Feng@Sun.COM  */
1127555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x900)
1137555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x958)
1147555SFei.Feng@Sun.COM 
1157555SFei.Feng@Sun.COM /*
1167555SFei.Feng@Sun.COM  * channels 0 - 10
1177555SFei.Feng@Sun.COM  */
1187555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_CHNL(x)	(FH_MEM_TFDIB_LOWER_BOUND + (x) * 0x8)
1197555SFei.Feng@Sun.COM 
1207555SFei.Feng@Sun.COM /*
1217555SFei.Feng@Sun.COM  * TFDIB registers used in Service Mode
1227555SFei.Feng@Sun.COM  */
1237555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_CHNL9_REG0	(FH_MEM_TFDIB_CHNL(9))
1247555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_CHNL9_REG1	(FH_MEM_TFDIB_CHNL(9) + 4)
1257555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_CHNL10_REG0	(FH_MEM_TFDIB_CHNL(10))
1267555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_CHNL10_REG1	(FH_MEM_TFDIB_CHNL(10) + 4)
1277555SFei.Feng@Sun.COM 
1287555SFei.Feng@Sun.COM /*
1297555SFei.Feng@Sun.COM  * Tx service channels
1307555SFei.Feng@Sun.COM  */
1317555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_DRAM_ADDR_MSB_MASK	(0xF00000000)
1327555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_TB_LENGTH_MASK	(0x0001FFFF)	/* bits 16:0 */
1337555SFei.Feng@Sun.COM 
1347555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_DRAM_ADDR_LSB_BITSHIFT	(0)
1357555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_DRAM_ADDR_MSB_BITSHIFT	(32)
1367555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_TB_LENGTH_BITSHIFT		(0)
1377555SFei.Feng@Sun.COM 
1387555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_REG0_ADDR_MASK	(0xFFFFFFFF)
1397555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_REG1_ADDR_MASK	(0xF0000000)
1407555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_REG1_LENGTH_MASK	(0x0001FFFF)
1417555SFei.Feng@Sun.COM 
1427555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_REG0_ADDR_BITSHIFT	(0)
1437555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_REG1_ADDR_BITSHIFT	(28)
1447555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_REG1_LENGTH_BITSHIFT	(0)
1457555SFei.Feng@Sun.COM #define	FH_MEM_TFDIB_DRAM_ADDR_LSB_MASK		(0xFFFFFFFF)
1467555SFei.Feng@Sun.COM 
1477555SFei.Feng@Sun.COM /*
1487555SFei.Feng@Sun.COM  * TRB Area - Transmit Request Buffers
1497555SFei.Feng@Sun.COM  */
1507555SFei.Feng@Sun.COM #define	FH_MEM_TRB_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x0958)
1517555SFei.Feng@Sun.COM #define	FH_MEM_TRB_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x0980)
1527555SFei.Feng@Sun.COM 
1537555SFei.Feng@Sun.COM /*
1547555SFei.Feng@Sun.COM  * channels 0 - 8
1557555SFei.Feng@Sun.COM  */
1567555SFei.Feng@Sun.COM #define	FH_MEM_TRB_CHNL(x)	(FH_MEM_TRB_LOWER_BOUND + (x) * 0x4)
1577555SFei.Feng@Sun.COM 
1587555SFei.Feng@Sun.COM /*
1597555SFei.Feng@Sun.COM  * Keep-Warm (KW) buffer base address.
1607555SFei.Feng@Sun.COM  *
1617555SFei.Feng@Sun.COM  * Driver must allocate a 4KByte buffer that is used by Shirely Peak(SP) for
1627555SFei.Feng@Sun.COM  * keeping the
1637555SFei.Feng@Sun.COM  * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
1647555SFei.Feng@Sun.COM  * DRAM access when SP is Txing or Rxing.  The dummy accesses prevent host
1657555SFei.Feng@Sun.COM  * from going into a power-savings mode that would cause higher DRAM latency,
1667555SFei.Feng@Sun.COM  * and possible data over/under-runs, before all Tx/Rx is complete.
1677555SFei.Feng@Sun.COM  *
1687555SFei.Feng@Sun.COM  * Driver loads IWH_FH_KW_MEM_ADDR_REG with the physical address (bits 35:4)
1697555SFei.Feng@Sun.COM  * of the buffer, which must be 4K aligned.  Once this is set up, the SP
1707555SFei.Feng@Sun.COM  * automatically invokes keep-warm accesses when normal accesses might not
1717555SFei.Feng@Sun.COM  * be sufficient to maintain fast DRAM response.
1727555SFei.Feng@Sun.COM  *
1737555SFei.Feng@Sun.COM  * Bit fields:
1747555SFei.Feng@Sun.COM  * 31-0:  Keep-warm buffer physical base address [35:4], must be 4K aligned
1757555SFei.Feng@Sun.COM  */
1767555SFei.Feng@Sun.COM #define	IWH_FH_KW_MEM_ADDR_REG	(FH_MEM_LOWER_BOUND + 0x97C)
1777555SFei.Feng@Sun.COM 
1787555SFei.Feng@Sun.COM /*
1797555SFei.Feng@Sun.COM  * STAGB Area - Scheduler TAG Buffer
1807555SFei.Feng@Sun.COM  */
1817555SFei.Feng@Sun.COM #define	FH_MEM_STAGB_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x980)
1827555SFei.Feng@Sun.COM #define	FH_MEM_STAGB_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x9D0)
1837555SFei.Feng@Sun.COM 
1847555SFei.Feng@Sun.COM /*
1857555SFei.Feng@Sun.COM  * channels 0 - 8
1867555SFei.Feng@Sun.COM  */
1877555SFei.Feng@Sun.COM #define	FH_MEM_STAGB_0(x)	(FH_MEM_STAGB_LOWER_BOUND + (x) * 0x8)
1887555SFei.Feng@Sun.COM #define	FH_MEM_STAGB_1(x)	(FH_MEM_STAGB_LOWER_BOUND + 0x4 + (x) * 0x8)
1897555SFei.Feng@Sun.COM 
1907555SFei.Feng@Sun.COM /*
1917555SFei.Feng@Sun.COM  * Tx service channels
1927555SFei.Feng@Sun.COM  */
1937555SFei.Feng@Sun.COM #define	FH_MEM_SRAM_ADDR_9	(FH_MEM_STAGB_LOWER_BOUND + 0x048)
1947555SFei.Feng@Sun.COM #define	FH_MEM_SRAM_ADDR_10	(FH_MEM_STAGB_LOWER_BOUND + 0x04C)
1957555SFei.Feng@Sun.COM 
1967555SFei.Feng@Sun.COM #define	FH_MEM_STAGB_SRAM_ADDR_MASK	(0x00FFFFFF)
1977555SFei.Feng@Sun.COM 
1987555SFei.Feng@Sun.COM /*
1997555SFei.Feng@Sun.COM  * TFD Circular Buffers Base (CBBC) addresses
2007555SFei.Feng@Sun.COM  *
2017555SFei.Feng@Sun.COM  * SP has 16 base pointer registers, one for each of 16 host-DRAM-resident
2027555SFei.Feng@Sun.COM  * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
2037555SFei.Feng@Sun.COM  * (see struct iwh_tfd_frame).  These 16 pointer registers are offset by 0x04
2047555SFei.Feng@Sun.COM  * bytes from one another.  Each TFD circular buffer in DRAM must be 256-byte
2057555SFei.Feng@Sun.COM  * aligned (address bits 0-7 must be 0).
2067555SFei.Feng@Sun.COM  *
2077555SFei.Feng@Sun.COM  * Bit fields in each pointer register:
2087555SFei.Feng@Sun.COM  * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned
2097555SFei.Feng@Sun.COM  */
2107555SFei.Feng@Sun.COM #define	FH_MEM_CBBC_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x9D0)
2117555SFei.Feng@Sun.COM #define	FH_MEM_CBBC_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xA10)
2127555SFei.Feng@Sun.COM 
2137555SFei.Feng@Sun.COM /*
2147555SFei.Feng@Sun.COM  * queues 0 - 15
2157555SFei.Feng@Sun.COM  */
2167555SFei.Feng@Sun.COM #define	FH_MEM_CBBC_QUEUE(x)	(FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
2177555SFei.Feng@Sun.COM 
2187555SFei.Feng@Sun.COM /*
2197555SFei.Feng@Sun.COM  * TAGR Area - TAG reconstruct table
2207555SFei.Feng@Sun.COM  */
2217555SFei.Feng@Sun.COM #define	FH_MEM_TAGR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xA10)
2227555SFei.Feng@Sun.COM #define	FH_MEM_TAGR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xA70)
2237555SFei.Feng@Sun.COM 
2247555SFei.Feng@Sun.COM /*
2257555SFei.Feng@Sun.COM  * TDBGR Area - Tx Debug Registers
2267555SFei.Feng@Sun.COM  */
2277555SFei.Feng@Sun.COM #define	FH_MEM_TDBGR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0x0A70)
2287555SFei.Feng@Sun.COM #define	FH_MEM_TDBGR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0x0B20)
2297555SFei.Feng@Sun.COM 
2307555SFei.Feng@Sun.COM /*
2317555SFei.Feng@Sun.COM  * channels 0 - 10
2327555SFei.Feng@Sun.COM  */
2337555SFei.Feng@Sun.COM #define	FH_MEM_TDBGR_CHNL(x)	(FH_MEM_TDBGR_LOWER_BOUND + (x) * 0x10)
2347555SFei.Feng@Sun.COM 
2357555SFei.Feng@Sun.COM #define	FH_MEM_TDBGR_CHNL_REG_0(x)	(FH_MEM_TDBGR_CHNL(x))
2367555SFei.Feng@Sun.COM #define	FH_MEM_TDBGR_CHNL_REG_1(x)	(FH_MEM_TDBGR_CHNL_REG_0(x) + 0x4)
2377555SFei.Feng@Sun.COM 
2387555SFei.Feng@Sun.COM #define	FH_MEM_TDBGR_CHNL_BYTES_TO_FIFO_MASK	(0x000FFFFF)
2397555SFei.Feng@Sun.COM #define	FH_MEM_TDBGR_CHNL_BYTES_TO_FIFO_BITSHIFT	(0)
2407555SFei.Feng@Sun.COM 
2417555SFei.Feng@Sun.COM /*
2427555SFei.Feng@Sun.COM  * RDBUF Area
2437555SFei.Feng@Sun.COM  */
2447555SFei.Feng@Sun.COM #define	FH_MEM_RDBUF_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xB80)
2457555SFei.Feng@Sun.COM #define	FH_MEM_RDBUF_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xBC0)
2467555SFei.Feng@Sun.COM #define	FH_MEM_RDBUF_CHNL0	(FH_MEM_RDBUF_LOWER_BOUND)
2477555SFei.Feng@Sun.COM 
2487555SFei.Feng@Sun.COM /*
2497555SFei.Feng@Sun.COM  * Rx SRAM Control and Status Registers (RSCSR)
2507555SFei.Feng@Sun.COM  *
2517555SFei.Feng@Sun.COM  * These registers provide handshake between driver and Shirley Peak for
2527555SFei.Feng@Sun.COM  * the Rx queue
2537555SFei.Feng@Sun.COM  * (this queue handles *all* command responses, notifications, Rx data, etc.
2547555SFei.Feng@Sun.COM  * sent from SP uCode to host driver).  Unlike Tx, there is only one Rx
2557555SFei.Feng@Sun.COM  * queue, and only one Rx DMA/FIFO channel.  Also unlike Tx, which can
2567555SFei.Feng@Sun.COM  * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
2577555SFei.Feng@Sun.COM  * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
2587555SFei.Feng@Sun.COM  * mapping between RBDs and RBs.
2597555SFei.Feng@Sun.COM  *
2607555SFei.Feng@Sun.COM  * Driver must allocate host DRAM memory for the following, and set the
2617555SFei.Feng@Sun.COM  * physical address of each into SP registers:
2627555SFei.Feng@Sun.COM  *
2637555SFei.Feng@Sun.COM  * 1)  Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
2647555SFei.Feng@Sun.COM  *     entries (although any power of 2, up to 4096, is selectable by driver).
2657555SFei.Feng@Sun.COM  *     Each entry (1 dword) points to a receive buffer (RB) of consistent size
2667555SFei.Feng@Sun.COM  *     (typically 4K, although 8K or 16K are also selectable by driver).
2677555SFei.Feng@Sun.COM  *     Driver sets up RB size and number of RBDs in the CB via Rx config
2687555SFei.Feng@Sun.COM  *     register FH_MEM_RCSR_CHNL0_CONFIG_REG.
2697555SFei.Feng@Sun.COM  *
2707555SFei.Feng@Sun.COM  *     Bit fields within one RBD:
2717555SFei.Feng@Sun.COM  *     27-0:  Receive Buffer physical address bits [35:8], 256-byte aligned.
2727555SFei.Feng@Sun.COM  *
2737555SFei.Feng@Sun.COM  *     Driver sets physical address [35:8] of base of RBD circular buffer
2747555SFei.Feng@Sun.COM  *     into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
2757555SFei.Feng@Sun.COM  *
2767555SFei.Feng@Sun.COM  * 2)  Rx status buffer, 8 bytes, in which SP indicates which Rx Buffers
2777555SFei.Feng@Sun.COM  *     (RBs) have been filled, via a "write pointer", actually the index of
2787555SFei.Feng@Sun.COM  *     the RB's corresponding RBD within the circular buffer.  Driver sets
2797555SFei.Feng@Sun.COM  *     physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
2807555SFei.Feng@Sun.COM  *
2817555SFei.Feng@Sun.COM  *     Bit fields in lower dword of Rx status buffer (upper dword not used
2827555SFei.Feng@Sun.COM  *     by driver; see struct iwh_shared, val0):
2837555SFei.Feng@Sun.COM  *     31-12:  Not used by driver
2847555SFei.Feng@Sun.COM  *     11- 0:  Index of last filled Rx buffer descriptor
2857555SFei.Feng@Sun.COM  *             (SP writes, driver reads this value)
2867555SFei.Feng@Sun.COM  *
2877555SFei.Feng@Sun.COM  * As the driver prepares Receive Buffers (RBs) for SP to fill, driver must
2887555SFei.Feng@Sun.COM  * enter pointers to these RBs into contiguous RBD circular buffer entries,
2897555SFei.Feng@Sun.COM  * and update the SP's "write" index register, FH_RSCSR_CHNL0_RBDCB_WPTR_REG.
2907555SFei.Feng@Sun.COM  *
2917555SFei.Feng@Sun.COM  * This "write" index corresponds to the *next* RBD that the driver will make
2927555SFei.Feng@Sun.COM  * available, i.e. one RBD past the the tail of the ready-to-fill RBDs within
2937555SFei.Feng@Sun.COM  * the circular buffer.  This value should initially be 0 (before preparing any
2947555SFei.Feng@Sun.COM  * RBs), should be 8 after preparing the first 8 RBs (for example), and must
2957555SFei.Feng@Sun.COM  * wrap back to 0 at the end of the circular buffer (but don't wrap before
2967555SFei.Feng@Sun.COM  * "read" index has advanced past 1!  See below).
2977555SFei.Feng@Sun.COM  * NOTE:  SP EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8.
2987555SFei.Feng@Sun.COM  *
2997555SFei.Feng@Sun.COM  * As the SP fills RBs (referenced from contiguous RBDs within the circular
3007555SFei.Feng@Sun.COM  * buffer), it updates the Rx status buffer in DRAM, 2) described above,
3017555SFei.Feng@Sun.COM  * to tell the driver the index of the latest filled RBD.  The driver must
3027555SFei.Feng@Sun.COM  * read this "read" index from DRAM after receiving an Rx interrupt from SP.
3037555SFei.Feng@Sun.COM  *
3047555SFei.Feng@Sun.COM  * The driver must also internally keep track of a third index, which is the
3057555SFei.Feng@Sun.COM  * next RBD to process.  When receiving an Rx interrupt, driver should process
3067555SFei.Feng@Sun.COM  * all filled but unprocessed RBs up to, but not including, the RB
3077555SFei.Feng@Sun.COM  * corresponding to the "read" index.  For example, if "read" index becomes "1",
3087555SFei.Feng@Sun.COM  * driver may process the RB pointed to by RBD 0.  Depending on volume of
3097555SFei.Feng@Sun.COM  * traffic, there may be many RBs to process.
3107555SFei.Feng@Sun.COM  *
3117555SFei.Feng@Sun.COM  * If read index == write index, SP thinks there is no room to put new data.
3127555SFei.Feng@Sun.COM  * Due to this, the maximum number of filled RBs is 255, instead of 256.  To
3137555SFei.Feng@Sun.COM  * be safe, make sure that there is a gap of at least 2 RBDs between "write"
3147555SFei.Feng@Sun.COM  * and "read" indexes; that is, make sure that there are no more than 254
3157555SFei.Feng@Sun.COM  * buffers waiting to be filled.
3167555SFei.Feng@Sun.COM  */
3177555SFei.Feng@Sun.COM #define	FH_MEM_RSCSR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xBC0)
3187555SFei.Feng@Sun.COM #define	FH_MEM_RSCSR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xC00)
3197555SFei.Feng@Sun.COM #define	FH_MEM_RSCSR_CHNL0	(FH_MEM_RSCSR_LOWER_BOUND)
3207555SFei.Feng@Sun.COM #define	FH_MEM_RSCSR_CHNL1	(FH_MEM_RSCSR_LOWER_BOUND + 0x020)
3217555SFei.Feng@Sun.COM 
3227555SFei.Feng@Sun.COM /*
3237555SFei.Feng@Sun.COM  * Physical base address of 8-byte Rx Status buffer.
3247555SFei.Feng@Sun.COM  * Bit fields:
3257555SFei.Feng@Sun.COM  * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
3267555SFei.Feng@Sun.COM  */
3277555SFei.Feng@Sun.COM 
3287555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL0_STTS_WPTR_REG	(FH_MEM_RSCSR_CHNL0)
3297555SFei.Feng@Sun.COM 
3307555SFei.Feng@Sun.COM /*
3317555SFei.Feng@Sun.COM  * Physical base address of Rx Buffer Descriptor Circular Buffer.
3327555SFei.Feng@Sun.COM  * Bit fields:
3337555SFei.Feng@Sun.COM  * 27-0:  RBD CD physical base address [35:8], must be 256-byte aligned.
3347555SFei.Feng@Sun.COM  */
3357555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL0_RBDCB_BASE_REG	(FH_MEM_RSCSR_CHNL0 + 0x004)
3367555SFei.Feng@Sun.COM 
3377555SFei.Feng@Sun.COM /*
3387555SFei.Feng@Sun.COM  * Rx write pointer (index, really!).
3397555SFei.Feng@Sun.COM  * Bit fields:
3407555SFei.Feng@Sun.COM  * 11-0:  Index of driver's most recent prepared-to-be-filled RBD, + 1.
3417555SFei.Feng@Sun.COM  *        NOTE:  For 256-entry circular buffer, use only bits [7:0].
3427555SFei.Feng@Sun.COM  */
3437555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL0_RBDCB_WPTR_REG	(FH_MEM_RSCSR_CHNL0 + 0x008)
3447555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL0_RBDCB_RPTR_REG	(FH_MEM_RSCSR_CHNL0 + 0x00c)
3457555SFei.Feng@Sun.COM 
3467555SFei.Feng@Sun.COM 
3477555SFei.Feng@Sun.COM /*
3487555SFei.Feng@Sun.COM  * RSCSR registers used in Service mode
3497555SFei.Feng@Sun.COM  */
3507555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL1_RB_WPTR_REG	(FH_MEM_RSCSR_CHNL1)
3517555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL1_RB_WPTR_OFFSET_REG	(FH_MEM_RSCSR_CHNL1 + 0x004)
3527555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL1_RB_CHUNK_NUM_REG		(FH_MEM_RSCSR_CHNL1 + 0x008)
3537555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL1_SRAM_ADDR_REG	(FH_MEM_RSCSR_CHNL1 + 0x00C)
3547555SFei.Feng@Sun.COM 
3557555SFei.Feng@Sun.COM /*
3567555SFei.Feng@Sun.COM  * Rx Config/Status Registers (RCSR)
3577555SFei.Feng@Sun.COM  * Rx Config Reg for channel 0 (only channel used)
3587555SFei.Feng@Sun.COM  *
3597555SFei.Feng@Sun.COM  * Driver must initialize FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for
3607555SFei.Feng@Sun.COM  * normal operation (see bit fields).
3617555SFei.Feng@Sun.COM  *
3627555SFei.Feng@Sun.COM  * Clearing FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
3637555SFei.Feng@Sun.COM  * Driver should poll FH_MEM_RSSR_RX_STATUS_REG	for
3647555SFei.Feng@Sun.COM  * FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
3657555SFei.Feng@Sun.COM  *
3667555SFei.Feng@Sun.COM  * Bit fields:
3677555SFei.Feng@Sun.COM  * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
3687555SFei.Feng@Sun.COM  *        '10' operate normally
3697555SFei.Feng@Sun.COM  * 29-24: reserved
3707555SFei.Feng@Sun.COM  * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
3717555SFei.Feng@Sun.COM  *        min "5" for 32 RBDs, max "12" for 4096 RBDs.
3727555SFei.Feng@Sun.COM  * 19-18: reserved
3737555SFei.Feng@Sun.COM  * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
3747555SFei.Feng@Sun.COM  *        '10' 12K, '11' 16K.
3757555SFei.Feng@Sun.COM  * 15-14: reserved
3767555SFei.Feng@Sun.COM  * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
3777555SFei.Feng@Sun.COM  * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
3787555SFei.Feng@Sun.COM  *        typical value 0x10 (about 1/2 msec)
3797555SFei.Feng@Sun.COM  * 3- 0: reserved
3807555SFei.Feng@Sun.COM  */
3817555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xC00)
3827555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xCC0)
3837555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL0	(FH_MEM_RCSR_LOWER_BOUND)
3847555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL1	(FH_MEM_RCSR_LOWER_BOUND + 0x020)
3857555SFei.Feng@Sun.COM 
3867555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL0_CONFIG_REG	(FH_MEM_RCSR_CHNL0)
3877555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL0_CREDIT_REG	(FH_MEM_RCSR_CHNL0 + 0x004)
3887555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL0_RBD_STTS_REG	(FH_MEM_RCSR_CHNL0 + 0x008)
3897555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL0_RB_STTS_REG	(FH_MEM_RCSR_CHNL0 + 0x00C)
3907555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL0_RXPD_STTS_REG	(FH_MEM_RCSR_CHNL0 + 0x010)
3917555SFei.Feng@Sun.COM 
3927555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL0_RBD_STTS_FRAME_RB_CNT_MASK	(0x7FFFFFF0)
3937555SFei.Feng@Sun.COM 
3947555SFei.Feng@Sun.COM /*
3957555SFei.Feng@Sun.COM  * RCSR registers used in Service mode
3967555SFei.Feng@Sun.COM  */
3977555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL1_CONFIG_REG	(FH_MEM_RCSR_CHNL1)
3987555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL1_RB_STTS_REG	(FH_MEM_RCSR_CHNL1 + 0x00C)
3997555SFei.Feng@Sun.COM #define	FH_MEM_RCSR_CHNL1_RX_PD_STTS_REG	(FH_MEM_RCSR_CHNL1 + 0x010)
4007555SFei.Feng@Sun.COM 
4017555SFei.Feng@Sun.COM /*
4027555SFei.Feng@Sun.COM  * Rx Shared Status Registers (RSSR)
4037555SFei.Feng@Sun.COM  *
4047555SFei.Feng@Sun.COM  * After stopping Rx DMA channel (writing 0 to FH_MEM_RCSR_CHNL0_CONFIG_REG),
4057555SFei.Feng@Sun.COM  * driver must poll FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
4067555SFei.Feng@Sun.COM  *
4077555SFei.Feng@Sun.COM  * Bit fields:
4087555SFei.Feng@Sun.COM  * 24:  1 = Channel 0 is idle
4097555SFei.Feng@Sun.COM  *
4107555SFei.Feng@Sun.COM  * FH_MEM_RSSR_SHARED_CTRL_REG and FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV contain
4117555SFei.Feng@Sun.COM  * default values that should not be altered by the driver.
4127555SFei.Feng@Sun.COM  */
4137555SFei.Feng@Sun.COM #define	FH_MEM_RSSR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xC40)
4147555SFei.Feng@Sun.COM #define	FH_MEM_RSSR_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xD00)
4157555SFei.Feng@Sun.COM #define	FH_MEM_RSSR_SHARED_CTRL_REG	(FH_MEM_RSSR_LOWER_BOUND)
4167555SFei.Feng@Sun.COM #define	FH_MEM_RSSR_RX_STATUS_REG	(FH_MEM_RSSR_LOWER_BOUND + 0x004)
4177555SFei.Feng@Sun.COM #define	FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV (FH_MEM_RSSR_LOWER_BOUND + 0x008)
4187555SFei.Feng@Sun.COM 
4197555SFei.Feng@Sun.COM /*
4207555SFei.Feng@Sun.COM  * Transmit DMA Channel Control/Status Registers (TCSR)
4217555SFei.Feng@Sun.COM  *
4227555SFei.Feng@Sun.COM  * SP has one configuration register for each of 8 Tx DMA/FIFO channels
4237555SFei.Feng@Sun.COM  * supported in hardware; config regs are separated by 0x20 bytes.
4247555SFei.Feng@Sun.COM  *
4257555SFei.Feng@Sun.COM  * To use a Tx DMA channel, driver must initialize its
4267555SFei.Feng@Sun.COM  *
4277555SFei.Feng@Sun.COM  *
4287555SFei.Feng@Sun.COM  * All other bits should be 0.
4297555SFei.Feng@Sun.COM  *
4307555SFei.Feng@Sun.COM  * Bit fields:
4317555SFei.Feng@Sun.COM  * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
4327555SFei.Feng@Sun.COM  *        '10' operate normally
4337555SFei.Feng@Sun.COM  * 29- 4: Reserved, set to "0"
4347555SFei.Feng@Sun.COM  *     3: Enable internal DMA requests (1, normal operation), disable (0)
4357555SFei.Feng@Sun.COM  *  2- 0: Reserved, set to "0"
4367555SFei.Feng@Sun.COM  */
4377555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_UPPER_BOUND	(IWH_FH_REGS_LOWER_BOUND + 0xE60)
4387555SFei.Feng@Sun.COM 
4397555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_NUM	(7)
4407555SFei.Feng@Sun.COM 
4417555SFei.Feng@Sun.COM /*
4427555SFei.Feng@Sun.COM  * Tx Shared Status Registers (TSSR)
4437555SFei.Feng@Sun.COM  *
4447555SFei.Feng@Sun.COM  * After stopping Tx DMA channel (writing 0 to
4457555SFei.Feng@Sun.COM  * IWH_FH_TSSR_TX_STATUS_REG until selected Tx channel is idle
4467555SFei.Feng@Sun.COM  * (channel's buffers empty | no pending requests).
4477555SFei.Feng@Sun.COM  *
4487555SFei.Feng@Sun.COM  * Bit fields:
4497555SFei.Feng@Sun.COM  * 31-24:  1 = Channel buffers empty (channel 7:0)
4507555SFei.Feng@Sun.COM  * 23-16:  1 = No pending requests (channel 7:0)
4517555SFei.Feng@Sun.COM  */
4527555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_LOWER_BOUND	(IWH_FH_REGS_LOWER_BOUND + 0xEA0)
4537555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_UPPER_BOUND	(IWH_FH_REGS_LOWER_BOUND + 0xEC0)
4547555SFei.Feng@Sun.COM 
4557555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG (IWH_FH_TSSR_LOWER_BOUND + 0x008)
4567555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_STATUS_REG	(IWH_FH_TSSR_LOWER_BOUND + 0x010)
4577555SFei.Feng@Sun.COM 
4587555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON	(0xFF000000)
4597555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON	(0x00FF0000)
4607555SFei.Feng@Sun.COM 
4617555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_64B	(0x00000000)
4627555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B	(0x00000400)
4637555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_256B	(0x00000800)
4647555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_512B	(0x00000C00)
4657555SFei.Feng@Sun.COM 
4667555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON	(0x00000100)
4677555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON	(0x00000080)
4687555SFei.Feng@Sun.COM 
4697555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH	(0x00000020)
4707555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH	(0x00000005)
4717555SFei.Feng@Sun.COM 
4727555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl)	\
4737555SFei.Feng@Sun.COM 	((1 << (_chnl)) << 24)
4747555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) \
4757555SFei.Feng@Sun.COM 	((1 << (_chnl)) << 16)
4767555SFei.Feng@Sun.COM 
4777555SFei.Feng@Sun.COM #define	IWH_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) \
4787555SFei.Feng@Sun.COM 	(IWH_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \
4797555SFei.Feng@Sun.COM 	IWH_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl))
4807555SFei.Feng@Sun.COM 
4817555SFei.Feng@Sun.COM /*
4827555SFei.Feng@Sun.COM  * TFDIB
4837555SFei.Feng@Sun.COM  */
4847555SFei.Feng@Sun.COM #define	IWH_FH_TFDIB_UPPER_BOUND	(IWH_FH_REGS_LOWER_BOUND + 0x958)
4857555SFei.Feng@Sun.COM #define	IWH_FH_TFDIB_CTRL1_REG_POS_MSB	(28)
4867555SFei.Feng@Sun.COM #define	IWH_FH_TFDIB_LOWER_BOUND	(IWH_FH_REGS_LOWER_BOUND + 0x900)
4877555SFei.Feng@Sun.COM 
4887555SFei.Feng@Sun.COM #define	IWH_FH_TFDIB_CTRL0_REG(_chnl)\
4897555SFei.Feng@Sun.COM 	(IWH_FH_TFDIB_LOWER_BOUND + 0x8 * _chnl)
4907555SFei.Feng@Sun.COM 
4917555SFei.Feng@Sun.COM #define	IWH_FH_TFDIB_CTRL1_REG(_chnl)\
4927555SFei.Feng@Sun.COM 	(IWH_FH_TFDIB_LOWER_BOUND + 0x8 * _chnl + 0x4)
4937555SFei.Feng@Sun.COM 
4947555SFei.Feng@Sun.COM /*
4957555SFei.Feng@Sun.COM  * Debug Monitor Area
4967555SFei.Feng@Sun.COM  */
4977555SFei.Feng@Sun.COM #define	FH_MEM_DM_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xEE0)
4987555SFei.Feng@Sun.COM #define	FH_MEM_DM_UPPER_BOUND	(FH_MEM_LOWER_BOUND + 0xEF0)
4997555SFei.Feng@Sun.COM #define	FH_MEM_DM_CONTROL_MASK_REG	(FH_MEM_DM_LOWER_BOUND)
5007555SFei.Feng@Sun.COM #define	FH_MEM_DM_CONTROL_START_REG	(FH_MEM_DM_LOWER_BOUND + 0x004)
5017555SFei.Feng@Sun.COM #define	FH_MEM_DM_CONTROL_STATUS_REG	(FH_MEM_DM_LOWER_BOUND + 0x008)
5027555SFei.Feng@Sun.COM #define	FH_MEM_DM_MONITOR_REG	(FH_MEM_DM_LOWER_BOUND + 0x00C)
5037555SFei.Feng@Sun.COM 
5047555SFei.Feng@Sun.COM #define	FH_TB1_ADDR_LOW_MASK	(0xFFFFFFFF)	/* bits 31:0 */
5057555SFei.Feng@Sun.COM #define	FH_TB1_ADDR_HIGH_MASK	(0xF00000000)	/* bits 35:32 */
5067555SFei.Feng@Sun.COM #define	FH_TB2_ADDR_LOW_MASK	(0x0000FFFF)	/* bits 15:0 */
5077555SFei.Feng@Sun.COM #define	FH_TB2_ADDR_HIGH_MASK	(0xFFFFF0000)	/* bits 35:16 */
5087555SFei.Feng@Sun.COM 
5097555SFei.Feng@Sun.COM #define	FH_TB1_ADDR_LOW_BITSHIFT	(0)
5107555SFei.Feng@Sun.COM #define	FH_TB1_ADDR_HIGH_BITSHIFT	(32)
5117555SFei.Feng@Sun.COM #define	FH_TB2_ADDR_LOW_BITSHIFT	(0)
5127555SFei.Feng@Sun.COM #define	FH_TB2_ADDR_HIGH_BITSHIFT	(16)
5137555SFei.Feng@Sun.COM 
5147555SFei.Feng@Sun.COM #define	FH_TB1_LENGTH_MASK	(0x00000FFF)	/* bits 11:0 */
5157555SFei.Feng@Sun.COM #define	FH_TB2_LENGTH_MASK	(0x00000FFF)	/* bits 11:0 */
5167555SFei.Feng@Sun.COM 
5177555SFei.Feng@Sun.COM /*
5187555SFei.Feng@Sun.COM  * number of FH channels including 2 service mode
5197555SFei.Feng@Sun.COM  */
5207555SFei.Feng@Sun.COM #define	NUM_OF_FH_CHANNELS	(10)
5217555SFei.Feng@Sun.COM 
5227555SFei.Feng@Sun.COM /*
5237555SFei.Feng@Sun.COM  * ctrl field bitology
5247555SFei.Feng@Sun.COM  */
5257555SFei.Feng@Sun.COM #define	FH_TFD_CTRL_PADDING_MASK	(0xC0000000)	/* bits 31:30 */
5267555SFei.Feng@Sun.COM #define	FH_TFD_CTRL_NUMTB_MASK		(0x1F000000)	/* bits 28:24 */
5277555SFei.Feng@Sun.COM 
5287555SFei.Feng@Sun.COM #define	FH_TFD_CTRL_PADDING_BITSHIFT	(30)
5297555SFei.Feng@Sun.COM #define	FH_TFD_CTRL_NUMTB_BITSHIFT	(24)
5307555SFei.Feng@Sun.COM 
5317555SFei.Feng@Sun.COM #define	FH_TFD_GET_NUM_TBS(ctrl) \
5327555SFei.Feng@Sun.COM 	((ctrl & FH_TFD_CTRL_NUMTB_MASK) >> FH_TFD_CTRL_NUMTB_BITSHIFT)
5337555SFei.Feng@Sun.COM #define	FH_TFD_GET_PADDING(ctrl) \
5347555SFei.Feng@Sun.COM 	((ctrl & FH_TFD_CTRL_PADDING_MASK) >> FH_TFD_CTRL_PADDING_BITSHIFT)
5357555SFei.Feng@Sun.COM 
5367555SFei.Feng@Sun.COM /*
5377555SFei.Feng@Sun.COM  * TCSR: tx_config register values
5387555SFei.Feng@Sun.COM  */
5397555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF	(0x00000000)
5407555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER	(0x00000001)
5417555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_ARC	(0x00000002)
5427555SFei.Feng@Sun.COM 
5437555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL	(0x00000008)
5447555SFei.Feng@Sun.COM 
5457555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT	(0x00000000)
5467555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD	(0x00200000)
5477555SFei.Feng@Sun.COM 
5487555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT		(0x00000000)
5497555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD	(0x00400000)
5507555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD		(0x00800000)
5517555SFei.Feng@Sun.COM 
5527555SFei.Feng@Sun.COM 
5537555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY	(0x00000000)
5547555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT	(0x00002000)
5557555SFei.Feng@Sun.COM 
5567555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR	(0x00000001)
5577555SFei.Feng@Sun.COM 
5587555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM	(20)
5597555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX	(12)
5607555SFei.Feng@Sun.COM 
5617555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID	(0x00000003)
5627555SFei.Feng@Sun.COM 
5637555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE	(0x80000000)
5647555SFei.Feng@Sun.COM 
5657555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL	(0x00000000)
5667555SFei.Feng@Sun.COM 
5677555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD		(0x00100000)
5687555SFei.Feng@Sun.COM 
5697555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE	(0x00000000)
5707555SFei.Feng@Sun.COM 
5717555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_LOWER_BOUND	(FH_MEM_LOWER_BOUND + 0xD00)
5727555SFei.Feng@Sun.COM 
5737555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl)\
5747555SFei.Feng@Sun.COM 	(IWH_FH_TCSR_LOWER_BOUND + 0x20 * _chnl)
5757555SFei.Feng@Sun.COM 
5767555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_TX_CREDIT_REG(_chnl)\
5777555SFei.Feng@Sun.COM 	(IWH_FH_TCSR_LOWER_BOUND + 0x20 * _chnl + 0x4)
5787555SFei.Feng@Sun.COM 
5797555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_TX_BUF_STS_REG(_chnl)\
5807555SFei.Feng@Sun.COM 	(IWH_FH_TCSR_LOWER_BOUND + 0x20 * _chnl + 0x8)
5817555SFei.Feng@Sun.COM #define	IWH_FH_TCSR_CHNL_NUM		(7)
5827555SFei.Feng@Sun.COM 
5837555SFei.Feng@Sun.COM /*
5847555SFei.Feng@Sun.COM  * CBB table
5857555SFei.Feng@Sun.COM  */
5867555SFei.Feng@Sun.COM #define	FH_CBB_ADDR_MASK	0x0FFFFFFF	/* bits 27:0 */
5877555SFei.Feng@Sun.COM #define	FH_CBB_ADDR_BIT_SHIFT	(8)
5887555SFei.Feng@Sun.COM 
5897555SFei.Feng@Sun.COM /*
5907555SFei.Feng@Sun.COM  * RCSR:  channel 0 rx_config register defines
5917555SFei.Feng@Sun.COM  */
5927555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MASK (0xC0000000) /* bits 30-31 */
5937555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MASK (0x00F00000) /* bits 20-23 */
5947555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MASK (0x00030000) /* bits 16-17 */
5957555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MASK (0x00008000) /* bit 15 */
5967555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MASK (0x00001000) /* bit 12 */
5977555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MASK (0x00000FF0) /* bit 4-11 */
5987555SFei.Feng@Sun.COM 
5997555SFei.Feng@Sun.COM #define	FH_RCSR_RX_CONFIG_RBDCB_SIZE_BITSHIFT	(20)
6007555SFei.Feng@Sun.COM #define	FH_RCSR_RX_CONFIG_RB_SIZE_BITSHIFT	(16)
6017555SFei.Feng@Sun.COM 
6027555SFei.Feng@Sun.COM #define	FH_RCSR_GET_RDBC_SIZE(reg) \
6037555SFei.Feng@Sun.COM 	((reg & FH_RCSR_RX_CONFIG_RDBC_SIZE_MASK) >> \
6047555SFei.Feng@Sun.COM 	FH_RCSR_RX_CONFIG_RDBC_SIZE_BITSHIFT)
6057555SFei.Feng@Sun.COM 
6067555SFei.Feng@Sun.COM /*
6077555SFei.Feng@Sun.COM  * RCSR:  channel 1 rx_config register defines
6087555SFei.Feng@Sun.COM  */
6097555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL1_RX_CONFIG_DMA_CHNL_EN_MASK  (0xC0000000) /* bits 30-31 */
6107555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_MASK	  (0x00003000) /* bits 12-13 */
6117555SFei.Feng@Sun.COM 
6127555SFei.Feng@Sun.COM /*
6137555SFei.Feng@Sun.COM  * RCSR: rx_config register values
6147555SFei.Feng@Sun.COM  */
6157555SFei.Feng@Sun.COM #define	FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL	(0x00000000)
6167555SFei.Feng@Sun.COM #define	FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL	(0x40000000)
6177555SFei.Feng@Sun.COM #define	FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL	(0x80000000)
6187555SFei.Feng@Sun.COM #define	FH_RCSR_RX_CONFIG_SINGLE_FRAME_MODE	(0x00008000)
6197555SFei.Feng@Sun.COM 
6207555SFei.Feng@Sun.COM #define	FH_RCSR_RX_CONFIG_RDRBD_DISABLE_VAL	(0x00000000)
6217555SFei.Feng@Sun.COM #define	FH_RCSR_RX_CONFIG_RDRBD_ENABLE_VAL	(0x20000000)
6227555SFei.Feng@Sun.COM 
6237555SFei.Feng@Sun.COM #define	IWH_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K	(0x00000000)
62410266SQuaker.Fang@Sun.COM #define	IWH_TX_RTS_RETRY_LIMIT		(60)
62510266SQuaker.Fang@Sun.COM #define	IWH_TX_DATA_RETRY_LIMIT		(15)
62610266SQuaker.Fang@Sun.COM 
62710266SQuaker.Fang@Sun.COM #define	IWH_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K	(0x00010000)
62810266SQuaker.Fang@Sun.COM #define	IWH_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K	(0x00020000)
62910266SQuaker.Fang@Sun.COM #define	IWH_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K	(0x00030000)
6307555SFei.Feng@Sun.COM 
6317555SFei.Feng@Sun.COM /*
6327555SFei.Feng@Sun.COM  * RCSR channel 0 config register values
6337555SFei.Feng@Sun.COM  */
6347555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL	(0x00000000)
6357555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL	(0x00001000)
6367555SFei.Feng@Sun.COM 
6377555SFei.Feng@Sun.COM /*
6387555SFei.Feng@Sun.COM  * RCSR channel 1 config register values
6397555SFei.Feng@Sun.COM  */
6407555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_NO_INT_VAL	(0x00000000)
6417555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_INT_HOST_VAL	(0x00001000)
6427555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_INT_RTC_VAL	(0x00002000)
6437555SFei.Feng@Sun.COM #define	FH_RCSR_CHNL1_RX_CONFIG_IRQ_DEST_INT_HOST_RTC_VAL (0x00003000)
6447555SFei.Feng@Sun.COM 
6457555SFei.Feng@Sun.COM /*
6467555SFei.Feng@Sun.COM  * RCSR: rb status register defines
6477555SFei.Feng@Sun.COM  */
6487555SFei.Feng@Sun.COM #define	FH_RCSR_RB_BYTE_TO_SEND_MASK	(0x0001FFFF)	/* bits 0-16 */
6497555SFei.Feng@Sun.COM 
6507555SFei.Feng@Sun.COM /*
6517555SFei.Feng@Sun.COM  * RSCSR: defs used in normal mode
6527555SFei.Feng@Sun.COM  */
6537555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL0_RBDCB_WPTR_MASK	(0x00000FFF)	/* bits 0-11 */
6547555SFei.Feng@Sun.COM 
6557555SFei.Feng@Sun.COM /*
6567555SFei.Feng@Sun.COM  * RSCSR: defs used in service mode
6577555SFei.Feng@Sun.COM  */
6587555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL1_SRAM_ADDR_MASK	(0x00FFFFFF)	/* bits 0-23 */
6597555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL1_RB_WPTR_MASK	(0x0FFFFFFF)	/* bits 0-27 */
6607555SFei.Feng@Sun.COM #define	FH_RSCSR_CHNL1_RB_WPTR_OFFSET_MASK	(0x000000FF)	/* bits 0-7 */
6617555SFei.Feng@Sun.COM 
6627555SFei.Feng@Sun.COM /*
6637555SFei.Feng@Sun.COM  * RSSR: RX Enable Error IRQ to Driver register defines
6647555SFei.Feng@Sun.COM  */
6657555SFei.Feng@Sun.COM #define	FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV_NO_RBD (0x00400000)	/* bit 22 */
6667555SFei.Feng@Sun.COM 
6677555SFei.Feng@Sun.COM #define	FH_DRAM2SRAM_DRAM_ADDR_HIGH_MASK	(0xFFFFFFF00)	/* bits 8-35 */
6687555SFei.Feng@Sun.COM #define	FH_DRAM2SRAM_DRAM_ADDR_LOW_MASK		(0x000000FF)	/* bits 0-7 */
6697555SFei.Feng@Sun.COM 
6707555SFei.Feng@Sun.COM #define	FH_DRAM2SRAM_DRAM_ADDR_HIGH_BITSHIFT	(8)	/* bits 8-35 */
6717555SFei.Feng@Sun.COM 
6727555SFei.Feng@Sun.COM /*
6737555SFei.Feng@Sun.COM  * RX DRAM status regs definitions
6747555SFei.Feng@Sun.COM  */
6757555SFei.Feng@Sun.COM #define	FH_RX_RB_NUM_MASK	(0x00000FFF)	/* bits 0-11 */
6767555SFei.Feng@Sun.COM #define	FH_RX_FRAME_NUM_MASK	(0x0FFF0000) /* bits 16-27 */
6777555SFei.Feng@Sun.COM 
6787555SFei.Feng@Sun.COM #define	FH_RX_RB_NUM_BITSHIFT	(0)
6797555SFei.Feng@Sun.COM #define	FH_RX_FRAME_NUM_BITSHIFT	(16)
6807555SFei.Feng@Sun.COM 
6817555SFei.Feng@Sun.COM /*
6827555SFei.Feng@Sun.COM  * Tx Scheduler
6837555SFei.Feng@Sun.COM  *
6847555SFei.Feng@Sun.COM  * The Tx Scheduler selects the next frame to be transmitted, chosing TFDs
6857555SFei.Feng@Sun.COM  * (Transmit Frame Descriptors) from up to 16 circular queues resident in
6867555SFei.Feng@Sun.COM  * host DRAM.  It steers each frame's Tx command (which contains the frame
6877555SFei.Feng@Sun.COM  * data) through one of up to 7 prioritized Tx DMA FIFO channels within the
6887555SFei.Feng@Sun.COM  * device.  A queue maps to only one (selectable by driver) Tx DMA channel,
6897555SFei.Feng@Sun.COM  * but one DMA channel may take input from several queues.
6907555SFei.Feng@Sun.COM  *
6917555SFei.Feng@Sun.COM  * Tx DMA channels have dedicated purposes.  For SP, and are used as follows:
6927555SFei.Feng@Sun.COM  * BMC TODO:  CONFIRM channel assignments, esp for 0/1
6937555SFei.Feng@Sun.COM  *
6947555SFei.Feng@Sun.COM  * 0 -- EDCA BK (background) frames, lowest priority
6957555SFei.Feng@Sun.COM  * 1 -- EDCA BE (best effort) frames, normal priority
6967555SFei.Feng@Sun.COM  * 2 -- EDCA VI (video) frames, higher priority
6977555SFei.Feng@Sun.COM  * 3 -- EDCA VO (voice) and management frames, highest priority
6987555SFei.Feng@Sun.COM  * 4 -- Commands (e.g. RXON, etc.)
6997555SFei.Feng@Sun.COM  * 5 -- HCCA short frames
7007555SFei.Feng@Sun.COM  * 6 -- HCCA long frames
7017555SFei.Feng@Sun.COM  * 7 -- not used by driver (device-internal only)
7027555SFei.Feng@Sun.COM  *
7037555SFei.Feng@Sun.COM  * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6.
7047555SFei.Feng@Sun.COM  * In addition, driver can map queues 7-15 to Tx DMA/FIFO channels 0-3 to
7057555SFei.Feng@Sun.COM  * support 11n aggregation via EDCA DMA channels. BMC confirm.
7067555SFei.Feng@Sun.COM  *
7077555SFei.Feng@Sun.COM  * The driver sets up each queue to work in one of two modes:
7087555SFei.Feng@Sun.COM  *
7097555SFei.Feng@Sun.COM  * 1)  Scheduler-Ack, in which the scheduler automatically supports a
7107555SFei.Feng@Sun.COM  *     block-ack (BA) window of up to 64 TFDs.  In this mode, each queue
7117555SFei.Feng@Sun.COM  *     contains TFDs for a unique combination of Recipient Address (RA)
7127555SFei.Feng@Sun.COM  *     and Traffic Identifier (TID), that is, traffic of a given
7137555SFei.Feng@Sun.COM  *     Quality-Of-Service (QOS) priority, destined for a single station.
7147555SFei.Feng@Sun.COM  *
7157555SFei.Feng@Sun.COM  *     In scheduler-ack mode, the scheduler keeps track of the Tx status of
7167555SFei.Feng@Sun.COM  *     each frame within the BA window, including whether it's been transmitted,
7177555SFei.Feng@Sun.COM  *     and whether it's been acknowledged by the receiving station.  The device
7187555SFei.Feng@Sun.COM  *     automatically processes block-acks received from the receiving STA,
7197555SFei.Feng@Sun.COM  *     and reschedules un-acked frames to be retransmitted (successful
7207555SFei.Feng@Sun.COM  *     Tx completion may end up being out-of-order).
7217555SFei.Feng@Sun.COM  *
7227555SFei.Feng@Sun.COM  *     The driver must maintain the queue's Byte Count table in host DRAM
7237555SFei.Feng@Sun.COM  *     (struct iwh_sched_queue_byte_cnt_tbl) for this mode.
7247555SFei.Feng@Sun.COM  *     This mode does not support fragmentation.
7257555SFei.Feng@Sun.COM  *
7267555SFei.Feng@Sun.COM  * 2)  FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order.
7277555SFei.Feng@Sun.COM  *     The device may automatically retry Tx, but will retry only one frame
7287555SFei.Feng@Sun.COM  *     at a time, until receiving ACK from receiving station, or reaching
7297555SFei.Feng@Sun.COM  *     retry limit and giving up.
7307555SFei.Feng@Sun.COM  *
7317555SFei.Feng@Sun.COM  *     The command queue (#4) must use this mode!
7327555SFei.Feng@Sun.COM  *     This mode does not require use of the Byte Count table in host DRAM.
7337555SFei.Feng@Sun.COM  *
7347555SFei.Feng@Sun.COM  * Driver controls scheduler operation via 3 means:
7357555SFei.Feng@Sun.COM  * 1)  Scheduler registers
7367555SFei.Feng@Sun.COM  * 2)  Shared scheduler data base in internal 4956 SRAM
7377555SFei.Feng@Sun.COM  * 3)  Shared data in host DRAM
7387555SFei.Feng@Sun.COM  *
7397555SFei.Feng@Sun.COM  * Initialization:
7407555SFei.Feng@Sun.COM  *
7417555SFei.Feng@Sun.COM  * When loading, driver should allocate memory for:
7427555SFei.Feng@Sun.COM  * 1)  16 TFD circular buffers, each with space for (typically) 256 TFDs.
7437555SFei.Feng@Sun.COM  * 2)  16 Byte Count circular buffers in 16 KBytes contiguous memory
7447555SFei.Feng@Sun.COM  *     (1024 bytes for each queue).
7457555SFei.Feng@Sun.COM  *
7467555SFei.Feng@Sun.COM  * After receiving "Alive" response from uCode, driver must initialize
7477555SFei.Feng@Sun.COM  * the following (especially for queue #4, the command queue, otherwise
7487555SFei.Feng@Sun.COM  * the driver can't issue commands!):
7497555SFei.Feng@Sun.COM  *
7507555SFei.Feng@Sun.COM  * 1)  SP's scheduler data base area in SRAM:
7517555SFei.Feng@Sun.COM  *     a)  Read SRAM address of data base area from SCD_SRAM_BASE_ADDR
7527555SFei.Feng@Sun.COM  *     b)  Clear and Init SCD_CONTEXT_DATA_OFFSET area (size 128 bytes)
7537555SFei.Feng@Sun.COM  *     c)  Clear SCD_TX_STTS_BITMAP_OFFSET area (size 256 bytes)
7547555SFei.Feng@Sun.COM  *     d)  Clear (BMC and init?) SCD_TRANSLATE_TBL_OFFSET (size 32 bytes)
7557555SFei.Feng@Sun.COM  *
7567555SFei.Feng@Sun.COM  * 2)  Init SCD_DRAM_BASE_ADDR with physical base of Tx byte count circular
7577555SFei.Feng@Sun.COM  *     buffer array, allocated by driver in host DRAM.
7587555SFei.Feng@Sun.COM  *
7597555SFei.Feng@Sun.COM  * 3)
7607555SFei.Feng@Sun.COM  */
7617555SFei.Feng@Sun.COM 
7627555SFei.Feng@Sun.COM /*
7637555SFei.Feng@Sun.COM  * Max Tx window size is the max number of contiguous TFDs that the scheduler
7647555SFei.Feng@Sun.COM  * can keep track of at one time when creating block-ack chains of frames.
7657555SFei.Feng@Sun.COM  * Note that "64" matches the number of ack bits in a block-ack.
7667555SFei.Feng@Sun.COM  * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize
7677555SFei.Feng@Sun.COM  * SCD_CONTEXT_QUEUE_OFFSET(x) values.
7687555SFei.Feng@Sun.COM  */
7697555SFei.Feng@Sun.COM #define	SCD_WIN_SIZE	64
7707555SFei.Feng@Sun.COM #define	SCD_FRAME_LIMIT	64
7717555SFei.Feng@Sun.COM 
7727555SFei.Feng@Sun.COM /*
7737555SFei.Feng@Sun.COM  * Driver may need to update queue-empty bits after changing queue's
7747555SFei.Feng@Sun.COM  * write and read pointers (indexes) during (re-)initialization (i.e. when
7757555SFei.Feng@Sun.COM  * scheduler is not tracking what's happening).
7767555SFei.Feng@Sun.COM  * Bit fields:
7777555SFei.Feng@Sun.COM  * 31-16:  Write mask -- 1: update empty bit, 0: don't change empty bit
7787555SFei.Feng@Sun.COM  * 15-00:  Empty state, one for each queue -- 1: empty, 0: non-empty
7797555SFei.Feng@Sun.COM  * NOTE BMC:  THIS REGISTER NOT USED BY LINUX DRIVER.
7807555SFei.Feng@Sun.COM  */
7817555SFei.Feng@Sun.COM #define	SCD_EMPTY_BITS	(SCD_START_OFFSET + 0x4)
7827555SFei.Feng@Sun.COM 
7837555SFei.Feng@Sun.COM /*
7847555SFei.Feng@Sun.COM  * Physical base address of array of byte count (BC) circular buffers (CBs).
7857555SFei.Feng@Sun.COM  * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode.
7867555SFei.Feng@Sun.COM  * This register points to BC CB for queue 0, must be on 1024-byte boundary.
7877555SFei.Feng@Sun.COM  * Others are spaced by 1024 bytes.
7887555SFei.Feng@Sun.COM  * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad.
7897555SFei.Feng@Sun.COM  * (Index into a queue's BC CB) = (index into queue's TFD CB) = (SSN & 0xff).
7907555SFei.Feng@Sun.COM  * Bit fields:
7917555SFei.Feng@Sun.COM  * 25-00:  Byte Count CB physical address [35:10], must be 1024-byte aligned.
7927555SFei.Feng@Sun.COM  */
7937555SFei.Feng@Sun.COM #define	SCD_AIT		(SCD_START_OFFSET + 0x18)
7947555SFei.Feng@Sun.COM 
7957555SFei.Feng@Sun.COM /*
7967555SFei.Feng@Sun.COM  * Queue (x) Write Pointers (indexes, really!), one for each Tx queue.
7977555SFei.Feng@Sun.COM  * Initialized and updated by driver as new TFDs are added to queue.
7987555SFei.Feng@Sun.COM  * NOTE:  If using Block Ack, index must correspond to frame's
7997555SFei.Feng@Sun.COM  *        Start Sequence Number; index = (SSN & 0xff)
8007555SFei.Feng@Sun.COM  * NOTE BMC:  Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses?
8017555SFei.Feng@Sun.COM  */
8027555SFei.Feng@Sun.COM #define	SCD_QUEUE_WRPTR(x)	(SCD_START_OFFSET + 0x24 + (x) * 4)
8037555SFei.Feng@Sun.COM 
8047555SFei.Feng@Sun.COM /*
8057555SFei.Feng@Sun.COM  * Queue (x) Read Pointers (indexes, really!), one for each Tx queue.
8067555SFei.Feng@Sun.COM  * For FIFO mode, index indicates next frame to transmit.
8077555SFei.Feng@Sun.COM  * For Scheduler-ACK mode, index indicates first frame in Tx window.
8087555SFei.Feng@Sun.COM  * Initialized by driver, updated by scheduler.
8097555SFei.Feng@Sun.COM  */
8107555SFei.Feng@Sun.COM #define	SCD_QUEUE_RDPTR(x)	(SCD_START_OFFSET + 0x64 + (x) * 4)
8117555SFei.Feng@Sun.COM #define	SCD_SETQUEUENUM		(SCD_START_OFFSET + 0xa4)
8127555SFei.Feng@Sun.COM #define	SCD_SET_TXSTAT_TXED	(SCD_START_OFFSET + 0xa8)
8137555SFei.Feng@Sun.COM #define	SCD_SET_TXSTAT_DONE	(SCD_START_OFFSET + 0xac)
8147555SFei.Feng@Sun.COM #define	SCD_SET_TXSTAT_NOT_SCHD	(SCD_START_OFFSET + 0xb0)
8157555SFei.Feng@Sun.COM #define	SCD_DECREASE_CREDIT	(SCD_START_OFFSET + 0xb4)
8167555SFei.Feng@Sun.COM #define	SCD_DECREASE_SCREDIT	(SCD_START_OFFSET + 0xb8)
8177555SFei.Feng@Sun.COM #define	SCD_LOAD_CREDIT		(SCD_START_OFFSET + 0xbc)
8187555SFei.Feng@Sun.COM #define	SCD_LOAD_SCREDIT	(SCD_START_OFFSET + 0xc0)
8197555SFei.Feng@Sun.COM #define	SCD_BAR			(SCD_START_OFFSET + 0xc4)
8207555SFei.Feng@Sun.COM #define	SCD_BAR_DW0		(SCD_START_OFFSET + 0xc8)
8217555SFei.Feng@Sun.COM #define	SCD_BAR_DW1		(SCD_START_OFFSET + 0xcc)
8227555SFei.Feng@Sun.COM 
8237555SFei.Feng@Sun.COM /*
8247555SFei.Feng@Sun.COM  * Select which queues work in chain mode (1) vs. not (0).
8257555SFei.Feng@Sun.COM  * Use chain mode to build chains of aggregated frames.
8267555SFei.Feng@Sun.COM  * Bit fields:
8277555SFei.Feng@Sun.COM  * 31-16:  Reserved
8287555SFei.Feng@Sun.COM  * 15-00:  Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time
8297555SFei.Feng@Sun.COM  * NOTE:  If driver sets up queue for chain mode, it should be also set up
8307555SFei.Feng@Sun.COM  *        Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x).
8317555SFei.Feng@Sun.COM  */
8327555SFei.Feng@Sun.COM #define	SCD_QUERY_REQ		(SCD_START_OFFSET + 0xd8)
8337555SFei.Feng@Sun.COM #define	SCD_QUERY_RES		(SCD_START_OFFSET + 0xdc)
8347555SFei.Feng@Sun.COM #define	SCD_PENDING_FRAMES	(SCD_START_OFFSET + 0xe0)
8357555SFei.Feng@Sun.COM 
8367555SFei.Feng@Sun.COM /*
8377555SFei.Feng@Sun.COM  * Select which queues interrupt driver when read pointer (index) increments.
8387555SFei.Feng@Sun.COM  * Bit fields:
8397555SFei.Feng@Sun.COM  * 31-16:  Reserved
8407555SFei.Feng@Sun.COM  * 15-00:  Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled
8417555SFei.Feng@Sun.COM  * NOTE BMC:  THIS FUNCTIONALITY IS APPARENTLY A NO-OP.
8427555SFei.Feng@Sun.COM  */
8437555SFei.Feng@Sun.COM #define	SCD_INTERRUPT_THRESHOLD	(SCD_START_OFFSET + 0xe8)
8447555SFei.Feng@Sun.COM #define	SCD_QUERY_MIN_FRAME_SIZE	(SCD_START_OFFSET + 0x100)
8457555SFei.Feng@Sun.COM 
8467555SFei.Feng@Sun.COM 
8477555SFei.Feng@Sun.COM /*
8487555SFei.Feng@Sun.COM  * SP internal SRAM structures for scheduler, shared with driver ...
8497555SFei.Feng@Sun.COM  * Driver should clear and initialize the following areas after receiving
8507555SFei.Feng@Sun.COM  * "Alive" response from SP uCode, i.e. after initial
8517555SFei.Feng@Sun.COM  * uCode load, or after a uCode load done for error recovery:
8527555SFei.Feng@Sun.COM  *
8537555SFei.Feng@Sun.COM  * SCD_CONTEXT_DATA_OFFSET (size 128 bytes)
8547555SFei.Feng@Sun.COM  * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes)
8557555SFei.Feng@Sun.COM  * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes)
8567555SFei.Feng@Sun.COM  *
8577555SFei.Feng@Sun.COM  * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR.
8587555SFei.Feng@Sun.COM  * All OFFSET values must be added to this base address.
8597555SFei.Feng@Sun.COM  * Use HBUS_TARG_MEM_* registers to access SRAM.
8607555SFei.Feng@Sun.COM  */
8617555SFei.Feng@Sun.COM 
8627555SFei.Feng@Sun.COM /*
8637555SFei.Feng@Sun.COM  * Queue context.  One 8-byte entry for each of 16 queues.
8647555SFei.Feng@Sun.COM  *
8657555SFei.Feng@Sun.COM  * Driver should clear this entire area (size 0x80) to 0 after receiving
8667555SFei.Feng@Sun.COM  * "Alive" notification from uCode.  Additionally, driver should init
8677555SFei.Feng@Sun.COM  * each queue's entry as follows:
8687555SFei.Feng@Sun.COM  *
8697555SFei.Feng@Sun.COM  * LS Dword bit fields:
8707555SFei.Feng@Sun.COM  *  0-06:  Max Tx window size for Scheduler-ACK.  Driver should init to 64.
8717555SFei.Feng@Sun.COM  *
8727555SFei.Feng@Sun.COM  * MS Dword bit fields:
8737555SFei.Feng@Sun.COM  * 16-22:  Frame limit.  Driver should init to 10 (0xa).
8747555SFei.Feng@Sun.COM  *
8757555SFei.Feng@Sun.COM  * Driver should init all other bits to 0.
8767555SFei.Feng@Sun.COM  *
8777555SFei.Feng@Sun.COM  * Init must be done after driver receives "Alive" response from SP uCode,
8787555SFei.Feng@Sun.COM  * and when setting up queue for aggregation.
8797555SFei.Feng@Sun.COM  */
8807555SFei.Feng@Sun.COM #define	SCD_CONTEXT_DATA_OFFSET		0x380
8817555SFei.Feng@Sun.COM 
8827555SFei.Feng@Sun.COM /*
8837555SFei.Feng@Sun.COM  * Tx Status Bitmap
8847555SFei.Feng@Sun.COM  *
8857555SFei.Feng@Sun.COM  * Driver should clear this entire area (size 0x100) to 0 after receiving
8867555SFei.Feng@Sun.COM  * "Alive" notification from uCode.  Area is used only by device itself;
8877555SFei.Feng@Sun.COM  * no other support (besides clearing) is required from driver.
8887555SFei.Feng@Sun.COM  */
8897555SFei.Feng@Sun.COM #define	SCD_TX_STTS_BITMAP_OFFSET	0x400
8907555SFei.Feng@Sun.COM 
8917555SFei.Feng@Sun.COM /*
8927555SFei.Feng@Sun.COM  * RAxTID to queue translation mapping.
8937555SFei.Feng@Sun.COM  *
8947555SFei.Feng@Sun.COM  * When queue is in Scheduler-ACK mode, frames placed in a that queue must be
8957555SFei.Feng@Sun.COM  * for only one combination of receiver address (RA) and traffic ID (TID), i.e.
8967555SFei.Feng@Sun.COM  * one QOS priority level destined for one station (for this link, not final
8977555SFei.Feng@Sun.COM  * destination).  The SCD_TRANSLATE_TABLE area provides 16 16-bit mappings,
8987555SFei.Feng@Sun.COM  * one for each of the 16 queues.  If queue is not in Scheduler-ACK mode, the
8997555SFei.Feng@Sun.COM  * device ignores the mapping value.
9007555SFei.Feng@Sun.COM  *
9017555SFei.Feng@Sun.COM  * Bit fields, for each 16-bit map:
9027555SFei.Feng@Sun.COM  * 15-9:  Reserved, set to 0
9037555SFei.Feng@Sun.COM  *  8-4:  Index into device's station table for recipient station
9047555SFei.Feng@Sun.COM  *  3-0:  Traffic ID (tid), range 0-15
9057555SFei.Feng@Sun.COM  *
9067555SFei.Feng@Sun.COM  * Driver should clear this entire area (size 32 bytes) to 0 after receiving
9077555SFei.Feng@Sun.COM  * "Alive" notification from uCode.  To update a 16-bit map value, driver
9087555SFei.Feng@Sun.COM  * must read a dword-aligned value from device SRAM, replace the 16-bit map
9097555SFei.Feng@Sun.COM  * value of interest, and write the dword value back into device SRAM.
9107555SFei.Feng@Sun.COM  */
9117555SFei.Feng@Sun.COM #define	SCD_TRANSLATE_TBL_OFFSET	0x500
9127555SFei.Feng@Sun.COM #define	SCD_CONTEXT_QUEUE_OFFSET(x)	(SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
9137555SFei.Feng@Sun.COM #define	SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
9147555SFei.Feng@Sun.COM 	((SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
9157555SFei.Feng@Sun.COM 
9167555SFei.Feng@Sun.COM /*
9177555SFei.Feng@Sun.COM  * Mask to enable contiguous Tx DMA/FIFO channels between "lo" and "hi".
9187555SFei.Feng@Sun.COM  */
9197555SFei.Feng@Sun.COM #define	SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \
9207555SFei.Feng@Sun.COM 	((1<<(hi))|((1<<(hi))-(1<<(lo))))
9217555SFei.Feng@Sun.COM 
9227555SFei.Feng@Sun.COM #define	SCD_MODE_REG_BIT_SEARCH_MODE		(1<<0)
9237555SFei.Feng@Sun.COM #define	SCD_MODE_REG_BIT_SBYP_MODE		(1<<1)
9247555SFei.Feng@Sun.COM 
9257555SFei.Feng@Sun.COM #define	SCD_TXFIFO_POS_TID			(0)
9267555SFei.Feng@Sun.COM #define	SCD_TXFIFO_POS_RA			(4)
9277555SFei.Feng@Sun.COM #define	SCD_QUEUE_STTS_REG_POS_SCD_ACK		(8)
9287555SFei.Feng@Sun.COM #define	SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN	(10)
9297555SFei.Feng@Sun.COM 
9307555SFei.Feng@Sun.COM #define	SCD_QUEUE_RA_TID_MAP_RATID_MSK		(0x01FF)
9317555SFei.Feng@Sun.COM 
9327555SFei.Feng@Sun.COM #define	SCD_QUEUE_CTX_REG1_WIN_SIZE_POS		(0)
9337555SFei.Feng@Sun.COM #define	SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK		(0x0000007F)
9347555SFei.Feng@Sun.COM #define	SCD_QUEUE_CTX_REG1_CREDIT_POS		(8)
9357555SFei.Feng@Sun.COM #define	SCD_QUEUE_CTX_REG1_CREDIT_MSK		(0x00FFFF00)
9367555SFei.Feng@Sun.COM #define	SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS	(24)
9377555SFei.Feng@Sun.COM #define	SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK	(0xFF000000)
9387555SFei.Feng@Sun.COM #define	SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS	(16)
9397555SFei.Feng@Sun.COM #define	SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK	(0x007F0000)
9407555SFei.Feng@Sun.COM 
9417555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BIT_KEDRON_R	(0x00000010)
9427555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER	(0x00000C00)
9437555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BIT_MAC_SI		(0x00000100)
9447555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI	(0x00000200)
9457555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_EEP_SEM		(0x00200000)
9467555SFei.Feng@Sun.COM #define	IWH_CSR_ANA_PLL_CFG			(0x00880300)
947*11531SFei.Feng@Sun.COM #define	CSR_DBG_HPET_MEM_REG_VAL		(0xFFFF0000)
9487555SFei.Feng@Sun.COM 
9497555SFei.Feng@Sun.COM /* IWH-END */
9507555SFei.Feng@Sun.COM 
9517555SFei.Feng@Sun.COM 
9527555SFei.Feng@Sun.COM #define	STATISTICS_FLG_CLEAR				(0x1)
9537555SFei.Feng@Sun.COM #define	STATISTICS_FLG_DISABLE_NOTIFICATION		(0x2)
9547555SFei.Feng@Sun.COM 
9557555SFei.Feng@Sun.COM #define	STATISTICS_REPLY_FLG_CLEAR			(0x1)
9567555SFei.Feng@Sun.COM #define	STATISTICS_REPLY_FLG_BAND_24G_MSK		(0x2)
9577555SFei.Feng@Sun.COM #define	STATISTICS_REPLY_FLG_TGJ_NARROW_BAND_MSK	(0x4)
9587555SFei.Feng@Sun.COM #define	STATISTICS_REPLY_FLG_FAT_MODE_MSK		(0x8)
9597555SFei.Feng@Sun.COM #define	RX_PHY_FLAGS_ANTENNAE_OFFSET			(4)
9607555SFei.Feng@Sun.COM #define	RX_PHY_FLAGS_ANTENNAE_MASK			(0x70)
9617555SFei.Feng@Sun.COM 
9627555SFei.Feng@Sun.COM /*
9637555SFei.Feng@Sun.COM  * Register and values
9647555SFei.Feng@Sun.COM  */
9657555SFei.Feng@Sun.COM #define	CSR_BASE	(0x0)
9667555SFei.Feng@Sun.COM #define	HBUS_BASE	(0x400)
9677555SFei.Feng@Sun.COM 
9687555SFei.Feng@Sun.COM #define	HBUS_TARG_MBX_C	(HBUS_BASE+0x030)
9697555SFei.Feng@Sun.COM 
9707555SFei.Feng@Sun.COM /*
9717555SFei.Feng@Sun.COM  * CSR (control and status registers)
9727555SFei.Feng@Sun.COM  */
9737555SFei.Feng@Sun.COM #define	CSR_SW_VER		(CSR_BASE+0x000)
9747555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG	(CSR_BASE+0x000) /* hardware interface config */
9757555SFei.Feng@Sun.COM #define	CSR_INT_COALESCING	(CSR_BASE+0x004) /* accum ints, 32-usec units */
9767555SFei.Feng@Sun.COM #define	CSR_INT		(CSR_BASE+0x008) /* host interrupt status/ack */
9777555SFei.Feng@Sun.COM #define	CSR_INT_MASK	(CSR_BASE+0x00c) /* host interrupt enable */
9787555SFei.Feng@Sun.COM #define	CSR_FH_INT_STATUS	(CSR_BASE+0x010) /* busmaster int status/ack */
9797555SFei.Feng@Sun.COM #define	CSR_GPIO_IN	(CSR_BASE+0x018) /* read external chip pins */
9807555SFei.Feng@Sun.COM #define	CSR_RESET	(CSR_BASE+0x020) /* busmaster enable, NMI, etc */
9817555SFei.Feng@Sun.COM #define	CSR_GP_CNTRL	(CSR_BASE+0x024)
9827555SFei.Feng@Sun.COM #define	CSR_HW_REV	(CSR_BASE+0x028)
9837555SFei.Feng@Sun.COM #define	CSR_EEPROM_REG	(CSR_BASE+0x02c)
9847555SFei.Feng@Sun.COM #define	CSR_EEPROM_GP	(CSR_BASE+0x030)
9857555SFei.Feng@Sun.COM #define	CSR_UCODE_DRV_GP1	(CSR_BASE+0x054)
9867555SFei.Feng@Sun.COM #define	CSR_UCODE_DRV_GP1_SET	(CSR_BASE+0x058)
9877555SFei.Feng@Sun.COM #define	CSR_UCODE_DRV_GP1_CLR	(CSR_BASE+0x05c)
9887555SFei.Feng@Sun.COM #define	CSR_UCODE_DRV_GP2	(CSR_BASE+0x060)
9897555SFei.Feng@Sun.COM #define	CSR_GIO_CHICKEN_BITS	(CSR_BASE+0x100)
9907555SFei.Feng@Sun.COM #define	CSR_ANA_PLL_CFG		(CSR_BASE+0x20c)
9917555SFei.Feng@Sun.COM #define	CSR_HW_REV_WA_REG	(CSR_BASE+0x22C)
992*11531SFei.Feng@Sun.COM #define	CSR_DBG_HPET_MEM_REG	(CSR_BASE+0x240)
9937555SFei.Feng@Sun.COM 
9947555SFei.Feng@Sun.COM /*
9957555SFei.Feng@Sun.COM  * BSM (Bootstrap State Machine)
9967555SFei.Feng@Sun.COM  */
9977555SFei.Feng@Sun.COM #define	BSM_BASE		(CSR_BASE + 0x3400)
9987555SFei.Feng@Sun.COM 
9997555SFei.Feng@Sun.COM #define	BSM_WR_CTRL_REG  	(BSM_BASE + 0x000) /* ctl and status */
10007555SFei.Feng@Sun.COM #define	BSM_WR_MEM_SRC_REG 	(BSM_BASE + 0x004) /* source in BSM mem */
10017555SFei.Feng@Sun.COM #define	BSM_WR_MEM_DST_REG 	(BSM_BASE + 0x008) /* dest in SRAM mem */
10027555SFei.Feng@Sun.COM #define	BSM_WR_DWCOUNT_REG 	(BSM_BASE + 0x00C) /* bytes */
10037555SFei.Feng@Sun.COM #define	BSM_WR_STATUS_REG	(BSM_BASE + 0x010) /* bit 0:  1 == done */
10047555SFei.Feng@Sun.COM 
10057555SFei.Feng@Sun.COM /*
10067555SFei.Feng@Sun.COM  * BSM special memory, stays powered during power-save sleeps
10077555SFei.Feng@Sun.COM  */
10087555SFei.Feng@Sun.COM #define	BSM_SRAM_LOWER_BOUND	(CSR_BASE + 0x3800)
10097555SFei.Feng@Sun.COM #define	BSM_SRAM_SIZE		(1024)
10107555SFei.Feng@Sun.COM 
10117555SFei.Feng@Sun.COM 
10127555SFei.Feng@Sun.COM /*
10137555SFei.Feng@Sun.COM  * card static random access memory (SRAM) for processor data and instructs
10147555SFei.Feng@Sun.COM  */
10157555SFei.Feng@Sun.COM #define	RTC_INST_LOWER_BOUND		(0x00000)
10167555SFei.Feng@Sun.COM #define	ALM_RTC_INST_UPPER_BOUND 	(0x14000)
10177555SFei.Feng@Sun.COM 
10187555SFei.Feng@Sun.COM #define	RTC_DATA_LOWER_BOUND		(0x800000)
10197555SFei.Feng@Sun.COM #define	ALM_RTC_DATA_UPPER_BOUND	(0x808000)
10207555SFei.Feng@Sun.COM 
10217555SFei.Feng@Sun.COM /*
10227555SFei.Feng@Sun.COM  * HBUS (Host-side bus)
10237555SFei.Feng@Sun.COM  */
10247555SFei.Feng@Sun.COM #define	HBUS_TARG_MEM_RADDR 	(HBUS_BASE+0x00c)
10257555SFei.Feng@Sun.COM #define	HBUS_TARG_MEM_WADDR 	(HBUS_BASE+0x010)
10267555SFei.Feng@Sun.COM #define	HBUS_TARG_MEM_WDAT	(HBUS_BASE+0x018)
10277555SFei.Feng@Sun.COM #define	HBUS_TARG_MEM_RDAT	(HBUS_BASE+0x01c)
10287555SFei.Feng@Sun.COM #define	HBUS_TARG_PRPH_WADDR	(HBUS_BASE+0x044)
10297555SFei.Feng@Sun.COM #define	HBUS_TARG_PRPH_RADDR	(HBUS_BASE+0x048)
10307555SFei.Feng@Sun.COM #define	HBUS_TARG_PRPH_WDAT 	(HBUS_BASE+0x04c)
10317555SFei.Feng@Sun.COM #define	HBUS_TARG_PRPH_RDAT 	(HBUS_BASE+0x050)
10327555SFei.Feng@Sun.COM #define	HBUS_TARG_WRPTR		(HBUS_BASE+0x060)
10337555SFei.Feng@Sun.COM 
10347555SFei.Feng@Sun.COM /*
10357555SFei.Feng@Sun.COM  * HW I/F configuration
10367555SFei.Feng@Sun.COM  */
10377555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MB	(0x00000100)
10387555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MM	(0x00000200)
10397555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BIT_SKU_MRC	(0x00000400)
10407555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BIT_BOARD_TYPE	(0x00000800)
10417555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A	(0x00000000)
10427555SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B	(0x00001000)
1043*11531SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BITS_NIC_READY		(0x00400000)
1044*11531SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BITS_HAP_WAKE_L1A		(0x00080000)
1045*11531SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BITS_NIC_PREPARE_DONE	(0x02000000)
1046*11531SFei.Feng@Sun.COM #define	CSR_HW_IF_CONFIG_REG_BITS_PREPARE		(0x08000000)
10477555SFei.Feng@Sun.COM 
10487555SFei.Feng@Sun.COM #define	CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP    	(0x00000001)
10497555SFei.Feng@Sun.COM #define	CSR_UCODE_SW_BIT_RFKILL			(0x00000002)
10507555SFei.Feng@Sun.COM #define	CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED   	(0x00000004)
10517555SFei.Feng@Sun.COM #define	CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT	(0x00000008)
10527555SFei.Feng@Sun.COM 
10537555SFei.Feng@Sun.COM #define	CSR_GPIO_IN_BIT_AUX_POWER	(0x00000200)
10547555SFei.Feng@Sun.COM #define	CSR_GPIO_IN_VAL_VAUX_PWR_SRC	(0x00000000)
10557555SFei.Feng@Sun.COM #define	CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX  (0x00800000)
10567555SFei.Feng@Sun.COM #define	CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER  (0x20000000)
10577555SFei.Feng@Sun.COM #define	CSR_GPIO_IN_VAL_VMAIN_PWR_SRC	CSR_GPIO_IN_BIT_AUX_POWER
10587555SFei.Feng@Sun.COM 
10597555SFei.Feng@Sun.COM #define	PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT	(0x80000000)
10607555SFei.Feng@Sun.COM 
10617555SFei.Feng@Sun.COM /*
10627555SFei.Feng@Sun.COM  * interrupt flags in INTA, set by uCode or hardware (e.g. dma),
10637555SFei.Feng@Sun.COM  * acknowledged (reset) by host writing "1" to flagged bits.
10647555SFei.Feng@Sun.COM  */
10657555SFei.Feng@Sun.COM #define	BIT_INT_FH_RX \
10667555SFei.Feng@Sun.COM 	(((uint32_t)1) << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
10677555SFei.Feng@Sun.COM #define	BIT_INT_ERR	(1<<29) /* DMA hardware error FH_INT[31] */
10687555SFei.Feng@Sun.COM #define	BIT_INT_FH_TX	(1<<27) /* Tx DMA FH_INT[1:0] */
10697555SFei.Feng@Sun.COM #define	BIT_INT_MAC_CLK_ACTV (1<<26) /* NIC controller's clock toggled on/off */
10707555SFei.Feng@Sun.COM #define	BIT_INT_SWERROR	(1<<25) /* uCode error */
10717555SFei.Feng@Sun.COM #define	BIT_INT_RF_KILL	(1<<7)  /* HW RFKILL switch GP_CNTRL[27] toggled */
10727555SFei.Feng@Sun.COM #define	BIT_INT_CT_KILL	(1<<6)  /* Critical temp (chip too hot) rfkill */
10737555SFei.Feng@Sun.COM #define	BIT_INT_SW_RX 	(1<<3)  /* Rx, command responses, 3945 */
10747555SFei.Feng@Sun.COM #define	BIT_INT_WAKEUP 	(1<<1)  /* NIC controller waking up (pwr mgmt) */
10757555SFei.Feng@Sun.COM #define	BIT_INT_ALIVE 	(1<<0)  /* uCode interrupts once it initializes */
10767555SFei.Feng@Sun.COM 
10777555SFei.Feng@Sun.COM #define	CSR_INI_SET_MASK	(BIT_INT_FH_RX   |  \
10787555SFei.Feng@Sun.COM 				BIT_INT_ERR |      \
10797555SFei.Feng@Sun.COM 				BIT_INT_FH_TX   |  \
10807555SFei.Feng@Sun.COM 				BIT_INT_SWERROR |  \
10817555SFei.Feng@Sun.COM 				BIT_INT_RF_KILL |  \
10827555SFei.Feng@Sun.COM 				BIT_INT_SW_RX   |  \
10837555SFei.Feng@Sun.COM 				BIT_INT_WAKEUP  |  \
10847555SFei.Feng@Sun.COM 				BIT_INT_ALIVE)
10857555SFei.Feng@Sun.COM 
10867555SFei.Feng@Sun.COM /*
10877555SFei.Feng@Sun.COM  * interrupt flags in FH (flow handler) (PCI busmaster DMA)
10887555SFei.Feng@Sun.COM  */
10897555SFei.Feng@Sun.COM #define	BIT_FH_INT_ERR		(((uint32_t)1) << 31) /* Error */
10907555SFei.Feng@Sun.COM #define	BIT_FH_INT_HI_PRIOR	(1<<30) /* High priority Rx,bypass coalescing */
10917555SFei.Feng@Sun.COM #define	BIT_FH_INT_RX_CHNL2	(1<<18) /* Rx channel 2 (3945 only) */
10927555SFei.Feng@Sun.COM #define	BIT_FH_INT_RX_CHNL1	(1<<17) /* Rx channel 1 */
10937555SFei.Feng@Sun.COM #define	BIT_FH_INT_RX_CHNL0	(1<<16) /* Rx channel 0 */
10947555SFei.Feng@Sun.COM #define	BIT_FH_INT_TX_CHNL6	(1<<6)  /* Tx channel 6 (3945 only) */
10957555SFei.Feng@Sun.COM #define	BIT_FH_INT_TX_CHNL1	(1<<1)  /* Tx channel 1 */
10967555SFei.Feng@Sun.COM #define	BIT_FH_INT_TX_CHNL0	(1<<0)  /* Tx channel 0 */
10977555SFei.Feng@Sun.COM 
10987555SFei.Feng@Sun.COM #define	FH_INT_RX_MASK		(BIT_FH_INT_HI_PRIOR |  \
10997555SFei.Feng@Sun.COM 				BIT_FH_INT_RX_CHNL1 |  \
11007555SFei.Feng@Sun.COM 				BIT_FH_INT_RX_CHNL0)
11017555SFei.Feng@Sun.COM 
11027555SFei.Feng@Sun.COM #define	FH_INT_TX_MASK		(BIT_FH_INT_TX_CHNL6 |  \
11037555SFei.Feng@Sun.COM 				BIT_FH_INT_TX_CHNL1 |  \
11047555SFei.Feng@Sun.COM 				BIT_FH_INT_TX_CHNL0)
11057555SFei.Feng@Sun.COM 
11067555SFei.Feng@Sun.COM /*
11077555SFei.Feng@Sun.COM  * RESET
11087555SFei.Feng@Sun.COM  */
11097555SFei.Feng@Sun.COM #define	CSR_RESET_REG_FLAG_NEVO_RESET		(0x00000001)
11107555SFei.Feng@Sun.COM #define	CSR_RESET_REG_FLAG_FORCE_NMI		(0x00000002)
11117555SFei.Feng@Sun.COM #define	CSR_RESET_REG_FLAG_SW_RESET		(0x00000080)
11127555SFei.Feng@Sun.COM #define	CSR_RESET_REG_FLAG_MASTER_DISABLED	(0x00000100)
11137555SFei.Feng@Sun.COM #define	CSR_RESET_REG_FLAG_STOP_MASTER  	(0x00000200)
11147555SFei.Feng@Sun.COM 
11157555SFei.Feng@Sun.COM /*
11167555SFei.Feng@Sun.COM  * GP (general purpose) CONTROL
11177555SFei.Feng@Sun.COM  */
11187555SFei.Feng@Sun.COM #define	CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY	(0x00000001)
11197555SFei.Feng@Sun.COM #define	CSR_GP_CNTRL_REG_FLAG_INIT_DONE   	(0x00000004)
11207555SFei.Feng@Sun.COM #define	CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ 	(0x00000008)
11217555SFei.Feng@Sun.COM #define	CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP 	(0x00000010)
11227555SFei.Feng@Sun.COM 
11237555SFei.Feng@Sun.COM #define	CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN	(0x00000001)
11247555SFei.Feng@Sun.COM 
11257555SFei.Feng@Sun.COM #define	CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE	(0x07000000)
11267555SFei.Feng@Sun.COM #define	CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE	(0x04000000)
11277555SFei.Feng@Sun.COM #define	CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW 	(0x08000000)
11287555SFei.Feng@Sun.COM 
11297555SFei.Feng@Sun.COM /*
11307555SFei.Feng@Sun.COM  * APMG (power management) constants
11317555SFei.Feng@Sun.COM  */
11327555SFei.Feng@Sun.COM #define	APMG_CLK_CTRL_REG  	(0x003000)
11337555SFei.Feng@Sun.COM #define	ALM_APMG_CLK_EN  	(0x003004)
11347555SFei.Feng@Sun.COM #define	ALM_APMG_CLK_DIS   	(0x003008)
11357555SFei.Feng@Sun.COM #define	ALM_APMG_PS_CTL    	(0x00300c)
11367555SFei.Feng@Sun.COM #define	ALM_APMG_PCIDEV_STT	(0x003010)
11377555SFei.Feng@Sun.COM #define	ALM_APMG_RFKILL    	(0x003014)
11387555SFei.Feng@Sun.COM #define	ALM_APMG_LARC_INT 	(0x00301c)
11397555SFei.Feng@Sun.COM #define	ALM_APMG_LARC_INT_MSK	(0x003020)
11407555SFei.Feng@Sun.COM 
11417555SFei.Feng@Sun.COM #define	APMG_CLK_REG_VAL_DMA_CLK_RQT	(0x00000200)
11427555SFei.Feng@Sun.COM #define	APMG_CLK_REG_VAL_BSM_CLK_RQT	(0x00000800)
11437555SFei.Feng@Sun.COM 
11447555SFei.Feng@Sun.COM #define	APMG_PS_CTRL_REG_VAL_ALM_R_RESET_REQ	(0x04000000)
11457555SFei.Feng@Sun.COM 
11467555SFei.Feng@Sun.COM #define	APMG_DEV_STATE_REG_VAL_L1_ACTIVE_DISABLE	(0x00000800)
11477555SFei.Feng@Sun.COM 
11487555SFei.Feng@Sun.COM #define	APMG_PS_CTRL_REG_MSK_POWER_SRC		(0x03000000)
11497555SFei.Feng@Sun.COM #define	APMG_PS_CTRL_REG_VAL_POWER_SRC_VMAIN	(0x00000000)
11507555SFei.Feng@Sun.COM #define	APMG_PS_CTRL_REG_VAL_POWER_SRC_VAUX	(0x01000000)
11517555SFei.Feng@Sun.COM 
11527555SFei.Feng@Sun.COM /*
11537555SFei.Feng@Sun.COM  * BSM (bootstrap state machine)
11547555SFei.Feng@Sun.COM  */
11557555SFei.Feng@Sun.COM /*
11567555SFei.Feng@Sun.COM  * start boot load now
11577555SFei.Feng@Sun.COM  */
11587555SFei.Feng@Sun.COM #define	BSM_WR_CTRL_REG_BIT_START	(0x80000000)
11597555SFei.Feng@Sun.COM /*
11607555SFei.Feng@Sun.COM  * enable boot after power up
11617555SFei.Feng@Sun.COM  */
11627555SFei.Feng@Sun.COM #define	BSM_WR_CTRL_REG_BIT_START_EN	(0x40000000)
11637555SFei.Feng@Sun.COM 
11647555SFei.Feng@Sun.COM /*
11657555SFei.Feng@Sun.COM  * DBM
11667555SFei.Feng@Sun.COM  */
11677555SFei.Feng@Sun.COM #define	ALM_FH_SRVC_CHNL				(6)
11687555SFei.Feng@Sun.COM #define	IWH_FH_SRVC_LOWER_BOUND		(IWH_FH_REGS_LOWER_BOUND + 0x9C8)
11697555SFei.Feng@Sun.COM #define	IWH_FH_SRVC_CHNL		(9)
11707555SFei.Feng@Sun.COM 
11717555SFei.Feng@Sun.COM 
11727555SFei.Feng@Sun.COM #define	IWH_FH_SRVC_CHNL_SRAM_ADDR_REG(_chnl)\
11737555SFei.Feng@Sun.COM 	(IWH_FH_SRVC_LOWER_BOUND + (_chnl - 9) * 0x4)
11747555SFei.Feng@Sun.COM 
11757555SFei.Feng@Sun.COM #define	ALM_FH_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE		(20)
11767555SFei.Feng@Sun.COM #define	ALM_FH_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH		(4)
11777555SFei.Feng@Sun.COM 
11787555SFei.Feng@Sun.COM #define	ALM_FH_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN		(0x08000000)
11797555SFei.Feng@Sun.COM #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE	(0x80000000)
11807555SFei.Feng@Sun.COM #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE		(0x20000000)
11817555SFei.Feng@Sun.COM #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128		(0x01000000)
11827555SFei.Feng@Sun.COM #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST		(0x00001000)
11837555SFei.Feng@Sun.COM #define	ALM_FH_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH		(0x00000000)
11847555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF		(0x00000000)
11857555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER		(0x00000001)
11867555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL	(0x00000000)
11877555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL	(0x00000008)
11887555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD		(0x00200000)
11897555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT		(0x00000000)
11907555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE		(0x00000000)
11917555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE		(0x80000000)
11927555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID		(0x00004000)
11937555SFei.Feng@Sun.COM #define	ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR		(0x00000001)
11947555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON	(0xFF000000)
11957555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON	(0x00FF0000)
11967555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B	(0x00000400)
11977555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON	(0x00000100)
11987555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON	(0x00000080)
11997555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH	(0x00000020)
12007555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH		(0x00000005)
12017555SFei.Feng@Sun.COM 
12027555SFei.Feng@Sun.COM #define	ALM_TB_MAX_BYTES_COUNT	(0xFFF0)
12037555SFei.Feng@Sun.COM 
12047555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) \
12057555SFei.Feng@Sun.COM 	((1LU << _channel) << 24)
12067555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel) \
12077555SFei.Feng@Sun.COM 	((1LU << _channel) << 16)
12087555SFei.Feng@Sun.COM 
12097555SFei.Feng@Sun.COM #define	ALM_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_channel) \
12107555SFei.Feng@Sun.COM 	(ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) | \
12117555SFei.Feng@Sun.COM 	ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel))
12127555SFei.Feng@Sun.COM #define	PCI_CFG_REV_ID_BIT_BASIC_SKU	(0x40)	/* bit 6 */
12137555SFei.Feng@Sun.COM #define	PCI_CFG_REV_ID_BIT_RTP		(0x80)	/* bit 7 */
121411152SFei.Feng@Sun.COM #define	PCI_CFG_RETRY_TIMEOUT		(0x41)
12157555SFei.Feng@Sun.COM 
12167555SFei.Feng@Sun.COM #define	HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED	(0x00000004)
12177555SFei.Feng@Sun.COM 
12187555SFei.Feng@Sun.COM #define	TFD_QUEUE_MIN		0
12197555SFei.Feng@Sun.COM #define	TFD_QUEUE_MAX		6
12207555SFei.Feng@Sun.COM #define	TFD_QUEUE_SIZE_MAX	(256)
12217555SFei.Feng@Sun.COM 
12227555SFei.Feng@Sun.COM /*
12237555SFei.Feng@Sun.COM  * spectrum and channel data structures
12247555SFei.Feng@Sun.COM  */
12257555SFei.Feng@Sun.COM #define	IWH_NUM_SCAN_RATES	(2)
12267555SFei.Feng@Sun.COM 
12277555SFei.Feng@Sun.COM #define	IWH_SCAN_FLAG_24GHZ  (1<<0)
12287555SFei.Feng@Sun.COM #define	IWH_SCAN_FLAG_52GHZ  (1<<1)
12297555SFei.Feng@Sun.COM #define	IWH_SCAN_FLAG_ACTIVE (1<<2)
12307555SFei.Feng@Sun.COM #define	IWH_SCAN_FLAG_DIRECT (1<<3)
12317555SFei.Feng@Sun.COM 
12327555SFei.Feng@Sun.COM #define	IWH_MAX_CMD_SIZE 1024
12337555SFei.Feng@Sun.COM 
12347555SFei.Feng@Sun.COM #define	IWH_DEFAULT_TX_RETRY	15
12357555SFei.Feng@Sun.COM #define	IWH_MAX_TX_RETRY	16
12367555SFei.Feng@Sun.COM 
12377555SFei.Feng@Sun.COM #define	RFD_SIZE	4
12387555SFei.Feng@Sun.COM #define	NUM_TFD_CHUNKS	4
12397555SFei.Feng@Sun.COM 
12407555SFei.Feng@Sun.COM #define	RX_QUEUE_SIZE		256
12417555SFei.Feng@Sun.COM #define	RX_QUEUE_SIZE_LOG	8
12427555SFei.Feng@Sun.COM 
12437555SFei.Feng@Sun.COM /*
12447555SFei.Feng@Sun.COM  * TX Queue Flag Definitions
12457555SFei.Feng@Sun.COM  */
12467555SFei.Feng@Sun.COM /*
12477555SFei.Feng@Sun.COM  * use short preamble
12487555SFei.Feng@Sun.COM  */
12497555SFei.Feng@Sun.COM #define	DCT_FLAG_LONG_PREAMBLE	0x00
12507555SFei.Feng@Sun.COM #define	DCT_FLAG_SHORT_PREAMBLE	0x04
12517555SFei.Feng@Sun.COM 
12527555SFei.Feng@Sun.COM /*
12537555SFei.Feng@Sun.COM  * ACK rx is expected to follow
12547555SFei.Feng@Sun.COM  */
12557555SFei.Feng@Sun.COM #define	DCT_FLAG_ACK_REQD		0x80
12567555SFei.Feng@Sun.COM 
12577555SFei.Feng@Sun.COM #define	IWH_MB_DISASSOCIATE_THRESHOLD_DEFAULT	24
12587555SFei.Feng@Sun.COM #define	IWH_MB_ROAMING_THRESHOLD_DEFAULT		8
12597555SFei.Feng@Sun.COM #define	IWH_REAL_RATE_RX_PACKET_THRESHOLD		300
12607555SFei.Feng@Sun.COM 
12617555SFei.Feng@Sun.COM /*
12627555SFei.Feng@Sun.COM  * QoS  definitions
12637555SFei.Feng@Sun.COM  */
126410266SQuaker.Fang@Sun.COM 
126510266SQuaker.Fang@Sun.COM #define	AC_NUM		(4)	/* the number of access category */
12667555SFei.Feng@Sun.COM 
126710266SQuaker.Fang@Sun.COM /*
126810266SQuaker.Fang@Sun.COM  * index of every AC in firmware
126910266SQuaker.Fang@Sun.COM  */
127010266SQuaker.Fang@Sun.COM #define	QOS_AC_BK	(0)
127110266SQuaker.Fang@Sun.COM #define	QOS_AC_BE	(1)
127210266SQuaker.Fang@Sun.COM #define	QOS_AC_VI	(2)
127310266SQuaker.Fang@Sun.COM #define	QOS_AC_VO	(3)
127410266SQuaker.Fang@Sun.COM #define	QOS_AC_INVALID	(-1)
12757555SFei.Feng@Sun.COM 
127610266SQuaker.Fang@Sun.COM #define	QOS_CW_RANGE_MIN	(0)	/* exponential of 2 */
127710266SQuaker.Fang@Sun.COM #define	QOS_CW_RANGE_MAX	(15)	/* exponential of 2 */
127810266SQuaker.Fang@Sun.COM #define	QOS_TXOP_MIN		(0)	/* unit of 32 microsecond */
127910266SQuaker.Fang@Sun.COM #define	QOS_TXOP_MAX		(255)	/* unit of 32 microsecond */
128010266SQuaker.Fang@Sun.COM #define	QOS_AIFSN_MIN		(2)
128110266SQuaker.Fang@Sun.COM #define	QOS_AIFSN_MAX		(15)	/* undefined */
12827555SFei.Feng@Sun.COM 
128310266SQuaker.Fang@Sun.COM /*
128410266SQuaker.Fang@Sun.COM  * masks for flags of QoS parameter command
128510266SQuaker.Fang@Sun.COM  */
128610266SQuaker.Fang@Sun.COM #define	QOS_PARAM_FLG_UPDATE_EDCA	(0x01)
128710266SQuaker.Fang@Sun.COM #define	QOS_PARAM_FLG_TGN		(0x02)
12887555SFei.Feng@Sun.COM 
128910266SQuaker.Fang@Sun.COM /*
129010266SQuaker.Fang@Sun.COM  * index of TX queue for every AC
129110266SQuaker.Fang@Sun.COM  */
129210266SQuaker.Fang@Sun.COM #define	QOS_AC_BK_TO_TXQ	(3)
129310266SQuaker.Fang@Sun.COM #define	QOS_AC_BE_TO_TXQ	(2)
129410266SQuaker.Fang@Sun.COM #define	QOS_AC_VI_TO_TXQ	(1)
129510266SQuaker.Fang@Sun.COM #define	QOS_AC_VO_TO_TXQ	(0)
129610266SQuaker.Fang@Sun.COM #define	TXQ_FOR_AC_MIN		(0)
129710266SQuaker.Fang@Sun.COM #define	TXQ_FOR_AC_MAX		(3)
129810266SQuaker.Fang@Sun.COM #define	TXQ_FOR_AC_INVALID	(-1)
129910266SQuaker.Fang@Sun.COM #define	NON_QOS_TXQ		QOS_AC_BE_TO_TXQ
130010266SQuaker.Fang@Sun.COM #define	QOS_TXQ_FOR_MGT		QOS_AC_VO_TO_TXQ
13017555SFei.Feng@Sun.COM 
130210266SQuaker.Fang@Sun.COM #define	WME_TID_MIN	(0)
130310266SQuaker.Fang@Sun.COM #define	WME_TID_MAX	(7)
130410266SQuaker.Fang@Sun.COM #define	WME_TID_INVALID	(-1)
13057555SFei.Feng@Sun.COM 
130610266SQuaker.Fang@Sun.COM /*
130710266SQuaker.Fang@Sun.COM  * HT definitions
130810266SQuaker.Fang@Sun.COM  */
13097555SFei.Feng@Sun.COM 
131010266SQuaker.Fang@Sun.COM /*
131110266SQuaker.Fang@Sun.COM  * HT capabilities masks
131210266SQuaker.Fang@Sun.COM  */
131310266SQuaker.Fang@Sun.COM #define	HT_CAP_SUP_WIDTH	(0x0002)
131410266SQuaker.Fang@Sun.COM #define	HT_CAP_MIMO_PS		(0x000c)
131510266SQuaker.Fang@Sun.COM #define	HT_CAP_GRN_FLD		(0x0010)
131610266SQuaker.Fang@Sun.COM #define	HT_CAP_SGI_20		(0x0020)
131710266SQuaker.Fang@Sun.COM #define	HT_CAP_SGI_40		(0x0040)
131810266SQuaker.Fang@Sun.COM #define	HT_CAP_DELAY_BA		(0x0400)
131910266SQuaker.Fang@Sun.COM #define	HT_CAP_MAX_AMSDU	(0x0800)
132010266SQuaker.Fang@Sun.COM #define	HT_CAP_MCS_TX_DEFINED	(0x01)
132110266SQuaker.Fang@Sun.COM #define	HT_CAP_MCS_TX_RX_DIFF	(0x02)
132210266SQuaker.Fang@Sun.COM #define	HT_CAP_MCS_TX_STREAMS	(0x0c)
132310266SQuaker.Fang@Sun.COM #define	HT_CAP_MCS_TX_UEQM	(0x10)
13247555SFei.Feng@Sun.COM 
132510266SQuaker.Fang@Sun.COM #define	HT_CAP_MIMO_PS_STATIC	(0)
132610266SQuaker.Fang@Sun.COM #define	HT_CAP_MIMO_PS_DYNAMIC	(1)
132710266SQuaker.Fang@Sun.COM #define	HT_CAP_MIMO_PS_INVALID	(2)
132810266SQuaker.Fang@Sun.COM #define	HT_CAP_MIMO_PS_NONE	(3)
13297555SFei.Feng@Sun.COM 
133010266SQuaker.Fang@Sun.COM #define	HT_RX_AMPDU_FACTOR_8K	(0x0)
133110266SQuaker.Fang@Sun.COM #define	HT_RX_AMPDU_FACTOR_16K	(0x1)
133210266SQuaker.Fang@Sun.COM #define	HT_RX_AMPDU_FACTOR_32K	(0x2)
133310266SQuaker.Fang@Sun.COM #define	HT_RX_AMPDU_FACTOR_64K	(0x3)
133410266SQuaker.Fang@Sun.COM #define	HT_RX_AMPDU_FACTOR	HT_RX_AMPDU_FACTOR_8K
133510266SQuaker.Fang@Sun.COM #define	HT_RX_AMPDU_FACTOR_MSK	(0x3)
13367555SFei.Feng@Sun.COM 
133710266SQuaker.Fang@Sun.COM #define	HT_MPDU_DENSITY_4USEC	(0x5)
133810266SQuaker.Fang@Sun.COM #define	HT_MPDU_DENSITY_8USEC	(0x6)
133910266SQuaker.Fang@Sun.COM #define	HT_MPDU_DENSITY		HT_MPDU_DENSITY_4USEC
134010266SQuaker.Fang@Sun.COM #define	HT_MPDU_DENSITY_MSK	(0x1c)
134110266SQuaker.Fang@Sun.COM #define	HT_MPDU_DENSITY_POS	(2)
13427555SFei.Feng@Sun.COM 
134310266SQuaker.Fang@Sun.COM #define	HT_RATESET_NUM		(16)
134410266SQuaker.Fang@Sun.COM #define	HT_1CHAIN_RATE_MIN_IDX	(0x0)
134510266SQuaker.Fang@Sun.COM #define	HT_1CHAIN_RATE_MAX_IDX	(0x7)
134610266SQuaker.Fang@Sun.COM #define	HT_2CHAIN_RATE_MIN_IDX	(0x8)
134710266SQuaker.Fang@Sun.COM #define	HT_2CHAIN_RATE_MAX_IDX	(0xf)
134810266SQuaker.Fang@Sun.COM 
134910266SQuaker.Fang@Sun.COM struct iwh_ampdu_param {
135010266SQuaker.Fang@Sun.COM 	uint8_t	factor;
135110266SQuaker.Fang@Sun.COM 	uint8_t	density;
135210266SQuaker.Fang@Sun.COM };
13537555SFei.Feng@Sun.COM 
135410266SQuaker.Fang@Sun.COM typedef	struct iwh_ht_conf {
135510266SQuaker.Fang@Sun.COM 	uint8_t			ht_support;
135610266SQuaker.Fang@Sun.COM 	uint16_t		cap;
135710266SQuaker.Fang@Sun.COM 	struct iwh_ampdu_param	ampdu_p;
135810266SQuaker.Fang@Sun.COM 	uint8_t			tx_support_mcs[HT_RATESET_NUM];
135910266SQuaker.Fang@Sun.COM 	uint8_t			rx_support_mcs[HT_RATESET_NUM];
136010266SQuaker.Fang@Sun.COM 	uint8_t			valid_chains;
136110266SQuaker.Fang@Sun.COM 	uint8_t			tx_stream_count;
136210266SQuaker.Fang@Sun.COM 	uint8_t			rx_stream_count;
136310266SQuaker.Fang@Sun.COM 	uint8_t			ht_protection;
136410266SQuaker.Fang@Sun.COM } iwh_ht_conf_t;
13657555SFei.Feng@Sun.COM 
136610266SQuaker.Fang@Sun.COM #define	NO_HT_PROT		(0)
136710266SQuaker.Fang@Sun.COM #define	HT_PROT_CHAN_NON_HT	(1)
136810266SQuaker.Fang@Sun.COM #define	HT_PROT_FAT		(2)
136910266SQuaker.Fang@Sun.COM #define	HT_PROT_ASSOC_NON_HT	(3)
13707555SFei.Feng@Sun.COM 
137110266SQuaker.Fang@Sun.COM /*
137210266SQuaker.Fang@Sun.COM  * HT flags for RXON command.
137310266SQuaker.Fang@Sun.COM  */
137410266SQuaker.Fang@Sun.COM #define	RXON_FLG_CONTROL_CHANNEL_LOCATION_MSK	0x400000
137510266SQuaker.Fang@Sun.COM #define	RXON_FLG_CONTROL_CHANNEL_LOC_LOW_MSK	0x000000
137610266SQuaker.Fang@Sun.COM #define	RXON_FLG_CONTROL_CHANNEL_LOC_HIGH_MSK	0x400000
13777555SFei.Feng@Sun.COM 
137810266SQuaker.Fang@Sun.COM #define	RXON_FLG_HT_OPERATING_MODE_POS		(23)
137910266SQuaker.Fang@Sun.COM #define	RXON_FLG_HT_PROT_MSK			0x800000
138010266SQuaker.Fang@Sun.COM #define	RXON_FLG_FAT_PROT_MSK			0x1000000
13817555SFei.Feng@Sun.COM 
138210266SQuaker.Fang@Sun.COM #define	RXON_FLG_CHANNEL_MODE_POS		(25)
138310266SQuaker.Fang@Sun.COM #define	RXON_FLG_CHANNEL_MODE_MSK		0x06000000
138410266SQuaker.Fang@Sun.COM #define	RXON_FLG_CHANNEL_MODE_LEGACY_MSK	0x00000000
138510266SQuaker.Fang@Sun.COM #define	RXON_FLG_CHANNEL_MODE_PURE_40_MSK	0x02000000
138610266SQuaker.Fang@Sun.COM #define	RXON_FLG_CHANNEL_MODE_MIXED_MSK		0x04000000
13877555SFei.Feng@Sun.COM 
138810266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_DRIVER_FORCE_MSK		(0x1<<0)
138910266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_VALID_MSK			(0x7<<1)
139010266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_VALID_POS			(1)
139110266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_FORCE_SEL_MSK		(0x7<<4)
139210266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_FORCE_SEL_POS		(4)
139310266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK	(0x7<<7)
139410266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_FORCE_MIMO_SEL_POS	(7)
139510266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_CNT_MSK			(0x3<<10)
139610266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_CNT_POS			(10)
139710266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_MIMO_CNT_MSK		(0x3<<12)
139810266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_MIMO_CNT_POS		(12)
139910266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_MIMO_FORCE_MSK		(0x1<<14)
140010266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_MIMO_FORCE_POS		(14)
140110266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_A_MSK			(1)
140210266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_B_MSK			(2)
140310266SQuaker.Fang@Sun.COM #define	RXON_RX_CHAIN_C_MSK			(4)
14047555SFei.Feng@Sun.COM 
14057555SFei.Feng@Sun.COM /*
14067555SFei.Feng@Sun.COM  * Generic queue structure
14077555SFei.Feng@Sun.COM  *
14087555SFei.Feng@Sun.COM  * Contains common data for Rx and Tx queues
14097555SFei.Feng@Sun.COM  */
14107555SFei.Feng@Sun.COM #define	TFD_CTL_COUNT_SET(n)	(n<<24)
14117555SFei.Feng@Sun.COM #define	TFD_CTL_COUNT_GET(ctl)	((ctl>>24) & 7)
14127555SFei.Feng@Sun.COM #define	TFD_CTL_PAD_SET(n)	(n<<28)
14137555SFei.Feng@Sun.COM #define	TFD_CTL_PAD_GET(ctl)	(ctl>>28)
14147555SFei.Feng@Sun.COM 
14157555SFei.Feng@Sun.COM #define	TFD_TX_CMD_SLOTS 64
14167555SFei.Feng@Sun.COM #define	TFD_CMD_SLOTS 32
14177555SFei.Feng@Sun.COM 
14187555SFei.Feng@Sun.COM /*
14197555SFei.Feng@Sun.COM  * Tx/Rx Queues
14207555SFei.Feng@Sun.COM  *
14217555SFei.Feng@Sun.COM  * Most communication between driver and SP is via queues of data buffers.
14227555SFei.Feng@Sun.COM  * For example, all commands that the driver issues to device's embedded
14237555SFei.Feng@Sun.COM  * controller (uCode) are via the command queue (one of the Tx queues).  All
14247555SFei.Feng@Sun.COM  * uCode command responses/replies/notifications, including Rx frames, are
14257555SFei.Feng@Sun.COM  * conveyed from uCode to driver via the Rx queue.
14267555SFei.Feng@Sun.COM  *
14277555SFei.Feng@Sun.COM  * Most support for these queues, including handshake support, resides in
14287555SFei.Feng@Sun.COM  * structures in host DRAM, shared between the driver and the device.  When
14297555SFei.Feng@Sun.COM  * allocating this memory, the driver must make sure that data written by
14307555SFei.Feng@Sun.COM  * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's
14317555SFei.Feng@Sun.COM  * cache memory), so DRAM and cache are consistent, and the device can
14327555SFei.Feng@Sun.COM  * immediately see changes made by the driver.
14337555SFei.Feng@Sun.COM  *
14347555SFei.Feng@Sun.COM  * SP supports up to 16 DRAM-based Tx queues, and services these queues via
14357555SFei.Feng@Sun.COM  * up to 7 DMA channels (FIFOs).  Each Tx queue is supported by a circular array
14367555SFei.Feng@Sun.COM  * in DRAM containing 256 Transmit Frame Descriptors (TFDs).
14377555SFei.Feng@Sun.COM  */
14387555SFei.Feng@Sun.COM #define	IWH_MAX_WIN_SIZE	64
14397555SFei.Feng@Sun.COM #define	IWH_QUEUE_SIZE	256
14407555SFei.Feng@Sun.COM #define	IWH_NUM_FIFOS	7
14417555SFei.Feng@Sun.COM #define	IWH_NUM_QUEUES	20
14427555SFei.Feng@Sun.COM #define	IWH_CMD_QUEUE_NUM	4
14437555SFei.Feng@Sun.COM #define	IWH_KW_SIZE 0x1000	/* 4k */
14447555SFei.Feng@Sun.COM #define	IWH_CMD_FIFO_NUM	7
14457555SFei.Feng@Sun.COM 
14467555SFei.Feng@Sun.COM struct iwh_rate {
14477555SFei.Feng@Sun.COM 	union {
14487555SFei.Feng@Sun.COM 		struct {
14497555SFei.Feng@Sun.COM 			uint8_t rate;
14507555SFei.Feng@Sun.COM 			uint8_t flags;
14517555SFei.Feng@Sun.COM 			uint16_t ext_flags;
14527555SFei.Feng@Sun.COM 		} s;
14537555SFei.Feng@Sun.COM 		uint32_t rate_n_flags;
14547555SFei.Feng@Sun.COM 	} r;
14557555SFei.Feng@Sun.COM };
14567555SFei.Feng@Sun.COM 
14577555SFei.Feng@Sun.COM struct iwh_dram_scratch {
14587555SFei.Feng@Sun.COM 	uint8_t try_cnt;
14597555SFei.Feng@Sun.COM 	uint8_t bt_kill_cnt;
14607555SFei.Feng@Sun.COM 	uint16_t reserved;
14617555SFei.Feng@Sun.COM };
14627555SFei.Feng@Sun.COM 
14637555SFei.Feng@Sun.COM 
14647555SFei.Feng@Sun.COM struct iwh_tx_power {
14657555SFei.Feng@Sun.COM 	uint8_t tx_gain;	/* gain for analog radio */
14667555SFei.Feng@Sun.COM 	uint8_t dsp_atten;	/* gain for DSP */
14677555SFei.Feng@Sun.COM };
14687555SFei.Feng@Sun.COM 
14697555SFei.Feng@Sun.COM 
14707555SFei.Feng@Sun.COM union iwh_tx_power_triple_stream {
14717555SFei.Feng@Sun.COM 	struct {
14727555SFei.Feng@Sun.COM 		uint8_t radio_tx_gain[3];
14737555SFei.Feng@Sun.COM 		uint8_t reserved1;
14747555SFei.Feng@Sun.COM 		uint8_t dsp_predis_atten[3];
14757555SFei.Feng@Sun.COM 		uint8_t reserved2;
14767555SFei.Feng@Sun.COM 	}s;
14777555SFei.Feng@Sun.COM 	uint32_t val1;
14787555SFei.Feng@Sun.COM 	uint32_t val2;
14797555SFei.Feng@Sun.COM };
14807555SFei.Feng@Sun.COM 
14817555SFei.Feng@Sun.COM struct iwh_tx_power_db {
14827555SFei.Feng@Sun.COM 	union	iwh_tx_power_triple_stream ht_ofdm_power[24];
14837555SFei.Feng@Sun.COM 	union	iwh_tx_power_triple_stream cck_power[2];
14847555SFei.Feng@Sun.COM };
14857555SFei.Feng@Sun.COM 
14867555SFei.Feng@Sun.COM typedef struct iwh_tx_power_table_cmd {
14877555SFei.Feng@Sun.COM 	uint8_t band;
14887555SFei.Feng@Sun.COM 	uint8_t pa_measurements;
14897555SFei.Feng@Sun.COM 	uint8_t channel;
14907555SFei.Feng@Sun.COM 	uint8_t max_mcs;
14917555SFei.Feng@Sun.COM 	struct iwh_tx_power_db	db;
14927555SFei.Feng@Sun.COM } iwh_tx_power_table_cmd_t;
14937555SFei.Feng@Sun.COM 
14947555SFei.Feng@Sun.COM /*
149510266SQuaker.Fang@Sun.COM  * Hardware rate scaling set by iwh_ap_lq function.
149610266SQuaker.Fang@Sun.COM  * Given a particular initial rate and mode, the driver uses the
149710266SQuaker.Fang@Sun.COM  * following formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM]
149810266SQuaker.Fang@Sun.COM  * rate table in the Link Quality command:
149910266SQuaker.Fang@Sun.COM  *
150010266SQuaker.Fang@Sun.COM  * 1) If using High-throughput(HT)(SISO or MIMO) initial rate:
150110266SQuaker.Fang@Sun.COM  *    a) Use this same initial rate for first 3 entries.
150210266SQuaker.Fang@Sun.COM  *    b) Find next lower available rate using same mode(SISO or MIMO),
150310266SQuaker.Fang@Sun.COM  *	 use for next 3 entries. If no lower rate available, switch to
150410266SQuaker.Fang@Sun.COM  *	 legacy mode(no FAT channel, no MIMO, no short guard interval).
150510266SQuaker.Fang@Sun.COM  *    c) If using MIMO, set command's mimo_delimeter to number of
150610266SQuaker.Fang@Sun.COM  *	 entries using MIMO(3 or 6).
150710266SQuaker.Fang@Sun.COM  *    d) After trying 2 HT rates, switch to legacy mode(no FAT channel,
150810266SQuaker.Fang@Sun.COM  *	 no MIMO, no short qguard interval), at the next lower bit rate
150910266SQuaker.Fang@Sun.COM  *	 (e.g. if second HT bit rate was 54, try 48 legacy),and follow
151010266SQuaker.Fang@Sun.COM  *   legacy procedure for remaining table entries.
151110266SQuaker.Fang@Sun.COM  *
151210266SQuaker.Fang@Sun.COM  * 2) If using legacy initial rate:
151310266SQuaker.Fang@Sun.COM  *    a) Use the initial rate for only one entry.
151410266SQuaker.Fang@Sun.COM  *    b) For each following entry, reduce the rate to next lower available
151510266SQuaker.Fang@Sun.COM  *	 rate, until reaching the lowest available rate.
151610266SQuaker.Fang@Sun.COM  *    c) When reducing rate, also switch antenna selection.
151710266SQuaker.Fang@Sun.COM  *    b) Once lowest available rate is reached, repreat this rate until
151810266SQuaker.Fang@Sun.COM  *   rate table is filled(16 entries),switching antenna each entry.
15197555SFei.Feng@Sun.COM  */
15207555SFei.Feng@Sun.COM 
15217555SFei.Feng@Sun.COM /*
15227555SFei.Feng@Sun.COM  * OFDM HT rate masks
15237555SFei.Feng@Sun.COM  */
15247555SFei.Feng@Sun.COM #define	R_MCS_6M_MSK 0x1
15257555SFei.Feng@Sun.COM #define	R_MCS_12M_MSK 0x2
15267555SFei.Feng@Sun.COM #define	R_MCS_18M_MSK 0x4
15277555SFei.Feng@Sun.COM #define	R_MCS_24M_MSK 0x8
15287555SFei.Feng@Sun.COM #define	R_MCS_36M_MSK 0x10
15297555SFei.Feng@Sun.COM #define	R_MCS_48M_MSK 0x20
15307555SFei.Feng@Sun.COM #define	R_MCS_54M_MSK 0x40
15317555SFei.Feng@Sun.COM #define	R_MCS_60M_MSK 0x80
15327555SFei.Feng@Sun.COM #define	R_MCS_12M_DUAL_MSK 0x100
15337555SFei.Feng@Sun.COM #define	R_MCS_24M_DUAL_MSK 0x200
15347555SFei.Feng@Sun.COM #define	R_MCS_36M_DUAL_MSK 0x400
15357555SFei.Feng@Sun.COM #define	R_MCS_48M_DUAL_MSK 0x800
15367555SFei.Feng@Sun.COM 
15377555SFei.Feng@Sun.COM #define	RATE_MCS_CODE_MSK 0x7
15387555SFei.Feng@Sun.COM #define	RATE_MCS_MIMO_POS 3
15397555SFei.Feng@Sun.COM #define	RATE_MCS_MIMO_MSK 0x8
15407555SFei.Feng@Sun.COM #define	RATE_MCS_HT_DUP_POS 5
15417555SFei.Feng@Sun.COM #define	RATE_MCS_HT_DUP_MSK 0x20
15427555SFei.Feng@Sun.COM #define	RATE_MCS_FLAGS_POS 8
15437555SFei.Feng@Sun.COM #define	RATE_MCS_HT_POS 8
15447555SFei.Feng@Sun.COM #define	RATE_MCS_HT_MSK 0x100
15457555SFei.Feng@Sun.COM #define	RATE_MCS_CCK_POS 9
15467555SFei.Feng@Sun.COM #define	RATE_MCS_CCK_MSK 0x200
15477555SFei.Feng@Sun.COM #define	RATE_MCS_GF_POS 10
15487555SFei.Feng@Sun.COM #define	RATE_MCS_GF_MSK 0x400
15497555SFei.Feng@Sun.COM 
15507555SFei.Feng@Sun.COM #define	RATE_MCS_FAT_POS 11
15517555SFei.Feng@Sun.COM #define	RATE_MCS_FAT_MSK 0x800
15527555SFei.Feng@Sun.COM #define	RATE_MCS_DUP_POS 12
15537555SFei.Feng@Sun.COM #define	RATE_MCS_DUP_MSK 0x1000
15547555SFei.Feng@Sun.COM #define	RATE_MCS_SGI_POS 13
15557555SFei.Feng@Sun.COM #define	RATE_MCS_SGI_MSK 0x2000
15567555SFei.Feng@Sun.COM 
15577555SFei.Feng@Sun.COM #define	EEPROM_SEM_TIMEOUT 10
15587555SFei.Feng@Sun.COM #define	EEPROM_SEM_RETRY_LIMIT 1000
15597555SFei.Feng@Sun.COM 
15607555SFei.Feng@Sun.COM /*
15617555SFei.Feng@Sun.COM  * Antenna masks:
15627555SFei.Feng@Sun.COM  * bit14:15 01 B inactive, A active
15637555SFei.Feng@Sun.COM  *          10 B active, A inactive
15647555SFei.Feng@Sun.COM  *          11 Both active
15657555SFei.Feng@Sun.COM  */
15667555SFei.Feng@Sun.COM #define	RATE_MCS_ANT_A_POS	14
15677555SFei.Feng@Sun.COM #define	RATE_MCS_ANT_B_POS	15
15687555SFei.Feng@Sun.COM #define	RATE_MCS_ANT_A_MSK	0x4000
15697555SFei.Feng@Sun.COM #define	RATE_MCS_ANT_B_MSK	0x8000
15707555SFei.Feng@Sun.COM #define	RATE_MCS_ANT_AB_MSK	0xc000
15717555SFei.Feng@Sun.COM 
15727555SFei.Feng@Sun.COM #define	is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A))
15737555SFei.Feng@Sun.COM #define	is_siso(tbl) (((tbl) == LQ_SISO))
15747555SFei.Feng@Sun.COM #define	is_mimo(tbl) (((tbl) == LQ_MIMO))
15757555SFei.Feng@Sun.COM #define	is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl))
15767555SFei.Feng@Sun.COM #define	is_a_band(tbl) (((tbl) == LQ_A))
15777555SFei.Feng@Sun.COM #define	is_g_and(tbl) (((tbl) == LQ_G))
15787555SFei.Feng@Sun.COM 
15797555SFei.Feng@Sun.COM /*
15807555SFei.Feng@Sun.COM  * RS_NEW_API: only TLC_RTS remains and moved to bit 0
15817555SFei.Feng@Sun.COM  */
15827555SFei.Feng@Sun.COM #define	LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK	(1<<0)
15837555SFei.Feng@Sun.COM 
15847555SFei.Feng@Sun.COM #define	LINK_QUAL_AC_NUM 4
15857555SFei.Feng@Sun.COM #define	LINK_QUAL_MAX_RETRY_NUM 16
15867555SFei.Feng@Sun.COM 
15877555SFei.Feng@Sun.COM #define	LINK_QUAL_ANT_A_MSK (1<<0)
15887555SFei.Feng@Sun.COM #define	LINK_QUAL_ANT_B_MSK (1<<1)
15897555SFei.Feng@Sun.COM #define	LINK_QUAL_ANT_MSK   (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK)
15907555SFei.Feng@Sun.COM 
15917555SFei.Feng@Sun.COM struct iwh_link_qual_general_params {
15927555SFei.Feng@Sun.COM 	uint8_t flags;
15937555SFei.Feng@Sun.COM 	uint8_t mimo_delimiter;
15947555SFei.Feng@Sun.COM 	uint8_t single_stream_ant_msk;
15957555SFei.Feng@Sun.COM 	uint8_t dual_stream_ant_msk;
15967555SFei.Feng@Sun.COM 	uint8_t start_rate_index[LINK_QUAL_AC_NUM];
15977555SFei.Feng@Sun.COM };
15987555SFei.Feng@Sun.COM 
15997555SFei.Feng@Sun.COM struct iwh_link_qual_agg_params {
16007555SFei.Feng@Sun.COM 	uint16_t agg_time_limit;
16017555SFei.Feng@Sun.COM 	uint8_t agg_dis_start_th;
16027555SFei.Feng@Sun.COM 	uint8_t agg_frame_cnt_limit;
16037555SFei.Feng@Sun.COM 	uint32_t reserved;
16047555SFei.Feng@Sun.COM };
16057555SFei.Feng@Sun.COM 
16067555SFei.Feng@Sun.COM typedef struct iwh_link_quality_cmd {
16077555SFei.Feng@Sun.COM 	uint8_t sta_id;
16087555SFei.Feng@Sun.COM 	uint8_t reserved1;
16097555SFei.Feng@Sun.COM 	uint16_t control;
16107555SFei.Feng@Sun.COM 	struct iwh_link_qual_general_params general_params;
16117555SFei.Feng@Sun.COM 	struct iwh_link_qual_agg_params agg_params;
16127555SFei.Feng@Sun.COM 	uint32_t rate_n_flags[LINK_QUAL_MAX_RETRY_NUM];
16137555SFei.Feng@Sun.COM 	uint32_t reserved2;
16147555SFei.Feng@Sun.COM } iwh_link_quality_cmd_t;
16157555SFei.Feng@Sun.COM 
16167555SFei.Feng@Sun.COM struct	iwh_rx_mpdu_body_size {
16177555SFei.Feng@Sun.COM 	uint16_t	byte_count;
16187555SFei.Feng@Sun.COM 	uint16_t	reserved;
16197555SFei.Feng@Sun.COM };
16207555SFei.Feng@Sun.COM 
16217555SFei.Feng@Sun.COM typedef struct iwh_rx_phy_res {
16227555SFei.Feng@Sun.COM 	uint8_t non_cfg_phy_cnt;  /* non configurable DSP phy data byte count */
16237555SFei.Feng@Sun.COM 	uint8_t cfg_phy_cnt;	/* configurable DSP phy data byte count */
16247555SFei.Feng@Sun.COM 	uint8_t stat_id;	/* configurable DSP phy data set ID */
16257555SFei.Feng@Sun.COM 	uint8_t reserved1;
16267555SFei.Feng@Sun.COM 	uint32_t timestampl; /* TSF at on air rise */
16277555SFei.Feng@Sun.COM 	uint32_t timestamph;
16287555SFei.Feng@Sun.COM 	uint32_t beacon_time_stamp; /* beacon at on-air rise */
16297555SFei.Feng@Sun.COM 	uint16_t phy_flags;	/* general phy flags: band, modulation, ... */
16307555SFei.Feng@Sun.COM 	uint16_t channel;		/* channel number */
16317555SFei.Feng@Sun.COM 	/* for various implementations of non_cfg_phy */
16327555SFei.Feng@Sun.COM 	uint8_t	 non_cfg_phy[32];
16337555SFei.Feng@Sun.COM 	struct iwh_rate rate;	/* rate in ucode internal format */
16347555SFei.Feng@Sun.COM 	uint16_t byte_count;		/* frame's byte-count */
16357555SFei.Feng@Sun.COM 	uint16_t reserved3;
16367555SFei.Feng@Sun.COM } iwh_rx_phy_res_t;
16377555SFei.Feng@Sun.COM 
16387555SFei.Feng@Sun.COM struct iwh_rx_mpdu_res_start {
16397555SFei.Feng@Sun.COM 	uint16_t byte_count;
16407555SFei.Feng@Sun.COM 	uint16_t reserved;
16417555SFei.Feng@Sun.COM };
16427555SFei.Feng@Sun.COM 
16437555SFei.Feng@Sun.COM #define	IWH_AGC_DB_MASK 	(0x3f80)	/* MASK(7,13) */
16447555SFei.Feng@Sun.COM #define	IWH_AGC_DB_POS	(7)
16457555SFei.Feng@Sun.COM 
16467555SFei.Feng@Sun.COM #define	IWH_RX_RES_PHY_CNT	(8)
16477555SFei.Feng@Sun.COM #define	IWH_RX_RES_AGC_IDX	(1)
16487555SFei.Feng@Sun.COM #define	IWH_RX_RES_RSSI_AB_IDX	(2)
16497555SFei.Feng@Sun.COM #define	IWH_RX_RES_RSSI_C_IDX	(3)
16507555SFei.Feng@Sun.COM #define	IWH_OFDM_AGC_MSK	(0xFE00)
16517555SFei.Feng@Sun.COM #define	IWH_OFDM_AGC_BIT_POS	(9)
16527555SFei.Feng@Sun.COM #define	IWH_OFDM_RSSI_A_MSK	(0x00FF)
16537555SFei.Feng@Sun.COM #define	IWH_OFDM_RSSI_A_BIT_POS	(0)
16547555SFei.Feng@Sun.COM #define	IWH_OFDM_RSSI_B_MSK	(0xFF0000)
16557555SFei.Feng@Sun.COM #define	IWH_OFDM_RSSI_B_BIT_POS	(16)
16567555SFei.Feng@Sun.COM #define	IWH_OFDM_RSSI_C_MSK	(0x00FF)
16577555SFei.Feng@Sun.COM #define	IWH_OFDM_RSSI_C_BIT_POS	(0)
16587555SFei.Feng@Sun.COM #define	IWH_RSSI_OFFSET		(44)
16597555SFei.Feng@Sun.COM 
16607555SFei.Feng@Sun.COM /*
16617555SFei.Feng@Sun.COM  * Fixed (non-configurable) rx data from phy
16627555SFei.Feng@Sun.COM  */
16637555SFei.Feng@Sun.COM struct iwh_rx_non_cfg_phy {
16647555SFei.Feng@Sun.COM 	uint32_t non_cfg_phy[IWH_RX_RES_PHY_CNT];	/* upto 8 phy entries */
16657555SFei.Feng@Sun.COM };
16667555SFei.Feng@Sun.COM 
16677555SFei.Feng@Sun.COM /*
16687555SFei.Feng@Sun.COM  * Byte Count Table Entry
16697555SFei.Feng@Sun.COM  *
16707555SFei.Feng@Sun.COM  * Bit fields:
16717555SFei.Feng@Sun.COM  * 15-12: reserved
16727555SFei.Feng@Sun.COM  * 11- 0: total to-be-transmitted byte count of frame (does not include command)
16737555SFei.Feng@Sun.COM  */
16747555SFei.Feng@Sun.COM struct iwh_queue_byte_cnt_entry {
16757555SFei.Feng@Sun.COM 	uint16_t val;
16767555SFei.Feng@Sun.COM };
16777555SFei.Feng@Sun.COM 
16787555SFei.Feng@Sun.COM /*
16797555SFei.Feng@Sun.COM  * Byte Count table
16807555SFei.Feng@Sun.COM  *
16817555SFei.Feng@Sun.COM  * Each Tx queue uses a byte-count table containing 320 entries:
16827555SFei.Feng@Sun.COM  * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that
16837555SFei.Feng@Sun.COM  * duplicate the first 64 entries (to avoid wrap-around within a Tx window;
16847555SFei.Feng@Sun.COM  * max Tx window is 64 TFDs).
16857555SFei.Feng@Sun.COM  *
16867555SFei.Feng@Sun.COM  * When driver sets up a new TFD, it must also enter the total byte count
16877555SFei.Feng@Sun.COM  * of the frame to be transmitted into the corresponding entry in the byte
16887555SFei.Feng@Sun.COM  * count table for the chosen Tx queue.  If the TFD index is 0-63, the driver
16897555SFei.Feng@Sun.COM  * must duplicate the byte count entry in corresponding index 256-319.
16907555SFei.Feng@Sun.COM  *
16917555SFei.Feng@Sun.COM  * "dont_care" padding puts each byte count table on a 1024-byte boundary;
16927555SFei.Feng@Sun.COM  * SP assumes tables are separated by 1024 bytes.
16937555SFei.Feng@Sun.COM  */
16947555SFei.Feng@Sun.COM struct iwh_sched_queue_byte_cnt_tbl {
16957555SFei.Feng@Sun.COM 	struct iwh_queue_byte_cnt_entry tfd_offset[IWH_QUEUE_SIZE +
16967555SFei.Feng@Sun.COM 	    IWH_MAX_WIN_SIZE];
16977555SFei.Feng@Sun.COM };
16987555SFei.Feng@Sun.COM 
16997555SFei.Feng@Sun.COM /*
17007555SFei.Feng@Sun.COM  * struct iwh_shared, handshake area for Tx and Rx
17017555SFei.Feng@Sun.COM  *
17027555SFei.Feng@Sun.COM  * For convenience in allocating memory, this structure combines 2 areas of
17037555SFei.Feng@Sun.COM  * DRAM which must be shared between driver and SP.  These do not need to
17047555SFei.Feng@Sun.COM  * be combined, if better allocation would result from keeping them separate:
17057555SFei.Feng@Sun.COM  * TODO:  Split these; carried over from 3945, doesn't work well for SP.
17067555SFei.Feng@Sun.COM  *
17077555SFei.Feng@Sun.COM  * 1)  The Tx byte count tables occupy 1024 bytes each (16 KBytes total for
17087555SFei.Feng@Sun.COM  *     16 queues).  Driver uses SCD_DRAM_BASE_ADDR to tell SP where to find
17097555SFei.Feng@Sun.COM  *     the first of these tables.  SP assumes tables are 1024 bytes apart.
17107555SFei.Feng@Sun.COM  *
17117555SFei.Feng@Sun.COM  * 2)  The Rx status (val0 and val1) occupies only 8 bytes.  Driver uses
17127555SFei.Feng@Sun.COM  *     FH_RSCSR_CHNL0_STTS_WPTR_REG to tell SP where to find this area.
17137555SFei.Feng@Sun.COM  *     Driver reads val0 to determine the latest Receive Buffer Descriptor (RBD)
17147555SFei.Feng@Sun.COM  *     that has been filled by the SP.
17157555SFei.Feng@Sun.COM  *
17167555SFei.Feng@Sun.COM  * Bit fields val0:
17177555SFei.Feng@Sun.COM  * 31-12:  Not used
17187555SFei.Feng@Sun.COM  * 11- 0:  Index of last filled Rx buffer descriptor (SP writes, driver reads)
17197555SFei.Feng@Sun.COM  *
17207555SFei.Feng@Sun.COM  * Bit fields val1:
17217555SFei.Feng@Sun.COM  * 31- 0:  Not used
17227555SFei.Feng@Sun.COM  */
17237555SFei.Feng@Sun.COM typedef struct iwh_shared {
17247555SFei.Feng@Sun.COM 	struct iwh_sched_queue_byte_cnt_tbl
17257555SFei.Feng@Sun.COM 	    queues_byte_cnt_tbls[IWH_NUM_QUEUES];
17267555SFei.Feng@Sun.COM 	uint32_t val0;
17277555SFei.Feng@Sun.COM 	uint32_t val1;
17287555SFei.Feng@Sun.COM 	uint32_t padding1;  /* so that allocation will be aligned to 16B */
17297555SFei.Feng@Sun.COM 	uint32_t padding2;
17307555SFei.Feng@Sun.COM } iwh_shared_t;
17317555SFei.Feng@Sun.COM 
17327555SFei.Feng@Sun.COM 
17337555SFei.Feng@Sun.COM /*
17347555SFei.Feng@Sun.COM  * struct iwh_tfd_frame_data
17357555SFei.Feng@Sun.COM  *
17367555SFei.Feng@Sun.COM  * Describes up to 2 buffers containing (contiguous) portions of a Tx frame.
17377555SFei.Feng@Sun.COM  * Each buffer must be on dword boundary.
17387555SFei.Feng@Sun.COM  * Up to 10 iwh_tfd_frame_data structures, describing up to 20 buffers,
17397555SFei.Feng@Sun.COM  * may be filled within a TFD (iwh_tfd_frame).
17407555SFei.Feng@Sun.COM  *
17417555SFei.Feng@Sun.COM  * Bit fields in tb1_addr:
17427555SFei.Feng@Sun.COM  * 31- 0: Tx buffer 1 address bits [31:0]
17437555SFei.Feng@Sun.COM  *
17447555SFei.Feng@Sun.COM  * Bit fields in val1:
17457555SFei.Feng@Sun.COM  * 31-16: Tx buffer 2 address bits [15:0]
17467555SFei.Feng@Sun.COM  * 15- 4: Tx buffer 1 length (bytes)
17477555SFei.Feng@Sun.COM  *  3- 0: Tx buffer 1 address bits [32:32]
17487555SFei.Feng@Sun.COM  *
17497555SFei.Feng@Sun.COM  * Bit fields in val2:
17507555SFei.Feng@Sun.COM  * 31-20: Tx buffer 2 length (bytes)
17517555SFei.Feng@Sun.COM  * 19- 0: Tx buffer 2 address bits [35:16]
17527555SFei.Feng@Sun.COM  */
17537555SFei.Feng@Sun.COM struct iwh_tfd_frame_data {
17547555SFei.Feng@Sun.COM 		uint32_t tb1_addr;
17557555SFei.Feng@Sun.COM 		uint32_t val1;
17567555SFei.Feng@Sun.COM 		uint32_t val2;
17577555SFei.Feng@Sun.COM };
17587555SFei.Feng@Sun.COM 
17597555SFei.Feng@Sun.COM typedef struct iwh_tx_desc {
17607555SFei.Feng@Sun.COM 	uint32_t	val0;
17617555SFei.Feng@Sun.COM 	struct iwh_tfd_frame_data pa[10];
17627555SFei.Feng@Sun.COM 	uint32_t reserved;
17637555SFei.Feng@Sun.COM } iwh_tx_desc_t;
17647555SFei.Feng@Sun.COM 
17657555SFei.Feng@Sun.COM struct	agg_tx_status {
17667555SFei.Feng@Sun.COM 	uint16_t	status;
17677555SFei.Feng@Sun.COM 	uint16_t	sequence;
17687555SFei.Feng@Sun.COM };
17697555SFei.Feng@Sun.COM 
17707555SFei.Feng@Sun.COM typedef struct iwh_tx_stat {
17717555SFei.Feng@Sun.COM 	uint8_t		frame_count;
17727555SFei.Feng@Sun.COM 	uint8_t		bt_kill_count;
17737555SFei.Feng@Sun.COM 	uint8_t		nrts;
17747555SFei.Feng@Sun.COM 	uint8_t		ntries;
17757555SFei.Feng@Sun.COM 	struct iwh_rate rate;
17767555SFei.Feng@Sun.COM 	uint16_t	duration;
17777555SFei.Feng@Sun.COM 	uint16_t	reserved;
17787555SFei.Feng@Sun.COM 	uint32_t	pa_power1;
17797555SFei.Feng@Sun.COM 	uint32_t	pa_power2;
17807555SFei.Feng@Sun.COM 	uint32_t	tfd_info;
17817555SFei.Feng@Sun.COM 	uint16_t	seq_ctl;
17827555SFei.Feng@Sun.COM 	uint16_t	byte_cnt;
17837555SFei.Feng@Sun.COM 	uint32_t	tlc_info;
17847555SFei.Feng@Sun.COM 	struct	agg_tx_status	status;
17857555SFei.Feng@Sun.COM } iwh_tx_stat_t;
17867555SFei.Feng@Sun.COM 
17877555SFei.Feng@Sun.COM struct iwh_cmd_header {
17887555SFei.Feng@Sun.COM 	uint8_t		type;
17897555SFei.Feng@Sun.COM 	uint8_t		flags;
17907555SFei.Feng@Sun.COM 	uint8_t		idx;
17917555SFei.Feng@Sun.COM 	uint8_t		qid;
17927555SFei.Feng@Sun.COM };
17937555SFei.Feng@Sun.COM 
17947555SFei.Feng@Sun.COM typedef struct iwh_rx_desc {
17957555SFei.Feng@Sun.COM 	uint32_t	len;
17967555SFei.Feng@Sun.COM 	struct iwh_cmd_header hdr;
17977555SFei.Feng@Sun.COM } iwh_rx_desc_t;
17987555SFei.Feng@Sun.COM 
17997555SFei.Feng@Sun.COM typedef struct iwh_rx_stat {
18007555SFei.Feng@Sun.COM 	uint8_t		len;
18017555SFei.Feng@Sun.COM 	uint8_t		id;
18027555SFei.Feng@Sun.COM 	uint8_t		rssi;	/* received signal strength */
18037555SFei.Feng@Sun.COM 	uint8_t		agc;	/* access gain control */
18047555SFei.Feng@Sun.COM 	uint16_t	signal;
18057555SFei.Feng@Sun.COM 	uint16_t	noise;
18067555SFei.Feng@Sun.COM } iwh_rx_stat_t;
18077555SFei.Feng@Sun.COM 
18087555SFei.Feng@Sun.COM typedef struct iwh_rx_head {
18097555SFei.Feng@Sun.COM 	uint16_t	chan;
18107555SFei.Feng@Sun.COM 	uint16_t	flags;
18117555SFei.Feng@Sun.COM 	uint8_t		reserved;
18127555SFei.Feng@Sun.COM 	uint8_t		rate;
18137555SFei.Feng@Sun.COM 	uint16_t	len;
18147555SFei.Feng@Sun.COM } iwh_rx_head_t;
18157555SFei.Feng@Sun.COM 
18167555SFei.Feng@Sun.COM typedef struct iwh_rx_tail {
18177555SFei.Feng@Sun.COM 	uint32_t	flags;
18187555SFei.Feng@Sun.COM 	uint32_t	timestampl;
18197555SFei.Feng@Sun.COM 	uint32_t	timestamph;
18207555SFei.Feng@Sun.COM 	uint32_t	tbeacon;
18217555SFei.Feng@Sun.COM } iwh_rx_tail_t;
18227555SFei.Feng@Sun.COM 
18237555SFei.Feng@Sun.COM enum {
18247555SFei.Feng@Sun.COM 	IWH_AP_ID = 0,
18257555SFei.Feng@Sun.COM 	IWH_MULTICAST_ID,
18267555SFei.Feng@Sun.COM 	IWH_STA_ID,
18277555SFei.Feng@Sun.COM 	IWH_BROADCAST_ID = 15,
18287555SFei.Feng@Sun.COM 	IWH_STATION_COUNT = 16,
18297555SFei.Feng@Sun.COM 	IWH_INVALID_STATION
18307555SFei.Feng@Sun.COM };
18317555SFei.Feng@Sun.COM 
18327555SFei.Feng@Sun.COM /*
18337555SFei.Feng@Sun.COM  * key flags
18347555SFei.Feng@Sun.COM  */
18357555SFei.Feng@Sun.COM enum {
18367555SFei.Feng@Sun.COM 	STA_KEY_FLG_ENCRYPT_MSK = 0x7,
18377555SFei.Feng@Sun.COM 	STA_KEY_FLG_NO_ENC = 0x0,
18387555SFei.Feng@Sun.COM 	STA_KEY_FLG_WEP = 0x1,
18397555SFei.Feng@Sun.COM 	STA_KEY_FLG_CCMP = 0x2,
18407555SFei.Feng@Sun.COM 	STA_KEY_FLG_TKIP = 0x3,
18417555SFei.Feng@Sun.COM 
18427555SFei.Feng@Sun.COM 	STA_KEY_FLG_KEYID_POS = 8,
18437555SFei.Feng@Sun.COM 	STA_KEY_FLG_INVALID = 0x0800,
18447555SFei.Feng@Sun.COM };
18457555SFei.Feng@Sun.COM 
18467555SFei.Feng@Sun.COM /*
18477555SFei.Feng@Sun.COM  * modify flags
18487555SFei.Feng@Sun.COM  */
18497555SFei.Feng@Sun.COM enum {
18507555SFei.Feng@Sun.COM 	STA_MODIFY_KEY_MASK = 0x01,
18517555SFei.Feng@Sun.COM 	STA_MODIFY_TID_DISABLE_TX = 0x02,
18527555SFei.Feng@Sun.COM 	STA_MODIFY_TX_RATE_MSK = 0x04
18537555SFei.Feng@Sun.COM };
18547555SFei.Feng@Sun.COM 
18557555SFei.Feng@Sun.COM enum {
18567555SFei.Feng@Sun.COM 	RX_RES_STATUS_NO_CRC32_ERROR = (1 << 0),
18577555SFei.Feng@Sun.COM 	RX_RES_STATUS_NO_RXE_OVERFLOW = (1 << 1),
18587555SFei.Feng@Sun.COM };
18597555SFei.Feng@Sun.COM 
18607555SFei.Feng@Sun.COM enum {
18617555SFei.Feng@Sun.COM 	RX_RES_PHY_FLAGS_BAND_24_MSK = (1 << 0),
18627555SFei.Feng@Sun.COM 	RX_RES_PHY_FLAGS_MOD_CCK_MSK = (1 << 1),
18637555SFei.Feng@Sun.COM 	RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK = (1 << 2),
18647555SFei.Feng@Sun.COM 	RX_RES_PHY_FLAGS_NARROW_BAND_MSK = (1 << 3),
18657555SFei.Feng@Sun.COM 	RX_RES_PHY_FLAGS_ANTENNA_MSK = 0xf0,
18667555SFei.Feng@Sun.COM 
18677555SFei.Feng@Sun.COM 	RX_RES_STATUS_SEC_TYPE_MSK = (0x7 << 8),
18687555SFei.Feng@Sun.COM 	RX_RES_STATUS_SEC_TYPE_NONE = (STA_KEY_FLG_NO_ENC << 8),
18697555SFei.Feng@Sun.COM 	RX_RES_STATUS_SEC_TYPE_WEP = (STA_KEY_FLG_WEP << 8),
18707555SFei.Feng@Sun.COM 	RX_RES_STATUS_SEC_TYPE_TKIP = (STA_KEY_FLG_TKIP << 8),
18717555SFei.Feng@Sun.COM 	RX_RES_STATUS_SEC_TYPE_CCMP = (STA_KEY_FLG_CCMP << 8),
18727555SFei.Feng@Sun.COM 
18737555SFei.Feng@Sun.COM 	RX_RES_STATUS_DECRYPT_TYPE_MSK = (0x3 << 11),
18747555SFei.Feng@Sun.COM 	RX_RES_STATUS_NOT_DECRYPT = (0x0 << 11),
18757555SFei.Feng@Sun.COM 	RX_RES_STATUS_DECRYPT_OK = (0x3 << 11),
18767555SFei.Feng@Sun.COM 	RX_RES_STATUS_BAD_ICV_MIC = (0x1 << 11),
18777555SFei.Feng@Sun.COM 	RX_RES_STATUS_BAD_KEY_TTAK = (0x2 << 11),
18787555SFei.Feng@Sun.COM };
18797555SFei.Feng@Sun.COM 
18807555SFei.Feng@Sun.COM enum {
18817555SFei.Feng@Sun.COM 	REPLY_ALIVE = 0x1,
18827555SFei.Feng@Sun.COM 	REPLY_ERROR = 0x2,
18837555SFei.Feng@Sun.COM 
18847555SFei.Feng@Sun.COM 	/* RXON state commands */
18857555SFei.Feng@Sun.COM 	REPLY_RXON = 0x10,
18867555SFei.Feng@Sun.COM 	REPLY_RXON_ASSOC = 0x11,
18877555SFei.Feng@Sun.COM 	REPLY_QOS_PARAM = 0x13,
18887555SFei.Feng@Sun.COM 	REPLY_RXON_TIMING = 0x14,
18897555SFei.Feng@Sun.COM 
18907555SFei.Feng@Sun.COM 	/* Multi-Station support */
18917555SFei.Feng@Sun.COM 	REPLY_ADD_STA = 0x18,
18927555SFei.Feng@Sun.COM 	REPLY_REMOVE_STA = 0x19,
18937555SFei.Feng@Sun.COM 	REPLY_REMOVE_ALL_STA = 0x1a,
18947555SFei.Feng@Sun.COM 
18957555SFei.Feng@Sun.COM 	/* RX, TX */
18967555SFei.Feng@Sun.COM 
18977555SFei.Feng@Sun.COM 	REPLY_TX = 0x1c,
18987555SFei.Feng@Sun.COM 
18997555SFei.Feng@Sun.COM 	/* timers commands */
19007555SFei.Feng@Sun.COM 	REPLY_BCON = 0x27,
19017555SFei.Feng@Sun.COM 
19027555SFei.Feng@Sun.COM 	REPLY_SHUTDOWN = 0x40,
19037555SFei.Feng@Sun.COM 
19047555SFei.Feng@Sun.COM 	/* MISC commands */
19057555SFei.Feng@Sun.COM 	REPLY_RATE_SCALE = 0x47,
19067555SFei.Feng@Sun.COM 	REPLY_LEDS_CMD = 0x48,
19077555SFei.Feng@Sun.COM 	REPLY_TX_LINK_QUALITY_CMD = 0x4e,
19087555SFei.Feng@Sun.COM 
19097555SFei.Feng@Sun.COM 	COEX_PRIORITY_TABLE_CMD = 0x5a,
19107555SFei.Feng@Sun.COM 	CALIBRATION_CFG_CMD = 0x65,
19117555SFei.Feng@Sun.COM 	CALIBRATION_RES_NOTIFICATION = 0x66,
19127555SFei.Feng@Sun.COM 	CALIBRATION_COMPLETE_NOTIFICATION = 0x67,
19137555SFei.Feng@Sun.COM 
19147555SFei.Feng@Sun.COM 	/* 802.11h related */
19157555SFei.Feng@Sun.COM 	RADAR_NOTIFICATION = 0x70,
19167555SFei.Feng@Sun.COM 	REPLY_QUIET_CMD = 0x71,
19177555SFei.Feng@Sun.COM 	REPLY_CHANNEL_SWITCH = 0x72,
19187555SFei.Feng@Sun.COM 	CHANNEL_SWITCH_NOTIFICATION = 0x73,
19197555SFei.Feng@Sun.COM 	REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74,
19207555SFei.Feng@Sun.COM 	SPECTRUM_MEASURE_NOTIFICATION = 0x75,
19217555SFei.Feng@Sun.COM 
19227555SFei.Feng@Sun.COM 	/* Power Management *** */
19237555SFei.Feng@Sun.COM 	POWER_TABLE_CMD = 0x77,
19247555SFei.Feng@Sun.COM 	PM_SLEEP_NOTIFICATION = 0x7A,
19257555SFei.Feng@Sun.COM 	PM_DEBUG_STATISTIC_NOTIFIC = 0x7B,
19267555SFei.Feng@Sun.COM 
19277555SFei.Feng@Sun.COM 	/* Scan commands and notifications */
19287555SFei.Feng@Sun.COM 	REPLY_SCAN_CMD = 0x80,
19297555SFei.Feng@Sun.COM 	REPLY_SCAN_ABORT_CMD = 0x81,
19307555SFei.Feng@Sun.COM 
19317555SFei.Feng@Sun.COM 	SCAN_START_NOTIFICATION = 0x82,
19327555SFei.Feng@Sun.COM 	SCAN_RESULTS_NOTIFICATION = 0x83,
19337555SFei.Feng@Sun.COM 	SCAN_COMPLETE_NOTIFICATION = 0x84,
19347555SFei.Feng@Sun.COM 
19357555SFei.Feng@Sun.COM 	/* IBSS/AP commands */
19367555SFei.Feng@Sun.COM 	BEACON_NOTIFICATION = 0x90,
19377555SFei.Feng@Sun.COM 	REPLY_TX_BEACON = 0x91,
19387555SFei.Feng@Sun.COM 	WHO_IS_AWAKE_NOTIFICATION = 0x94,
19397555SFei.Feng@Sun.COM 
19407555SFei.Feng@Sun.COM 	QUIET_NOTIFICATION = 0x96,
19417555SFei.Feng@Sun.COM 	REPLY_TX_PWR_TABLE_CMD = 0x97,
19427555SFei.Feng@Sun.COM 	MEASURE_ABORT_NOTIFICATION = 0x99,
19437555SFei.Feng@Sun.COM 
19447555SFei.Feng@Sun.COM 	REPLY_CALIBRATION_TUNE = 0x9a,
19457555SFei.Feng@Sun.COM 
19467555SFei.Feng@Sun.COM 	/* BT config command */
19477555SFei.Feng@Sun.COM 	REPLY_BT_CONFIG = 0x9b,
19487555SFei.Feng@Sun.COM 	REPLY_STATISTICS_CMD = 0x9c,
19497555SFei.Feng@Sun.COM 	STATISTICS_NOTIFICATION = 0x9d,
19507555SFei.Feng@Sun.COM 
19517555SFei.Feng@Sun.COM 	/* RF-KILL commands and notifications *** */
19527555SFei.Feng@Sun.COM 	REPLY_CARD_STATE_CMD = 0xa0,
19537555SFei.Feng@Sun.COM 	CARD_STATE_NOTIFICATION = 0xa1,
19547555SFei.Feng@Sun.COM 
19557555SFei.Feng@Sun.COM 	/* Missed beacons notification */
19567555SFei.Feng@Sun.COM 	MISSED_BEACONS_NOTIFICATION = 0xa2,
19577555SFei.Feng@Sun.COM 	MISSED_BEACONS_NOTIFICATION_TH_CMD = 0xa3,
19587555SFei.Feng@Sun.COM 
19597555SFei.Feng@Sun.COM 	REPLY_CT_KILL_CONFIG_CMD = 0xa4,
19607555SFei.Feng@Sun.COM 	SENSITIVITY_CMD = 0xa8,
19617555SFei.Feng@Sun.COM 	REPLY_PHY_CALIBRATION_CMD = 0xb0,
19627555SFei.Feng@Sun.COM 	REPLY_RX_PHY_CMD = 0xc0,
19637555SFei.Feng@Sun.COM 	REPLY_RX_MPDU_CMD = 0xc1,
19647555SFei.Feng@Sun.COM 	REPLY_SP_RX = 0xc3,
19657555SFei.Feng@Sun.COM 	REPLY_COMPRESSED_BA = 0xc5,
19667555SFei.Feng@Sun.COM 	REPLY_MAX = 0xff
19677555SFei.Feng@Sun.COM };
19687555SFei.Feng@Sun.COM 
19697555SFei.Feng@Sun.COM typedef struct iwh_cmd {
19707555SFei.Feng@Sun.COM 	struct iwh_cmd_header hdr;
19717555SFei.Feng@Sun.COM 	uint8_t	data[1024];
19727555SFei.Feng@Sun.COM } iwh_cmd_t;
19737555SFei.Feng@Sun.COM 
19747555SFei.Feng@Sun.COM /*
19757555SFei.Feng@Sun.COM  * Alive Command & Response
19767555SFei.Feng@Sun.COM  */
19777555SFei.Feng@Sun.COM #define	UCODE_VALID_OK		(0x1)
19787555SFei.Feng@Sun.COM #define	INITIALIZE_SUBTYPE	(9)
19797555SFei.Feng@Sun.COM 
19807555SFei.Feng@Sun.COM struct iwh_alive_resp {
19817555SFei.Feng@Sun.COM 	uint8_t ucode_minor;
19827555SFei.Feng@Sun.COM 	uint8_t ucode_major;
19837555SFei.Feng@Sun.COM 	uint16_t reserved1;
19847555SFei.Feng@Sun.COM 	uint8_t sw_rev[8];
19857555SFei.Feng@Sun.COM 	uint8_t ver_type;
19867555SFei.Feng@Sun.COM 	uint8_t ver_subtype;
19877555SFei.Feng@Sun.COM 	uint16_t reserved2;
19887555SFei.Feng@Sun.COM 	uint32_t log_event_table_ptr;
19897555SFei.Feng@Sun.COM 	uint32_t error_event_table_ptr;
19907555SFei.Feng@Sun.COM 	uint32_t timestamp;
19917555SFei.Feng@Sun.COM 	uint32_t is_valid;
19927555SFei.Feng@Sun.COM };
19937555SFei.Feng@Sun.COM 
19947555SFei.Feng@Sun.COM struct iwh_init_alive_resp {
19957555SFei.Feng@Sun.COM 	struct iwh_alive_resp s;
19967555SFei.Feng@Sun.COM 	/* calibration values from "initialize" uCode */
19977555SFei.Feng@Sun.COM 	uint32_t voltage;	/* signed */
19987555SFei.Feng@Sun.COM 	uint32_t therm_r1[2];	/* signed 1st for normal, 2nd for FAT channel */
19997555SFei.Feng@Sun.COM 	uint32_t therm_r2[2];	/* signed */
20007555SFei.Feng@Sun.COM 	uint32_t therm_r3[2];	/* signed */
20017555SFei.Feng@Sun.COM 	uint32_t therm_r4[2];	/* signed */
20027555SFei.Feng@Sun.COM 		/*
20037555SFei.Feng@Sun.COM 		 * signed MIMO gain comp, 5 freq groups, 2 Tx chains
20047555SFei.Feng@Sun.COM 		 */
20057555SFei.Feng@Sun.COM 	uint32_t tx_atten[5][2];
20067555SFei.Feng@Sun.COM };
20077555SFei.Feng@Sun.COM 
20087555SFei.Feng@Sun.COM /*
20097555SFei.Feng@Sun.COM  * Rx config defines & structure
20107555SFei.Feng@Sun.COM  */
20117555SFei.Feng@Sun.COM /*
20127555SFei.Feng@Sun.COM  * rx_config device types
20137555SFei.Feng@Sun.COM  */
20147555SFei.Feng@Sun.COM enum {
20157555SFei.Feng@Sun.COM 	RXON_DEV_TYPE_AP = 1,
20167555SFei.Feng@Sun.COM 	RXON_DEV_TYPE_ESS = 3,
20177555SFei.Feng@Sun.COM 	RXON_DEV_TYPE_IBSS = 4,
20187555SFei.Feng@Sun.COM 	RXON_DEV_TYPE_SNIFFER = 6,
20197555SFei.Feng@Sun.COM };
20207555SFei.Feng@Sun.COM 
20217555SFei.Feng@Sun.COM /*
20227555SFei.Feng@Sun.COM  * rx_config flags
20237555SFei.Feng@Sun.COM  */
20247555SFei.Feng@Sun.COM enum {
20257555SFei.Feng@Sun.COM 	/* band & modulation selection */
20267555SFei.Feng@Sun.COM 	RXON_FLG_BAND_24G_MSK = (1 << 0),
20277555SFei.Feng@Sun.COM 	RXON_FLG_CCK_MSK = (1 << 1),
20287555SFei.Feng@Sun.COM 	/* auto detection enable */
20297555SFei.Feng@Sun.COM 	RXON_FLG_AUTO_DETECT_MSK = (1 << 2),
20307555SFei.Feng@Sun.COM 	/* TGg protection when tx */
20317555SFei.Feng@Sun.COM 	RXON_FLG_TGG_PROTECT_MSK = (1 << 3),
20327555SFei.Feng@Sun.COM 	/* cck short slot & preamble */
20337555SFei.Feng@Sun.COM 	RXON_FLG_SHORT_SLOT_MSK = (1 << 4),
20347555SFei.Feng@Sun.COM 	RXON_FLG_SHORT_PREAMBLE_MSK = (1 << 5),
20357555SFei.Feng@Sun.COM 	/* antenna selection */
20367555SFei.Feng@Sun.COM 	RXON_FLG_DIS_DIV_MSK = (1 << 7),
20377555SFei.Feng@Sun.COM 	RXON_FLG_ANT_SEL_MSK = 0x0f00,
20387555SFei.Feng@Sun.COM 	RXON_FLG_ANT_A_MSK = (1 << 8),
20397555SFei.Feng@Sun.COM 	RXON_FLG_ANT_B_MSK = (1 << 9),
20407555SFei.Feng@Sun.COM 	/* radar detection enable */
20417555SFei.Feng@Sun.COM 	RXON_FLG_RADAR_DETECT_MSK = (1 << 12),
20427555SFei.Feng@Sun.COM 	RXON_FLG_TGJ_NARROW_BAND_MSK = (1 << 13),
20437555SFei.Feng@Sun.COM 	/*
20447555SFei.Feng@Sun.COM 	 * rx response to host with 8-byte TSF
20457555SFei.Feng@Sun.COM 	 * (according to ON_AIR deassertion)
20467555SFei.Feng@Sun.COM 	 */
20477555SFei.Feng@Sun.COM 	RXON_FLG_TSF2HOST_MSK = (1 << 15),
20487555SFei.Feng@Sun.COM 	RXON_FLG_DIS_ACQUISITION = (1 << 27),
20497555SFei.Feng@Sun.COM 	RXON_FLG_DIS_RE_ACQUISITION = (1 << 28),
20507555SFei.Feng@Sun.COM 	RXON_FLG_DIS_BEAMFORM = (1 << 29)
20517555SFei.Feng@Sun.COM };
20527555SFei.Feng@Sun.COM 
20537555SFei.Feng@Sun.COM /*
20547555SFei.Feng@Sun.COM  * rx_config filter flags
20557555SFei.Feng@Sun.COM  */
20567555SFei.Feng@Sun.COM enum {
20577555SFei.Feng@Sun.COM 	/* accept all data frames */
20587555SFei.Feng@Sun.COM 	RXON_FILTER_PROMISC_MSK = (1 << 0),
20597555SFei.Feng@Sun.COM 	/* pass control & management to host */
20607555SFei.Feng@Sun.COM 	RXON_FILTER_CTL2HOST_MSK = (1 << 1),
20617555SFei.Feng@Sun.COM 	/* accept multi-cast */
20627555SFei.Feng@Sun.COM 	RXON_FILTER_ACCEPT_GRP_MSK = (1 << 2),
20637555SFei.Feng@Sun.COM 	/* don't decrypt uni-cast frames */
20647555SFei.Feng@Sun.COM 	RXON_FILTER_DIS_DECRYPT_MSK = (1 << 3),
20657555SFei.Feng@Sun.COM 	/* don't decrypt multi-cast frames */
20667555SFei.Feng@Sun.COM 	RXON_FILTER_DIS_GRP_DECRYPT_MSK = (1 << 4),
20677555SFei.Feng@Sun.COM 	/* STA is associated */
20687555SFei.Feng@Sun.COM 	RXON_FILTER_ASSOC_MSK = (1 << 5),
20697555SFei.Feng@Sun.COM 	/* transfer to host non bssid beacons in associated state */
20707555SFei.Feng@Sun.COM 	RXON_FILTER_BCON_AWARE_MSK = (1 << 6)
20717555SFei.Feng@Sun.COM };
20727555SFei.Feng@Sun.COM 
20737555SFei.Feng@Sun.COM 
20747555SFei.Feng@Sun.COM /*
20757555SFei.Feng@Sun.COM  * structure for RXON Command & Response
20767555SFei.Feng@Sun.COM  */
20777555SFei.Feng@Sun.COM typedef struct iwh_rxon_cmd {
20787555SFei.Feng@Sun.COM 	uint8_t		node_addr[IEEE80211_ADDR_LEN];
20797555SFei.Feng@Sun.COM 	uint16_t	reserved1;
20807555SFei.Feng@Sun.COM 	uint8_t		bssid[IEEE80211_ADDR_LEN];
20817555SFei.Feng@Sun.COM 	uint16_t	reserved2;
20827555SFei.Feng@Sun.COM 	uint8_t		wlap_bssid[IEEE80211_ADDR_LEN];
20837555SFei.Feng@Sun.COM 	uint16_t	reserved3;
20847555SFei.Feng@Sun.COM 	uint8_t		dev_type;
20857555SFei.Feng@Sun.COM 	uint8_t		air_propagation;
20867555SFei.Feng@Sun.COM 	uint16_t	rx_chain;
20877555SFei.Feng@Sun.COM 	uint8_t		ofdm_basic_rates;
20887555SFei.Feng@Sun.COM 	uint8_t		cck_basic_rates;
20897555SFei.Feng@Sun.COM 	uint16_t	assoc_id;
20907555SFei.Feng@Sun.COM 	uint32_t	flags;
20917555SFei.Feng@Sun.COM 	uint32_t	filter_flags;
20927555SFei.Feng@Sun.COM 	uint16_t	chan;
20937555SFei.Feng@Sun.COM 	uint8_t		ofdm_ht_single_stream_basic_rates;
20947555SFei.Feng@Sun.COM 	uint8_t		ofdm_ht_dual_stream_basic_rates;
20957555SFei.Feng@Sun.COM 	uint8_t		ofdm_ht_triple_stream_basic_rates;
20967555SFei.Feng@Sun.COM 	uint8_t		reserved4;
20977555SFei.Feng@Sun.COM 	uint16_t	acquisition_data;
20987555SFei.Feng@Sun.COM 	uint16_t	reserved5;
20997555SFei.Feng@Sun.COM } iwh_rxon_cmd_t;
21007555SFei.Feng@Sun.COM 
21017555SFei.Feng@Sun.COM typedef struct iwh_compressed_ba_resp {
21027555SFei.Feng@Sun.COM 	uint32_t sta_addr_lo32;
21037555SFei.Feng@Sun.COM 	uint16_t sta_addr_hi16;
21047555SFei.Feng@Sun.COM 	uint16_t reserved;
21057555SFei.Feng@Sun.COM 	uint8_t sta_id;
21067555SFei.Feng@Sun.COM 	uint8_t tid;
21077555SFei.Feng@Sun.COM 	uint16_t ba_seq_ctl;
21087555SFei.Feng@Sun.COM 	uint32_t ba_bitmap0;
21097555SFei.Feng@Sun.COM 	uint32_t ba_bitmap1;
21107555SFei.Feng@Sun.COM 	uint16_t scd_flow;
21117555SFei.Feng@Sun.COM 	uint16_t scd_ssn;
21127555SFei.Feng@Sun.COM } iwh_compressed_ba_resp_t;
21137555SFei.Feng@Sun.COM 
21147555SFei.Feng@Sun.COM #define	PHY_CALIBRATE_DIFF_GAIN_CMD	(7)
211511152SFei.Feng@Sun.COM #define	PHY_CALIBRATE_DC_CMD		(8)
21167555SFei.Feng@Sun.COM #define	PHY_CALIBRATE_LO_CMD		(9)
21177555SFei.Feng@Sun.COM #define	PHY_CALIBRATE_TX_IQ_CMD		(11)
21187555SFei.Feng@Sun.COM #define	PHY_CALIBRATE_CRYSTAL_FRQ_CMD	(15)
211911152SFei.Feng@Sun.COM #define	PHY_CALIBRATE_BASE_BAND_CMD	(16)
21207555SFei.Feng@Sun.COM #define	PHY_CALIBRATE_TX_IQ_PERD_CMD	(17)
21217555SFei.Feng@Sun.COM #define	HD_TABLE_SIZE	(11)
21227555SFei.Feng@Sun.COM 
21237555SFei.Feng@Sun.COM /*
21247555SFei.Feng@Sun.COM  * Param table within SENSITIVITY_CMD
21257555SFei.Feng@Sun.COM  */
21267555SFei.Feng@Sun.COM #define	HD_MIN_ENERGY_CCK_DET_INDEX		(0)
21277555SFei.Feng@Sun.COM #define	HD_MIN_ENERGY_OFDM_DET_INDEX		(1)
21287555SFei.Feng@Sun.COM #define	HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX	(2)
21297555SFei.Feng@Sun.COM #define	HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX	(3)
21307555SFei.Feng@Sun.COM #define	HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX	(4)
21317555SFei.Feng@Sun.COM #define	HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX	(5)
21327555SFei.Feng@Sun.COM #define	HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX	(6)
21337555SFei.Feng@Sun.COM #define	HD_BARKER_CORR_TH_ADD_MIN_INDEX		(7)
21347555SFei.Feng@Sun.COM #define	HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX	(8)
21357555SFei.Feng@Sun.COM #define	HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX	(9)
21367555SFei.Feng@Sun.COM #define	HD_OFDM_ENERGY_TH_IN_INDEX		(10)
21377555SFei.Feng@Sun.COM 
21387555SFei.Feng@Sun.COM typedef struct iwh_sensitivity_cmd {
21397555SFei.Feng@Sun.COM 	uint16_t control;
21407555SFei.Feng@Sun.COM 	uint16_t table[HD_TABLE_SIZE];
21417555SFei.Feng@Sun.COM } iwh_sensitivity_cmd_t;
21427555SFei.Feng@Sun.COM 
21437555SFei.Feng@Sun.COM typedef struct iwh_calibration_cmd {
21447555SFei.Feng@Sun.COM 	uint8_t opCode;
21457555SFei.Feng@Sun.COM 	uint8_t flags;
21467555SFei.Feng@Sun.COM 	uint16_t reserved;
21477555SFei.Feng@Sun.COM 	char diff_gain_a;
21487555SFei.Feng@Sun.COM 	char diff_gain_b;
21497555SFei.Feng@Sun.COM 	char diff_gain_c;
21507555SFei.Feng@Sun.COM 	uint8_t reserved1;
21517555SFei.Feng@Sun.COM } iwh_calibation_cmd_t;
21527555SFei.Feng@Sun.COM 
21537555SFei.Feng@Sun.COM 
21547555SFei.Feng@Sun.COM struct	iwh_calib_hdr {
21557555SFei.Feng@Sun.COM 	uint8_t	op_code;
21567555SFei.Feng@Sun.COM 	uint8_t	first_group;
21577555SFei.Feng@Sun.COM 	uint8_t	groups_num;
21587555SFei.Feng@Sun.COM 	uint8_t	data_valid;
21597555SFei.Feng@Sun.COM };
21607555SFei.Feng@Sun.COM 
21617555SFei.Feng@Sun.COM #define	FH_RSCSR_FRAME_SIZE_MASK	(0x00003FFF)
21627555SFei.Feng@Sun.COM 
21637555SFei.Feng@Sun.COM struct	iwh_calib_results {
21647555SFei.Feng@Sun.COM 	void		*tx_iq_res;
21657555SFei.Feng@Sun.COM 	uint32_t	tx_iq_res_len;
21667555SFei.Feng@Sun.COM 	void		*tx_iq_perd_res;
21677555SFei.Feng@Sun.COM 	uint32_t	tx_iq_perd_res_len;
21687555SFei.Feng@Sun.COM 	void		*lo_res;
21697555SFei.Feng@Sun.COM 	uint32_t	lo_res_len;
217011152SFei.Feng@Sun.COM 	void		*dc_res;
217111152SFei.Feng@Sun.COM 	uint32_t	dc_res_len;
217211152SFei.Feng@Sun.COM 	void		*base_band_res;
217311152SFei.Feng@Sun.COM 	uint32_t	base_band_res_len;
21747555SFei.Feng@Sun.COM };
21757555SFei.Feng@Sun.COM 
21767555SFei.Feng@Sun.COM #define	IWH_CALIB_INIT_CFG_ALL	(0xFFFFFFFF)
21777555SFei.Feng@Sun.COM 
21787555SFei.Feng@Sun.COM struct	iwh_calib_cfg_elmnt_s {
21797555SFei.Feng@Sun.COM 	uint32_t	is_enable;
21807555SFei.Feng@Sun.COM 	uint32_t	start;
21817555SFei.Feng@Sun.COM 	uint32_t	send_res;
21827555SFei.Feng@Sun.COM 	uint32_t	apply_res;
21837555SFei.Feng@Sun.COM 	uint32_t	resered;
21847555SFei.Feng@Sun.COM };
21857555SFei.Feng@Sun.COM 
21867555SFei.Feng@Sun.COM struct	iwh_calib_cfg_status_s {
21877555SFei.Feng@Sun.COM 	struct	iwh_calib_cfg_elmnt_s	once;
21887555SFei.Feng@Sun.COM 	struct	iwh_calib_cfg_elmnt_s	perd;
21897555SFei.Feng@Sun.COM 	uint32_t	flags;
21907555SFei.Feng@Sun.COM };
21917555SFei.Feng@Sun.COM 
21927555SFei.Feng@Sun.COM struct	iwh_calib_cfg_cmd {
21937555SFei.Feng@Sun.COM 	struct	iwh_calib_cfg_status_s	ucd_calib_cfg;
21947555SFei.Feng@Sun.COM 	struct	iwh_calib_cfg_status_s	drv_calib_cfg;
21957555SFei.Feng@Sun.COM 	uint32_t	reserved1;
21967555SFei.Feng@Sun.COM };
21977555SFei.Feng@Sun.COM 
21987555SFei.Feng@Sun.COM struct	iwh_cal_crystal_freq {
21997555SFei.Feng@Sun.COM 	uint8_t	cap_pin1;
22007555SFei.Feng@Sun.COM 	uint8_t	cap_pin2;
22017555SFei.Feng@Sun.COM };
22027555SFei.Feng@Sun.COM 
22037555SFei.Feng@Sun.COM typedef	struct	iwh_calibration_crystal_cmd {
22047555SFei.Feng@Sun.COM 	uint8_t	opCode;
22057555SFei.Feng@Sun.COM 	uint8_t	first_group;
22067555SFei.Feng@Sun.COM 	uint8_t	num_group;
22077555SFei.Feng@Sun.COM 	uint8_t	all_data_valid;
22087555SFei.Feng@Sun.COM 	struct	iwh_cal_crystal_freq	data;
22097555SFei.Feng@Sun.COM } iwh_calibration_crystal_cmd_t;
22107555SFei.Feng@Sun.COM 
22117555SFei.Feng@Sun.COM #define	COEX_NUM_OF_EVENTS	(16)
22127555SFei.Feng@Sun.COM 
22137555SFei.Feng@Sun.COM struct	iwh_wimax_coex_event_entry {
22147555SFei.Feng@Sun.COM 	uint8_t	request_prio;
22157555SFei.Feng@Sun.COM 	uint8_t	win_medium_prio;
22167555SFei.Feng@Sun.COM 	uint8_t	reserved;
22177555SFei.Feng@Sun.COM 	uint8_t	flags;
22187555SFei.Feng@Sun.COM };
22197555SFei.Feng@Sun.COM 
22207555SFei.Feng@Sun.COM typedef	struct	iwh_wimax_coex_cmd {
22217555SFei.Feng@Sun.COM 	uint8_t	flags;
22227555SFei.Feng@Sun.COM 	uint8_t	reserved[3];
22237555SFei.Feng@Sun.COM 	struct iwh_wimax_coex_event_entry	sta_prio[COEX_NUM_OF_EVENTS];
22247555SFei.Feng@Sun.COM } iwh_wimax_coex_cmd_t;
22257555SFei.Feng@Sun.COM 
22267555SFei.Feng@Sun.COM typedef struct iwh_missed_beacon_notif {
22277555SFei.Feng@Sun.COM 	uint32_t consequtive_missed_beacons;
22287555SFei.Feng@Sun.COM 	uint32_t total_missed_becons;
22297555SFei.Feng@Sun.COM 	uint32_t num_expected_beacons;
22307555SFei.Feng@Sun.COM 	uint32_t num_recvd_beacons;
22317555SFei.Feng@Sun.COM } iwh_missed_beacon_notif_t;
22327555SFei.Feng@Sun.COM 
22337555SFei.Feng@Sun.COM typedef struct iwh_ct_kill_config {
22347555SFei.Feng@Sun.COM 	uint32_t   reserved;
22357555SFei.Feng@Sun.COM 	uint32_t   critical_temperature_M;
22367555SFei.Feng@Sun.COM 	uint32_t   critical_temperature_R;
22377555SFei.Feng@Sun.COM } iwh_ct_kill_config_t;
22387555SFei.Feng@Sun.COM 
22397555SFei.Feng@Sun.COM /*
22407555SFei.Feng@Sun.COM  * structure for command IWH_CMD_ASSOCIATE
22417555SFei.Feng@Sun.COM  */
22427555SFei.Feng@Sun.COM typedef struct iwh_assoc {
22437555SFei.Feng@Sun.COM 	uint32_t	flags;
22447555SFei.Feng@Sun.COM 	uint32_t	filter;
22457555SFei.Feng@Sun.COM 	uint8_t		ofdm_mask;
22467555SFei.Feng@Sun.COM 	uint8_t		cck_mask;
22477555SFei.Feng@Sun.COM 	uint8_t		ofdm_ht_single_stream_basic_rates;
22487555SFei.Feng@Sun.COM 	uint8_t		ofdm_ht_dual_stream_basic_rates;
22497555SFei.Feng@Sun.COM 	uint16_t	rx_chain_select_flags;
22507555SFei.Feng@Sun.COM 	uint16_t	reserved;
22517555SFei.Feng@Sun.COM } iwh_assoc_t;
22527555SFei.Feng@Sun.COM 
22537555SFei.Feng@Sun.COM /*
22547555SFei.Feng@Sun.COM  * structure for command IWH_CMD_TSF
22557555SFei.Feng@Sun.COM  */
22567555SFei.Feng@Sun.COM typedef struct iwh_cmd_tsf {
22577555SFei.Feng@Sun.COM 	uint32_t	timestampl;
22587555SFei.Feng@Sun.COM 	uint32_t	timestamph;
22597555SFei.Feng@Sun.COM 	uint16_t	bintval;
22607555SFei.Feng@Sun.COM 	uint16_t	atim;
22617555SFei.Feng@Sun.COM 	uint32_t	binitval;
22627555SFei.Feng@Sun.COM 	uint16_t	lintval;
22637555SFei.Feng@Sun.COM 	uint16_t	reserved;
22647555SFei.Feng@Sun.COM } iwh_cmd_tsf_t;
22657555SFei.Feng@Sun.COM 
22667555SFei.Feng@Sun.COM /*
22677555SFei.Feng@Sun.COM  * structure for IWH_CMD_ADD_NODE
22687555SFei.Feng@Sun.COM  */
226910266SQuaker.Fang@Sun.COM #define	STA_MODE_ADD_MSK		(0)
227010266SQuaker.Fang@Sun.COM #define	STA_MODE_MODIFY_MSK		(1)
227110266SQuaker.Fang@Sun.COM 
227210266SQuaker.Fang@Sun.COM #define	STA_FLG_RTS_MIMO_PROT		(1 << 17)
227310266SQuaker.Fang@Sun.COM #define	STA_FLG_MAX_AMPDU_POS		(19)
227410266SQuaker.Fang@Sun.COM #define	STA_FLG_AMPDU_DENSITY_POS	(23)
227510266SQuaker.Fang@Sun.COM #define	STA_FLG_FAT_EN			(1 << 21)
227610266SQuaker.Fang@Sun.COM 
227710266SQuaker.Fang@Sun.COM #define	STA_MODIFY_KEY_MASK		(0x01)
227810266SQuaker.Fang@Sun.COM #define	STA_MODIFY_TID_DISABLE_TX	(0x02)
227910266SQuaker.Fang@Sun.COM #define	STA_MODIFY_TX_RATE_MSK		(0x04)
228010266SQuaker.Fang@Sun.COM #define	STA_MODIFY_ADDBA_TID_MSK	(0x08)
228110266SQuaker.Fang@Sun.COM #define	STA_MODIFY_DELBA_TID_MSK	(0x10)
228210266SQuaker.Fang@Sun.COM 
22837555SFei.Feng@Sun.COM struct	sta_id_modify {
22847555SFei.Feng@Sun.COM 	uint8_t		addr[6];
22857555SFei.Feng@Sun.COM 	uint16_t	reserved1;
22867555SFei.Feng@Sun.COM 	uint8_t		sta_id;
22877555SFei.Feng@Sun.COM 	uint8_t		modify_mask;
22887555SFei.Feng@Sun.COM 	uint16_t	reserved2;
22897555SFei.Feng@Sun.COM };
22907555SFei.Feng@Sun.COM 
22917555SFei.Feng@Sun.COM struct	iwh_keyinfo {
22927555SFei.Feng@Sun.COM 	uint16_t	key_flags;
22937555SFei.Feng@Sun.COM 	uint8_t		tkip_rx_tsc_byte2;
22947555SFei.Feng@Sun.COM 	uint8_t		reserved1;
22957555SFei.Feng@Sun.COM 	uint16_t	tkip_rx_ttak[5];
22967555SFei.Feng@Sun.COM 	uint8_t		key_offset;
22977555SFei.Feng@Sun.COM 	uint8_t		reserved2;
22987555SFei.Feng@Sun.COM 	uint8_t		key[16];
22997555SFei.Feng@Sun.COM 	uint32_t	tx_secur_seq_cnt1;
23007555SFei.Feng@Sun.COM 	uint32_t	tx_secur_seq_cnt2;
23017555SFei.Feng@Sun.COM 	uint32_t	hw_tkip_mic_rx_key1;
23027555SFei.Feng@Sun.COM 	uint32_t	hw_tkip_mic_rx_key2;
23037555SFei.Feng@Sun.COM 	uint32_t	hw_tkip_mic_tx_key1;
23047555SFei.Feng@Sun.COM 	uint32_t	hw_tkip_mic_tx_key2;
23057555SFei.Feng@Sun.COM };
23067555SFei.Feng@Sun.COM typedef struct iwh_add_sta {
23077555SFei.Feng@Sun.COM 	uint8_t		mode;
23087555SFei.Feng@Sun.COM 	uint8_t		reserved[3];
23097555SFei.Feng@Sun.COM 	struct sta_id_modify	sta;
23107555SFei.Feng@Sun.COM 	struct iwh_keyinfo	key;
23117555SFei.Feng@Sun.COM 	uint32_t	station_flags;
23127555SFei.Feng@Sun.COM 	uint32_t	station_flags_msk;
23137555SFei.Feng@Sun.COM 	uint16_t	disable_tx;
23147555SFei.Feng@Sun.COM 	uint16_t	reserved1;
23157555SFei.Feng@Sun.COM 	uint8_t		add_immediate_ba_tid;
23167555SFei.Feng@Sun.COM 	uint8_t		remove_immediate_ba_tid;
23177555SFei.Feng@Sun.COM 	uint16_t	add_immediate_ba_ssn;
23187555SFei.Feng@Sun.COM 	uint32_t	reserved2;
23197555SFei.Feng@Sun.COM } iwh_add_sta_t;
23207555SFei.Feng@Sun.COM 
23217555SFei.Feng@Sun.COM typedef	struct iwh_rem_sta {
23227555SFei.Feng@Sun.COM 	uint8_t	num_sta;	/* number of removed stations */
23237555SFei.Feng@Sun.COM 	uint8_t	reserved1[3];
23247555SFei.Feng@Sun.COM 	uint8_t	addr[6];	/* MAC address of the first station */
23257555SFei.Feng@Sun.COM 	uint8_t	reserved2[2];
23267555SFei.Feng@Sun.COM } iwh_rem_sta_t;
23277555SFei.Feng@Sun.COM 
23287555SFei.Feng@Sun.COM /*
23297555SFei.Feng@Sun.COM  * Tx flags
23307555SFei.Feng@Sun.COM  */
23317555SFei.Feng@Sun.COM enum {
23327555SFei.Feng@Sun.COM 	TX_CMD_FLG_RTS_MSK = (1 << 1),
23337555SFei.Feng@Sun.COM 	TX_CMD_FLG_CTS_MSK = (1 << 2),
23347555SFei.Feng@Sun.COM 	TX_CMD_FLG_ACK_MSK = (1 << 3),
23357555SFei.Feng@Sun.COM 	TX_CMD_FLG_STA_RATE_MSK = (1 << 4),
23367555SFei.Feng@Sun.COM 	TX_CMD_FLG_IMM_BA_RSP_MASK = (1 << 6),
23377555SFei.Feng@Sun.COM 	TX_CMD_FLG_FULL_TXOP_PROT_MSK = (1 << 7),
23387555SFei.Feng@Sun.COM 	TX_CMD_FLG_ANT_SEL_MSK = 0xf00,
23397555SFei.Feng@Sun.COM 	TX_CMD_FLG_ANT_A_MSK = (1 << 8),
23407555SFei.Feng@Sun.COM 	TX_CMD_FLG_ANT_B_MSK = (1 << 9),
23417555SFei.Feng@Sun.COM 
23427555SFei.Feng@Sun.COM 	/* ucode ignores BT priority for this frame */
23437555SFei.Feng@Sun.COM 	TX_CMD_FLG_BT_DIS_MSK = (1 << 12),
23447555SFei.Feng@Sun.COM 
23457555SFei.Feng@Sun.COM 	/* ucode overrides sequence control */
23467555SFei.Feng@Sun.COM 	TX_CMD_FLG_SEQ_CTL_MSK = (1 << 13),
23477555SFei.Feng@Sun.COM 
23487555SFei.Feng@Sun.COM 	/* signal that this frame is non-last MPDU */
23497555SFei.Feng@Sun.COM 	TX_CMD_FLG_MORE_FRAG_MSK = (1 << 14),
23507555SFei.Feng@Sun.COM 
23517555SFei.Feng@Sun.COM 	/* calculate TSF in outgoing frame */
23527555SFei.Feng@Sun.COM 	TX_CMD_FLG_TSF_MSK = (1 << 16),
23537555SFei.Feng@Sun.COM 
23547555SFei.Feng@Sun.COM 	/* activate TX calibration. */
23557555SFei.Feng@Sun.COM 	TX_CMD_FLG_CALIB_MSK = (1 << 17),
23567555SFei.Feng@Sun.COM 
23577555SFei.Feng@Sun.COM 	/*
23587555SFei.Feng@Sun.COM 	 * signals that 2 bytes pad was inserted
23597555SFei.Feng@Sun.COM 	 * after the MAC header
23607555SFei.Feng@Sun.COM 	 */
23617555SFei.Feng@Sun.COM 	TX_CMD_FLG_MH_PAD_MSK = (1 << 20),
23627555SFei.Feng@Sun.COM 
23637555SFei.Feng@Sun.COM 	/* HCCA-AP - disable duration overwriting. */
23647555SFei.Feng@Sun.COM 	TX_CMD_FLG_DUR_MSK = (1 << 25),
23657555SFei.Feng@Sun.COM };
23667555SFei.Feng@Sun.COM 
23677555SFei.Feng@Sun.COM 
23687555SFei.Feng@Sun.COM /*
23697555SFei.Feng@Sun.COM  * structure for command IWH_CMD_TX_DATA
23707555SFei.Feng@Sun.COM  */
23717555SFei.Feng@Sun.COM typedef struct iwh_tx_cmd {
23727555SFei.Feng@Sun.COM 	uint16_t len;
23737555SFei.Feng@Sun.COM 	uint16_t next_frame_len;
23747555SFei.Feng@Sun.COM 	uint32_t tx_flags;
23757555SFei.Feng@Sun.COM 	struct iwh_dram_scratch scratch;
23767555SFei.Feng@Sun.COM 	struct iwh_rate rate;
23777555SFei.Feng@Sun.COM 	uint8_t sta_id;
23787555SFei.Feng@Sun.COM 	uint8_t sec_ctl;
23797555SFei.Feng@Sun.COM 	uint8_t initial_rate_index;
23807555SFei.Feng@Sun.COM 	uint8_t reserved;
23817555SFei.Feng@Sun.COM 	uint8_t key[16];
23827555SFei.Feng@Sun.COM 	uint16_t next_frame_flags;
23837555SFei.Feng@Sun.COM 	uint16_t reserved2;
23847555SFei.Feng@Sun.COM 	union {
23857555SFei.Feng@Sun.COM 		uint32_t life_time;
23867555SFei.Feng@Sun.COM 		uint32_t attempt;
23877555SFei.Feng@Sun.COM 	} stop_time;
23887555SFei.Feng@Sun.COM 	uint32_t dram_lsb_ptr;
23897555SFei.Feng@Sun.COM 	uint8_t dram_msb_ptr;
23907555SFei.Feng@Sun.COM 	uint8_t rts_retry_limit;
23917555SFei.Feng@Sun.COM 	uint8_t data_retry_limit;
23927555SFei.Feng@Sun.COM 	uint8_t tid_tspec;
23937555SFei.Feng@Sun.COM 	union {
23947555SFei.Feng@Sun.COM 		uint16_t pm_frame_timeout;
23957555SFei.Feng@Sun.COM 		uint16_t attempt_duration;
23967555SFei.Feng@Sun.COM 	} timeout;
23977555SFei.Feng@Sun.COM 	uint16_t driver_txop;
23987555SFei.Feng@Sun.COM } iwh_tx_cmd_t;
23997555SFei.Feng@Sun.COM 
24007555SFei.Feng@Sun.COM 
24017555SFei.Feng@Sun.COM /*
24027555SFei.Feng@Sun.COM  * structure for command "TX beacon"
24037555SFei.Feng@Sun.COM  */
24047555SFei.Feng@Sun.COM 
24057555SFei.Feng@Sun.COM typedef struct iwh_tx_beacon_cmd {
24067555SFei.Feng@Sun.COM 	iwh_tx_cmd_t	config;
24077555SFei.Feng@Sun.COM 	uint16_t	tim_idx;
24087555SFei.Feng@Sun.COM 	uint8_t		tim_size;
24097555SFei.Feng@Sun.COM 	uint8_t		reserved;
24107555SFei.Feng@Sun.COM 	uint8_t		bcon_frame[2342];
24117555SFei.Feng@Sun.COM } iwh_tx_beacon_cmd_t;
24127555SFei.Feng@Sun.COM 
24137555SFei.Feng@Sun.COM 
24147555SFei.Feng@Sun.COM /*
24157555SFei.Feng@Sun.COM  * LEDs Command & Response
24167555SFei.Feng@Sun.COM  * REPLY_LEDS_CMD = 0x48 (command, has simple generic response)
24177555SFei.Feng@Sun.COM  *
24187555SFei.Feng@Sun.COM  * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field),
24197555SFei.Feng@Sun.COM  * this command turns it on or off, or sets up a periodic blinking cycle.
24207555SFei.Feng@Sun.COM  */
24217555SFei.Feng@Sun.COM typedef struct iwh_led_cmd {
24227555SFei.Feng@Sun.COM 	uint32_t interval;	/* "interval" in uSec */
24237555SFei.Feng@Sun.COM 	uint8_t id;		/* 1: Activity, 2: Link, 3: Tech */
24247555SFei.Feng@Sun.COM 		/*
24257555SFei.Feng@Sun.COM 		 * # intervals off while blinking;
24267555SFei.Feng@Sun.COM 		 * "0", with > 0 "on" value, turns LED on
24277555SFei.Feng@Sun.COM 		 */
24287555SFei.Feng@Sun.COM 	uint8_t off;
24297555SFei.Feng@Sun.COM 		/*
24307555SFei.Feng@Sun.COM 		 * # intervals on while blinking;
24317555SFei.Feng@Sun.COM 		 * "0", regardless of "off", turns LED off
24327555SFei.Feng@Sun.COM 		 */
24337555SFei.Feng@Sun.COM 	uint8_t on;
24347555SFei.Feng@Sun.COM 	uint8_t reserved;
24357555SFei.Feng@Sun.COM } iwh_led_cmd_t;
24367555SFei.Feng@Sun.COM 
24377555SFei.Feng@Sun.COM /*
24387555SFei.Feng@Sun.COM  * structure for IWH_CMD_SET_POWER_MODE
24397555SFei.Feng@Sun.COM  */
24407555SFei.Feng@Sun.COM typedef struct iwh_powertable_cmd {
24417555SFei.Feng@Sun.COM 	uint16_t	flags;
24427555SFei.Feng@Sun.COM 	uint8_t		keep_alive_seconds;
24437555SFei.Feng@Sun.COM 	uint8_t		debug_flags;
24447555SFei.Feng@Sun.COM 	uint32_t	rx_timeout;
24457555SFei.Feng@Sun.COM 	uint32_t	tx_timeout;
24467555SFei.Feng@Sun.COM 	uint32_t	sleep[5];
24477555SFei.Feng@Sun.COM 	uint32_t	keep_alive_beacons;
24487555SFei.Feng@Sun.COM } iwh_powertable_cmd_t;
24497555SFei.Feng@Sun.COM 
24507555SFei.Feng@Sun.COM struct iwh_ssid_ie {
24517555SFei.Feng@Sun.COM 	uint8_t id;
24527555SFei.Feng@Sun.COM 	uint8_t len;
24537555SFei.Feng@Sun.COM 	uint8_t ssid[32];
24547555SFei.Feng@Sun.COM };
24557555SFei.Feng@Sun.COM /*
24567555SFei.Feng@Sun.COM  * structure for command IWH_CMD_SCAN
24577555SFei.Feng@Sun.COM  */
24587555SFei.Feng@Sun.COM typedef struct iwh_scan_hdr {
24597555SFei.Feng@Sun.COM 	uint16_t len;
24607555SFei.Feng@Sun.COM 	uint8_t	 reserved1;
24617555SFei.Feng@Sun.COM 	uint8_t	 nchan;
24627555SFei.Feng@Sun.COM 		/*
24637555SFei.Feng@Sun.COM 		 * dwell only this long on quiet chnl
24647555SFei.Feng@Sun.COM 		 * (active scan)
24657555SFei.Feng@Sun.COM 		 */
24667555SFei.Feng@Sun.COM 	uint16_t quiet_time;
24677555SFei.Feng@Sun.COM 	uint16_t quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */
24687555SFei.Feng@Sun.COM 	uint16_t good_crc_th; /* passive -> active promotion threshold */
24697555SFei.Feng@Sun.COM 	uint16_t rx_chain;
24707555SFei.Feng@Sun.COM 		/*
24717555SFei.Feng@Sun.COM 		 * max usec to be out of associated (service)
24727555SFei.Feng@Sun.COM 		 * chnl
24737555SFei.Feng@Sun.COM 		 */
24747555SFei.Feng@Sun.COM 	uint32_t max_out_time;
24757555SFei.Feng@Sun.COM 		/*
24767555SFei.Feng@Sun.COM 		 * pause scan this long when returning to svc
24777555SFei.Feng@Sun.COM 		 * chnl.
24787555SFei.Feng@Sun.COM 		 * SP -- 31:22 # beacons, 21:0 additional usec.
24797555SFei.Feng@Sun.COM 		 */
24807555SFei.Feng@Sun.COM 	uint32_t suspend_time;
24817555SFei.Feng@Sun.COM 	uint32_t flags;
24827555SFei.Feng@Sun.COM 	uint32_t filter_flags;
24837555SFei.Feng@Sun.COM 	struct	 iwh_tx_cmd tx_cmd;
24847555SFei.Feng@Sun.COM 	struct	 iwh_ssid_ie direct_scan[20];
24857555SFei.Feng@Sun.COM 	/* followed by probe request body */
24867555SFei.Feng@Sun.COM 	/* followed by nchan x iwh_scan_chan */
24877555SFei.Feng@Sun.COM } iwh_scan_hdr_t;
24887555SFei.Feng@Sun.COM 
24897555SFei.Feng@Sun.COM typedef struct iwh_scan_chan {
24907555SFei.Feng@Sun.COM 	uint32_t	type;
24917555SFei.Feng@Sun.COM 	uint16_t	chan;
24927555SFei.Feng@Sun.COM 	struct iwh_tx_power	tpc;
24937555SFei.Feng@Sun.COM 	uint16_t	active_dwell;	/* dwell time */
24947555SFei.Feng@Sun.COM 	uint16_t	passive_dwell;	/* dwell time */
24957555SFei.Feng@Sun.COM } iwh_scan_chan_t;
24967555SFei.Feng@Sun.COM 
24977555SFei.Feng@Sun.COM /*
24987555SFei.Feng@Sun.COM  * structure for IWH_CMD_BLUETOOTH
24997555SFei.Feng@Sun.COM  */
25007555SFei.Feng@Sun.COM typedef struct iwh_bt_cmd {
25017555SFei.Feng@Sun.COM 	uint8_t		flags;
25027555SFei.Feng@Sun.COM 	uint8_t		lead_time;
25037555SFei.Feng@Sun.COM 	uint8_t		max_kill;
25047555SFei.Feng@Sun.COM 	uint8_t		reserved;
25057555SFei.Feng@Sun.COM 	uint32_t	kill_ack_mask;
25067555SFei.Feng@Sun.COM 	uint32_t	kill_cts_mask;
25077555SFei.Feng@Sun.COM } iwh_bt_cmd_t;
25087555SFei.Feng@Sun.COM 
250910266SQuaker.Fang@Sun.COM typedef struct iwh_wme_param {
251010266SQuaker.Fang@Sun.COM 	uint8_t		aifsn;
251110266SQuaker.Fang@Sun.COM 	uint8_t		cwmin_e;
251210266SQuaker.Fang@Sun.COM 	uint8_t		cwmax_e;
251310266SQuaker.Fang@Sun.COM 	uint16_t	txop;
251410266SQuaker.Fang@Sun.COM } iwh_wme_param_t;
251510266SQuaker.Fang@Sun.COM /*
251610266SQuaker.Fang@Sun.COM  * QoS parameter command (REPLY_QOS_PARAM = 0x13)
251710266SQuaker.Fang@Sun.COM  * FIFO0-background, FIFO1-best effort, FIFO2-video, FIFO3-voice
251810266SQuaker.Fang@Sun.COM  */
251910266SQuaker.Fang@Sun.COM 
252010266SQuaker.Fang@Sun.COM struct iwh_edca_param {
252110266SQuaker.Fang@Sun.COM 	uint16_t	cw_min;
252210266SQuaker.Fang@Sun.COM 	uint16_t	cw_max;
252310266SQuaker.Fang@Sun.COM 	uint8_t		aifsn;
252410266SQuaker.Fang@Sun.COM 	uint8_t		reserved;
252510266SQuaker.Fang@Sun.COM 	uint16_t	txop;
252610266SQuaker.Fang@Sun.COM };
252710266SQuaker.Fang@Sun.COM 
252810266SQuaker.Fang@Sun.COM typedef struct iwh_qos_param_cmd {
252910266SQuaker.Fang@Sun.COM 	uint32_t	flags;
253010266SQuaker.Fang@Sun.COM 	struct iwh_edca_param	ac[AC_NUM];
253110266SQuaker.Fang@Sun.COM } iwh_qos_param_cmd_t;
253210266SQuaker.Fang@Sun.COM 
25337555SFei.Feng@Sun.COM /*
25347555SFei.Feng@Sun.COM  * firmware image header
25357555SFei.Feng@Sun.COM  */
25367555SFei.Feng@Sun.COM typedef struct iwh_firmware_hdr {
25377555SFei.Feng@Sun.COM 	uint32_t	version;
25387555SFei.Feng@Sun.COM 	uint32_t	textsz;
25397555SFei.Feng@Sun.COM 	uint32_t	datasz;
25407555SFei.Feng@Sun.COM 	uint32_t	init_textsz;
25417555SFei.Feng@Sun.COM 	uint32_t	init_datasz;
25427555SFei.Feng@Sun.COM 	uint32_t	bootsz;
25437555SFei.Feng@Sun.COM } iwh_firmware_hdr_t;
25447555SFei.Feng@Sun.COM 
25457555SFei.Feng@Sun.COM /*
25467555SFei.Feng@Sun.COM  * structure for IWH_START_SCAN notification
25477555SFei.Feng@Sun.COM  */
25487555SFei.Feng@Sun.COM typedef struct iwh_start_scan {
25497555SFei.Feng@Sun.COM 	uint32_t	timestampl;
25507555SFei.Feng@Sun.COM 	uint32_t	timestamph;
25517555SFei.Feng@Sun.COM 	uint32_t	tbeacon;
25527555SFei.Feng@Sun.COM 	uint8_t		chan;
25537555SFei.Feng@Sun.COM 	uint8_t		band;
25547555SFei.Feng@Sun.COM 	uint16_t	reserved;
25557555SFei.Feng@Sun.COM 	uint32_t	status;
25567555SFei.Feng@Sun.COM } iwh_start_scan_t;
25577555SFei.Feng@Sun.COM 
25587700SFei.Feng@Sun.COM /*
25597700SFei.Feng@Sun.COM  * structure for IWK_SCAN_COMPLETE notification
25607700SFei.Feng@Sun.COM  */
25617700SFei.Feng@Sun.COM typedef struct iwh_stop_scan {
25627700SFei.Feng@Sun.COM 	uint8_t		nchan;
25637700SFei.Feng@Sun.COM 	uint8_t		status;
25647700SFei.Feng@Sun.COM 	uint8_t		reserved;
25657700SFei.Feng@Sun.COM 	uint8_t		chan;
25667700SFei.Feng@Sun.COM 	uint8_t		tsf;
25677700SFei.Feng@Sun.COM } iwh_stop_scan_t;
25687700SFei.Feng@Sun.COM 
25697555SFei.Feng@Sun.COM 
25707555SFei.Feng@Sun.COM #define	IWH_READ(sc, reg)						\
25717555SFei.Feng@Sun.COM 	ddi_get32((sc)->sc_handle, (uint32_t *)((sc)->sc_base + (reg)))
25727555SFei.Feng@Sun.COM 
25737555SFei.Feng@Sun.COM #define	IWH_WRITE(sc, reg, val)					\
25747555SFei.Feng@Sun.COM 	ddi_put32((sc)->sc_handle, (uint32_t *)((sc)->sc_base + (reg)), (val))
25757555SFei.Feng@Sun.COM 
25767555SFei.Feng@Sun.COM /*
25777555SFei.Feng@Sun.COM  * Driver can access peripheral registers
25787555SFei.Feng@Sun.COM  * and ram via HBUS_TARG_PRPH_* registers.
25797555SFei.Feng@Sun.COM  */
25807555SFei.Feng@Sun.COM 
25817555SFei.Feng@Sun.COM #define	PRPH_BASE	(0x00000)
25827555SFei.Feng@Sun.COM #define	PRPH_END	(0xFFFFF)
25837555SFei.Feng@Sun.COM 
25847555SFei.Feng@Sun.COM #define	IWH_SCD_BASE	(PRPH_BASE + 0xA02C00)
25857555SFei.Feng@Sun.COM 
25867555SFei.Feng@Sun.COM #define	IWH_SCD_SRAM_BASE_ADDR	(IWH_SCD_BASE + 0x0)
25877555SFei.Feng@Sun.COM #define	IWH_SCD_DRAM_BASE_ADDR	(IWH_SCD_BASE + 0x8)
25887555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUECHAIN_SEL	(IWH_SCD_BASE + 0xE8)
25897555SFei.Feng@Sun.COM #define	IWH_SCD_AGGR_SEL	(IWH_SCD_BASE + 0x248)
25907555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_RDPTR(x)	(IWH_SCD_BASE + 0x68 + (x) * 4)
25917555SFei.Feng@Sun.COM #define	IWH_SCD_INTERRUPT_MASK	(IWH_SCD_BASE + 0x108)
25927555SFei.Feng@Sun.COM #define	IWH_SCD_TXFACT		(IWH_SCD_BASE + 0x1C)
25937555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_STATUS_BITS(x)	(IWH_SCD_BASE + 0x10C + (x) * 4)
25947555SFei.Feng@Sun.COM 
25957555SFei.Feng@Sun.COM #define	IWH_SCD_CONTEXT_DATA_OFFSET	(0x600)
25967555SFei.Feng@Sun.COM #define	IWH_SCD_TX_STTS_BITMAP_OFFSET	(0x7B1)
25977555SFei.Feng@Sun.COM #define	IWH_SCD_TRANSLATE_TBL_OFFSET	(0x7E0)
25987555SFei.Feng@Sun.COM 
25997555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS	(0)
26007555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK	(0x0000007F)
26017555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS	(16)
26027555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK	(0x007F0000)
26037555SFei.Feng@Sun.COM 
26047555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUECHAIN_SEL_ALL(x)	(((1 << (x)) - 1) &\
26057555SFei.Feng@Sun.COM 				(~(1 << IWH_CMD_QUEUE_NUM)))
26067555SFei.Feng@Sun.COM 
26077555SFei.Feng@Sun.COM #define	IWH_SCD_CONTEXT_QUEUE_OFFSET(x)\
26087555SFei.Feng@Sun.COM 		(IWH_SCD_CONTEXT_DATA_OFFSET + (x) * 8)
26097555SFei.Feng@Sun.COM 
26107555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_STTS_REG_POS_TXF		(0)
26117555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_STTS_REG_POS_ACTIVE	(3)
26127555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_STTS_REG_POS_WSL		(4)
26137555SFei.Feng@Sun.COM #define	IWH_SCD_QUEUE_STTS_REG_MSK		(0x00FF0000)
26147555SFei.Feng@Sun.COM 
26157555SFei.Feng@Sun.COM /* TX command security control */
26167555SFei.Feng@Sun.COM #define	TX_CMD_SEC_WEP		(0x01)
26177555SFei.Feng@Sun.COM #define	TX_CMD_SEC_CCM		(0x02)
26187555SFei.Feng@Sun.COM #define	TX_CMD_SEC_TKIP		(0x03)
26197555SFei.Feng@Sun.COM #define	TX_CMD_SEC_MSK		(0x03)
26207555SFei.Feng@Sun.COM #define	TX_CMD_SEC_SHIFT	(6)
26217555SFei.Feng@Sun.COM #define	TX_CMD_SEC_KEY128	(0x08)
26227555SFei.Feng@Sun.COM 
26237555SFei.Feng@Sun.COM #define	WEP_IV_LEN	(4)
26247555SFei.Feng@Sun.COM #define	WEP_ICV_LEN	(4)
26257555SFei.Feng@Sun.COM #define	CCMP_MIC_LEN	(8)
26267555SFei.Feng@Sun.COM #define	TKIP_ICV_LEN	(4)
26277555SFei.Feng@Sun.COM 
26287555SFei.Feng@Sun.COM #ifdef __cplusplus
26297555SFei.Feng@Sun.COM }
26307555SFei.Feng@Sun.COM #endif
26317555SFei.Feng@Sun.COM 
26327555SFei.Feng@Sun.COM #endif /* _IWH_HW_H_ */
2633