Home | History | Annotate | Line # | Download | only in pci
if_alcreg.h revision 1.2
      1  1.1  jmcneill /*	$OpenBSD: if_alcreg.h,v 1.1 2009/08/08 09:31:13 kevlo Exp $	*/
      2  1.1  jmcneill /*-
      3  1.1  jmcneill  * Copyright (c) 2009, Pyun YongHyeon <yongari (at) FreeBSD.org>
      4  1.1  jmcneill  * All rights reserved.
      5  1.1  jmcneill  *
      6  1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
      7  1.1  jmcneill  * modification, are permitted provided that the following conditions
      8  1.1  jmcneill  * are met:
      9  1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     10  1.1  jmcneill  *    notice unmodified, this list of conditions, and the following
     11  1.1  jmcneill  *    disclaimer.
     12  1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     15  1.1  jmcneill  *
     16  1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17  1.1  jmcneill  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  1.1  jmcneill  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.1  jmcneill  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20  1.1  jmcneill  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  1.1  jmcneill  * DAMATES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  1.1  jmcneill  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1  jmcneill  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  1.1  jmcneill  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1  jmcneill  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1  jmcneill  * SUCH DAMATE.
     27  1.1  jmcneill  *
     28  1.1  jmcneill  * $FreeBSD: src/sys/dev/alc/if_alcreg.h,v 1.1 2009/06/10 02:07:58 yongari Exp $
     29  1.1  jmcneill  */
     30  1.1  jmcneill 
     31  1.1  jmcneill #ifndef	_IF_ALCREG_H
     32  1.1  jmcneill #define	_IF_ALCREG_H
     33  1.1  jmcneill 
     34  1.1  jmcneill #define ALC_PCIR_BAR			0x10
     35  1.1  jmcneill 
     36  1.2  jmcneill #define ATHEROS_AR8152_B_V10		0xC0
     37  1.2  jmcneill #define ATHEROS_AR8152_B_V11		0xC1
     38  1.2  jmcneill 
     39  1.1  jmcneill /* 0x0000 - 0x02FF : PCIe configuration space */
     40  1.1  jmcneill 
     41  1.1  jmcneill #define	ALC_PEX_UNC_ERR_SEV		0x10C
     42  1.1  jmcneill #define	PEX_UNC_ERR_SEV_TRN		0x00000001
     43  1.1  jmcneill #define	PEX_UNC_ERR_SEV_DLP		0x00000010
     44  1.1  jmcneill #define	PEX_UNC_ERR_SEV_PSN_TLP		0x00001000
     45  1.1  jmcneill #define	PEX_UNC_ERR_SEV_FCP		0x00002000
     46  1.1  jmcneill #define	PEX_UNC_ERR_SEV_CPL_TO		0x00004000
     47  1.1  jmcneill #define	PEX_UNC_ERR_SEV_CA		0x00008000
     48  1.1  jmcneill #define	PEX_UNC_ERR_SEV_UC		0x00010000
     49  1.1  jmcneill #define	PEX_UNC_ERR_SEV_ROV		0x00020000
     50  1.1  jmcneill #define	PEX_UNC_ERR_SEV_MLFP		0x00040000
     51  1.1  jmcneill #define	PEX_UNC_ERR_SEV_ECRC		0x00080000
     52  1.1  jmcneill #define	PEX_UNC_ERR_SEV_UR		0x00100000
     53  1.1  jmcneill 
     54  1.1  jmcneill #define	ALC_TWSI_CFG			0x218
     55  1.1  jmcneill #define	TWSI_CFG_SW_LD_START		0x00000800
     56  1.1  jmcneill #define	TWSI_CFG_HW_LD_START		0x00001000
     57  1.1  jmcneill #define	TWSI_CFG_LD_EXIST		0x00400000
     58  1.1  jmcneill 
     59  1.1  jmcneill #define	ALC_PCIE_PHYMISC		0x1000
     60  1.1  jmcneill #define	PCIE_PHYMISC_FORCE_RCV_DET	0x00000004
     61  1.1  jmcneill 
     62  1.2  jmcneill #define	ALC_PCIE_PHYMISC2		0x1004
     63  1.2  jmcneill #define	PCIE_PHYMISC2_SERDES_CDR_MASK	0x00030000
     64  1.2  jmcneill #define	PCIE_PHYMISC2_SERDES_TH_MASK	0x000C0000
     65  1.2  jmcneill #define	PCIE_PHYMISC2_SERDES_CDR_SHIFT	16
     66  1.2  jmcneill #define	PCIE_PHYMISC2_SERDES_TH_SHIFT	18
     67  1.2  jmcneill 
     68  1.1  jmcneill #define	ALC_TWSI_DEBUG			0x1108
     69  1.1  jmcneill #define	TWSI_DEBUG_DEV_EXIST		0x20000000
     70  1.1  jmcneill 
     71  1.1  jmcneill #define	ALC_EEPROM_CFG			0x12C0
     72  1.1  jmcneill #define	EEPROM_CFG_DATA_HI_MASK		0x0000FFFF
     73  1.1  jmcneill #define	EEPROM_CFG_ADDR_MASK		0x03FF0000
     74  1.1  jmcneill #define	EEPROM_CFG_ACK			0x40000000
     75  1.1  jmcneill #define	EEPROM_CFG_RW			0x80000000
     76  1.1  jmcneill #define	EEPROM_CFG_DATA_HI_SHIFT	0
     77  1.1  jmcneill #define	EEPROM_CFG_ADDR_SHIFT		16
     78  1.1  jmcneill 
     79  1.1  jmcneill #define	ALC_EEPROM_DATA_LO		0x12C4
     80  1.1  jmcneill 
     81  1.1  jmcneill #define	ALC_OPT_CFG			0x12F0
     82  1.1  jmcneill #define	OPT_CFG_CLK_ENB			0x00000002
     83  1.1  jmcneill 
     84  1.1  jmcneill #define	ALC_PM_CFG			0x12F8
     85  1.1  jmcneill #define	PM_CFG_SERDES_ENB		0x00000001
     86  1.1  jmcneill #define	PM_CFG_RBER_ENB			0x00000002
     87  1.1  jmcneill #define	PM_CFG_CLK_REQ_ENB		0x00000004
     88  1.1  jmcneill #define	PM_CFG_ASPM_L1_ENB		0x00000008
     89  1.1  jmcneill #define	PM_CFG_SERDES_L1_ENB		0x00000010
     90  1.1  jmcneill #define	PM_CFG_SERDES_PLL_L1_ENB	0x00000020
     91  1.1  jmcneill #define	PM_CFG_SERDES_PD_EX_L1		0x00000040
     92  1.1  jmcneill #define	PM_CFG_SERDES_BUDS_RX_L1_ENB	0x00000080
     93  1.1  jmcneill #define	PM_CFG_L0S_ENTRY_TIMER_MASK	0x00000F00
     94  1.1  jmcneill #define	PM_CFG_ASPM_L0S_ENB		0x00001000
     95  1.1  jmcneill #define	PM_CFG_CLK_SWH_L1		0x00002000
     96  1.1  jmcneill #define	PM_CFG_CLK_PWM_VER1_1		0x00004000
     97  1.1  jmcneill #define	PM_CFG_PCIE_RECV		0x00008000
     98  1.1  jmcneill #define	PM_CFG_L1_ENTRY_TIMER_MASK	0x000F0000
     99  1.1  jmcneill #define	PM_CFG_PM_REQ_TIMER_MASK	0x00F00000
    100  1.2  jmcneill #define	PM_CFG_LCKDET_TIMER_MASK	0x0F000000
    101  1.2  jmcneill #define	PM_CFG_EN_BUFS_RX_L0S		0x10000000
    102  1.2  jmcneill #define	PM_CFG_SA_DLY_ENB		0x20000000
    103  1.1  jmcneill #define	PM_CFG_MAC_ASPM_CHK		0x40000000
    104  1.1  jmcneill #define	PM_CFG_HOTRST			0x80000000
    105  1.1  jmcneill #define	PM_CFG_L0S_ENTRY_TIMER_SHIFT	8
    106  1.1  jmcneill #define	PM_CFG_L1_ENTRY_TIMER_SHIFT	16
    107  1.1  jmcneill #define	PM_CFG_PM_REQ_TIMER_SHIFT	20
    108  1.1  jmcneill #define	PM_CFG_LCKDET_TIMER_SHIFT	24
    109  1.1  jmcneill 
    110  1.2  jmcneill #define PM_CFG_L0S_ENTRY_TIMER_DEFAULT	6
    111  1.2  jmcneill #define	PM_CFG_L1_ENTRY_TIMER_DEFAULT	1
    112  1.2  jmcneill #define	PM_CFG_LCKDET_TIMER_DEFAULT	12
    113  1.2  jmcneill #define	PM_CFG_PM_REQ_TIMER_DEFAULT	12
    114  1.2  jmcneill 
    115  1.2  jmcneill #define	ALC_LTSSM_ID_CFG		0x12FC
    116  1.2  jmcneill #define	LTSSM_ID_WRO_ENB		0x00001000
    117  1.2  jmcneill 
    118  1.1  jmcneill #define	ALC_MASTER_CFG			0x1400
    119  1.1  jmcneill #define	MASTER_RESET			0x00000001
    120  1.2  jmcneill #define	MASTER_TEST_MODE_MASK		0x0000000C
    121  1.1  jmcneill #define	MASTER_BERT_START		0x00000010
    122  1.2  jmcneill #define	MASTER_OOB_DIS_OFF		0x00000040
    123  1.2  jmcneill #define	MASTER_SA_TIMER_ENB		0x00000080
    124  1.1  jmcneill #define	MASTER_MTIMER_ENB		0x00000100
    125  1.1  jmcneill #define	MASTER_MANUAL_INTR_ENB		0x00000200
    126  1.1  jmcneill #define	MASTER_IM_TX_TIMER_ENB		0x00000400
    127  1.1  jmcneill #define	MASTER_IM_RX_TIMER_ENB		0x00000800
    128  1.1  jmcneill #define	MASTER_CLK_SEL_DIS		0x00001000
    129  1.1  jmcneill #define	MASTER_CLK_SWH_MODE		0x00002000
    130  1.1  jmcneill #define	MASTER_INTR_RD_CLR		0x00004000
    131  1.1  jmcneill #define	MASTER_CHIP_REV_MASK		0x00FF0000
    132  1.1  jmcneill #define	MASTER_CHIP_ID_MASK		0x7F000000
    133  1.1  jmcneill #define	MASTER_OTP_SEL			0x80000000
    134  1.1  jmcneill #define	MASTER_TEST_MODE_SHIFT		2
    135  1.1  jmcneill #define	MASTER_CHIP_REV_SHIFT		16
    136  1.1  jmcneill #define	MASTER_CHIP_ID_SHIFT		24
    137  1.1  jmcneill 
    138  1.2  jmcneill /* Number of ticks per usec for AR813x/AR815x. */
    139  1.1  jmcneill #define	ALC_TICK_USECS			2
    140  1.1  jmcneill #define	ALC_USECS(x)			((x) / ALC_TICK_USECS)
    141  1.1  jmcneill 
    142  1.1  jmcneill #define	ALC_MANUAL_TIMER		0x1404
    143  1.1  jmcneill 
    144  1.1  jmcneill #define	ALC_IM_TIMER			0x1408
    145  1.1  jmcneill #define	IM_TIMER_TX_MASK		0x0000FFFF
    146  1.1  jmcneill #define	IM_TIMER_RX_MASK		0xFFFF0000
    147  1.1  jmcneill #define	IM_TIMER_TX_SHIFT		0
    148  1.1  jmcneill #define	IM_TIMER_RX_SHIFT		16
    149  1.1  jmcneill #define	ALC_IM_TIMER_MIN		0
    150  1.1  jmcneill #define	ALC_IM_TIMER_MAX		130000	/* 130ms */
    151  1.1  jmcneill /*
    152  1.1  jmcneill  * 100us will ensure alc(4) wouldn't generate more than 10000 Rx
    153  1.1  jmcneill  * interrupts in a second.
    154  1.1  jmcneill  */
    155  1.1  jmcneill #define	ALC_IM_RX_TIMER_DEFAULT		100	/* 100us */
    156  1.1  jmcneill /*
    157  1.1  jmcneill  * alc(4) does not rely on Tx completion interrupts, so set it
    158  1.1  jmcneill  * somewhat large value to reduce Tx completion interrupts.
    159  1.1  jmcneill  */
    160  1.1  jmcneill #define	ALC_IM_TX_TIMER_DEFAULT		50000	/* 50ms */
    161  1.1  jmcneill 
    162  1.1  jmcneill #define	ALC_GPHY_CFG			0x140C	/* 16bits */
    163  1.1  jmcneill #define	GPHY_CFG_EXT_RESET		0x0001
    164  1.1  jmcneill #define	GPHY_CFG_RTL_MODE		0x0002
    165  1.1  jmcneill #define	GPHY_CFG_LED_MODE		0x0004
    166  1.1  jmcneill #define	GPHY_CFG_ANEG_NOW		0x0008
    167  1.1  jmcneill #define	GPHY_CFG_RECV_ANEG		0x0010
    168  1.1  jmcneill #define	GPHY_CFG_GATE_25M_ENB		0x0020
    169  1.1  jmcneill #define	GPHY_CFG_LPW_EXIT		0x0040
    170  1.1  jmcneill #define	GPHY_CFG_PHY_IDDQ		0x0080
    171  1.1  jmcneill #define	GPHY_CFG_PHY_IDDQ_DIS		0x0100
    172  1.1  jmcneill #define	GPHY_CFG_PCLK_SEL_DIS		0x0200
    173  1.1  jmcneill #define	GPHY_CFG_HIB_EN			0x0400
    174  1.1  jmcneill #define	GPHY_CFG_HIB_PULSE		0x0800
    175  1.1  jmcneill #define	GPHY_CFG_SEL_ANA_RESET		0x1000
    176  1.1  jmcneill #define	GPHY_CFG_PHY_PLL_ON		0x2000
    177  1.1  jmcneill #define	GPHY_CFG_PWDOWN_HW		0x4000
    178  1.1  jmcneill #define	GPHY_CFG_PHY_PLL_BYPASS		0x8000
    179  1.1  jmcneill 
    180  1.1  jmcneill #define	ALC_IDLE_STATUS			0x1410
    181  1.1  jmcneill #define	IDLE_STATUS_RXMAC		0x00000001
    182  1.1  jmcneill #define	IDLE_STATUS_TXMAC		0x00000002
    183  1.1  jmcneill #define	IDLE_STATUS_RXQ			0x00000004
    184  1.1  jmcneill #define	IDLE_STATUS_TXQ			0x00000008
    185  1.1  jmcneill #define	IDLE_STATUS_DMARD		0x00000010
    186  1.1  jmcneill #define	IDLE_STATUS_DMAWR		0x00000020
    187  1.1  jmcneill #define	IDLE_STATUS_SMB			0x00000040
    188  1.1  jmcneill #define	IDLE_STATUS_CMB			0x00000080
    189  1.1  jmcneill 
    190  1.1  jmcneill #define	ALC_MDIO			0x1414
    191  1.1  jmcneill #define	MDIO_DATA_MASK			0x0000FFFF
    192  1.1  jmcneill #define	MDIO_REG_ADDR_MASK		0x001F0000
    193  1.1  jmcneill #define	MDIO_OP_READ			0x00200000
    194  1.1  jmcneill #define	MDIO_OP_WRITE			0x00000000
    195  1.1  jmcneill #define	MDIO_SUP_PREAMBLE		0x00400000
    196  1.1  jmcneill #define	MDIO_OP_EXECUTE			0x00800000
    197  1.1  jmcneill #define	MDIO_CLK_25_4			0x00000000
    198  1.1  jmcneill #define	MDIO_CLK_25_6			0x02000000
    199  1.1  jmcneill #define	MDIO_CLK_25_8			0x03000000
    200  1.1  jmcneill #define	MDIO_CLK_25_10			0x04000000
    201  1.1  jmcneill #define	MDIO_CLK_25_14			0x05000000
    202  1.1  jmcneill #define	MDIO_CLK_25_20			0x06000000
    203  1.1  jmcneill #define	MDIO_CLK_25_28			0x07000000
    204  1.1  jmcneill #define	MDIO_OP_BUSY			0x08000000
    205  1.1  jmcneill #define	MDIO_AP_ENB			0x10000000
    206  1.1  jmcneill #define	MDIO_DATA_SHIFT			0
    207  1.1  jmcneill #define	MDIO_REG_ADDR_SHIFT		16
    208  1.1  jmcneill 
    209  1.1  jmcneill #define	MDIO_REG_ADDR(x)	\
    210  1.1  jmcneill 	(((x) << MDIO_REG_ADDR_SHIFT) & MDIO_REG_ADDR_MASK)
    211  1.1  jmcneill /* Default PHY address. */
    212  1.1  jmcneill #define	ALC_PHY_ADDR			0
    213  1.1  jmcneill 
    214  1.1  jmcneill #define	ALC_PHY_STATUS			0x1418
    215  1.1  jmcneill #define	PHY_STATUS_RECV_ENB		0x00000001
    216  1.1  jmcneill #define	PHY_STATUS_GENERAL_MASK		0x0000FFFF
    217  1.1  jmcneill #define	PHY_STATUS_OE_PWSP_MASK		0x07FF0000
    218  1.1  jmcneill #define	PHY_STATUS_LPW_STATE		0x80000000
    219  1.1  jmcneill #define	PHY_STATIS_OE_PWSP_SHIFT	16
    220  1.1  jmcneill 
    221  1.1  jmcneill /* Packet memory BIST. */
    222  1.1  jmcneill #define	ALC_BIST0			0x141C
    223  1.1  jmcneill #define	BIST0_ENB			0x00000001
    224  1.1  jmcneill #define	BIST0_SRAM_FAIL			0x00000002
    225  1.1  jmcneill #define	BIST0_FUSE_FLAG			0x00000004
    226  1.1  jmcneill 
    227  1.1  jmcneill /* PCIe retry buffer BIST. */
    228  1.1  jmcneill #define	ALC_BIST1			0x1420
    229  1.1  jmcneill #define	BIST1_ENB			0x00000001
    230  1.1  jmcneill #define	BIST1_SRAM_FAIL			0x00000002
    231  1.1  jmcneill #define	BIST1_FUSE_FLAG			0x00000004
    232  1.1  jmcneill 
    233  1.1  jmcneill #define	ALC_SERDES_LOCK			0x1424
    234  1.1  jmcneill #define	SERDES_LOCK_DET			0x00000001
    235  1.1  jmcneill #define	SERDES_LOCK_DET_ENB		0x00000002
    236  1.2  jmcneill #define	SERDES_MAC_CLK_SLOWDOWN		0x00020000
    237  1.2  jmcneill #define	SERDES_PHY_CLK_SLOWDOWN		0x00040000
    238  1.1  jmcneill 
    239  1.1  jmcneill #define	ALC_MAC_CFG			0x1480
    240  1.1  jmcneill #define	MAC_CFG_TX_ENB			0x00000001
    241  1.1  jmcneill #define	MAC_CFG_RX_ENB			0x00000002
    242  1.1  jmcneill #define	MAC_CFG_TX_FC			0x00000004
    243  1.1  jmcneill #define	MAC_CFG_RX_FC			0x00000008
    244  1.1  jmcneill #define	MAC_CFG_LOOP			0x00000010
    245  1.1  jmcneill #define	MAC_CFG_FULL_DUPLEX		0x00000020
    246  1.1  jmcneill #define	MAC_CFG_TX_CRC_ENB		0x00000040
    247  1.1  jmcneill #define	MAC_CFG_TX_AUTO_PAD		0x00000080
    248  1.1  jmcneill #define	MAC_CFG_TX_LENCHK		0x00000100
    249  1.1  jmcneill #define	MAC_CFG_RX_JUMBO_ENB		0x00000200
    250  1.1  jmcneill #define	MAC_CFG_PREAMBLE_MASK		0x00003C00
    251  1.1  jmcneill #define	MAC_CFG_VLAN_TAG_STRIP		0x00004000
    252  1.1  jmcneill #define	MAC_CFG_PROMISC			0x00008000
    253  1.1  jmcneill #define	MAC_CFG_TX_PAUSE		0x00010000
    254  1.1  jmcneill #define	MAC_CFG_SCNT			0x00020000
    255  1.1  jmcneill #define	MAC_CFG_SYNC_RST_TX		0x00040000
    256  1.1  jmcneill #define	MAC_CFG_SIM_RST_TX		0x00080000
    257  1.1  jmcneill #define	MAC_CFG_SPEED_MASK		0x00300000
    258  1.1  jmcneill #define	MAC_CFG_SPEED_10_100		0x00100000
    259  1.1  jmcneill #define	MAC_CFG_SPEED_1000		0x00200000
    260  1.1  jmcneill #define	MAC_CFG_DBG_TX_BACKOFF		0x00400000
    261  1.1  jmcneill #define	MAC_CFG_TX_JUMBO_ENB		0x00800000
    262  1.1  jmcneill #define	MAC_CFG_RXCSUM_ENB		0x01000000
    263  1.1  jmcneill #define	MAC_CFG_ALLMULTI		0x02000000
    264  1.1  jmcneill #define	MAC_CFG_BCAST			0x04000000
    265  1.1  jmcneill #define	MAC_CFG_DBG			0x08000000
    266  1.1  jmcneill #define	MAC_CFG_SINGLE_PAUSE_ENB	0x10000000
    267  1.2  jmcneill #define	MAC_CFG_HASH_ALG_CRC32		0x20000000
    268  1.2  jmcneill #define	MAC_CFG_SPEED_MODE_SW		0x40000000
    269  1.1  jmcneill #define	MAC_CFG_PREAMBLE_SHIFT		10
    270  1.1  jmcneill #define	MAC_CFG_PREAMBLE_DEFAULT	7
    271  1.1  jmcneill 
    272  1.1  jmcneill #define	ALC_IPG_IFG_CFG			0x1484
    273  1.1  jmcneill #define	IPG_IFG_IPGT_MASK		0x0000007F
    274  1.1  jmcneill #define	IPG_IFG_MIFG_MASK		0x0000FF00
    275  1.1  jmcneill #define	IPG_IFG_IPG1_MASK		0x007F0000
    276  1.1  jmcneill #define	IPG_IFG_IPG2_MASK		0x7F000000
    277  1.1  jmcneill #define	IPG_IFG_IPGT_SHIFT		0
    278  1.1  jmcneill #define	IPG_IFG_IPGT_DEFAULT		0x60
    279  1.1  jmcneill #define	IPG_IFG_MIFG_SHIFT		8
    280  1.1  jmcneill #define	IPG_IFG_MIFG_DEFAULT		0x50
    281  1.1  jmcneill #define	IPG_IFG_IPG1_SHIFT		16
    282  1.1  jmcneill #define	IPG_IFG_IPG1_DEFAULT		0x40
    283  1.1  jmcneill #define	IPG_IFG_IPG2_SHIFT		24
    284  1.1  jmcneill #define	IPG_IFG_IPG2_DEFAULT		0x60
    285  1.1  jmcneill 
    286  1.1  jmcneill /* Station address. */
    287  1.1  jmcneill #define	ALC_PAR0			0x1488
    288  1.1  jmcneill #define	ALC_PAR1			0x148C
    289  1.1  jmcneill 
    290  1.1  jmcneill /* 64bit multicast hash register. */
    291  1.1  jmcneill #define	ALC_MAR0			0x1490
    292  1.1  jmcneill #define	ALC_MAR1			0x1494
    293  1.1  jmcneill 
    294  1.1  jmcneill /* half-duplex parameter configuration. */
    295  1.1  jmcneill #define	ALC_HDPX_CFG			0x1498
    296  1.1  jmcneill #define	HDPX_CFG_LCOL_MASK		0x000003FF
    297  1.1  jmcneill #define	HDPX_CFG_RETRY_MASK		0x0000F000
    298  1.1  jmcneill #define	HDPX_CFG_EXC_DEF_EN		0x00010000
    299  1.1  jmcneill #define	HDPX_CFG_NO_BACK_C		0x00020000
    300  1.1  jmcneill #define	HDPX_CFG_NO_BACK_P		0x00040000
    301  1.1  jmcneill #define	HDPX_CFG_ABEBE			0x00080000
    302  1.1  jmcneill #define	HDPX_CFG_ABEBT_MASK		0x00F00000
    303  1.1  jmcneill #define	HDPX_CFG_JAMIPG_MASK		0x0F000000
    304  1.1  jmcneill #define	HDPX_CFG_LCOL_SHIFT		0
    305  1.1  jmcneill #define	HDPX_CFG_LCOL_DEFAULT		0x37
    306  1.1  jmcneill #define	HDPX_CFG_RETRY_SHIFT		12
    307  1.1  jmcneill #define	HDPX_CFG_RETRY_DEFAULT		0x0F
    308  1.1  jmcneill #define	HDPX_CFG_ABEBT_SHIFT		20
    309  1.1  jmcneill #define	HDPX_CFG_ABEBT_DEFAULT		0x0A
    310  1.1  jmcneill #define	HDPX_CFG_JAMIPG_SHIFT		24
    311  1.1  jmcneill #define	HDPX_CFG_JAMIPG_DEFAULT		0x07
    312  1.1  jmcneill 
    313  1.1  jmcneill #define	ALC_FRAME_SIZE			0x149C
    314  1.1  jmcneill 
    315  1.1  jmcneill #define	ALC_WOL_CFG			0x14A0
    316  1.1  jmcneill #define	WOL_CFG_PATTERN			0x00000001
    317  1.1  jmcneill #define	WOL_CFG_PATTERN_ENB		0x00000002
    318  1.1  jmcneill #define	WOL_CFG_MAGIC			0x00000004
    319  1.1  jmcneill #define	WOL_CFG_MAGIC_ENB		0x00000008
    320  1.1  jmcneill #define	WOL_CFG_LINK_CHG		0x00000010
    321  1.1  jmcneill #define	WOL_CFG_LINK_CHG_ENB		0x00000020
    322  1.1  jmcneill #define	WOL_CFG_PATTERN_DET		0x00000100
    323  1.1  jmcneill #define	WOL_CFG_MAGIC_DET		0x00000200
    324  1.1  jmcneill #define	WOL_CFG_LINK_CHG_DET		0x00000400
    325  1.1  jmcneill #define	WOL_CFG_CLK_SWITCH_ENB		0x00008000
    326  1.1  jmcneill #define	WOL_CFG_PATTERN0		0x00010000
    327  1.1  jmcneill #define	WOL_CFG_PATTERN1		0x00020000
    328  1.1  jmcneill #define	WOL_CFG_PATTERN2		0x00040000
    329  1.1  jmcneill #define	WOL_CFG_PATTERN3		0x00080000
    330  1.1  jmcneill #define	WOL_CFG_PATTERN4		0x00100000
    331  1.1  jmcneill #define	WOL_CFG_PATTERN5		0x00200000
    332  1.1  jmcneill #define	WOL_CFG_PATTERN6		0x00400000
    333  1.1  jmcneill 
    334  1.1  jmcneill /* WOL pattern length. */
    335  1.1  jmcneill #define	ALC_PATTERN_CFG0		0x14A4
    336  1.1  jmcneill #define	PATTERN_CFG_0_LEN_MASK		0x0000007F
    337  1.1  jmcneill #define	PATTERN_CFG_1_LEN_MASK		0x00007F00
    338  1.1  jmcneill #define	PATTERN_CFG_2_LEN_MASK		0x007F0000
    339  1.1  jmcneill #define	PATTERN_CFG_3_LEN_MASK		0x7F000000
    340  1.1  jmcneill 
    341  1.1  jmcneill #define	ALC_PATTERN_CFG1		0x14A8
    342  1.1  jmcneill #define	PATTERN_CFG_4_LEN_MASK		0x0000007F
    343  1.1  jmcneill #define	PATTERN_CFG_5_LEN_MASK		0x00007F00
    344  1.1  jmcneill #define	PATTERN_CFG_6_LEN_MASK		0x007F0000
    345  1.1  jmcneill 
    346  1.1  jmcneill /* RSS */
    347  1.1  jmcneill #define	ALC_RSS_KEY0			0x14B0
    348  1.1  jmcneill 
    349  1.1  jmcneill #define	ALC_RSS_KEY1			0x14B4
    350  1.1  jmcneill 
    351  1.1  jmcneill #define	ALC_RSS_KEY2			0x14B8
    352  1.1  jmcneill 
    353  1.1  jmcneill #define	ALC_RSS_KEY3			0x14BC
    354  1.1  jmcneill 
    355  1.1  jmcneill #define	ALC_RSS_KEY4			0x14C0
    356  1.1  jmcneill 
    357  1.1  jmcneill #define	ALC_RSS_KEY5			0x14C4
    358  1.1  jmcneill 
    359  1.1  jmcneill #define	ALC_RSS_KEY6			0x14C8
    360  1.1  jmcneill 
    361  1.1  jmcneill #define	ALC_RSS_KEY7			0x14CC
    362  1.1  jmcneill 
    363  1.1  jmcneill #define	ALC_RSS_KEY8			0x14D0
    364  1.1  jmcneill 
    365  1.1  jmcneill #define	ALC_RSS_KEY9			0x14D4
    366  1.1  jmcneill 
    367  1.1  jmcneill #define	ALC_RSS_IDT_TABLE0		0x14E0
    368  1.1  jmcneill 
    369  1.1  jmcneill #define	ALC_RSS_IDT_TABLE1		0x14E4
    370  1.1  jmcneill 
    371  1.1  jmcneill #define	ALC_RSS_IDT_TABLE2		0x14E8
    372  1.1  jmcneill 
    373  1.1  jmcneill #define	ALC_RSS_IDT_TABLE3		0x14EC
    374  1.1  jmcneill 
    375  1.1  jmcneill #define	ALC_RSS_IDT_TABLE4		0x14F0
    376  1.1  jmcneill 
    377  1.1  jmcneill #define	ALC_RSS_IDT_TABLE5		0x14F4
    378  1.1  jmcneill 
    379  1.1  jmcneill #define	ALC_RSS_IDT_TABLE6		0x14F8
    380  1.1  jmcneill 
    381  1.1  jmcneill #define	ALC_RSS_IDT_TABLE7		0x14FC
    382  1.1  jmcneill 
    383  1.1  jmcneill #define	ALC_SRAM_RD0_ADDR		0x1500
    384  1.1  jmcneill 
    385  1.1  jmcneill #define	ALC_SRAM_RD1_ADDR		0x1504
    386  1.1  jmcneill 
    387  1.1  jmcneill #define	ALC_SRAM_RD2_ADDR		0x1508
    388  1.1  jmcneill 
    389  1.1  jmcneill #define	ALC_SRAM_RD3_ADDR		0x150C
    390  1.1  jmcneill 
    391  1.1  jmcneill #define	RD_HEAD_ADDR_MASK		0x000003FF
    392  1.1  jmcneill #define	RD_TAIL_ADDR_MASK		0x03FF0000
    393  1.1  jmcneill #define	RD_HEAD_ADDR_SHIFT		0
    394  1.1  jmcneill #define	RD_TAIL_ADDR_SHIFT		16
    395  1.1  jmcneill 
    396  1.1  jmcneill #define	ALC_RD_NIC_LEN0			0x1510	/* 8 bytes unit */
    397  1.1  jmcneill #define	RD_NIC_LEN_MASK			0x000003FF
    398  1.1  jmcneill 
    399  1.1  jmcneill #define	ALC_RD_NIC_LEN1			0x1514
    400  1.1  jmcneill 
    401  1.1  jmcneill #define	ALC_SRAM_TD_ADDR		0x1518
    402  1.1  jmcneill #define	TD_HEAD_ADDR_MASK		0x000003FF
    403  1.1  jmcneill #define	TD_TAIL_ADDR_MASK		0x03FF0000
    404  1.1  jmcneill #define	TD_HEAD_ADDR_SHIFT		0
    405  1.1  jmcneill #define	TD_TAIL_ADDR_SHIFT		16
    406  1.1  jmcneill 
    407  1.1  jmcneill #define	ALC_SRAM_TD_LEN			0x151C	/* 8 bytes unit */
    408  1.1  jmcneill #define	SRAM_TD_LEN_MASK		0x000003FF
    409  1.1  jmcneill 
    410  1.1  jmcneill #define	ALC_SRAM_RX_FIFO_ADDR		0x1520
    411  1.1  jmcneill 
    412  1.1  jmcneill #define	ALC_SRAM_RX_FIFO_LEN		0x1524
    413  1.1  jmcneill 
    414  1.1  jmcneill #define	ALC_SRAM_TX_FIFO_ADDR		0x1528
    415  1.1  jmcneill 
    416  1.1  jmcneill #define	ALC_SRAM_TX_FIFO_LEN		0x152C
    417  1.1  jmcneill 
    418  1.1  jmcneill #define	ALC_SRAM_TCPH_ADDR		0x1530
    419  1.1  jmcneill #define	SRAM_TCPH_ADDR_MASK		0x00000FFF
    420  1.1  jmcneill #define	SRAM_PATH_ADDR_MASK		0x0FFF0000
    421  1.1  jmcneill #define	SRAM_TCPH_ADDR_SHIFT		0
    422  1.1  jmcneill #define	SRAM_PKTH_ADDR_SHIFT		16
    423  1.1  jmcneill 
    424  1.1  jmcneill #define	ALC_DMA_BLOCK			0x1534
    425  1.1  jmcneill #define	DMA_BLOCK_LOAD			0x00000001
    426  1.1  jmcneill 
    427  1.1  jmcneill #define	ALC_RX_BASE_ADDR_HI		0x1540
    428  1.1  jmcneill 
    429  1.1  jmcneill #define	ALC_TX_BASE_ADDR_HI		0x1544
    430  1.1  jmcneill 
    431  1.1  jmcneill #define	ALC_SMB_BASE_ADDR_HI		0x1548
    432  1.1  jmcneill 
    433  1.1  jmcneill #define	ALC_SMB_BASE_ADDR_LO		0x154C
    434  1.1  jmcneill 
    435  1.1  jmcneill #define	ALC_RD0_HEAD_ADDR_LO		0x1550
    436  1.1  jmcneill 
    437  1.1  jmcneill #define	ALC_RD1_HEAD_ADDR_LO		0x1554
    438  1.1  jmcneill 
    439  1.1  jmcneill #define	ALC_RD2_HEAD_ADDR_LO		0x1558
    440  1.1  jmcneill 
    441  1.1  jmcneill #define	ALC_RD3_HEAD_ADDR_LO		0x155C
    442  1.1  jmcneill 
    443  1.1  jmcneill #define	ALC_RD_RING_CNT			0x1560
    444  1.1  jmcneill #define	RD_RING_CNT_MASK		0x00000FFF
    445  1.1  jmcneill #define	RD_RING_CNT_SHIFT		0
    446  1.1  jmcneill 
    447  1.1  jmcneill #define	ALC_RX_BUF_SIZE			0x1564
    448  1.1  jmcneill #define	RX_BUF_SIZE_MASK		0x0000FFFF
    449  1.1  jmcneill /*
    450  1.1  jmcneill  * If larger buffer size than 1536 is specified the controller
    451  1.1  jmcneill  * will be locked up. This is hardware limitation.
    452  1.1  jmcneill  */
    453  1.1  jmcneill #define	RX_BUF_SIZE_MAX			1536
    454  1.1  jmcneill 
    455  1.1  jmcneill #define	ALC_RRD0_HEAD_ADDR_LO		0x1568
    456  1.1  jmcneill 
    457  1.1  jmcneill #define	ALC_RRD1_HEAD_ADDR_LO		0x156C
    458  1.1  jmcneill 
    459  1.1  jmcneill #define	ALC_RRD2_HEAD_ADDR_LO		0x1570
    460  1.1  jmcneill 
    461  1.1  jmcneill #define	ALC_RRD3_HEAD_ADDR_LO		0x1574
    462  1.1  jmcneill 
    463  1.1  jmcneill #define	ALC_RRD_RING_CNT		0x1578
    464  1.1  jmcneill #define	RRD_RING_CNT_MASK		0x00000FFF
    465  1.1  jmcneill #define	RRD_RING_CNT_SHIFT		0
    466  1.1  jmcneill 
    467  1.1  jmcneill #define	ALC_TDH_HEAD_ADDR_LO		0x157C
    468  1.1  jmcneill 
    469  1.1  jmcneill #define	ALC_TDL_HEAD_ADDR_LO		0x1580
    470  1.1  jmcneill 
    471  1.1  jmcneill #define	ALC_TD_RING_CNT			0x1584
    472  1.1  jmcneill #define	TD_RING_CNT_MASK		0x0000FFFF
    473  1.1  jmcneill #define	TD_RING_CNT_SHIFT		0
    474  1.1  jmcneill 
    475  1.1  jmcneill #define	ALC_CMB_BASE_ADDR_LO		0x1588
    476  1.1  jmcneill 
    477  1.1  jmcneill #define	ALC_TXQ_CFG			0x1590
    478  1.1  jmcneill #define	TXQ_CFG_TD_BURST_MASK		0x0000000F
    479  1.1  jmcneill #define	TXQ_CFG_IP_OPTION_ENB		0x00000010
    480  1.1  jmcneill #define	TXQ_CFG_ENB			0x00000020
    481  1.1  jmcneill #define	TXQ_CFG_ENHANCED_MODE		0x00000040
    482  1.1  jmcneill #define	TXQ_CFG_8023_ENB		0x00000080
    483  1.1  jmcneill #define	TXQ_CFG_TX_FIFO_BURST_MASK	0xFFFF0000
    484  1.1  jmcneill #define	TXQ_CFG_TD_BURST_SHIFT		0
    485  1.1  jmcneill #define	TXQ_CFG_TD_BURST_DEFAULT	5
    486  1.1  jmcneill #define	TXQ_CFG_TX_FIFO_BURST_SHIFT	16
    487  1.1  jmcneill 
    488  1.1  jmcneill #define	ALC_TSO_OFFLOAD_THRESH		0x1594	/* 8 bytes unit */
    489  1.1  jmcneill #define	TSO_OFFLOAD_THRESH_MASK		0x000007FF
    490  1.1  jmcneill #define	TSO_OFFLOAD_THRESH_SHIFT	0
    491  1.1  jmcneill #define	TSO_OFFLOAD_THRESH_UNIT		8
    492  1.1  jmcneill #define	TSO_OFFLOAD_THRESH_UNIT_SHIFT	3
    493  1.1  jmcneill 
    494  1.1  jmcneill #define	ALC_TXF_WATER_MARK		0x1598	/* 8 bytes unit */
    495  1.1  jmcneill #define	TXF_WATER_MARK_HI_MASK		0x00000FFF
    496  1.1  jmcneill #define	TXF_WATER_MARK_LO_MASK		0x0FFF0000
    497  1.1  jmcneill #define	TXF_WATER_MARK_BURST_ENB	0x80000000
    498  1.1  jmcneill #define	TXF_WATER_MARK_LO_SHIFT		0
    499  1.1  jmcneill #define	TXF_WATER_MARK_HI_SHIFT		16
    500  1.1  jmcneill 
    501  1.1  jmcneill #define	ALC_THROUGHPUT_MON		0x159C
    502  1.1  jmcneill #define	THROUGHPUT_MON_RATE_MASK	0x00000003
    503  1.1  jmcneill #define	THROUGHPUT_MON_ENB		0x00000080
    504  1.1  jmcneill #define	THROUGHPUT_MON_RATE_SHIFT	0
    505  1.1  jmcneill 
    506  1.1  jmcneill #define	ALC_RXQ_CFG			0x15A0
    507  1.1  jmcneill #define	RXQ_CFG_ASPM_THROUGHPUT_LIMIT_MASK	0x00000003
    508  1.1  jmcneill #define	RXQ_CFG_ASPM_THROUGHPUT_LIMIT_NONE	0x00000000
    509  1.1  jmcneill #define	RXQ_CFG_ASPM_THROUGHPUT_LIMIT_1M	0x00000001
    510  1.1  jmcneill #define	RXQ_CFG_ASPM_THROUGHPUT_LIMIT_10M	0x00000002
    511  1.1  jmcneill #define	RXQ_CFG_ASPM_THROUGHPUT_LIMIT_100M	0x00000003
    512  1.1  jmcneill #define	RXQ_CFG_QUEUE1_ENB		0x00000010
    513  1.1  jmcneill #define	RXQ_CFG_QUEUE2_ENB		0x00000020
    514  1.1  jmcneill #define	RXQ_CFG_QUEUE3_ENB		0x00000040
    515  1.1  jmcneill #define	RXQ_CFG_IPV6_CSUM_ENB		0x00000080
    516  1.1  jmcneill #define	RXQ_CFG_RSS_HASH_TBL_LEN_MASK	0x0000FF00
    517  1.1  jmcneill #define	RXQ_CFG_RSS_HASH_IPV4		0x00010000
    518  1.1  jmcneill #define	RXQ_CFG_RSS_HASH_IPV4_TCP	0x00020000
    519  1.1  jmcneill #define	RXQ_CFG_RSS_HASH_IPV6		0x00040000
    520  1.1  jmcneill #define	RXQ_CFG_RSS_HASH_IPV6_TCP	0x00080000
    521  1.1  jmcneill #define	RXQ_CFG_RD_BURST_MASK		0x03F00000
    522  1.1  jmcneill #define	RXQ_CFG_RSS_MODE_DIS		0x00000000
    523  1.1  jmcneill #define	RXQ_CFG_RSS_MODE_SQSINT		0x04000000
    524  1.1  jmcneill #define	RXQ_CFG_RSS_MODE_MQUESINT	0x08000000
    525  1.1  jmcneill #define	RXQ_CFG_RSS_MODE_MQUEMINT	0x0C000000
    526  1.1  jmcneill #define	RXQ_CFG_NIP_QUEUE_SEL_TBL	0x10000000
    527  1.1  jmcneill #define	RXQ_CFG_RSS_HASH_ENB		0x20000000
    528  1.1  jmcneill #define	RXQ_CFG_CUT_THROUGH_ENB		0x40000000
    529  1.1  jmcneill #define	RXQ_CFG_QUEUE0_ENB		0x80000000
    530  1.1  jmcneill #define	RXQ_CFG_RSS_HASH_TBL_LEN_SHIFT	8
    531  1.1  jmcneill #define	RXQ_CFG_RD_BURST_DEFAULT	8
    532  1.1  jmcneill #define	RXQ_CFG_RD_BURST_SHIFT		20
    533  1.1  jmcneill #define	RXQ_CFG_ENB					\
    534  1.1  jmcneill 	(RXQ_CFG_QUEUE0_ENB | RXQ_CFG_QUEUE1_ENB |	\
    535  1.1  jmcneill 	 RXQ_CFG_QUEUE2_ENB | RXQ_CFG_QUEUE3_ENB)
    536  1.1  jmcneill 
    537  1.1  jmcneill #define	ALC_RX_RD_FREE_THRESH		0x15A4	/* 8 bytes unit. */
    538  1.1  jmcneill #define	RX_RD_FREE_THRESH_HI_MASK	0x0000003F
    539  1.1  jmcneill #define	RX_RD_FREE_THRESH_LO_MASK	0x00000FC0
    540  1.1  jmcneill #define	RX_RD_FREE_THRESH_HI_SHIFT	0
    541  1.1  jmcneill #define	RX_RD_FREE_THRESH_LO_SHIFT	6
    542  1.1  jmcneill #define	RX_RD_FREE_THRESH_HI_DEFAULT	16
    543  1.1  jmcneill #define	RX_RD_FREE_THRESH_LO_DEFAULT	8
    544  1.1  jmcneill 
    545  1.1  jmcneill #define	ALC_RX_FIFO_PAUSE_THRESH	0x15A8
    546  1.1  jmcneill #define	RX_FIFO_PAUSE_THRESH_LO_MASK	0x00000FFF
    547  1.1  jmcneill #define	RX_FIFO_PAUSE_THRESH_HI_MASK	0x0FFF0000
    548  1.1  jmcneill #define	RX_FIFO_PAUSE_THRESH_LO_SHIFT	0
    549  1.1  jmcneill #define	RX_FIFO_PAUSE_THRESH_HI_SHIFT	16
    550  1.1  jmcneill 
    551  1.1  jmcneill #define	ALC_RD_DMA_CFG			0x15AC
    552  1.1  jmcneill #define	RD_DMA_CFG_THRESH_MASK		0x00000FFF	/* 8 bytes unit */
    553  1.1  jmcneill #define	RD_DMA_CFG_TIMER_MASK		0xFFFF0000
    554  1.1  jmcneill #define	RD_DMA_CFG_THRESH_SHIFT		0
    555  1.1  jmcneill #define	RD_DMA_CFG_TIMER_SHIFT		16
    556  1.1  jmcneill #define	RD_DMA_CFG_THRESH_DEFAULT	0x100
    557  1.1  jmcneill #define	RD_DMA_CFG_TIMER_DEFAULT	0
    558  1.1  jmcneill #define	RD_DMA_CFG_TICK_USECS		8
    559  1.1  jmcneill #define	ALC_RD_DMA_CFG_USECS(x)		((x) / RD_DMA_CFG_TICK_USECS)
    560  1.1  jmcneill 
    561  1.1  jmcneill #define	ALC_RSS_HASH_VALUE		0x15B0
    562  1.1  jmcneill 
    563  1.1  jmcneill #define	ALC_RSS_HASH_FLAG		0x15B4
    564  1.1  jmcneill 
    565  1.1  jmcneill #define	ALC_RSS_CPU			0x15B8
    566  1.1  jmcneill 
    567  1.1  jmcneill #define	ALC_DMA_CFG			0x15C0
    568  1.1  jmcneill #define	DMA_CFG_IN_ORDER		0x00000001
    569  1.1  jmcneill #define	DMA_CFG_ENH_ORDER		0x00000002
    570  1.1  jmcneill #define	DMA_CFG_OUT_ORDER		0x00000004
    571  1.1  jmcneill #define	DMA_CFG_RCB_64			0x00000000
    572  1.1  jmcneill #define	DMA_CFG_RCB_128			0x00000008
    573  1.1  jmcneill #define	DMA_CFG_RD_BURST_128		0x00000000
    574  1.1  jmcneill #define	DMA_CFG_RD_BURST_256		0x00000010
    575  1.1  jmcneill #define	DMA_CFG_RD_BURST_512		0x00000020
    576  1.1  jmcneill #define	DMA_CFG_RD_BURST_1024		0x00000030
    577  1.1  jmcneill #define	DMA_CFG_RD_BURST_2048		0x00000040
    578  1.1  jmcneill #define	DMA_CFG_RD_BURST_4096		0x00000050
    579  1.1  jmcneill #define	DMA_CFG_WR_BURST_128		0x00000000
    580  1.1  jmcneill #define	DMA_CFG_WR_BURST_256		0x00000080
    581  1.1  jmcneill #define	DMA_CFG_WR_BURST_512		0x00000100
    582  1.1  jmcneill #define	DMA_CFG_WR_BURST_1024		0x00000180
    583  1.1  jmcneill #define	DMA_CFG_WR_BURST_2048		0x00000200
    584  1.1  jmcneill #define	DMA_CFG_WR_BURST_4096		0x00000280
    585  1.1  jmcneill #define	DMA_CFG_RD_REQ_PRI		0x00000400
    586  1.1  jmcneill #define	DMA_CFG_RD_DELAY_CNT_MASK	0x0000F800
    587  1.1  jmcneill #define	DMA_CFG_WR_DELAY_CNT_MASK	0x000F0000
    588  1.1  jmcneill #define	DMA_CFG_CMB_ENB			0x00100000
    589  1.1  jmcneill #define	DMA_CFG_SMB_ENB			0x00200000
    590  1.1  jmcneill #define	DMA_CFG_CMB_NOW			0x00400000
    591  1.1  jmcneill #define	DMA_CFG_SMB_DIS			0x01000000
    592  1.1  jmcneill #define	DMA_CFG_SMB_NOW			0x80000000
    593  1.1  jmcneill #define	DMA_CFG_RD_BURST_MASK		0x07
    594  1.1  jmcneill #define	DMA_CFG_RD_BURST_SHIFT		4
    595  1.1  jmcneill #define	DMA_CFG_WR_BURST_MASK		0x07
    596  1.1  jmcneill #define	DMA_CFG_WR_BURST_SHIFT		7
    597  1.1  jmcneill #define	DMA_CFG_RD_DELAY_CNT_SHIFT	11
    598  1.1  jmcneill #define	DMA_CFG_WR_DELAY_CNT_SHIFT	16
    599  1.1  jmcneill #define	DMA_CFG_RD_DELAY_CNT_DEFAULT	15
    600  1.1  jmcneill #define	DMA_CFG_WR_DELAY_CNT_DEFAULT	4
    601  1.1  jmcneill 
    602  1.1  jmcneill #define	ALC_SMB_STAT_TIMER		0x15C4
    603  1.1  jmcneill #define	SMB_STAT_TIMER_MASK		0x00FFFFFF
    604  1.1  jmcneill #define	SMB_STAT_TIMER_SHIFT		0
    605  1.1  jmcneill 
    606  1.1  jmcneill #define	ALC_CMB_TD_THRESH		0x15C8
    607  1.1  jmcneill #define	CMB_TD_THRESH_MASK		0x0000FFFF
    608  1.1  jmcneill #define	CMB_TD_THRESH_SHIFT		0
    609  1.1  jmcneill 
    610  1.1  jmcneill #define	ALC_CMB_TX_TIMER		0x15CC
    611  1.1  jmcneill #define	CMB_TX_TIMER_MASK		0x0000FFFF
    612  1.1  jmcneill #define	CMB_TX_TIMER_SHIFT		0
    613  1.1  jmcneill 
    614  1.1  jmcneill #define	ALC_MBOX_RD0_PROD_IDX		0x15E0
    615  1.1  jmcneill 
    616  1.1  jmcneill #define	ALC_MBOX_RD1_PROD_IDX		0x15E4
    617  1.1  jmcneill 
    618  1.1  jmcneill #define	ALC_MBOX_RD2_PROD_IDX		0x15E8
    619  1.1  jmcneill 
    620  1.1  jmcneill #define	ALC_MBOX_RD3_PROD_IDX		0x15EC
    621  1.1  jmcneill 
    622  1.1  jmcneill #define	ALC_MBOX_RD_PROD_MASK		0x0000FFFF
    623  1.1  jmcneill #define	MBOX_RD_PROD_SHIFT		0
    624  1.1  jmcneill 
    625  1.1  jmcneill #define	ALC_MBOX_TD_PROD_IDX		0x15F0
    626  1.1  jmcneill #define	MBOX_TD_PROD_HI_IDX_MASK	0x0000FFFF
    627  1.1  jmcneill #define	MBOX_TD_PROD_LO_IDX_MASK	0xFFFF0000
    628  1.1  jmcneill #define	MBOX_TD_PROD_HI_IDX_SHIFT	0
    629  1.1  jmcneill #define	MBOX_TD_PROD_LO_IDX_SHIFT	16
    630  1.1  jmcneill 
    631  1.1  jmcneill #define	ALC_MBOX_TD_CONS_IDX		0x15F4
    632  1.1  jmcneill #define	MBOX_TD_CONS_HI_IDX_MASK	0x0000FFFF
    633  1.1  jmcneill #define	MBOX_TD_CONS_LO_IDX_MASK	0xFFFF0000
    634  1.1  jmcneill #define	MBOX_TD_CONS_HI_IDX_SHIFT	0
    635  1.1  jmcneill #define	MBOX_TD_CONS_LO_IDX_SHIFT	16
    636  1.1  jmcneill 
    637  1.1  jmcneill #define	ALC_MBOX_RD01_CONS_IDX		0x15F8
    638  1.1  jmcneill #define	MBOX_RD0_CONS_IDX_MASK		0x0000FFFF
    639  1.1  jmcneill #define	MBOX_RD1_CONS_IDX_MASK		0xFFFF0000
    640  1.1  jmcneill #define	MBOX_RD0_CONS_IDX_SHIFT		0
    641  1.1  jmcneill #define	MBOX_RD1_CONS_IDX_SHIFT		16
    642  1.1  jmcneill 
    643  1.1  jmcneill #define	ALC_MBOX_RD23_CONS_IDX		0x15FC
    644  1.1  jmcneill #define	MBOX_RD2_CONS_IDX_MASK		0x0000FFFF
    645  1.1  jmcneill #define	MBOX_RD3_CONS_IDX_MASK		0xFFFF0000
    646  1.1  jmcneill #define	MBOX_RD2_CONS_IDX_SHIFT		0
    647  1.1  jmcneill #define	MBOX_RD3_CONS_IDX_SHIFT		16
    648  1.1  jmcneill 
    649  1.1  jmcneill #define	ALC_INTR_STATUS			0x1600
    650  1.1  jmcneill #define	INTR_SMB			0x00000001
    651  1.1  jmcneill #define	INTR_TIMER			0x00000002
    652  1.1  jmcneill #define	INTR_MANUAL_TIMER		0x00000004
    653  1.1  jmcneill #define	INTR_RX_FIFO_OFLOW		0x00000008
    654  1.1  jmcneill #define	INTR_RD0_UNDERRUN		0x00000010
    655  1.1  jmcneill #define	INTR_RD1_UNDERRUN		0x00000020
    656  1.1  jmcneill #define	INTR_RD2_UNDERRUN		0x00000040
    657  1.1  jmcneill #define	INTR_RD3_UNDERRUN		0x00000080
    658  1.1  jmcneill #define	INTR_TX_FIFO_UNDERRUN		0x00000100
    659  1.1  jmcneill #define	INTR_DMA_RD_TO_RST		0x00000200
    660  1.1  jmcneill #define	INTR_DMA_WR_TO_RST		0x00000400
    661  1.1  jmcneill #define	INTR_TX_CREDIT			0x00000800
    662  1.1  jmcneill #define	INTR_GPHY			0x00001000
    663  1.1  jmcneill #define	INTR_GPHY_LOW_PW		0x00002000
    664  1.1  jmcneill #define	INTR_TXQ_TO_RST			0x00004000
    665  1.1  jmcneill #define	INTR_TX_PKT			0x00008000
    666  1.1  jmcneill #define	INTR_RX_PKT0			0x00010000
    667  1.1  jmcneill #define	INTR_RX_PKT1			0x00020000
    668  1.1  jmcneill #define	INTR_RX_PKT2			0x00040000
    669  1.1  jmcneill #define	INTR_RX_PKT3			0x00080000
    670  1.1  jmcneill #define	INTR_MAC_RX			0x00100000
    671  1.1  jmcneill #define	INTR_MAC_TX			0x00200000
    672  1.1  jmcneill #define	INTR_UNDERRUN			0x00400000
    673  1.1  jmcneill #define	INTR_FRAME_ERROR		0x00800000
    674  1.1  jmcneill #define	INTR_FRAME_OK			0x01000000
    675  1.1  jmcneill #define	INTR_CSUM_ERROR			0x02000000
    676  1.1  jmcneill #define	INTR_PHY_LINK_DOWN		0x04000000
    677  1.1  jmcneill #define	INTR_DIS_INT			0x80000000
    678  1.1  jmcneill 
    679  1.1  jmcneill /* Interrupt Mask Register */
    680  1.1  jmcneill #define	ALC_INTR_MASK			0x1604
    681  1.1  jmcneill 
    682  1.1  jmcneill #ifdef	notyet
    683  1.1  jmcneill #define	INTR_RX_PKT					\
    684  1.1  jmcneill 	(INTR_RX_PKT0 | INTR_RX_PKT1 | INTR_RX_PKT2 |	\
    685  1.1  jmcneill 	 INTR_RX_PKT3)
    686  1.1  jmcneill #define	INTR_RD_UNDERRUN				\
    687  1.1  jmcneill 	(INTR_RD0_UNDERRUN | INTR_RD1_UNDERRUN |	\
    688  1.1  jmcneill 	INTR_RD2_UNDERRUN | INTR_RD3_UNDERRUN)
    689  1.1  jmcneill #else
    690  1.1  jmcneill #define	INTR_RX_PKT			INTR_RX_PKT0
    691  1.1  jmcneill #define	INTR_RD_UNDERRUN		INTR_RD0_UNDERRUN
    692  1.1  jmcneill #endif
    693  1.1  jmcneill 
    694  1.1  jmcneill #define	ALC_INTRS					\
    695  1.1  jmcneill 	(INTR_DMA_RD_TO_RST | INTR_DMA_WR_TO_RST |	\
    696  1.1  jmcneill 	INTR_TXQ_TO_RST	| INTR_RX_PKT | INTR_TX_PKT |	\
    697  1.1  jmcneill 	INTR_RX_FIFO_OFLOW | INTR_RD_UNDERRUN |		\
    698  1.1  jmcneill 	INTR_TX_FIFO_UNDERRUN)
    699  1.1  jmcneill 
    700  1.1  jmcneill #define	ALC_INTR_RETRIG_TIMER		0x1608
    701  1.1  jmcneill #define	INTR_RETRIG_TIMER_MASK		0x0000FFFF
    702  1.1  jmcneill #define	INTR_RETRIG_TIMER_SHIFT		0
    703  1.1  jmcneill 
    704  1.1  jmcneill #define	ALC_HDS_CFG			0x160C
    705  1.1  jmcneill #define	HDS_CFG_ENB			0x00000001
    706  1.1  jmcneill #define	HDS_CFG_BACKFILLSIZE_MASK	0x000FFF00
    707  1.1  jmcneill #define	HDS_CFG_MAX_HDRSIZE_MASK	0xFFF00000
    708  1.1  jmcneill #define	HDS_CFG_BACKFILLSIZE_SHIFT	8
    709  1.1  jmcneill #define	HDS_CFG_MAX_HDRSIZE_SHIFT	20
    710  1.1  jmcneill 
    711  1.2  jmcneill /* AR813x/AR815x registers for MAC statistics */
    712  1.1  jmcneill #define	ALC_RX_MIB_BASE			0x1700
    713  1.1  jmcneill 
    714  1.1  jmcneill #define	ALC_TX_MIB_BASE			0x1760
    715  1.1  jmcneill 
    716  1.2  jmcneill #define	ALC_CLK_GATING_CFG		0x1814
    717  1.2  jmcneill #define	CLK_GATING_DMAW_ENB		0x0001
    718  1.2  jmcneill #define	CLK_GATING_DMAR_ENB		0x0002
    719  1.2  jmcneill #define	CLK_GATING_TXQ_ENB		0x0004
    720  1.2  jmcneill #define	CLK_GATING_RXQ_ENB		0x0008
    721  1.2  jmcneill #define	CLK_GATING_TXMAC_ENB		0x0010
    722  1.2  jmcneill #define	CLK_GATING_RXMAC_ENB		0x0020
    723  1.2  jmcneill 
    724  1.1  jmcneill #define	ALC_DEBUG_DATA0			0x1900
    725  1.1  jmcneill 
    726  1.1  jmcneill #define	ALC_DEBUG_DATA1			0x1904
    727  1.1  jmcneill 
    728  1.1  jmcneill #define	ALC_MII_DBG_ADDR		0x1D
    729  1.1  jmcneill #define	ALC_MII_DBG_DATA		0x1E
    730  1.1  jmcneill 
    731  1.1  jmcneill #define	MII_ANA_CFG0			0x00
    732  1.1  jmcneill #define	ANA_RESTART_CAL			0x0001
    733  1.1  jmcneill #define	ANA_MANUL_SWICH_ON_MASK		0x001E
    734  1.1  jmcneill #define	ANA_MAN_ENABLE			0x0020
    735  1.1  jmcneill #define	ANA_SEL_HSP			0x0040
    736  1.1  jmcneill #define	ANA_EN_HB			0x0080
    737  1.1  jmcneill #define	ANA_EN_HBIAS			0x0100
    738  1.1  jmcneill #define	ANA_OEN_125M			0x0200
    739  1.1  jmcneill #define	ANA_EN_LCKDT			0x0400
    740  1.1  jmcneill #define	ANA_LCKDT_PHY			0x0800
    741  1.1  jmcneill #define	ANA_AFE_MODE			0x1000
    742  1.1  jmcneill #define	ANA_VCO_SLOW			0x2000
    743  1.1  jmcneill #define	ANA_VCO_FAST			0x4000
    744  1.1  jmcneill #define	ANA_SEL_CLK125M_DSP		0x8000
    745  1.1  jmcneill #define	ANA_MANUL_SWICH_ON_SHIFT	1
    746  1.1  jmcneill 
    747  1.1  jmcneill #define	MII_ANA_CFG4			0x04
    748  1.1  jmcneill #define	ANA_IECHO_ADJ_MASK		0x0F
    749  1.1  jmcneill #define	ANA_IECHO_ADJ_3_MASK		0x000F
    750  1.1  jmcneill #define	ANA_IECHO_ADJ_2_MASK		0x00F0
    751  1.1  jmcneill #define	ANA_IECHO_ADJ_1_MASK		0x0F00
    752  1.1  jmcneill #define	ANA_IECHO_ADJ_0_MASK		0xF000
    753  1.1  jmcneill #define	ANA_IECHO_ADJ_3_SHIFT		0
    754  1.1  jmcneill #define	ANA_IECHO_ADJ_2_SHIFT		4
    755  1.1  jmcneill #define	ANA_IECHO_ADJ_1_SHIFT		8
    756  1.1  jmcneill #define	ANA_IECHO_ADJ_0_SHIFT		12
    757  1.1  jmcneill 
    758  1.1  jmcneill #define	MII_ANA_CFG5			0x05
    759  1.1  jmcneill #define	ANA_SERDES_CDR_BW_MASK		0x0003
    760  1.1  jmcneill #define	ANA_MS_PAD_DBG			0x0004
    761  1.1  jmcneill #define	ANA_SPEEDUP_DBG			0x0008
    762  1.1  jmcneill #define	ANA_SERDES_TH_LOS_MASK		0x0030
    763  1.1  jmcneill #define	ANA_SERDES_EN_DEEM		0x0040
    764  1.1  jmcneill #define	ANA_SERDES_TXELECIDLE		0x0080
    765  1.1  jmcneill #define	ANA_SERDES_BEACON		0x0100
    766  1.1  jmcneill #define	ANA_SERDES_HALFTXDR		0x0200
    767  1.1  jmcneill #define	ANA_SERDES_SEL_HSP		0x0400
    768  1.1  jmcneill #define	ANA_SERDES_EN_PLL		0x0800
    769  1.1  jmcneill #define	ANA_SERDES_EN			0x1000
    770  1.1  jmcneill #define	ANA_SERDES_EN_LCKDT		0x2000
    771  1.1  jmcneill #define	ANA_SERDES_CDR_BW_SHIFT		0
    772  1.1  jmcneill #define	ANA_SERDES_TH_LOS_SHIFT		4
    773  1.1  jmcneill 
    774  1.1  jmcneill #define	MII_ANA_CFG11			0x0B
    775  1.1  jmcneill #define	ANA_PS_HIB_EN			0x8000
    776  1.1  jmcneill 
    777  1.1  jmcneill #define	MII_ANA_CFG18			0x12
    778  1.1  jmcneill #define	ANA_TEST_MODE_10BT_01MASK	0x0003
    779  1.1  jmcneill #define	ANA_LOOP_SEL_10BT		0x0004
    780  1.1  jmcneill #define	ANA_RGMII_MODE_SW		0x0008
    781  1.1  jmcneill #define	ANA_EN_LONGECABLE		0x0010
    782  1.1  jmcneill #define	ANA_TEST_MODE_10BT_2		0x0020
    783  1.1  jmcneill #define	ANA_EN_10BT_IDLE		0x0400
    784  1.1  jmcneill #define	ANA_EN_MASK_TB			0x0800
    785  1.1  jmcneill #define	ANA_TRIGGER_SEL_TIMER_MASK	0x3000
    786  1.1  jmcneill #define	ANA_INTERVAL_SEL_TIMER_MASK	0xC000
    787  1.1  jmcneill #define	ANA_TEST_MODE_10BT_01SHIFT	0
    788  1.1  jmcneill #define	ANA_TRIGGER_SEL_TIMER_SHIFT	12
    789  1.1  jmcneill #define	ANA_INTERVAL_SEL_TIMER_SHIFT	14
    790  1.1  jmcneill 
    791  1.1  jmcneill #define	MII_ANA_CFG41			0x29
    792  1.1  jmcneill #define	ANA_TOP_PS_EN			0x8000
    793  1.1  jmcneill 
    794  1.1  jmcneill #define	MII_ANA_CFG54			0x36
    795  1.1  jmcneill #define	ANA_LONG_CABLE_TH_100_MASK	0x003F
    796  1.1  jmcneill #define	ANA_DESERVED			0x0040
    797  1.1  jmcneill #define	ANA_EN_LIT_CH			0x0080
    798  1.1  jmcneill #define	ANA_SHORT_CABLE_TH_100_MASK	0x3F00
    799  1.1  jmcneill #define	ANA_BP_BAD_LINK_ACCUM		0x4000
    800  1.1  jmcneill #define	ANA_BP_SMALL_BW			0x8000
    801  1.1  jmcneill #define	ANA_LONG_CABLE_TH_100_SHIFT	0
    802  1.1  jmcneill #define	ANA_SHORT_CABLE_TH_100_SHIFT	8
    803  1.1  jmcneill 
    804  1.1  jmcneill /* Statistics counters collected by the MAC. */
    805  1.1  jmcneill struct smb {
    806  1.1  jmcneill 	/* Rx stats. */
    807  1.1  jmcneill 	uint32_t rx_frames;
    808  1.1  jmcneill 	uint32_t rx_bcast_frames;
    809  1.1  jmcneill 	uint32_t rx_mcast_frames;
    810  1.1  jmcneill 	uint32_t rx_pause_frames;
    811  1.1  jmcneill 	uint32_t rx_control_frames;
    812  1.1  jmcneill 	uint32_t rx_crcerrs;
    813  1.1  jmcneill 	uint32_t rx_lenerrs;
    814  1.1  jmcneill 	uint32_t rx_bytes;
    815  1.1  jmcneill 	uint32_t rx_runts;
    816  1.1  jmcneill 	uint32_t rx_fragments;
    817  1.1  jmcneill 	uint32_t rx_pkts_64;
    818  1.1  jmcneill 	uint32_t rx_pkts_65_127;
    819  1.1  jmcneill 	uint32_t rx_pkts_128_255;
    820  1.1  jmcneill 	uint32_t rx_pkts_256_511;
    821  1.1  jmcneill 	uint32_t rx_pkts_512_1023;
    822  1.1  jmcneill 	uint32_t rx_pkts_1024_1518;
    823  1.1  jmcneill 	uint32_t rx_pkts_1519_max;
    824  1.1  jmcneill 	uint32_t rx_pkts_truncated;
    825  1.1  jmcneill 	uint32_t rx_fifo_oflows;
    826  1.1  jmcneill 	uint32_t rx_rrs_errs;
    827  1.1  jmcneill 	uint32_t rx_alignerrs;
    828  1.1  jmcneill 	uint32_t rx_bcast_bytes;
    829  1.1  jmcneill 	uint32_t rx_mcast_bytes;
    830  1.1  jmcneill 	uint32_t rx_pkts_filtered;
    831  1.1  jmcneill 	/* Tx stats. */
    832  1.1  jmcneill 	uint32_t tx_frames;
    833  1.1  jmcneill 	uint32_t tx_bcast_frames;
    834  1.1  jmcneill 	uint32_t tx_mcast_frames;
    835  1.1  jmcneill 	uint32_t tx_pause_frames;
    836  1.1  jmcneill 	uint32_t tx_excess_defer;
    837  1.1  jmcneill 	uint32_t tx_control_frames;
    838  1.1  jmcneill 	uint32_t tx_deferred;
    839  1.1  jmcneill 	uint32_t tx_bytes;
    840  1.1  jmcneill 	uint32_t tx_pkts_64;
    841  1.1  jmcneill 	uint32_t tx_pkts_65_127;
    842  1.1  jmcneill 	uint32_t tx_pkts_128_255;
    843  1.1  jmcneill 	uint32_t tx_pkts_256_511;
    844  1.1  jmcneill 	uint32_t tx_pkts_512_1023;
    845  1.1  jmcneill 	uint32_t tx_pkts_1024_1518;
    846  1.1  jmcneill 	uint32_t tx_pkts_1519_max;
    847  1.1  jmcneill 	uint32_t tx_single_colls;
    848  1.1  jmcneill 	uint32_t tx_multi_colls;
    849  1.1  jmcneill 	uint32_t tx_late_colls;
    850  1.1  jmcneill 	uint32_t tx_excess_colls;
    851  1.1  jmcneill 	uint32_t tx_abort;
    852  1.1  jmcneill 	uint32_t tx_underrun;
    853  1.1  jmcneill 	uint32_t tx_desc_underrun;
    854  1.1  jmcneill 	uint32_t tx_lenerrs;
    855  1.1  jmcneill 	uint32_t tx_pkts_truncated;
    856  1.1  jmcneill 	uint32_t tx_bcast_bytes;
    857  1.1  jmcneill 	uint32_t tx_mcast_bytes;
    858  1.1  jmcneill 	uint32_t updated;
    859  1.1  jmcneill };
    860  1.1  jmcneill 
    861  1.1  jmcneill /* CMB(Coalesing message block) */
    862  1.1  jmcneill struct cmb {
    863  1.1  jmcneill 	uint32_t cons;
    864  1.1  jmcneill };
    865  1.1  jmcneill 
    866  1.1  jmcneill /* Rx free descriptor */
    867  1.1  jmcneill struct rx_desc {
    868  1.1  jmcneill 	uint64_t addr;
    869  1.1  jmcneill };
    870  1.1  jmcneill 
    871  1.1  jmcneill /* Rx return descriptor */
    872  1.1  jmcneill struct rx_rdesc {
    873  1.1  jmcneill 	uint32_t rdinfo;
    874  1.1  jmcneill #define	RRD_CSUM_MASK			0x0000FFFF
    875  1.1  jmcneill #define	RRD_RD_CNT_MASK			0x000F0000
    876  1.1  jmcneill #define	RRD_RD_IDX_MASK			0xFFF00000
    877  1.1  jmcneill #define	RRD_CSUM_SHIFT			0
    878  1.1  jmcneill #define	RRD_RD_CNT_SHIFT		16
    879  1.1  jmcneill #define	RRD_RD_IDX_SHIFT		20
    880  1.1  jmcneill #define	RRD_CSUM(x)			\
    881  1.1  jmcneill 	(((x) & RRD_CSUM_MASK) >> RRD_CSUM_SHIFT)
    882  1.1  jmcneill #define	RRD_RD_CNT(x)			\
    883  1.1  jmcneill 	(((x) & RRD_RD_CNT_MASK) >> RRD_RD_CNT_SHIFT)
    884  1.1  jmcneill #define	RRD_RD_IDX(x)			\
    885  1.1  jmcneill 	(((x) & RRD_RD_IDX_MASK) >> RRD_RD_IDX_SHIFT)
    886  1.1  jmcneill 	uint32_t rss;
    887  1.1  jmcneill 	uint32_t vtag;
    888  1.1  jmcneill #define	RRD_VLAN_MASK			0x0000FFFF
    889  1.1  jmcneill #define	RRD_HEAD_LEN_MASK		0x00FF0000
    890  1.1  jmcneill #define	RRD_HDS_MASK			0x03000000
    891  1.1  jmcneill #define	RRD_HDS_NONE			0x00000000
    892  1.1  jmcneill #define	RRD_HDS_HEAD			0x01000000
    893  1.1  jmcneill #define	RRD_HDS_DATA			0x02000000
    894  1.1  jmcneill #define	RRD_CPU_MASK			0x0C000000
    895  1.1  jmcneill #define	RRD_HASH_FLAG_MASK		0xF0000000
    896  1.1  jmcneill #define	RRD_VLAN_SHIFT			0
    897  1.1  jmcneill #define	RRD_HEAD_LEN_SHIFT		16
    898  1.1  jmcneill #define	RRD_HDS_SHIFT			24
    899  1.1  jmcneill #define	RRD_CPU_SHIFT			26
    900  1.1  jmcneill #define	RRD_HASH_FLAG_SHIFT		28
    901  1.1  jmcneill #define	RRD_VLAN(x)			\
    902  1.1  jmcneill 	(((x) & RRD_VLAN_MASK) >> RRD_VLAN_SHIFT)
    903  1.1  jmcneill #define	RRD_HEAD_LEN(x)			\
    904  1.1  jmcneill 	(((x) & RRD_HEAD_LEN_MASK) >> RRD_HEAD_LEN_SHIFT)
    905  1.1  jmcneill #define	RRD_CPU(x)			\
    906  1.1  jmcneill 	(((x) & RRD_CPU_MASK) >> RRD_CPU_SHIFT)
    907  1.1  jmcneill 	uint32_t status;
    908  1.1  jmcneill #define	RRD_LEN_MASK			0x00003FFF
    909  1.1  jmcneill #define	RRD_LEN_SHIFT			0
    910  1.1  jmcneill #define	RRD_TCP_UDPCSUM_NOK		0x00004000
    911  1.1  jmcneill #define	RRD_IPCSUM_NOK			0x00008000
    912  1.1  jmcneill #define	RRD_VLAN_TAG			0x00010000
    913  1.1  jmcneill #define	RRD_PROTO_MASK			0x000E0000
    914  1.1  jmcneill #define	RRD_PROTO_IPV4			0x00020000
    915  1.1  jmcneill #define	RRD_PROTO_IPV6			0x000C0000
    916  1.1  jmcneill #define	RRD_ERR_SUM			0x00100000
    917  1.1  jmcneill #define	RRD_ERR_CRC			0x00200000
    918  1.1  jmcneill #define	RRD_ERR_ALIGN			0x00400000
    919  1.1  jmcneill #define	RRD_ERR_TRUNC			0x00800000
    920  1.1  jmcneill #define	RRD_ERR_RUNT			0x01000000
    921  1.1  jmcneill #define	RRD_ERR_ICMP			0x02000000
    922  1.1  jmcneill #define	RRD_BCAST			0x04000000
    923  1.1  jmcneill #define	RRD_MCAST			0x08000000
    924  1.1  jmcneill #define	RRD_SNAP_LLC			0x10000000
    925  1.1  jmcneill #define	RRD_ETHER			0x00000000
    926  1.1  jmcneill #define	RRD_FIFO_FULL			0x20000000
    927  1.1  jmcneill #define	RRD_ERR_LENGTH			0x40000000
    928  1.1  jmcneill #define	RRD_VALID			0x80000000
    929  1.1  jmcneill #define	RRD_BYTES(x)			\
    930  1.1  jmcneill 	(((x) & RRD_LEN_MASK) >> RRD_LEN_SHIFT)
    931  1.1  jmcneill #define	RRD_IPV4(x)			\
    932  1.1  jmcneill 	(((x) & RRD_PROTO_MASK) == RRD_PROTO_IPV4)
    933  1.1  jmcneill };
    934  1.1  jmcneill 
    935  1.1  jmcneill /* Tx descriptor */
    936  1.1  jmcneill struct tx_desc {
    937  1.1  jmcneill 	uint32_t len;
    938  1.1  jmcneill #define	TD_BUFLEN_MASK			0x00003FFF
    939  1.1  jmcneill #define	TD_VLAN_MASK			0xFFFF0000
    940  1.1  jmcneill #define	TD_BUFLEN_SHIFT			0
    941  1.1  jmcneill #define	TX_BYTES(x)			\
    942  1.1  jmcneill 	(((x) << TD_BUFLEN_SHIFT) & TD_BUFLEN_MASK)
    943  1.1  jmcneill #define	TD_VLAN_SHIFT			16
    944  1.1  jmcneill 	uint32_t flags;
    945  1.1  jmcneill #define	TD_L4HDR_OFFSET_MASK		0x000000FF	/* byte unit */
    946  1.1  jmcneill #define	TD_TCPHDR_OFFSET_MASK		0x000000FF	/* byte unit */
    947  1.1  jmcneill #define	TD_PLOAD_OFFSET_MASK		0x000000FF	/* 2 bytes unit */
    948  1.1  jmcneill #define	TD_CUSTOM_CSUM			0x00000100
    949  1.1  jmcneill #define	TD_IPCSUM			0x00000200
    950  1.1  jmcneill #define	TD_TCPCSUM			0x00000400
    951  1.1  jmcneill #define	TD_UDPCSUM			0x00000800
    952  1.1  jmcneill #define	TD_TSO				0x00001000
    953  1.1  jmcneill #define	TD_TSO_DESCV1			0x00000000
    954  1.1  jmcneill #define	TD_TSO_DESCV2			0x00002000
    955  1.1  jmcneill #define	TD_CON_VLAN_TAG			0x00004000
    956  1.1  jmcneill #define	TD_INS_VLAN_TAG			0x00008000
    957  1.1  jmcneill #define	TD_IPV4_DESCV2			0x00010000
    958  1.1  jmcneill #define	TD_LLC_SNAP			0x00020000
    959  1.1  jmcneill #define	TD_ETHERNET			0x00000000
    960  1.1  jmcneill #define	TD_CUSTOM_CSUM_OFFSET_MASK	0x03FC0000	/* 2 bytes unit */
    961  1.1  jmcneill #define	TD_CUSTOM_CSUM_EVEN_PAD		0x40000000
    962  1.1  jmcneill #define	TD_MSS_MASK			0x7FFC0000
    963  1.1  jmcneill #define	TD_EOP				0x80000000
    964  1.1  jmcneill #define	TD_L4HDR_OFFSET_SHIFT		0
    965  1.1  jmcneill #define	TD_TCPHDR_OFFSET_SHIFT		0
    966  1.1  jmcneill #define	TD_PLOAD_OFFSET_SHIFT		0
    967  1.1  jmcneill #define	TD_CUSTOM_CSUM_OFFSET_SHIFT	18
    968  1.1  jmcneill #define	TD_MSS_SHIFT			18
    969  1.1  jmcneill 	uint64_t addr;
    970  1.1  jmcneill };
    971  1.1  jmcneill 
    972  1.1  jmcneill #define	ALC_TX_RING_CNT		256
    973  1.1  jmcneill #define	ALC_TX_RING_ALIGN	sizeof(struct tx_desc)
    974  1.1  jmcneill #define	ALC_RX_RING_CNT		256
    975  1.1  jmcneill #define	ALC_RX_RING_ALIGN	sizeof(struct rx_desc)
    976  1.1  jmcneill #define	ALC_RX_BUF_ALIGN	4
    977  1.1  jmcneill #define	ALC_RR_RING_CNT		ALC_RX_RING_CNT
    978  1.1  jmcneill #define	ALC_RR_RING_ALIGN	sizeof(struct rx_rdesc)
    979  1.1  jmcneill #define	ALC_CMB_ALIGN		8
    980  1.1  jmcneill #define	ALC_SMB_ALIGN		8
    981  1.1  jmcneill 
    982  1.1  jmcneill #define	ALC_TSO_MAXSEGSIZE	4096
    983  1.1  jmcneill #define	ALC_TSO_MAXSIZE		(65535 + sizeof(struct ether_vlan_header))
    984  1.1  jmcneill #define	ALC_MAXTXSEGS		32
    985  1.1  jmcneill 
    986  1.1  jmcneill #define	ALC_ADDR_LO(x)		((uint64_t) (x) & 0xFFFFFFFF)
    987  1.1  jmcneill #define	ALC_ADDR_HI(x)		((uint64_t) (x) >> 32)
    988  1.1  jmcneill 
    989  1.1  jmcneill #define	ALC_DESC_INC(x, y)	((x) = ((x) + 1) % (y))
    990  1.1  jmcneill 
    991  1.1  jmcneill /* Water mark to kick reclaiming Tx buffers. */
    992  1.1  jmcneill #define	ALC_TX_DESC_HIWAT	((ALC_TX_RING_CNT * 6) / 10)
    993  1.1  jmcneill 
    994  1.1  jmcneill #define	ALC_MSI_MESSAGES	1
    995  1.1  jmcneill #define	ALC_MSIX_MESSAGES	1
    996  1.1  jmcneill 
    997  1.1  jmcneill #define	ALC_TX_RING_SZ		\
    998  1.1  jmcneill 	(sizeof(struct tx_desc) * ALC_TX_RING_CNT)
    999  1.1  jmcneill #define	ALC_RX_RING_SZ		\
   1000  1.1  jmcneill 	(sizeof(struct rx_desc) * ALC_RX_RING_CNT)
   1001  1.1  jmcneill #define	ALC_RR_RING_SZ		\
   1002  1.1  jmcneill 	(sizeof(struct rx_rdesc) * ALC_RR_RING_CNT)
   1003  1.1  jmcneill #define	ALC_CMB_SZ		(sizeof(struct cmb))
   1004  1.1  jmcneill #define	ALC_SMB_SZ		(sizeof(struct smb))
   1005  1.1  jmcneill 
   1006  1.1  jmcneill #define	ALC_PROC_MIN		16
   1007  1.1  jmcneill #define	ALC_PROC_MAX		(ALC_RX_RING_CNT - 1)
   1008  1.1  jmcneill #define	ALC_PROC_DEFAULT	(ALC_RX_RING_CNT / 4)
   1009  1.1  jmcneill 
   1010  1.1  jmcneill /*
   1011  1.2  jmcneill  * The number of bits reserved for MSS in AR813x/AR815x controllers
   1012  1.1  jmcneill  * are 13 bits. This limits the maximum interface MTU size in TSO
   1013  1.1  jmcneill  * case(8191 + sizeof(struct ip) + sizeof(struct tcphdr)) as upper
   1014  1.1  jmcneill  * stack should not generate TCP segments with MSS greater than the
   1015  1.1  jmcneill  * limit. Also Atheros says that maximum MTU for TSO is 6KB.
   1016  1.1  jmcneill  */
   1017  1.1  jmcneill #define	ALC_TSO_MTU		(6 * 1024)
   1018  1.1  jmcneill 
   1019  1.1  jmcneill struct alc_rxdesc {
   1020  1.1  jmcneill 	struct mbuf		*rx_m;
   1021  1.1  jmcneill 	bus_dmamap_t		rx_dmamap;
   1022  1.1  jmcneill 	struct rx_desc		*rx_desc;
   1023  1.1  jmcneill };
   1024  1.1  jmcneill 
   1025  1.1  jmcneill struct alc_txdesc {
   1026  1.1  jmcneill 	struct mbuf		*tx_m;
   1027  1.1  jmcneill 	bus_dmamap_t		tx_dmamap;
   1028  1.1  jmcneill };
   1029  1.1  jmcneill 
   1030  1.1  jmcneill struct alc_ring_data {
   1031  1.1  jmcneill 	struct tx_desc		*alc_tx_ring;
   1032  1.1  jmcneill 	bus_dma_segment_t	alc_tx_ring_seg;
   1033  1.1  jmcneill 	bus_addr_t		alc_tx_ring_paddr;
   1034  1.1  jmcneill 	struct rx_desc		*alc_rx_ring;
   1035  1.1  jmcneill 	bus_dma_segment_t	alc_rx_ring_seg;
   1036  1.1  jmcneill 	bus_addr_t		alc_rx_ring_paddr;
   1037  1.1  jmcneill 	struct rx_rdesc		*alc_rr_ring;
   1038  1.1  jmcneill 	bus_dma_segment_t	alc_rr_ring_seg;
   1039  1.1  jmcneill 	bus_addr_t		alc_rr_ring_paddr;
   1040  1.1  jmcneill 	struct cmb		*alc_cmb;
   1041  1.1  jmcneill 	bus_dma_segment_t	alc_cmb_seg;
   1042  1.1  jmcneill 	bus_addr_t		alc_cmb_paddr;
   1043  1.1  jmcneill 	struct smb		*alc_smb;
   1044  1.1  jmcneill 	bus_dma_segment_t	alc_smb_seg;
   1045  1.1  jmcneill 	bus_addr_t		alc_smb_paddr;
   1046  1.1  jmcneill };
   1047  1.1  jmcneill 
   1048  1.1  jmcneill struct alc_chain_data {
   1049  1.1  jmcneill 	struct alc_txdesc	alc_txdesc[ALC_TX_RING_CNT];
   1050  1.1  jmcneill 	struct alc_rxdesc	alc_rxdesc[ALC_RX_RING_CNT];
   1051  1.1  jmcneill 	bus_dmamap_t		alc_tx_ring_map;
   1052  1.1  jmcneill 	bus_dma_segment_t	alc_tx_ring_seg;
   1053  1.1  jmcneill 	bus_dmamap_t		alc_rx_ring_map;
   1054  1.1  jmcneill 	bus_dma_segment_t	alc_rx_ring_seg;
   1055  1.1  jmcneill 	bus_dmamap_t		alc_rr_ring_map;
   1056  1.1  jmcneill 	bus_dma_segment_t	alc_rr_ring_seg;
   1057  1.1  jmcneill 	bus_dmamap_t		alc_rx_sparemap;
   1058  1.1  jmcneill 	bus_dmamap_t		alc_cmb_map;
   1059  1.1  jmcneill 	bus_dma_segment_t	alc_cmb_seg;
   1060  1.1  jmcneill 	bus_dmamap_t		alc_smb_map;
   1061  1.1  jmcneill 	bus_dma_segment_t	alc_smb_seg;
   1062  1.1  jmcneill 
   1063  1.1  jmcneill 	int			alc_tx_prod;
   1064  1.1  jmcneill 	int			alc_tx_cons;
   1065  1.1  jmcneill 	int			alc_tx_cnt;
   1066  1.1  jmcneill 	int			alc_rx_cons;
   1067  1.1  jmcneill 	int			alc_rr_cons;
   1068  1.1  jmcneill 	int			alc_rxlen;
   1069  1.1  jmcneill 
   1070  1.1  jmcneill 	struct mbuf		*alc_rxhead;
   1071  1.1  jmcneill 	struct mbuf		*alc_rxtail;
   1072  1.1  jmcneill 	struct mbuf		*alc_rxprev_tail;
   1073  1.1  jmcneill };
   1074  1.1  jmcneill 
   1075  1.1  jmcneill struct alc_hw_stats {
   1076  1.1  jmcneill 	/* Rx stats. */
   1077  1.1  jmcneill 	uint32_t rx_frames;
   1078  1.1  jmcneill 	uint32_t rx_bcast_frames;
   1079  1.1  jmcneill 	uint32_t rx_mcast_frames;
   1080  1.1  jmcneill 	uint32_t rx_pause_frames;
   1081  1.1  jmcneill 	uint32_t rx_control_frames;
   1082  1.1  jmcneill 	uint32_t rx_crcerrs;
   1083  1.1  jmcneill 	uint32_t rx_lenerrs;
   1084  1.1  jmcneill 	uint64_t rx_bytes;
   1085  1.1  jmcneill 	uint32_t rx_runts;
   1086  1.1  jmcneill 	uint32_t rx_fragments;
   1087  1.1  jmcneill 	uint32_t rx_pkts_64;
   1088  1.1  jmcneill 	uint32_t rx_pkts_65_127;
   1089  1.1  jmcneill 	uint32_t rx_pkts_128_255;
   1090  1.1  jmcneill 	uint32_t rx_pkts_256_511;
   1091  1.1  jmcneill 	uint32_t rx_pkts_512_1023;
   1092  1.1  jmcneill 	uint32_t rx_pkts_1024_1518;
   1093  1.1  jmcneill 	uint32_t rx_pkts_1519_max;
   1094  1.1  jmcneill 	uint32_t rx_pkts_truncated;
   1095  1.1  jmcneill 	uint32_t rx_fifo_oflows;
   1096  1.1  jmcneill 	uint32_t rx_rrs_errs;
   1097  1.1  jmcneill 	uint32_t rx_alignerrs;
   1098  1.1  jmcneill 	uint64_t rx_bcast_bytes;
   1099  1.1  jmcneill 	uint64_t rx_mcast_bytes;
   1100  1.1  jmcneill 	uint32_t rx_pkts_filtered;
   1101  1.1  jmcneill 	/* Tx stats. */
   1102  1.1  jmcneill 	uint32_t tx_frames;
   1103  1.1  jmcneill 	uint32_t tx_bcast_frames;
   1104  1.1  jmcneill 	uint32_t tx_mcast_frames;
   1105  1.1  jmcneill 	uint32_t tx_pause_frames;
   1106  1.1  jmcneill 	uint32_t tx_excess_defer;
   1107  1.1  jmcneill 	uint32_t tx_control_frames;
   1108  1.1  jmcneill 	uint32_t tx_deferred;
   1109  1.1  jmcneill 	uint64_t tx_bytes;
   1110  1.1  jmcneill 	uint32_t tx_pkts_64;
   1111  1.1  jmcneill 	uint32_t tx_pkts_65_127;
   1112  1.1  jmcneill 	uint32_t tx_pkts_128_255;
   1113  1.1  jmcneill 	uint32_t tx_pkts_256_511;
   1114  1.1  jmcneill 	uint32_t tx_pkts_512_1023;
   1115  1.1  jmcneill 	uint32_t tx_pkts_1024_1518;
   1116  1.1  jmcneill 	uint32_t tx_pkts_1519_max;
   1117  1.1  jmcneill 	uint32_t tx_single_colls;
   1118  1.1  jmcneill 	uint32_t tx_multi_colls;
   1119  1.1  jmcneill 	uint32_t tx_late_colls;
   1120  1.1  jmcneill 	uint32_t tx_excess_colls;
   1121  1.1  jmcneill 	uint32_t tx_abort;
   1122  1.1  jmcneill 	uint32_t tx_underrun;
   1123  1.1  jmcneill 	uint32_t tx_desc_underrun;
   1124  1.1  jmcneill 	uint32_t tx_lenerrs;
   1125  1.1  jmcneill 	uint32_t tx_pkts_truncated;
   1126  1.1  jmcneill 	uint64_t tx_bcast_bytes;
   1127  1.1  jmcneill 	uint64_t tx_mcast_bytes;
   1128  1.1  jmcneill };
   1129  1.1  jmcneill 
   1130  1.2  jmcneill struct alc_ident {
   1131  1.2  jmcneill 	uint16_t	vendorid;
   1132  1.2  jmcneill 	uint16_t	deviceid;
   1133  1.2  jmcneill 	uint32_t	max_framelen;
   1134  1.2  jmcneill 	const char	*name;
   1135  1.2  jmcneill };
   1136  1.2  jmcneill 
   1137  1.1  jmcneill /*
   1138  1.1  jmcneill  * Software state per device.
   1139  1.1  jmcneill  */
   1140  1.1  jmcneill struct alc_softc {
   1141  1.1  jmcneill 	device_t		sc_dev;
   1142  1.1  jmcneill 	struct ethercom		sc_ec;
   1143  1.1  jmcneill 
   1144  1.1  jmcneill 	bus_space_tag_t		sc_mem_bt;
   1145  1.1  jmcneill 	bus_space_handle_t	sc_mem_bh;
   1146  1.1  jmcneill 	bus_size_t		sc_mem_size;
   1147  1.1  jmcneill 	bus_dma_tag_t		sc_dmat;
   1148  1.1  jmcneill 	pci_chipset_tag_t	sc_pct;
   1149  1.1  jmcneill 	pcitag_t		sc_pcitag;
   1150  1.1  jmcneill 
   1151  1.1  jmcneill 	void			*sc_irq_handle;
   1152  1.2  jmcneill 	struct alc_ident	*alc_ident;
   1153  1.1  jmcneill 	struct mii_data		sc_miibus;
   1154  1.1  jmcneill 	int			alc_rev;
   1155  1.2  jmcneill 	int			alc_expcap;
   1156  1.1  jmcneill 	int			alc_chip_rev;
   1157  1.1  jmcneill 	int			alc_phyaddr;
   1158  1.1  jmcneill 	uint8_t			alc_eaddr[ETHER_ADDR_LEN];
   1159  1.1  jmcneill 	uint32_t		alc_dma_rd_burst;
   1160  1.1  jmcneill 	uint32_t		alc_dma_wr_burst;
   1161  1.1  jmcneill 	uint32_t		alc_rcb;
   1162  1.1  jmcneill 	int			alc_flags;
   1163  1.1  jmcneill #define	ALC_FLAG_PCIE		0x0001
   1164  1.1  jmcneill #define	ALC_FLAG_PCIX		0x0002
   1165  1.1  jmcneill #define	ALC_FLAG_MSI		0x0004
   1166  1.1  jmcneill #define	ALC_FLAG_MSIX		0x0008
   1167  1.1  jmcneill #define	ALC_FLAG_FASTETHER	0x0020
   1168  1.1  jmcneill #define	ALC_FLAG_JUMBO		0x0040
   1169  1.1  jmcneill #define	ALC_FLAG_ASPM_MON	0x0080
   1170  1.1  jmcneill #define	ALC_FLAG_CMB_BUG	0x0100
   1171  1.1  jmcneill #define	ALC_FLAG_SMB_BUG	0x0200
   1172  1.2  jmcneill #define	ALC_FLAG_L0S		0x0400
   1173  1.2  jmcneill #define	ALC_FLAG_L1S		0x0800
   1174  1.2  jmcneill #define	ALC_FLAG_APS		0x1000
   1175  1.1  jmcneill #define	ALC_FLAG_LINK		0x8000
   1176  1.1  jmcneill 
   1177  1.1  jmcneill 	callout_t		sc_tick_ch;
   1178  1.1  jmcneill 	struct alc_hw_stats	alc_stats;
   1179  1.1  jmcneill 	struct alc_chain_data	alc_cdata;
   1180  1.1  jmcneill 	struct alc_ring_data	alc_rdata;
   1181  1.1  jmcneill 	int			alc_int_rx_mod;
   1182  1.1  jmcneill 	int			alc_int_tx_mod;
   1183  1.1  jmcneill 	int			alc_buf_size;
   1184  1.1  jmcneill };
   1185  1.1  jmcneill 
   1186  1.1  jmcneill /* Register access macros. */
   1187  1.1  jmcneill #define	CSR_WRITE_4(_sc, reg, val)	\
   1188  1.1  jmcneill 	bus_space_write_4((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
   1189  1.1  jmcneill #define	CSR_WRITE_2(_sc, reg, val)	\
   1190  1.1  jmcneill 	bus_space_write_2((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
   1191  1.1  jmcneill #define	CSR_WRITE_1(_sc, reg, val)	\
   1192  1.1  jmcneill 	bus_space_write_1((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg), (val))
   1193  1.1  jmcneill #define	CSR_READ_2(_sc, reg)		\
   1194  1.1  jmcneill 	bus_space_read_2((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg))
   1195  1.1  jmcneill #define	CSR_READ_4(_sc, reg)		\
   1196  1.1  jmcneill 	bus_space_read_4((sc)->sc_mem_bt, (sc)->sc_mem_bh, (reg))
   1197  1.1  jmcneill 
   1198  1.1  jmcneill #define	ALC_RXCHAIN_RESET(_sc)						\
   1199  1.1  jmcneill do {									\
   1200  1.1  jmcneill 	(_sc)->alc_cdata.alc_rxhead = NULL;				\
   1201  1.1  jmcneill 	(_sc)->alc_cdata.alc_rxtail = NULL;				\
   1202  1.1  jmcneill 	(_sc)->alc_cdata.alc_rxprev_tail = NULL;			\
   1203  1.1  jmcneill 	(_sc)->alc_cdata.alc_rxlen = 0;					\
   1204  1.1  jmcneill } while (0)
   1205  1.1  jmcneill 
   1206  1.1  jmcneill #define	ALC_TX_TIMEOUT		5
   1207  1.1  jmcneill #define	ALC_RESET_TIMEOUT	100
   1208  1.1  jmcneill #define	ALC_TIMEOUT		1000
   1209  1.1  jmcneill #define	ALC_PHY_TIMEOUT		1000
   1210  1.1  jmcneill 
   1211  1.1  jmcneill #endif	/* _IF_ALCREG_H */
   1212