Home | History | Annotate | Line # | Download | only in pci
if_wmreg.h revision 1.91
      1  1.91   msaitoh /*	$NetBSD: if_wmreg.h,v 1.91 2016/11/14 08:48:03 msaitoh Exp $	*/
      2   1.1   thorpej 
      3   1.1   thorpej /*
      4   1.1   thorpej  * Copyright (c) 2001 Wasabi Systems, Inc.
      5   1.1   thorpej  * All rights reserved.
      6   1.1   thorpej  *
      7   1.1   thorpej  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8   1.1   thorpej  *
      9   1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     10   1.1   thorpej  * modification, are permitted provided that the following conditions
     11   1.1   thorpej  * are met:
     12   1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     13   1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     14   1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     16   1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     17   1.1   thorpej  * 3. All advertising materials mentioning features or use of this software
     18   1.1   thorpej  *    must display the following acknowledgement:
     19   1.1   thorpej  *	This product includes software developed for the NetBSD Project by
     20   1.1   thorpej  *	Wasabi Systems, Inc.
     21   1.1   thorpej  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22   1.1   thorpej  *    or promote products derived from this software without specific prior
     23   1.1   thorpej  *    written permission.
     24   1.1   thorpej  *
     25   1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26   1.1   thorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27   1.1   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28   1.1   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29   1.1   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30   1.1   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31   1.1   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32   1.1   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33   1.1   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34   1.1   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35   1.1   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     36   1.1   thorpej  */
     37   1.1   thorpej 
     38  1.53   msaitoh /******************************************************************************
     39  1.53   msaitoh 
     40  1.53   msaitoh   Copyright (c) 2001-2012, Intel Corporation
     41  1.53   msaitoh   All rights reserved.
     42  1.53   msaitoh 
     43  1.53   msaitoh   Redistribution and use in source and binary forms, with or without
     44  1.53   msaitoh   modification, are permitted provided that the following conditions are met:
     45  1.53   msaitoh 
     46  1.53   msaitoh    1. Redistributions of source code must retain the above copyright notice,
     47  1.53   msaitoh       this list of conditions and the following disclaimer.
     48  1.53   msaitoh 
     49  1.53   msaitoh    2. Redistributions in binary form must reproduce the above copyright
     50  1.53   msaitoh       notice, this list of conditions and the following disclaimer in the
     51  1.53   msaitoh       documentation and/or other materials provided with the distribution.
     52  1.53   msaitoh 
     53  1.53   msaitoh    3. Neither the name of the Intel Corporation nor the names of its
     54  1.53   msaitoh       contributors may be used to endorse or promote products derived from
     55  1.53   msaitoh       this software without specific prior written permission.
     56  1.53   msaitoh 
     57  1.53   msaitoh   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     58  1.53   msaitoh   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     59  1.53   msaitoh   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     60  1.53   msaitoh   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     61  1.53   msaitoh   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     62  1.53   msaitoh   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     63  1.53   msaitoh   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     64  1.53   msaitoh   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     65  1.53   msaitoh   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     66  1.53   msaitoh   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     67  1.53   msaitoh   POSSIBILITY OF SUCH DAMAGE.
     68  1.53   msaitoh 
     69  1.53   msaitoh ******************************************************************************/
     70  1.53   msaitoh 
     71   1.1   thorpej /*
     72   1.4      yamt  * Register description for the Intel i82542 (``Wiseman''),
     73   1.1   thorpej  * i82543 (``Livengood''), and i82544 (``Cordova'') Gigabit
     74   1.1   thorpej  * Ethernet chips.
     75   1.1   thorpej  */
     76   1.1   thorpej 
     77   1.1   thorpej /*
     78   1.1   thorpej  * The wiseman supports 64-bit PCI addressing.  This structure
     79   1.1   thorpej  * describes the address in descriptors.
     80   1.1   thorpej  */
     81   1.1   thorpej typedef struct wiseman_addr {
     82   1.1   thorpej 	uint32_t	wa_low;		/* low-order 32 bits */
     83   1.1   thorpej 	uint32_t	wa_high;	/* high-order 32 bits */
     84  1.24     perry } __packed wiseman_addr_t;
     85   1.1   thorpej 
     86   1.1   thorpej /*
     87   1.1   thorpej  * The Wiseman receive descriptor.
     88   1.1   thorpej  *
     89   1.1   thorpej  * The receive descriptor ring must be aligned to a 4K boundary,
     90   1.1   thorpej  * and there must be an even multiple of 8 descriptors in the ring.
     91   1.1   thorpej  */
     92   1.1   thorpej typedef struct wiseman_rxdesc {
     93  1.46    dyoung 	volatile wiseman_addr_t	wrx_addr;	/* buffer address */
     94   1.1   thorpej 
     95  1.46    dyoung 	volatile uint16_t	wrx_len;	/* buffer length */
     96  1.46    dyoung 	volatile uint16_t	wrx_cksum;	/* checksum (starting at PCSS)*/
     97   1.1   thorpej 
     98  1.46    dyoung 	volatile uint8_t	wrx_status;	/* Rx status */
     99  1.46    dyoung 	volatile uint8_t	wrx_errors;	/* Rx errors */
    100  1.46    dyoung 	volatile uint16_t	wrx_special;	/* special field (VLAN, etc.) */
    101  1.24     perry } __packed wiseman_rxdesc_t;
    102   1.1   thorpej 
    103   1.1   thorpej /* wrx_status bits */
    104   1.1   thorpej #define	WRX_ST_DD	(1U << 0)	/* descriptor done */
    105   1.1   thorpej #define	WRX_ST_EOP	(1U << 1)	/* end of packet */
    106  1.15      yamt #define	WRX_ST_IXSM	(1U << 2)	/* ignore checksum indication */
    107   1.1   thorpej #define	WRX_ST_VP	(1U << 3)	/* VLAN packet */
    108   1.1   thorpej #define	WRX_ST_BPDU	(1U << 4)	/* ??? */
    109   1.1   thorpej #define	WRX_ST_TCPCS	(1U << 5)	/* TCP checksum performed */
    110   1.1   thorpej #define	WRX_ST_IPCS	(1U << 6)	/* IP checksum performed */
    111   1.1   thorpej #define	WRX_ST_PIF	(1U << 7)	/* passed in-exact filter */
    112   1.1   thorpej 
    113   1.1   thorpej /* wrx_error bits */
    114   1.1   thorpej #define	WRX_ER_CE	(1U << 0)	/* CRC error */
    115   1.1   thorpej #define	WRX_ER_SE	(1U << 1)	/* symbol error */
    116   1.1   thorpej #define	WRX_ER_SEQ	(1U << 2)	/* sequence error */
    117   1.1   thorpej #define	WRX_ER_ICE	(1U << 3)	/* ??? */
    118   1.1   thorpej #define	WRX_ER_CXE	(1U << 4)	/* carrier extension error */
    119   1.1   thorpej #define	WRX_ER_TCPE	(1U << 5)	/* TCP checksum error */
    120   1.1   thorpej #define	WRX_ER_IPE	(1U << 6)	/* IP checksum error */
    121   1.1   thorpej #define	WRX_ER_RXE	(1U << 7)	/* Rx data error */
    122   1.1   thorpej 
    123   1.1   thorpej /* wrx_special field for VLAN packets */
    124   1.1   thorpej #define	WRX_VLAN_ID(x)	((x) & 0x0fff)	/* VLAN identifier */
    125   1.1   thorpej #define	WRX_VLAN_CFI	(1U << 12)	/* Canonical Form Indicator */
    126   1.1   thorpej #define	WRX_VLAN_PRI(x)	(((x) >> 13) & 7)/* VLAN priority field */
    127   1.1   thorpej 
    128   1.1   thorpej /*
    129   1.1   thorpej  * The Wiseman transmit descriptor.
    130   1.1   thorpej  *
    131   1.1   thorpej  * The transmit descriptor ring must be aligned to a 4K boundary,
    132   1.1   thorpej  * and there must be an even multiple of 8 descriptors in the ring.
    133   1.1   thorpej  */
    134   1.9   tsutsui typedef struct wiseman_tx_fields {
    135   1.9   tsutsui 	uint8_t wtxu_status;		/* Tx status */
    136   1.9   tsutsui 	uint8_t wtxu_options;		/* options */
    137   1.9   tsutsui 	uint16_t wtxu_vlan;		/* VLAN info */
    138  1.24     perry } __packed wiseman_txfields_t;
    139   1.1   thorpej typedef struct wiseman_txdesc {
    140   1.1   thorpej 	wiseman_addr_t	wtx_addr;	/* buffer address */
    141   1.1   thorpej 	uint32_t	wtx_cmdlen;	/* command and length */
    142   1.1   thorpej 	wiseman_txfields_t wtx_fields;	/* fields; see below */
    143  1.24     perry } __packed wiseman_txdesc_t;
    144   1.1   thorpej 
    145   1.9   tsutsui /* Commands for wtx_cmdlen */
    146   1.1   thorpej #define	WTX_CMD_EOP	(1U << 24)	/* end of packet */
    147   1.1   thorpej #define	WTX_CMD_IFCS	(1U << 25)	/* insert FCS */
    148   1.1   thorpej #define	WTX_CMD_RS	(1U << 27)	/* report status */
    149   1.1   thorpej #define	WTX_CMD_RPS	(1U << 28)	/* report packet sent */
    150   1.1   thorpej #define	WTX_CMD_DEXT	(1U << 29)	/* descriptor extension */
    151   1.1   thorpej #define	WTX_CMD_VLE	(1U << 30)	/* VLAN enable */
    152   1.1   thorpej #define	WTX_CMD_IDE	(1U << 31)	/* interrupt delay enable */
    153   1.1   thorpej 
    154   1.1   thorpej /* Descriptor types (if DEXT is set) */
    155   1.9   tsutsui #define	WTX_DTYP_C	(0U << 20)	/* context */
    156  1.10   thorpej #define	WTX_DTYP_D	(1U << 20)	/* data */
    157   1.1   thorpej 
    158   1.1   thorpej /* wtx_fields status bits */
    159   1.1   thorpej #define	WTX_ST_DD	(1U << 0)	/* descriptor done */
    160   1.1   thorpej #define	WTX_ST_EC	(1U << 1)	/* excessive collisions */
    161   1.1   thorpej #define	WTX_ST_LC	(1U << 2)	/* late collision */
    162   1.1   thorpej #define	WTX_ST_TU	(1U << 3)	/* transmit underrun */
    163   1.1   thorpej 
    164   1.9   tsutsui /* wtx_fields option bits for IP/TCP/UDP checksum offload */
    165   1.9   tsutsui #define	WTX_IXSM	(1U << 0)	/* IP checksum offload */
    166   1.9   tsutsui #define	WTX_TXSM	(1U << 1)	/* TCP/UDP checksum offload */
    167   1.1   thorpej 
    168  1.13   thorpej /* Maximum payload per Tx descriptor */
    169  1.13   thorpej #define	WTX_MAX_LEN	4096
    170  1.13   thorpej 
    171   1.1   thorpej /*
    172   1.1   thorpej  * The Livengood TCP/IP context descriptor.
    173   1.1   thorpej  */
    174   1.1   thorpej struct livengood_tcpip_ctxdesc {
    175   1.1   thorpej 	uint32_t	tcpip_ipcs;	/* IP checksum context */
    176   1.1   thorpej 	uint32_t	tcpip_tucs;	/* TCP/UDP checksum context */
    177   1.1   thorpej 	uint32_t	tcpip_cmdlen;
    178   1.1   thorpej 	uint32_t	tcpip_seg;	/* TCP segmentation context */
    179   1.1   thorpej };
    180   1.1   thorpej 
    181   1.1   thorpej /* commands for context descriptors */
    182   1.2   thorpej #define	WTX_TCPIP_CMD_TCP	(1U << 24)	/* 1 = TCP, 0 = UDP */
    183   1.2   thorpej #define	WTX_TCPIP_CMD_IP	(1U << 25)	/* 1 = IPv4, 0 = IPv6 */
    184   1.1   thorpej #define	WTX_TCPIP_CMD_TSE	(1U << 26)	/* segmentation context valid */
    185   1.1   thorpej 
    186   1.1   thorpej #define	WTX_TCPIP_IPCSS(x)	((x) << 0)	/* checksum start */
    187   1.1   thorpej #define	WTX_TCPIP_IPCSO(x)	((x) << 8)	/* checksum value offset */
    188   1.1   thorpej #define	WTX_TCPIP_IPCSE(x)	((x) << 16)	/* checksum end */
    189   1.1   thorpej 
    190   1.1   thorpej #define	WTX_TCPIP_TUCSS(x)	((x) << 0)	/* checksum start */
    191   1.1   thorpej #define	WTX_TCPIP_TUCSO(x)	((x) << 8)	/* checksum value offset */
    192   1.1   thorpej #define	WTX_TCPIP_TUCSE(x)	((x) << 16)	/* checksum end */
    193   1.1   thorpej 
    194   1.1   thorpej #define	WTX_TCPIP_SEG_STATUS(x)	((x) << 0)
    195   1.1   thorpej #define	WTX_TCPIP_SEG_HDRLEN(x)	((x) << 8)
    196   1.1   thorpej #define	WTX_TCPIP_SEG_MSS(x)	((x) << 16)
    197   1.1   thorpej 
    198   1.1   thorpej /*
    199   1.1   thorpej  * PCI config registers used by the Wiseman.
    200   1.1   thorpej  */
    201   1.1   thorpej #define	WM_PCI_MMBA	PCI_MAPREG_START
    202  1.22    bouyer /* registers for FLASH access on ICH8 */
    203  1.22    bouyer #define WM_ICH8_FLASH	0x0014
    204   1.1   thorpej 
    205  1.89   msaitoh /* XXX Only for PCH_SPT? */
    206  1.89   msaitoh #define WM_PCI_DESCRING_STATUS	0xe4
    207  1.89   msaitoh #define DESCRING_STATUS_FLUSH_REQ	__BIT(8)
    208  1.89   msaitoh 
    209   1.1   thorpej /*
    210   1.1   thorpej  * Wiseman Control/Status Registers.
    211   1.1   thorpej  */
    212   1.1   thorpej #define	WMREG_CTRL	0x0000	/* Device Control Register */
    213   1.1   thorpej #define	CTRL_FD		(1U << 0)	/* full duplex */
    214   1.1   thorpej #define	CTRL_BEM	(1U << 1)	/* big-endian mode */
    215   1.1   thorpej #define	CTRL_PRIOR	(1U << 2)	/* 0 = receive, 1 = fair */
    216  1.56   msaitoh #define	CTRL_GIO_M_DIS	(1U << 2)	/* disabl PCI master access */
    217   1.1   thorpej #define	CTRL_LRST	(1U << 3)	/* link reset */
    218   1.1   thorpej #define	CTRL_ASDE	(1U << 5)	/* auto speed detect enable */
    219   1.1   thorpej #define	CTRL_SLU	(1U << 6)	/* set link up */
    220   1.1   thorpej #define	CTRL_ILOS	(1U << 7)	/* invert loss of signal */
    221   1.1   thorpej #define	CTRL_SPEED(x)	((x) << 8)	/* speed (Livengood) */
    222   1.1   thorpej #define	CTRL_SPEED_10	CTRL_SPEED(0)
    223   1.1   thorpej #define	CTRL_SPEED_100	CTRL_SPEED(1)
    224   1.1   thorpej #define	CTRL_SPEED_1000	CTRL_SPEED(2)
    225   1.1   thorpej #define	CTRL_SPEED_MASK	CTRL_SPEED(3)
    226   1.1   thorpej #define	CTRL_FRCSPD	(1U << 11)	/* force speed (Livengood) */
    227   1.1   thorpej #define	CTRL_FRCFDX	(1U << 12)	/* force full-duplex (Livengood) */
    228  1.20    bouyer #define CTRL_D_UD_EN	(1U << 13)	/* Dock/Undock enable */
    229  1.20    bouyer #define CTRL_D_UD_POL	(1U << 14)	/* Defined polarity of Dock/Undock indication in SDP[0] */
    230  1.20    bouyer #define CTRL_F_PHY_R 	(1U << 15)	/* Reset both PHY ports, through PHYRST_N pin */
    231  1.20    bouyer #define CTRL_EXT_LINK_EN (1U << 16)	/* enable link status from external LINK_0 and LINK_1 pins */
    232  1.45   msaitoh #define CTRL_LANPHYPC_OVERRIDE (1U << 16) /* SW control of LANPHYPC */
    233  1.45   msaitoh #define CTRL_LANPHYPC_VALUE (1U << 17)	/* SW value of LANPHYPC */
    234   1.1   thorpej #define	CTRL_SWDPINS_SHIFT	18
    235   1.1   thorpej #define	CTRL_SWDPINS_MASK	0x0f
    236   1.1   thorpej #define	CTRL_SWDPIN(x)		(1U << (CTRL_SWDPINS_SHIFT + (x)))
    237   1.1   thorpej #define	CTRL_SWDPIO_SHIFT	22
    238   1.1   thorpej #define	CTRL_SWDPIO_MASK	0x0f
    239   1.1   thorpej #define	CTRL_SWDPIO(x)		(1U << (CTRL_SWDPIO_SHIFT + (x)))
    240  1.90   msaitoh #define CTRL_MEHE	(1U << 19)	/* Memory Error Handling Enable(I217)*/
    241   1.1   thorpej #define	CTRL_RST	(1U << 26)	/* device reset */
    242   1.1   thorpej #define	CTRL_RFCE	(1U << 27)	/* Rx flow control enable */
    243   1.1   thorpej #define	CTRL_TFCE	(1U << 28)	/* Tx flow control enable */
    244   1.1   thorpej #define	CTRL_VME	(1U << 30)	/* VLAN Mode Enable */
    245   1.1   thorpej #define	CTRL_PHY_RESET	(1U << 31)	/* PHY reset (Cordova) */
    246   1.1   thorpej 
    247   1.7   thorpej #define	WMREG_CTRL_SHADOW 0x0004	/* Device Control Register (shadow) */
    248   1.6   thorpej 
    249   1.1   thorpej #define	WMREG_STATUS	0x0008	/* Device Status Register */
    250   1.1   thorpej #define	STATUS_FD	(1U << 0)	/* full duplex */
    251   1.1   thorpej #define	STATUS_LU	(1U << 1)	/* link up */
    252   1.1   thorpej #define	STATUS_TCKOK	(1U << 2)	/* Tx clock running */
    253   1.1   thorpej #define	STATUS_RBCOK	(1U << 3)	/* Rx clock running */
    254   1.3   thorpej #define	STATUS_FUNCID_SHIFT 2		/* 82546 function ID */
    255   1.3   thorpej #define	STATUS_FUNCID_MASK  3		/* ... */
    256   1.1   thorpej #define	STATUS_TXOFF	(1U << 4)	/* Tx paused */
    257   1.1   thorpej #define	STATUS_TBIMODE	(1U << 5)	/* fiber mode (Livengood) */
    258   1.1   thorpej #define	STATUS_SPEED(x)	((x) << 6)	/* speed indication */
    259   1.1   thorpej #define	STATUS_SPEED_10	  STATUS_SPEED(0)
    260   1.1   thorpej #define	STATUS_SPEED_100  STATUS_SPEED(1)
    261   1.1   thorpej #define	STATUS_SPEED_1000 STATUS_SPEED(2)
    262   1.1   thorpej #define	STATUS_ASDV(x)	((x) << 8)	/* auto speed det. val. (Livengood) */
    263  1.32   msaitoh #define	STATUS_LAN_INIT_DONE (1U << 9)	/* Lan Init Completion by NVM */
    264   1.1   thorpej #define	STATUS_MTXCKOK	(1U << 10)	/* MTXD clock running */
    265  1.33   msaitoh #define	STATUS_PHYRA	(1U << 10)	/* PHY Reset Asserted (PCH) */
    266   1.1   thorpej #define	STATUS_PCI66	(1U << 11)	/* 66MHz bus (Livengood) */
    267   1.1   thorpej #define	STATUS_BUS64	(1U << 12)	/* 64-bit bus (Livengood) */
    268   1.1   thorpej #define	STATUS_PCIX_MODE (1U << 13)	/* PCIX mode (Cordova) */
    269   1.1   thorpej #define	STATUS_PCIXSPD(x) ((x) << 14)	/* PCIX speed indication (Cordova) */
    270   1.1   thorpej #define	STATUS_PCIXSPD_50_66   STATUS_PCIXSPD(0)
    271   1.1   thorpej #define	STATUS_PCIXSPD_66_100  STATUS_PCIXSPD(1)
    272   1.1   thorpej #define	STATUS_PCIXSPD_100_133 STATUS_PCIXSPD(2)
    273   1.8   thorpej #define	STATUS_PCIXSPD_MASK    STATUS_PCIXSPD(3)
    274  1.41   msaitoh #define	STATUS_GIO_M_ENA (1U << 19)	/* GIO master enable */
    275  1.42   msaitoh #define	STATUS_DEV_RST_SET (1U << 20)	/* Device Reset Set */
    276   1.1   thorpej 
    277  1.89   msaitoh /* Strapping Option Register (PCH_SPT and newer) */
    278  1.89   msaitoh #define WMREG_STRAP	0x000c
    279  1.89   msaitoh #define STRAP_NVMSIZE	__BITS(1, 6)
    280  1.89   msaitoh #define STRAP_FREQ	__BITS(12, 13)
    281  1.89   msaitoh #define STRAP_SMBUSADDR	__BITS(17, 23)
    282  1.89   msaitoh 
    283   1.1   thorpej #define	WMREG_EECD	0x0010	/* EEPROM Control Register */
    284   1.1   thorpej #define	EECD_SK		(1U << 0)	/* clock */
    285   1.1   thorpej #define	EECD_CS		(1U << 1)	/* chip select */
    286   1.1   thorpej #define	EECD_DI		(1U << 2)	/* data in */
    287   1.1   thorpej #define	EECD_DO		(1U << 3)	/* data out */
    288   1.1   thorpej #define	EECD_FWE(x)	((x) << 4)	/* flash write enable control */
    289   1.1   thorpej #define	EECD_FWE_DISABLED EECD_FWE(1)
    290   1.1   thorpej #define	EECD_FWE_ENABLED  EECD_FWE(2)
    291   1.3   thorpej #define	EECD_EE_REQ	(1U << 6)	/* (shared) EEPROM request */
    292   1.3   thorpej #define	EECD_EE_GNT	(1U << 7)	/* (shared) EEPROM grant */
    293   1.3   thorpej #define	EECD_EE_PRES	(1U << 8)	/* EEPROM present */
    294   1.3   thorpej #define	EECD_EE_SIZE	(1U << 9)	/* EEPROM size
    295   1.3   thorpej 					   (0 = 64 word, 1 = 256 word) */
    296  1.20    bouyer #define	EECD_EE_AUTORD	(1U << 9)	/* auto read done */
    297   1.6   thorpej #define	EECD_EE_ABITS	(1U << 10)	/* EEPROM address bits
    298   1.6   thorpej 					   (based on type) */
    299  1.62   msaitoh #define	EECD_EE_SIZE_EX_MASK __BITS(14,11) /* EEPROM size for new devices */
    300   1.6   thorpej #define	EECD_EE_TYPE	(1U << 13)	/* EEPROM type
    301   1.6   thorpej 					   (0 = Microwire, 1 = SPI) */
    302  1.22    bouyer #define EECD_SEC1VAL	(1U << 22)	/* Sector One Valid */
    303  1.50   msaitoh #define EECD_SEC1VAL_VALMASK (EECD_EE_AUTORD | EECD_EE_PRES) /* Valid Mask */
    304   1.1   thorpej 
    305  1.17   msaitoh #define	WMREG_EERD	0x0014	/* EEPROM read */
    306  1.17   msaitoh #define	EERD_DONE	0x02    /* done bit */
    307  1.17   msaitoh #define	EERD_START	0x01	/* First bit for telling part to start operation */
    308  1.17   msaitoh #define	EERD_ADDR_SHIFT	2	/* Shift to the address bits */
    309  1.17   msaitoh #define	EERD_DATA_SHIFT	16	/* Offset to data in EEPROM read/write registers */
    310  1.17   msaitoh 
    311   1.1   thorpej #define	WMREG_CTRL_EXT	0x0018	/* Extended Device Control Register */
    312  1.78   msaitoh #define	CTRL_EXT_NSICR		__BIT(0) /* Non Interrupt clear on read */
    313   1.1   thorpej #define	CTRL_EXT_GPI_EN(x)	(1U << (x)) /* gpin interrupt enable */
    314  1.89   msaitoh #define CTRL_EXT_NVMVS		__BITS(0, 1) /* NVM valid sector */
    315   1.1   thorpej #define	CTRL_EXT_SWDPINS_SHIFT	4
    316   1.1   thorpej #define	CTRL_EXT_SWDPINS_MASK	0x0d
    317  1.42   msaitoh /* The bit order of the SW Definable pin is not 6543 but 3654! */
    318  1.42   msaitoh #define	CTRL_EXT_SWDPIN(x)	(1U << (CTRL_EXT_SWDPINS_SHIFT \
    319  1.42   msaitoh 		+ ((x) == 3 ? 3 : ((x) - 4))))
    320   1.1   thorpej #define	CTRL_EXT_SWDPIO_SHIFT	8
    321   1.1   thorpej #define	CTRL_EXT_SWDPIO_MASK	0x0d
    322  1.42   msaitoh #define	CTRL_EXT_SWDPIO(x)	(1U << (CTRL_EXT_SWDPIO_SHIFT \
    323  1.42   msaitoh 		+ ((x) == 3 ? 3 : ((x) - 4))))
    324  1.89   msaitoh #define	CTRL_EXT_FORCE_SMBUS	__BIT(11)  /* Force SMBus mode */
    325   1.1   thorpej #define	CTRL_EXT_ASDCHK		(1U << 12) /* ASD check */
    326   1.1   thorpej #define	CTRL_EXT_EE_RST		(1U << 13) /* EEPROM reset */
    327   1.1   thorpej #define	CTRL_EXT_IPS		(1U << 14) /* invert power state bit 0 */
    328   1.1   thorpej #define	CTRL_EXT_SPD_BYPS	(1U << 15) /* speed select bypass */
    329   1.1   thorpej #define	CTRL_EXT_IPS1		(1U << 16) /* invert power state bit 1 */
    330   1.1   thorpej #define	CTRL_EXT_RO_DIS		(1U << 17) /* relaxed ordering disabled */
    331  1.77   msaitoh #define	CTRL_EXT_SDLPE		(1U << 18) /* SerDes Low Power Enable */
    332  1.70   msaitoh #define	CTRL_EXT_DMA_DYN_CLK	(1U << 19) /* DMA Dynamic Gating Enable */
    333  1.87   msaitoh #define	CTRL_EXT_PHYPDEN	__BIT(20)
    334  1.38   msaitoh #define	CTRL_EXT_LINK_MODE_MASK		0x00C00000
    335  1.38   msaitoh #define	CTRL_EXT_LINK_MODE_GMII		0x00000000
    336  1.38   msaitoh #define	CTRL_EXT_LINK_MODE_KMRN		0x00000000
    337  1.38   msaitoh #define	CTRL_EXT_LINK_MODE_1000KX	0x00400000
    338  1.38   msaitoh #define	CTRL_EXT_LINK_MODE_SGMII	0x00800000
    339  1.38   msaitoh #define	CTRL_EXT_LINK_MODE_PCIX_SERDES	0x00800000
    340  1.38   msaitoh #define	CTRL_EXT_LINK_MODE_TBI		0x00C00000
    341  1.38   msaitoh #define	CTRL_EXT_LINK_MODE_PCIE_SERDES	0x00C00000
    342  1.78   msaitoh #define	CTRL_EXT_EIAME		__BIT(24) /* Extended Interrupt Auto Mask En */
    343  1.38   msaitoh #define CTRL_EXT_I2C_ENA	0x02000000  /* I2C enable */
    344  1.26   msaitoh #define	CTRL_EXT_DRV_LOAD	0x10000000
    345  1.78   msaitoh #define	CTRL_EXT_PBA		__BIT(31) /* PBA Support */
    346  1.20    bouyer 
    347   1.1   thorpej #define	WMREG_MDIC	0x0020	/* MDI Control Register */
    348   1.1   thorpej #define	MDIC_DATA(x)	((x) & 0xffff)
    349   1.1   thorpej #define	MDIC_REGADD(x)	((x) << 16)
    350  1.55   msaitoh #define	MDIC_PHY_SHIFT	21
    351  1.55   msaitoh #define	MDIC_PHY_MASK	__BITS(25, 21)
    352   1.1   thorpej #define	MDIC_PHYADD(x)	((x) << 21)
    353   1.1   thorpej #define	MDIC_OP_WRITE	(1U << 26)
    354   1.1   thorpej #define	MDIC_OP_READ	(2U << 26)
    355   1.1   thorpej #define	MDIC_READY	(1U << 28)
    356   1.1   thorpej #define	MDIC_I		(1U << 29)	/* interrupt on MDI complete */
    357   1.1   thorpej #define	MDIC_E		(1U << 30)	/* MDI error */
    358  1.55   msaitoh #define	MDIC_DEST	(1U << 31)	/* Destination */
    359   1.1   thorpej 
    360  1.38   msaitoh #define WMREG_SCTL	0x0024	/* SerDes Control - RW */
    361  1.38   msaitoh /*
    362  1.38   msaitoh  * These 4 macros are also used for other 8bit control registers on the
    363  1.38   msaitoh  * 82575
    364  1.38   msaitoh  */
    365  1.38   msaitoh #define SCTL_CTL_READY  (1U << 31)
    366  1.38   msaitoh #define SCTL_CTL_DATA_MASK 0x000000ff
    367  1.38   msaitoh #define SCTL_CTL_ADDR_SHIFT 8
    368  1.38   msaitoh #define SCTL_CTL_POLL_TIMEOUT 640
    369  1.60   msaitoh #define SCTL_DISABLE_SERDES_LOOPBACK 0x0400
    370  1.38   msaitoh 
    371   1.1   thorpej #define	WMREG_FCAL	0x0028	/* Flow Control Address Low */
    372   1.1   thorpej #define	FCAL_CONST	0x00c28001	/* Flow Control MAC addr low */
    373   1.1   thorpej 
    374   1.1   thorpej #define	WMREG_FCAH	0x002c	/* Flow Control Address High */
    375   1.1   thorpej #define	FCAH_CONST	0x00000100	/* Flow Control MAC addr high */
    376   1.1   thorpej 
    377   1.1   thorpej #define	WMREG_FCT	0x0030	/* Flow Control Type */
    378   1.1   thorpej 
    379  1.58   msaitoh #define	WMREG_KUMCTRLSTA 0x0034	/* MAC-PHY interface - RW */
    380  1.58   msaitoh #define	KUMCTRLSTA_MASK			0x0000FFFF
    381  1.58   msaitoh #define	KUMCTRLSTA_OFFSET		0x001F0000
    382  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_SHIFT		16
    383  1.58   msaitoh #define	KUMCTRLSTA_REN			0x00200000
    384  1.58   msaitoh 
    385  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_FIFO_CTRL	0x00000000
    386  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_CTRL		0x00000001
    387  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_INB_CTRL	0x00000002
    388  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_DIAG		0x00000003
    389  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_TIMEOUTS	0x00000004
    390  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_K1_CONFIG	0x00000007
    391  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_INB_PARAM	0x00000009
    392  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_HD_CTRL	0x00000010
    393  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_M2P_SERDES	0x0000001E
    394  1.58   msaitoh #define	KUMCTRLSTA_OFFSET_M2P_MODES	0x0000001F
    395  1.58   msaitoh 
    396  1.58   msaitoh /* FIFO Control */
    397  1.58   msaitoh #define	KUMCTRLSTA_FIFO_CTRL_RX_BYPASS	0x00000008
    398  1.58   msaitoh #define	KUMCTRLSTA_FIFO_CTRL_TX_BYPASS	0x00000800
    399  1.58   msaitoh 
    400  1.58   msaitoh /* In-Band Control */
    401  1.58   msaitoh #define	KUMCTRLSTA_INB_CTRL_LINK_TMOUT_DFLT 0x00000500
    402  1.58   msaitoh #define	KUMCTRLSTA_INB_CTRL_DIS_PADDING	0x00000010
    403  1.58   msaitoh 
    404  1.58   msaitoh /* Diag */
    405  1.58   msaitoh #define	KUMCTRLSTA_DIAG_NELPBK	0x1000
    406  1.58   msaitoh 
    407  1.58   msaitoh /* K1 Config */
    408  1.58   msaitoh #define	KUMCTRLSTA_K1_ENABLE	0x0002
    409  1.58   msaitoh 
    410  1.58   msaitoh /* Half-Duplex Control */
    411  1.58   msaitoh #define	KUMCTRLSTA_HD_CTRL_10_100_DEFAULT 0x00000004
    412  1.58   msaitoh #define	KUMCTRLSTA_HD_CTRL_1000_DEFAULT	0x00000000
    413  1.58   msaitoh 
    414   1.1   thorpej #define	WMREG_VET	0x0038	/* VLAN Ethertype */
    415  1.58   msaitoh #define	WMREG_MDPHYA	0x003C	/* PHY address - RW */
    416   1.1   thorpej #define	WMREG_RAL_BASE	0x0040	/* Receive Address List */
    417   1.1   thorpej #define	WMREG_CORDOVA_RAL_BASE 0x5400
    418   1.1   thorpej #define	WMREG_RAL_LO(b, x) ((b) + ((x) << 3))
    419   1.1   thorpej #define	WMREG_RAL_HI(b, x) (WMREG_RAL_LO(b, x) + 4)
    420   1.1   thorpej 	/*
    421   1.1   thorpej 	 * Receive Address List: The LO part is the low-order 32-bits
    422   1.1   thorpej 	 * of the MAC address.  The HI part is the high-order 16-bits
    423   1.1   thorpej 	 * along with a few control bits.
    424   1.1   thorpej 	 */
    425   1.1   thorpej #define	RAL_AS(x)	((x) << 16)	/* address select */
    426   1.1   thorpej #define	RAL_AS_DEST	RAL_AS(0)	/* (cordova?) */
    427   1.1   thorpej #define	RAL_AS_SOURCE	RAL_AS(1)	/* (cordova?) */
    428   1.1   thorpej #define	RAL_RDR1	(1U << 30)	/* put packet in alt. rx ring */
    429   1.1   thorpej #define	RAL_AV		(1U << 31)	/* entry is valid */
    430   1.1   thorpej 
    431  1.49   msaitoh #define	WM_RAL_TABSIZE		15	/* RAL size for old devices */
    432  1.49   msaitoh #define	WM_RAL_TABSIZE_ICH8	7	/* RAL size for ICH* and PCH* */
    433  1.88   msaitoh #define	WM_RAL_TABSIZE_PCH2	5	/* RAL size for PCH2 */
    434  1.88   msaitoh #define	WM_RAL_TABSIZE_PCH_LPT	12	/* RAL size for PCH_LPT */
    435  1.49   msaitoh #define	WM_RAL_TABSIZE_82575	16	/* RAL size for 82575 */
    436  1.49   msaitoh #define	WM_RAL_TABSIZE_82576	24	/* RAL size for 82576 and 82580 */
    437  1.49   msaitoh #define	WM_RAL_TABSIZE_I350	32	/* RAL size for I350 */
    438   1.1   thorpej 
    439   1.1   thorpej #define	WMREG_ICR	0x00c0	/* Interrupt Cause Register */
    440   1.1   thorpej #define	ICR_TXDW	(1U << 0)	/* Tx desc written back */
    441   1.1   thorpej #define	ICR_TXQE	(1U << 1)	/* Tx queue empty */
    442   1.1   thorpej #define	ICR_LSC		(1U << 2)	/* link status change */
    443   1.1   thorpej #define	ICR_RXSEQ	(1U << 3)	/* receive sequence error */
    444   1.1   thorpej #define	ICR_RXDMT0	(1U << 4)	/* Rx ring 0 nearly empty */
    445   1.1   thorpej #define	ICR_RXO		(1U << 6)	/* Rx overrun */
    446   1.1   thorpej #define	ICR_RXT0	(1U << 7)	/* Rx ring 0 timer */
    447   1.1   thorpej #define	ICR_MDAC	(1U << 9)	/* MDIO access complete */
    448   1.1   thorpej #define	ICR_RXCFG	(1U << 10)	/* Receiving /C/ */
    449   1.1   thorpej #define	ICR_GPI(x)	(1U << (x))	/* general purpose interrupts */
    450  1.83  knakahar #define	ICR_RXQ(x)	__BIT(20+(x))	/* 82574: Rx queue x interrupt x=0,1 */
    451  1.83  knakahar #define	ICR_TXQ(x)	__BIT(22+(x))	/* 82574: Tx queue x interrupt x=0,1 */
    452  1.78   msaitoh #define	ICR_OTHER	__BIT(24)	/* 82574: Other interrupt */
    453  1.20    bouyer #define	ICR_INT		(1U << 31)	/* device generated an interrupt */
    454   1.1   thorpej 
    455  1.14    briggs #define WMREG_ITR	0x00c4	/* Interrupt Throttling Register */
    456  1.14    briggs #define ITR_IVAL_MASK	0xffff		/* Interval mask */
    457  1.14    briggs #define ITR_IVAL_SHIFT	0		/* Interval shift */
    458  1.14    briggs 
    459   1.1   thorpej #define	WMREG_ICS	0x00c8	/* Interrupt Cause Set Register */
    460   1.1   thorpej 	/* See ICR bits. */
    461   1.1   thorpej 
    462  1.91   msaitoh #define	WMREG_IMS	0x00d0	/* Interrupt Mask Set Register */
    463  1.91   msaitoh 	/* See ICR bits. */
    464  1.91   msaitoh 
    465  1.91   msaitoh #define	WMREG_IMC	0x00d8	/* Interrupt Mask Clear Register */
    466  1.91   msaitoh 	/* See ICR bits. */
    467  1.91   msaitoh 
    468  1.91   msaitoh #define	WMREG_EIAC_82574 0x00dc	/* Interrupt Auto Clear Register */
    469  1.91   msaitoh #define	WMREG_EIAC_82574_MSIX_MASK	(ICR_RXQ(0) | ICR_RXQ(1)	\
    470  1.91   msaitoh 	    | ICR_TXQ(0) | ICR_TXQ(1) | ICR_OTHER)
    471  1.91   msaitoh 
    472  1.78   msaitoh #define WMREG_IVAR	0x00e4  /* Interrupt Vector Allocation Register */
    473  1.78   msaitoh #define WMREG_IVAR0	0x01700 /* Interrupt Vector Allocation */
    474  1.78   msaitoh #define IVAR_ALLOC_MASK  __BITS(0, 6)	/* Bit 5 and 6 are reserved */
    475  1.78   msaitoh #define IVAR_VALID       __BIT(7)
    476  1.78   msaitoh /* IVAR definitions for 82580 and newer */
    477  1.81  knakahar #define WMREG_IVAR_Q(x)	(WMREG_IVAR0 + ((x) / 2) * 4)
    478  1.78   msaitoh #define IVAR_TX_MASK_Q(x) (0x000000ff << (((x) % 2) == 0 ? 8 : 24))
    479  1.78   msaitoh #define IVAR_RX_MASK_Q(x) (0x000000ff << (((x) % 2) == 0 ? 0 : 16))
    480  1.78   msaitoh /* IVAR definitions for 82576 */
    481  1.78   msaitoh #define WMREG_IVAR_Q_82576(x)	(WMREG_IVAR0 + ((x) & 0x7) * 4)
    482  1.78   msaitoh #define IVAR_TX_MASK_Q_82576(x) (0x000000ff << (((x) / 8) == 0 ? 8 : 24))
    483  1.78   msaitoh #define IVAR_RX_MASK_Q_82576(x) (0x000000ff << (((x) / 8) == 0 ? 0 : 16))
    484  1.78   msaitoh /* IVAR definitions for 82574 */
    485  1.78   msaitoh #define IVAR_ALLOC_MASK_82574	__BITS(0, 2)
    486  1.78   msaitoh #define IVAR_VALID_82574	__BIT(3)
    487  1.78   msaitoh #define IVAR_TX_MASK_Q_82574(x) (0x0000000f << ((x) == 0 ? 8 : 12))
    488  1.78   msaitoh #define IVAR_RX_MASK_Q_82574(x) (0x0000000f << ((x) == 0 ? 0 : 4))
    489  1.78   msaitoh #define IVAR_OTHER_MASK		__BITS(16, 19)
    490  1.78   msaitoh #define IVAR_INT_ON_ALL_WB	__BIT(31)
    491  1.78   msaitoh 
    492  1.78   msaitoh #define WMREG_IVAR_MISC	0x01740 /* IVAR for other causes */
    493  1.78   msaitoh #define IVAR_MISC_TCPTIMER __BITS(0, 7)
    494  1.78   msaitoh #define IVAR_MISC_OTHER	__BITS(8, 15)
    495  1.78   msaitoh 
    496   1.1   thorpej #define	WMREG_RCTL	0x0100	/* Receive Control */
    497   1.1   thorpej #define	RCTL_EN		(1U << 1)	/* receiver enable */
    498   1.1   thorpej #define	RCTL_SBP	(1U << 2)	/* store bad packets */
    499   1.1   thorpej #define	RCTL_UPE	(1U << 3)	/* unicast promisc. enable */
    500   1.1   thorpej #define	RCTL_MPE	(1U << 4)	/* multicast promisc. enable */
    501   1.1   thorpej #define	RCTL_LPE	(1U << 5)	/* large packet enable */
    502   1.1   thorpej #define	RCTL_LBM(x)	((x) << 6)	/* loopback mode */
    503   1.1   thorpej #define	RCTL_LBM_NONE	RCTL_LBM(0)
    504   1.1   thorpej #define	RCTL_LBM_PHY	RCTL_LBM(3)
    505   1.1   thorpej #define	RCTL_RDMTS(x)	((x) << 8)	/* receive desc. min thresh size */
    506   1.1   thorpej #define	RCTL_RDMTS_1_2	RCTL_RDMTS(0)
    507   1.1   thorpej #define	RCTL_RDMTS_1_4	RCTL_RDMTS(1)
    508   1.1   thorpej #define	RCTL_RDMTS_1_8	RCTL_RDMTS(2)
    509   1.1   thorpej #define	RCTL_RDMTS_MASK	RCTL_RDMTS(3)
    510   1.1   thorpej #define	RCTL_MO(x)	((x) << 12)	/* multicast offset */
    511   1.1   thorpej #define	RCTL_BAM	(1U << 15)	/* broadcast accept mode */
    512  1.89   msaitoh #define	RCTL_RDMTS_HEX	__BIT(16)
    513   1.1   thorpej #define	RCTL_2k		(0 << 16)	/* 2k Rx buffers */
    514   1.1   thorpej #define	RCTL_1k		(1 << 16)	/* 1k Rx buffers */
    515   1.1   thorpej #define	RCTL_512	(2 << 16)	/* 512 byte Rx buffers */
    516   1.1   thorpej #define	RCTL_256	(3 << 16)	/* 256 byte Rx buffers */
    517   1.1   thorpej #define	RCTL_BSEX_16k	(1 << 16)	/* 16k Rx buffers (BSEX) */
    518   1.1   thorpej #define	RCTL_BSEX_8k	(2 << 16)	/* 8k Rx buffers (BSEX) */
    519   1.1   thorpej #define	RCTL_BSEX_4k	(3 << 16)	/* 4k Rx buffers (BSEX) */
    520   1.1   thorpej #define	RCTL_DPF	(1U << 22)	/* discard pause frames */
    521   1.1   thorpej #define	RCTL_PMCF	(1U << 23)	/* pass MAC control frames */
    522   1.1   thorpej #define	RCTL_BSEX	(1U << 25)	/* buffer size extension (Livengood) */
    523   1.1   thorpej #define	RCTL_SECRC	(1U << 26)	/* strip Ethernet CRC */
    524   1.1   thorpej 
    525   1.1   thorpej #define	WMREG_OLD_RDTR0	0x0108	/* Receive Delay Timer (ring 0) */
    526   1.1   thorpej #define	WMREG_RDTR	0x2820
    527   1.1   thorpej #define	RDTR_FPD	(1U << 31)	/* flush partial descriptor */
    528   1.1   thorpej 
    529  1.58   msaitoh #define WMREG_LTRC	0x01a0	/* Latency Tolerance Reportiong Control */
    530  1.14    briggs 
    531   1.1   thorpej #define	WMREG_OLD_RDBAL0 0x0110	/* Receive Descriptor Base Low (ring 0) */
    532  1.83  knakahar #define	WMREG_RDBAL(x) \
    533  1.83  knakahar 	((x) < 4 ? (0x02800 + ((x) * 0x100)) :	\
    534  1.83  knakahar 	    (0x0C000 + ((x) * 0x40)))
    535   1.1   thorpej 
    536   1.1   thorpej #define	WMREG_OLD_RDBAH0 0x0114	/* Receive Descriptor Base High (ring 0) */
    537  1.83  knakahar #define	WMREG_RDBAH(x) \
    538  1.83  knakahar 	((x) < 4 ? (0x02804 + ((x) * 0x100)) :	\
    539  1.83  knakahar 	    (0x0c004 + ((x) * 0x40)))
    540   1.1   thorpej 
    541   1.1   thorpej #define	WMREG_OLD_RDLEN0 0x0118	/* Receive Descriptor Length (ring 0) */
    542  1.83  knakahar #define	WMREG_RDLEN(x) \
    543  1.83  knakahar 	((x) < 4 ? (0x02808 + ((x) * 0x100)) :  \
    544  1.83  knakahar 	    (0x0c008 + ((x) * 0x40)))
    545  1.83  knakahar 
    546  1.83  knakahar #define	WMREG_SRRCTL(x) \
    547  1.83  knakahar 	((x) < 4 ? (0x0280c + ((x) * 0x100)) :	\
    548  1.83  knakahar 	    (0x0c00c + ((x) * 0x40)))	/* additional recv control used in 82575 ... */
    549  1.58   msaitoh #define SRRCTL_BSIZEPKT_MASK		0x0000007f
    550  1.38   msaitoh #define SRRCTL_BSIZEPKT_SHIFT		10	/* Shift _right_ */
    551  1.58   msaitoh #define SRRCTL_BSIZEHDRSIZE_MASK	0x00000f00
    552  1.38   msaitoh #define SRRCTL_BSIZEHDRSIZE_SHIFT	2	/* Shift _left_ */
    553  1.58   msaitoh #define SRRCTL_DESCTYPE_LEGACY		0x00000000
    554  1.58   msaitoh #define SRRCTL_DESCTYPE_ADV_ONEBUF	(1U << 25)
    555  1.58   msaitoh #define SRRCTL_DESCTYPE_HDR_SPLIT	(2U << 25)
    556  1.58   msaitoh #define SRRCTL_DESCTYPE_HDR_REPLICATION	(3U << 25)
    557  1.58   msaitoh #define SRRCTL_DESCTYPE_HDR_REPLICATION_LARGE_PKT (4U << 25)
    558  1.58   msaitoh #define SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS (5U << 25) /* 82575 only */
    559  1.58   msaitoh #define SRRCTL_DESCTYPE_MASK		(7U << 25)
    560  1.58   msaitoh #define SRRCTL_DROP_EN			0x80000000
    561   1.1   thorpej 
    562   1.1   thorpej #define	WMREG_OLD_RDH0	0x0120	/* Receive Descriptor Head (ring 0) */
    563  1.83  knakahar #define	WMREG_RDH(x) \
    564  1.83  knakahar 	((x) < 4 ? (0x02810 + ((x) * 0x100)) :  \
    565  1.83  knakahar 	    (0x0C010 + ((x) * 0x40)))
    566   1.1   thorpej 
    567   1.1   thorpej #define	WMREG_OLD_RDT0	0x0128	/* Receive Descriptor Tail (ring 0) */
    568  1.83  knakahar #define	WMREG_RDT(x) \
    569  1.83  knakahar 	((x) < 4 ? (0x02818 + ((x) * 0x100)) :	\
    570  1.83  knakahar 	    (0x0C018 + ((x) * 0x40)))
    571  1.83  knakahar 
    572  1.83  knakahar #define	WMREG_RXDCTL(x) \
    573  1.83  knakahar 	((x) < 4 ? (0x02828 + ((x) * 0x100)) :	\
    574  1.83  knakahar 	    (0x0c028 + ((x) * 0x40)))	/* Receive Descriptor Control */
    575   1.1   thorpej #define	RXDCTL_PTHRESH(x) ((x) << 0)	/* prefetch threshold */
    576   1.1   thorpej #define	RXDCTL_HTHRESH(x) ((x) << 8)	/* host threshold */
    577   1.1   thorpej #define	RXDCTL_WTHRESH(x) ((x) << 16)	/* write back threshold */
    578   1.1   thorpej #define	RXDCTL_GRAN	(1U << 24)	/* 0 = cacheline, 1 = descriptor */
    579  1.38   msaitoh /* flags used starting with 82575 ... */
    580  1.38   msaitoh #define RXDCTL_QUEUE_ENABLE  0x02000000 /* Enable specific Tx Queue */
    581  1.38   msaitoh #define RXDCTL_SWFLSH        0x04000000 /* Rx Desc. write-back flushing */
    582   1.1   thorpej 
    583   1.1   thorpej #define	WMREG_OLD_RDTR1	0x0130	/* Receive Delay Timer (ring 1) */
    584   1.1   thorpej #define	WMREG_OLD_RDBA1_LO 0x0138 /* Receive Descriptor Base Low (ring 1) */
    585   1.1   thorpej #define	WMREG_OLD_RDBA1_HI 0x013c /* Receive Descriptor Base High (ring 1) */
    586   1.1   thorpej #define	WMREG_OLD_RDLEN1 0x0140	/* Receive Drscriptor Length (ring 1) */
    587   1.1   thorpej #define	WMREG_OLD_RDH1	0x0148
    588   1.1   thorpej #define	WMREG_OLD_RDT1	0x0150
    589   1.1   thorpej #define	WMREG_OLD_FCRTH 0x0160	/* Flow Control Rx Threshold Hi (OLD) */
    590   1.1   thorpej #define	WMREG_FCRTL	0x2160	/* Flow Control Rx Threshold Lo */
    591   1.1   thorpej #define	FCRTH_DFLT	0x00008000
    592   1.1   thorpej 
    593   1.1   thorpej #define	WMREG_OLD_FCRTL 0x0168	/* Flow Control Rx Threshold Lo (OLD) */
    594   1.1   thorpej #define	WMREG_FCRTH	0x2168	/* Flow Control Rx Threhsold Hi */
    595   1.1   thorpej #define	FCRTL_DFLT	0x00004000
    596  1.11   thorpej #define	FCRTL_XONE	0x80000000	/* Enable XON frame transmission */
    597   1.1   thorpej 
    598   1.1   thorpej #define	WMREG_FCTTV	0x0170	/* Flow Control Transmit Timer Value */
    599  1.11   thorpej #define	FCTTV_DFLT	0x00000600
    600   1.1   thorpej 
    601   1.1   thorpej #define	WMREG_TXCW	0x0178	/* Transmit Configuration Word (TBI mode) */
    602   1.1   thorpej 	/* See MII ANAR_X bits. */
    603  1.60   msaitoh #define	TXCW_FD		(1U << 5)	/* Full Duplex */
    604  1.60   msaitoh #define	TXCW_HD		(1U << 6)	/* Half Duplex */
    605  1.27   msaitoh #define	TXCW_SYM_PAUSE	(1U << 7)	/* sym pause request */
    606  1.27   msaitoh #define	TXCW_ASYM_PAUSE	(1U << 8)	/* asym pause request */
    607   1.1   thorpej #define	TXCW_TxConfig	(1U << 30)	/* Tx Config */
    608   1.1   thorpej #define	TXCW_ANE	(1U << 31)	/* Autonegotiate */
    609   1.1   thorpej 
    610   1.1   thorpej #define	WMREG_RXCW	0x0180	/* Receive Configuration Word (TBI mode) */
    611   1.1   thorpej 	/* See MII ANLPAR_X bits. */
    612   1.1   thorpej #define	RXCW_NC		(1U << 26)	/* no carrier */
    613   1.1   thorpej #define	RXCW_IV		(1U << 27)	/* config invalid */
    614   1.1   thorpej #define	RXCW_CC		(1U << 28)	/* config change */
    615   1.1   thorpej #define	RXCW_C		(1U << 29)	/* /C/ reception */
    616   1.1   thorpej #define	RXCW_SYNCH	(1U << 30)	/* synchronized */
    617   1.1   thorpej #define	RXCW_ANC	(1U << 31)	/* autonegotiation complete */
    618   1.1   thorpej 
    619   1.1   thorpej #define	WMREG_MTA	0x0200	/* Multicast Table Array */
    620   1.1   thorpej #define	WMREG_CORDOVA_MTA 0x5200
    621   1.1   thorpej 
    622   1.1   thorpej #define	WMREG_TCTL	0x0400	/* Transmit Control Register */
    623   1.1   thorpej #define	TCTL_EN		(1U << 1)	/* transmitter enable */
    624   1.1   thorpej #define	TCTL_PSP	(1U << 3)	/* pad short packets */
    625   1.1   thorpej #define	TCTL_CT(x)	(((x) & 0xff) << 4)   /* 4:11 - collision threshold */
    626   1.1   thorpej #define	TCTL_COLD(x)	(((x) & 0x3ff) << 12) /* 12:21 - collision distance */
    627   1.1   thorpej #define	TCTL_SWXOFF	(1U << 22)	/* software XOFF */
    628   1.1   thorpej #define	TCTL_RTLC	(1U << 24)	/* retransmit on late collision */
    629   1.1   thorpej #define	TCTL_NRTU	(1U << 25)	/* no retransmit on underrun */
    630  1.19   msaitoh #define	TCTL_MULR	(1U << 28)	/* multiple request */
    631   1.1   thorpej 
    632   1.1   thorpej #define	TX_COLLISION_THRESHOLD		15
    633  1.17   msaitoh #define	TX_COLLISION_DISTANCE_HDX	512
    634  1.17   msaitoh #define	TX_COLLISION_DISTANCE_FDX	64
    635   1.1   thorpej 
    636  1.20    bouyer #define	WMREG_TCTL_EXT	0x0404	/* Transmit Control Register */
    637  1.20    bouyer #define	TCTL_EXT_BST_MASK	0x000003FF /* Backoff Slot Time */
    638  1.20    bouyer #define	TCTL_EXT_GCEX_MASK	0x000FFC00 /* Gigabit Carry Extend Padding */
    639  1.20    bouyer 
    640  1.20    bouyer #define	DEFAULT_80003ES2LAN_TCTL_EXT_GCEX 0x00010000
    641  1.20    bouyer 
    642   1.1   thorpej #define	WMREG_TIPG	0x0410	/* Transmit IPG Register */
    643   1.1   thorpej #define	TIPG_IPGT(x)	(x)		/* IPG transmit time */
    644   1.1   thorpej #define	TIPG_IPGR1(x)	((x) << 10)	/* IPG receive time 1 */
    645   1.1   thorpej #define	TIPG_IPGR2(x)	((x) << 20)	/* IPG receive time 2 */
    646   1.1   thorpej #define	TIPG_WM_DFLT	(TIPG_IPGT(0x0a) | TIPG_IPGR1(0x02) | TIPG_IPGR2(0x0a))
    647   1.1   thorpej #define	TIPG_LG_DFLT	(TIPG_IPGT(0x06) | TIPG_IPGR1(0x08) | TIPG_IPGR2(0x06))
    648   1.1   thorpej #define	TIPG_1000T_DFLT	(TIPG_IPGT(0x08) | TIPG_IPGR1(0x08) | TIPG_IPGR2(0x06))
    649  1.20    bouyer #define	TIPG_1000T_80003_DFLT \
    650  1.20    bouyer     (TIPG_IPGT(0x08) | TIPG_IPGR1(0x02) | TIPG_IPGR2(0x07))
    651  1.20    bouyer #define	TIPG_10_100_80003_DFLT \
    652  1.20    bouyer     (TIPG_IPGT(0x09) | TIPG_IPGR1(0x02) | TIPG_IPGR2(0x07))
    653   1.1   thorpej 
    654   1.1   thorpej #define	WMREG_TQC	0x0418
    655   1.1   thorpej 
    656  1.44   msaitoh #define	WMREG_OLD_TDBAL	0x0420	/* Transmit Descriptor Base Lo */
    657  1.83  knakahar #define	WMREG_TDBAL(x) \
    658  1.83  knakahar 	((x) < 4 ? (0x03800 + ((x) * 0x100)) :	\
    659  1.83  knakahar 	    (0x0E000 + ((x) * 0x40)))
    660   1.1   thorpej 
    661  1.44   msaitoh #define	WMREG_OLD_TDBAH	0x0424	/* Transmit Descriptor Base Hi */
    662  1.83  knakahar #define	WMREG_TDBAH(x)\
    663  1.83  knakahar 	((x) < 4 ? (0x03804 + ((x) * 0x100)) :	\
    664  1.83  knakahar 	    (0x0E004 + ((x) * 0x40)))
    665   1.1   thorpej 
    666   1.1   thorpej #define	WMREG_OLD_TDLEN	0x0428	/* Transmit Descriptor Length */
    667  1.83  knakahar #define	WMREG_TDLEN(x) \
    668  1.83  knakahar 	((x) < 4 ? (0x03808 + ((x) * 0x100)) :	\
    669  1.83  knakahar 	    (0x0E008 + ((x) * 0x40)))
    670   1.1   thorpej 
    671   1.1   thorpej #define	WMREG_OLD_TDH	0x0430	/* Transmit Descriptor Head */
    672  1.83  knakahar #define	WMREG_TDH(x) \
    673  1.83  knakahar 	((x) < 4 ? (0x03810 + ((x) * 0x100)) :	\
    674  1.83  knakahar 	    (0x0E010 + ((x) * 0x40)))
    675   1.1   thorpej 
    676   1.1   thorpej #define	WMREG_OLD_TDT	0x0438	/* Transmit Descriptor Tail */
    677  1.83  knakahar #define WMREG_TDT(x) \
    678  1.83  knakahar 	((x) < 4 ? (0x03818 + ((x) * 0x100)) :	\
    679  1.83  knakahar 	    (0x0E018 + ((x) * 0x40)))
    680   1.1   thorpej 
    681   1.1   thorpej #define	WMREG_OLD_TIDV	0x0440	/* Transmit Delay Interrupt Value */
    682   1.1   thorpej #define	WMREG_TIDV	0x3820
    683   1.1   thorpej 
    684   1.1   thorpej #define	WMREG_AIT	0x0458	/* Adaptive IFS Throttle */
    685   1.1   thorpej #define	WMREG_VFTA	0x0600
    686   1.1   thorpej 
    687  1.55   msaitoh #define	WMREG_MDICNFG	0x0e04	/* MDC/MDIO Configuration Register */
    688  1.55   msaitoh #define MDICNFG_PHY_SHIFT	21
    689  1.55   msaitoh #define MDICNFG_PHY_MASK	__BITS(25, 21)
    690  1.55   msaitoh #define MDICNFG_COM_MDIO	__BIT(30)
    691  1.55   msaitoh #define MDICNFG_DEST		__BIT(31)
    692  1.55   msaitoh 
    693   1.1   thorpej #define	WM_MC_TABSIZE	128
    694  1.22    bouyer #define	WM_ICH8_MC_TABSIZE 32
    695   1.1   thorpej #define	WM_VLAN_TABSIZE	128
    696   1.1   thorpej 
    697  1.59   msaitoh #define	WMREG_PHPM	0x0e14	/* PHY Power Management */
    698  1.59   msaitoh #define	PHPM_GO_LINK_D		__BIT(5)	/* Go Link Disconnect */
    699  1.59   msaitoh 
    700  1.58   msaitoh #define WMREG_EEER	0x0e30	/* Energy Efficiency Ethernet "EEE" */
    701  1.58   msaitoh #define EEER_TX_LPI_EN		0x00010000 /* EEER Tx LPI Enable */
    702  1.58   msaitoh #define EEER_RX_LPI_EN		0x00020000 /* EEER Rx LPI Enable */
    703  1.58   msaitoh #define EEER_LPI_FC		0x00040000 /* EEER Ena on Flow Cntrl */
    704  1.58   msaitoh #define EEER_EEER_NEG		0x20000000 /* EEER capability nego */
    705  1.58   msaitoh #define EEER_EEER_RX_LPI_STATUS	0x40000000 /* EEER Rx in LPI state */
    706  1.58   msaitoh #define EEER_EEER_TX_LPI_STATUS	0x80000000 /* EEER Tx in LPI state */
    707  1.58   msaitoh #define WMREG_EEE_SU	0x0e34	/* EEE Setup */
    708  1.58   msaitoh #define WMREG_IPCNFG	0x0e38	/* Internal PHY Configuration */
    709  1.72   msaitoh #define IPCNFG_10BASE_TE	0x00000002 /* IPCNFG 10BASE-Te low power op. */
    710  1.58   msaitoh #define IPCNFG_EEE_100M_AN	0x00000004 /* IPCNFG EEE Ena 100M AN */
    711  1.58   msaitoh #define IPCNFG_EEE_1G_AN	0x00000008 /* IPCNFG EEE Ena 1G AN */
    712  1.58   msaitoh 
    713  1.58   msaitoh #define WMREG_EXTCNFCTR	0x0f00  /* Extended Configuration Control */
    714  1.58   msaitoh #define EXTCNFCTR_PCIE_WRITE_ENABLE	0x00000001
    715  1.58   msaitoh #define EXTCNFCTR_PHY_WRITE_ENABLE	0x00000002
    716  1.58   msaitoh #define EXTCNFCTR_D_UD_ENABLE		0x00000004
    717  1.58   msaitoh #define EXTCNFCTR_D_UD_LATENCY		0x00000008
    718  1.58   msaitoh #define EXTCNFCTR_D_UD_OWNER		0x00000010
    719  1.58   msaitoh #define EXTCNFCTR_MDIO_SW_OWNERSHIP	0x00000020
    720  1.58   msaitoh #define EXTCNFCTR_MDIO_HW_OWNERSHIP	0x00000040
    721  1.58   msaitoh #define EXTCNFCTR_GATE_PHY_CFG		0x00000080
    722  1.58   msaitoh #define EXTCNFCTR_EXT_CNF_POINTER	0x0FFF0000
    723  1.58   msaitoh 
    724  1.58   msaitoh #define	WMREG_PHY_CTRL	0x0f10	/* PHY control */
    725  1.58   msaitoh #define	PHY_CTRL_SPD_EN		(1 << 0)
    726  1.58   msaitoh #define	PHY_CTRL_D0A_LPLU	(1 << 1)
    727  1.58   msaitoh #define	PHY_CTRL_NOND0A_LPLU	(1 << 2)
    728  1.58   msaitoh #define	PHY_CTRL_NOND0A_GBE_DIS	(1 << 3)
    729  1.86   msaitoh #define	PHY_CTRL_GBE_DIS	(1 << 6)
    730  1.58   msaitoh 
    731  1.89   msaitoh #define	WMREG_IOSFPC	0x0f28	/* Tx corrupted data */
    732  1.89   msaitoh 
    733   1.1   thorpej #define	WMREG_PBA	0x1000	/* Packet Buffer Allocation */
    734  1.12   thorpej #define	PBA_BYTE_SHIFT	10		/* KB -> bytes */
    735  1.12   thorpej #define	PBA_ADDR_SHIFT	7		/* KB -> quadwords */
    736  1.22    bouyer #define	PBA_8K		0x0008
    737  1.23   msaitoh #define	PBA_10K		0x000a
    738  1.19   msaitoh #define	PBA_12K		0x000c
    739  1.68   msaitoh #define	PBA_14K		0x000e
    740  1.12   thorpej #define	PBA_16K		0x0010		/* 16K, default Tx allocation */
    741  1.29   msaitoh #define	PBA_20K		0x0014
    742  1.12   thorpej #define	PBA_22K		0x0016
    743  1.12   thorpej #define	PBA_24K		0x0018
    744  1.45   msaitoh #define	PBA_26K		0x001a
    745  1.12   thorpej #define	PBA_30K		0x001e
    746  1.19   msaitoh #define	PBA_32K		0x0020
    747  1.51   msaitoh #define	PBA_34K		0x0022
    748  1.38   msaitoh #define	PBA_35K		0x0023
    749  1.12   thorpej #define	PBA_40K		0x0028
    750  1.12   thorpej #define	PBA_48K		0x0030		/* 48K, default Rx allocation */
    751  1.38   msaitoh #define	PBA_64K		0x0040
    752   1.1   thorpej 
    753  1.31   msaitoh #define	WMREG_PBS	0x1008	/* Packet Buffer Size (ICH) */
    754  1.22    bouyer 
    755  1.53   msaitoh #define	WMREG_PBECCSTS	0x100c	/* Packet Buffer ECC Status (PCH_LPT) */
    756  1.53   msaitoh #define	PBECCSTS_CORR_ERR_CNT_MASK	0x000000ff
    757  1.53   msaitoh #define	PBECCSTS_UNCORR_ERR_CNT_MASK	0x0000ff00
    758  1.53   msaitoh #define	PBECCSTS_UNCORR_ECC_ENABLE	0x00010000
    759  1.53   msaitoh 
    760  1.32   msaitoh #define WMREG_EEMNGCTL	0x1010	/* MNG EEprom Control */
    761  1.32   msaitoh #define EEMNGCTL_CFGDONE_0 0x040000	/* MNG config cycle done */
    762  1.32   msaitoh #define EEMNGCTL_CFGDONE_1 0x080000	/*  2nd port */
    763  1.32   msaitoh 
    764  1.38   msaitoh #define WMREG_I2CCMD	0x1028	/* SFPI2C Command Register - RW */
    765  1.38   msaitoh #define I2CCMD_REG_ADDR_SHIFT	16
    766  1.38   msaitoh #define I2CCMD_REG_ADDR		0x00ff0000
    767  1.38   msaitoh #define I2CCMD_PHY_ADDR_SHIFT	24
    768  1.38   msaitoh #define I2CCMD_PHY_ADDR		0x07000000
    769  1.38   msaitoh #define I2CCMD_OPCODE_READ	0x08000000
    770  1.38   msaitoh #define I2CCMD_OPCODE_WRITE	0x00000000
    771  1.38   msaitoh #define I2CCMD_RESET		0x10000000
    772  1.38   msaitoh #define I2CCMD_READY		0x20000000
    773  1.38   msaitoh #define I2CCMD_INTERRUPT_ENA	0x40000000
    774  1.38   msaitoh #define I2CCMD_ERROR		0x80000000
    775  1.38   msaitoh #define MAX_SGMII_PHY_REG_ADDR	255
    776  1.38   msaitoh #define I2CCMD_PHY_TIMEOUT	200
    777  1.38   msaitoh 
    778  1.58   msaitoh #define	WMREG_EEWR	0x102c	/* EEPROM write */
    779  1.58   msaitoh 
    780  1.53   msaitoh #define WMREG_PBA_ECC	0x01100	/* PBA ECC */
    781  1.53   msaitoh #define PBA_ECC_COUNTER_MASK	0xfff00000 /* ECC counter mask */
    782  1.53   msaitoh #define PBA_ECC_COUNTER_SHIFT	20	   /* ECC counter shift value */
    783  1.53   msaitoh #define	PBA_ECC_CORR_EN		0x00000001 /* Enable ECC error correction */
    784  1.53   msaitoh #define	PBA_ECC_STAT_CLR	0x00000002 /* Clear ECC error counter */
    785  1.53   msaitoh #define	PBA_ECC_INT_EN		0x00000004 /* Enable ICR bit 5 on ECC error */
    786  1.53   msaitoh 
    787  1.78   msaitoh #define WMREG_GPIE	0x01514 /* General Purpose Interrupt Enable */
    788  1.78   msaitoh #define GPIE_NSICR	__BIT(0)	/* Non Selective Interrupt Clear */
    789  1.78   msaitoh #define GPIE_MULTI_MSIX	__BIT(4)	/* Multiple MSIX */
    790  1.78   msaitoh #define GPIE_EIAME	__BIT(30)	/* Extended Interrupt Auto Mask Ena. */
    791  1.78   msaitoh #define GPIE_PBA	__BIT(31)	/* PBA support */
    792  1.78   msaitoh 
    793  1.38   msaitoh #define WMREG_EICS	0x01520  /* Ext. Interrupt Cause Set - WO */
    794  1.38   msaitoh #define WMREG_EIMS	0x01524  /* Ext. Interrupt Mask Set/Read - RW */
    795  1.38   msaitoh #define WMREG_EIMC	0x01528  /* Ext. Interrupt Mask Clear - WO */
    796  1.38   msaitoh #define WMREG_EIAC	0x0152C  /* Ext. Interrupt Auto Clear - RW */
    797  1.38   msaitoh #define WMREG_EIAM	0x01530  /* Ext. Interrupt Ack Auto Clear Mask - RW */
    798  1.38   msaitoh 
    799  1.38   msaitoh #define WMREG_EICR	0x01580  /* Ext. Interrupt Cause Read - R/clr */
    800  1.38   msaitoh 
    801  1.78   msaitoh #define WMREG_MSIXBM(x)	(0x1600 + (x) * 4) /* MSI-X Allocation */
    802  1.78   msaitoh 
    803  1.83  knakahar #define EITR_RX_QUEUE(x)	__BIT(0+(x)) /* Rx Queue x Interrupt x=[0-3] */
    804  1.83  knakahar #define EITR_TX_QUEUE(x)	__BIT(8+(x)) /* Tx Queue x Interrupt x=[0-3] */
    805  1.38   msaitoh #define EITR_TCP_TIMER	0x40000000 /* TCP Timer */
    806  1.38   msaitoh #define EITR_OTHER	0x80000000 /* Interrupt Cause Active */
    807  1.38   msaitoh 
    808  1.38   msaitoh #define WMREG_EITR(x)	(0x01680 + (0x4 * (x)))
    809  1.38   msaitoh #define EITR_ITR_INT_MASK	0x0000ffff
    810  1.38   msaitoh 
    811  1.69   msaitoh #define	WMREG_RXPBS	0x2404	/* Rx Packet Buffer Size  */
    812  1.69   msaitoh #define RXPBS_SIZE_MASK_82576	0x0000007F
    813  1.69   msaitoh 
    814  1.58   msaitoh #define	WMREG_RDFH	0x2410	/* Receive Data FIFO Head */
    815  1.58   msaitoh #define	WMREG_RDFT	0x2418	/* Receive Data FIFO Tail */
    816  1.58   msaitoh #define	WMREG_RDFHS	0x2420	/* Receive Data FIFO Head Saved */
    817  1.58   msaitoh #define	WMREG_RDFTS	0x2428	/* Receive Data FIFO Tail Saved */
    818  1.58   msaitoh #define	WMREG_RADV	0x282c	/* Receive Interrupt Absolute Delay Timer */
    819  1.58   msaitoh 
    820   1.1   thorpej #define	WMREG_TXDMAC	0x3000	/* Transfer DMA Control */
    821   1.1   thorpej #define	TXDMAC_DPP	(1U << 0)	/* disable packet prefetch */
    822   1.1   thorpej 
    823  1.28   msaitoh #define WMREG_KABGTXD	0x3004	/* AFE and Gap Transmit Ref Data */
    824  1.28   msaitoh #define	KABGTXD_BGSQLBIAS 0x00050000
    825  1.28   msaitoh 
    826  1.58   msaitoh #define	WMREG_TDFH	0x3410	/* Transmit Data FIFO Head */
    827  1.58   msaitoh #define	WMREG_TDFT	0x3418	/* Transmit Data FIFO Tail */
    828  1.58   msaitoh #define	WMREG_TDFHS	0x3420	/* Transmit Data FIFO Head Saved */
    829  1.58   msaitoh #define	WMREG_TDFTS	0x3428	/* Transmit Data FIFO Tail Saved */
    830  1.58   msaitoh #define	WMREG_TDFPC	0x3430	/* Transmit Data FIFO Packet Count */
    831  1.58   msaitoh 
    832  1.66   msaitoh #define	WMREG_TXDCTL(n)		/* Trandmit Descriptor Control */ \
    833  1.66   msaitoh 	(((n) < 4) ? (0x3828 + ((n) * 0x100)) : (0xe028 + ((n) * 0x40)))
    834  1.58   msaitoh #define	TXDCTL_PTHRESH(x) ((x) << 0)	/* prefetch threshold */
    835  1.58   msaitoh #define	TXDCTL_HTHRESH(x) ((x) << 8)	/* host threshold */
    836  1.58   msaitoh #define	TXDCTL_WTHRESH(x) ((x) << 16)	/* write back threshold */
    837  1.58   msaitoh /* flags used starting with 82575 ... */
    838  1.66   msaitoh #define TXDCTL_COUNT_DESC	__BIT(22) /* Enable the counting of desc.
    839  1.66   msaitoh 					   still to be processed. */
    840  1.58   msaitoh #define TXDCTL_QUEUE_ENABLE  0x02000000 /* Enable specific Tx Queue */
    841  1.58   msaitoh #define TXDCTL_SWFLSH        0x04000000 /* Tx Desc. write-back flushing */
    842  1.58   msaitoh #define TXDCTL_PRIORITY      0x08000000
    843  1.58   msaitoh 
    844  1.58   msaitoh #define	WMREG_TADV	0x382c	/* Transmit Absolute Interrupt Delay Timer */
    845   1.1   thorpej #define	WMREG_TSPMT	0x3830	/* TCP Segmentation Pad and Minimum
    846   1.1   thorpej 				   Threshold (Cordova) */
    847   1.1   thorpej #define	TSPMT_TSMT(x)	(x)		/* TCP seg min transfer */
    848   1.1   thorpej #define	TSPMT_TSPBP(x)	((x) << 16)	/* TCP seg pkt buf padding */
    849   1.1   thorpej 
    850  1.66   msaitoh #define	WMREG_TARC0	0x3840	/* Tx arbitration count (0) */
    851  1.66   msaitoh #define	WMREG_TARC1	0x3940	/* Tx arbitration count (1) */
    852  1.66   msaitoh 
    853  1.36   msaitoh #define	WMREG_CRCERRS	0x4000	/* CRC Error Count */
    854  1.36   msaitoh #define	WMREG_ALGNERRC	0x4004	/* Alignment Error Count */
    855  1.36   msaitoh #define	WMREG_SYMERRC	0x4008	/* Symbol Error Count */
    856  1.36   msaitoh #define	WMREG_RXERRC	0x400c	/* receive error Count - R/clr */
    857  1.36   msaitoh #define	WMREG_MPC	0x4010	/* Missed Packets Count - R/clr */
    858  1.20    bouyer #define	WMREG_COLC	0x4028	/* collision Count - R/clr */
    859  1.36   msaitoh #define	WMREG_SEC	0x4038	/* Sequence Error Count */
    860  1.36   msaitoh #define	WMREG_CEXTERR	0x403c	/* Carrier Extension Error Count */
    861  1.36   msaitoh #define	WMREG_RLEC	0x4040	/* Receive Length Error Count */
    862  1.11   thorpej #define	WMREG_XONRXC	0x4048	/* XON Rx Count - R/clr */
    863  1.11   thorpej #define	WMREG_XONTXC	0x404c	/* XON Tx Count - R/clr */
    864  1.11   thorpej #define	WMREG_XOFFRXC	0x4050	/* XOFF Rx Count - R/clr */
    865  1.11   thorpej #define	WMREG_XOFFTXC	0x4054	/* XOFF Tx Count - R/clr */
    866  1.11   thorpej #define	WMREG_FCRUC	0x4058	/* Flow Control Rx Unsupported Count - R/clr */
    867  1.36   msaitoh #define WMREG_RNBC	0x40a0	/* Receive No Buffers Count */
    868  1.58   msaitoh #define WMREG_TLPIC	0x4148	/* EEE Tx LPI Count */
    869  1.58   msaitoh #define WMREG_RLPIC	0x414c	/* EEE Rx LPI Count */
    870  1.20    bouyer 
    871  1.73   msaitoh #define	WMREG_PCS_CFG	0x4200	/* PCS Configuration */
    872  1.73   msaitoh #define	PCS_CFG_PCS_EN	__BIT(3)
    873  1.73   msaitoh 
    874  1.73   msaitoh #define	WMREG_PCS_LCTL	0x4208	/* PCS Link Control */
    875  1.73   msaitoh #define	PCS_LCTL_FSV_1000 __BIT(2)	/* AN Timeout Enable */
    876  1.73   msaitoh #define	PCS_LCTL_FDV_FULL __BIT(3)	/* AN Timeout Enable */
    877  1.73   msaitoh #define	PCS_LCTL_FSD __BIT(4)	/* AN Timeout Enable */
    878  1.73   msaitoh #define	PCS_LCTL_FORCE_FC __BIT(7)	/* AN Timeout Enable */
    879  1.73   msaitoh #define	PCS_LCTL_AN_ENABLE __BIT(16)	/* AN Timeout Enable */
    880  1.73   msaitoh #define	PCS_LCTL_AN_RESTART __BIT(17)	/* AN Timeout Enable */
    881  1.73   msaitoh #define	PCS_LCTL_AN_TIMEOUT __BIT(18)	/* AN Timeout Enable */
    882  1.73   msaitoh 
    883  1.73   msaitoh #define	WMREG_PCS_LSTS	0x420c	/* PCS Link Status */
    884  1.73   msaitoh #define PCS_LSTS_LINKOK	__BIT(0)
    885  1.73   msaitoh #define PCS_LSTS_SPEED_100  __BIT(1)
    886  1.73   msaitoh #define PCS_LSTS_SPEED_1000 __BIT(2)
    887  1.73   msaitoh #define PCS_LSTS_FDX	__BIT(3)
    888  1.73   msaitoh #define PCS_LSTS_AN_COMP __BIT(16)
    889  1.73   msaitoh 
    890  1.73   msaitoh #define	WMREG_PCS_ANADV	0x4218	/* AN Advertsement */
    891  1.73   msaitoh #define	WMREG_PCS_LPAB	0x421c	/* Link Partnet Ability */
    892  1.73   msaitoh 
    893  1.38   msaitoh #define	WMREG_RXCSUM	0x5000	/* Receive Checksum register */
    894  1.38   msaitoh #define	RXCSUM_PCSS	0x000000ff	/* Packet Checksum Start */
    895  1.38   msaitoh #define	RXCSUM_IPOFL	(1U << 8)	/* IP checksum offload */
    896  1.38   msaitoh #define	RXCSUM_TUOFL	(1U << 9)	/* TCP/UDP checksum offload */
    897  1.38   msaitoh #define	RXCSUM_IPV6OFL	(1U << 10)	/* IPv6 checksum offload */
    898  1.85  knakahar #define	RXCSUM_CRCOFL	(1U << 11)	/* SCTP CRC32 checksum offload */
    899  1.84  knakahar #define	RXCSUM_IPPCSE	(1U << 12)	/* IP payload checksum enable */
    900  1.84  knakahar #define	RXCSUM_PCSD	(1U << 13)	/* packet checksum disabled */
    901  1.38   msaitoh 
    902  1.38   msaitoh #define WMREG_RLPML	0x5004	/* Rx Long Packet Max Length */
    903  1.38   msaitoh 
    904  1.66   msaitoh #define WMREG_RFCTL	0x5008	/* Receive Filter Control */
    905  1.66   msaitoh #define WMREG_RFCTL_NFSWDIS	__BIT(6)  /* NFS Write Disable */
    906  1.66   msaitoh #define WMREG_RFCTL_NFSRDIS	__BIT(7)  /* NFS Read Disable */
    907  1.82   msaitoh #define WMREG_RFCTL_ACKDIS	__BIT(12) /* ACK Accelerate Disable */
    908  1.82   msaitoh #define WMREG_RFCTL_ACKD_DIS	__BIT(13) /* ACK data Disable */
    909  1.66   msaitoh #define WMREG_RFCTL_IPV6EXDIS	__BIT(16) /* IPv6 Extension Header Disable */
    910  1.66   msaitoh #define WMREG_RFCTL_NEWIPV6EXDIS __BIT(17) /* New IPv6 Extension Header */
    911  1.66   msaitoh 
    912  1.38   msaitoh #define	WMREG_WUC	0x5800	/* Wakeup Control */
    913  1.40   msaitoh #define	WUC_APME		0x00000001 /* APM Enable */
    914  1.40   msaitoh #define	WUC_PME_EN		0x00000002 /* PME Enable */
    915  1.40   msaitoh 
    916  1.40   msaitoh #define	WMREG_WUFC	0x5808	/* Wakeup Filter COntrol */
    917  1.40   msaitoh #define WUFC_MAG		0x00000002 /* Magic Packet Wakeup Enable */
    918  1.40   msaitoh #define WUFC_EX			0x00000004 /* Directed Exact Wakeup Enable */
    919  1.40   msaitoh #define WUFC_MC			0x00000008 /* Directed Multicast Wakeup En */
    920  1.40   msaitoh #define WUFC_BC			0x00000010 /* Broadcast Wakeup Enable */
    921  1.40   msaitoh #define WUFC_ARP		0x00000020 /* ARP Request Packet Wakeup En */
    922  1.40   msaitoh #define WUFC_IPV4		0x00000040 /* Directed IPv4 Packet Wakeup En */
    923  1.40   msaitoh #define WUFC_IPV6		0x00000080 /* Directed IPv6 Packet Wakeup En */
    924  1.38   msaitoh 
    925  1.84  knakahar #define WMREG_MRQC	0x5818	/* Multiple Receive Queues Command */
    926  1.84  knakahar #define MRQC_DISABLE_RSS	0x00000000
    927  1.84  knakahar #define MRQC_ENABLE_RSS_MQ_82574	__BIT(0) /* enable RSS for 82574 */
    928  1.84  knakahar #define MRQC_ENABLE_RSS_MQ	__BIT(1) /* enable hardware max RSS without VMDq */
    929  1.84  knakahar #define MRQC_ENABLE_RSS_VMDQ	__BITS(1, 0) /* enable RSS with VMDq */
    930  1.84  knakahar #define MRQC_DEFQ_MASK		__BITS(5, 3)
    931  1.84  knakahar 				/*
    932  1.84  knakahar 				 * Defines the default queue in non VMDq
    933  1.84  knakahar 				 * mode according to value of the Multiple Receive
    934  1.84  knakahar 				 * Queues Enable field.
    935  1.84  knakahar 				 */
    936  1.84  knakahar #define MRQC_DEFQ_NOT_RSS_FLT	__SHFTIN(__BIT(1), MRQC_DEFQ_MASK)
    937  1.84  knakahar 				/*
    938  1.84  knakahar 				 * the destination of all packets
    939  1.84  knakahar 				 * not forwarded by RSS or filters
    940  1.84  knakahar 				 */
    941  1.84  knakahar #define MRQC_DEFQ_NOT_MAC_ETH	__SHFTIN(__BITS(1, 0), MRQC_DEFQ_MASK)
    942  1.84  knakahar 				/*
    943  1.84  knakahar 				 * Def_Q field is ignored. Queueing
    944  1.84  knakahar 				 * decision of all packets not forwarded
    945  1.84  knakahar 				 * by MAC address and Ether-type filters
    946  1.84  knakahar 				 * is according to VT_CTL.DEF_PL field.
    947  1.84  knakahar 				 */
    948  1.84  knakahar #define MRQC_DEFQ_IGNORED1	__SHFTIN(__BIT(2), MRQC_DEFQ_MASK)
    949  1.84  knakahar 				/* Def_Q field is ignored */
    950  1.84  knakahar #define MRQC_DEFQ_IGNORED2	__SHFTIN(__BIT(2)|__BIT(0), MRQC_DEFQ_MASK)
    951  1.84  knakahar 				/* Def_Q field is ignored */
    952  1.84  knakahar #define MRQC_DEFQ_VMDQ		__SHFTIN(__BITS(2, 1), MRQC_DEFQ_MASK)
    953  1.84  knakahar 				/* for VMDq mode */
    954  1.84  knakahar #define MRQC_RSS_FIELD_IPV4_TCP		__BIT(16)
    955  1.84  knakahar #define MRQC_RSS_FIELD_IPV4		__BIT(17)
    956  1.84  knakahar #define MRQC_RSS_FIELD_IPV6_TCP_EX	__BIT(18)
    957  1.84  knakahar #define MRQC_RSS_FIELD_IPV6_EX		__BIT(19)
    958  1.84  knakahar #define MRQC_RSS_FIELD_IPV6		__BIT(20)
    959  1.84  knakahar #define MRQC_RSS_FIELD_IPV6_TCP		__BIT(21)
    960  1.84  knakahar #define MRQC_RSS_FIELD_IPV4_UDP		__BIT(22)
    961  1.84  knakahar #define MRQC_RSS_FIELD_IPV6_UDP		__BIT(23)
    962  1.84  knakahar #define MRQC_RSS_FIELD_IPV6_UDP_EX	__BIT(24)
    963  1.84  knakahar 
    964  1.84  knakahar #define WMREG_RETA_Q(x)		(0x5c00 + ((x) >> 2) * 4) /* Redirection Table */
    965  1.84  knakahar #define RETA_NUM_ENTRIES	128
    966  1.84  knakahar #define RETA_ENTRY_MASK_Q(x)	(0x000000ff << (((x) % 4) * 8)) /* Redirection Table */
    967  1.84  knakahar #define RETA_ENT_QINDEX_MASK		__BITS(3,0) /*queue index for 82580 and newer */
    968  1.84  knakahar #define RETA_ENT_QINDEX0_MASK_82575	__BITS(3,2) /*queue index for pool0 */
    969  1.84  knakahar #define RETA_ENT_QINDEX1_MASK_82575	__BITS(7,6) /*queue index for pool1 and regular RSS */
    970  1.84  knakahar #define RETA_ENT_QINDEX_MASK_82574	__BIT(7) /*queue index for 82574 */
    971  1.84  knakahar 
    972  1.84  knakahar #define WMREG_RSSRK(x)		(0x5c80 + (x) * 4) /* RSS Random Key Register */
    973  1.84  knakahar #define RSSRK_NUM_REGS		10
    974  1.84  knakahar 
    975  1.32   msaitoh #define	WMREG_MANC	0x5820	/* Management Control */
    976  1.40   msaitoh #define	MANC_SMBUS_EN		0x00000001
    977  1.40   msaitoh #define	MANC_ASF_EN		0x00000002
    978  1.40   msaitoh #define	MANC_ARP_EN		0x00002000
    979  1.54   msaitoh #define	MANC_RECV_TCO_RESET	0x00010000
    980  1.40   msaitoh #define	MANC_RECV_TCO_EN	0x00020000
    981  1.32   msaitoh #define	MANC_BLK_PHY_RST_ON_IDE	0x00040000
    982  1.54   msaitoh #define	MANC_RECV_ALL		0x00080000
    983  1.40   msaitoh #define	MANC_EN_MAC_ADDR_FILTER	0x00100000
    984  1.40   msaitoh #define	MANC_EN_MNG2HOST	0x00200000
    985  1.32   msaitoh 
    986  1.88   msaitoh #define	WMREG_MANC2H	0x5860	/* Management Control To Host - RW */
    987  1.40   msaitoh #define MANC2H_PORT_623		(1 << 5)
    988  1.40   msaitoh #define MANC2H_PORT_624		(1 << 6)
    989  1.20    bouyer 
    990  1.38   msaitoh #define WMREG_GCR	0x5b00	/* PCIe Control */
    991  1.38   msaitoh #define GCR_RXD_NO_SNOOP	0x00000001
    992  1.38   msaitoh #define GCR_RXDSCW_NO_SNOOP	0x00000002
    993  1.38   msaitoh #define GCR_RXDSCR_NO_SNOOP	0x00000004
    994  1.38   msaitoh #define GCR_TXD_NO_SNOOP	0x00000008
    995  1.38   msaitoh #define GCR_TXDSCW_NO_SNOOP	0x00000010
    996  1.38   msaitoh #define GCR_TXDSCR_NO_SNOOP	0x00000020
    997  1.38   msaitoh #define GCR_CMPL_TMOUT_MASK	0x0000f000
    998  1.38   msaitoh #define GCR_CMPL_TMOUT_10MS	0x00001000
    999  1.38   msaitoh #define GCR_CMPL_TMOUT_RESEND	0x00010000
   1000  1.38   msaitoh #define GCR_CAP_VER2		0x00040000
   1001  1.80   msaitoh #define GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
   1002  1.40   msaitoh 
   1003  1.40   msaitoh #define WMREG_FACTPS	0x5b30	/* Function Active and Power State to MNG */
   1004  1.40   msaitoh #define FACTPS_MNGCG		0x20000000
   1005  1.40   msaitoh #define FACTPS_LFS		0x40000000	/* LAN Function Select */
   1006  1.40   msaitoh 
   1007  1.38   msaitoh #define WMREG_GIOCTL	0x5b44	/* GIO Analog Control Register */
   1008  1.38   msaitoh #define WMREG_CCMCTL	0x5b48	/* CCM Control Register */
   1009  1.38   msaitoh #define WMREG_SCCTL	0x5b4c	/* PCIc PLL Configuration Register */
   1010  1.38   msaitoh 
   1011  1.18  uebayasi #define	WMREG_SWSM	0x5b50	/* SW Semaphore */
   1012  1.17   msaitoh #define	SWSM_SMBI	0x00000001	/* Driver Semaphore bit */
   1013  1.17   msaitoh #define	SWSM_SWESMBI	0x00000002	/* FW Semaphore bit */
   1014  1.17   msaitoh #define	SWSM_WMNG	0x00000004	/* Wake MNG Clock */
   1015  1.17   msaitoh #define	SWSM_DRV_LOAD	0x00000008	/* Driver Loaded Bit */
   1016  1.20    bouyer 
   1017  1.26   msaitoh #define	WMREG_FWSM	0x5b54	/* FW Semaphore */
   1018  1.88   msaitoh #define	FWSM_MODE		__BITS(1, 3)
   1019  1.40   msaitoh #define	MNG_ICH_IAMT_MODE	0x2	/* PT mode? */
   1020  1.26   msaitoh #define	MNG_IAMT_MODE		0x3
   1021  1.88   msaitoh #define FWSM_RSPCIPHY		__BIT(6)  /* Reset PHY on PCI reset */
   1022  1.88   msaitoh #define FWSM_WLOCK_MAC		__BITS(7, 9)  /* Reset PHY on PCI reset */
   1023  1.88   msaitoh #define FWSM_FW_VALID		__BIT(15) /* FW established a valid mode */
   1024  1.26   msaitoh 
   1025  1.57   msaitoh #define	WMREG_SWSM2	0x5b58	/* SW Semaphore 2 */
   1026  1.57   msaitoh #define SWSM2_LOCK		0x00000002 /* Secondary driver semaphore bit */
   1027  1.57   msaitoh 
   1028  1.20    bouyer #define	WMREG_SW_FW_SYNC 0x5b5c	/* software-firmware semaphore */
   1029  1.20    bouyer #define	SWFW_EEP_SM		0x0001 /* eeprom access */
   1030  1.20    bouyer #define	SWFW_PHY0_SM		0x0002 /* first ctrl phy access */
   1031  1.20    bouyer #define	SWFW_PHY1_SM		0x0004 /* second ctrl phy access */
   1032  1.20    bouyer #define	SWFW_MAC_CSR_SM		0x0008
   1033  1.38   msaitoh #define	SWFW_PHY2_SM		0x0020 /* first ctrl phy access */
   1034  1.38   msaitoh #define	SWFW_PHY3_SM		0x0040 /* first ctrl phy access */
   1035  1.20    bouyer #define	SWFW_SOFT_SHIFT		0	/* software semaphores */
   1036  1.20    bouyer #define	SWFW_FIRM_SHIFT		16	/* firmware semaphores */
   1037  1.22    bouyer 
   1038  1.66   msaitoh #define WMREG_GCR2	0x5b64	/* 3GPIO Control Register 2 */
   1039  1.89   msaitoh #define WMREG_FEXTNVM9	0x5bb4	/* Future Extended NVM 9 */
   1040  1.89   msaitoh #define WMREG_FEXTNVM11	0x5bbc	/* Future Extended NVM 11 */
   1041  1.89   msaitoh #define FEXTNVM11_DIS_MULRFIX	__BIT(13)	/* Disable MULR fix */
   1042  1.66   msaitoh 
   1043  1.58   msaitoh #define WMREG_CRC_OFFSET 0x5f50
   1044  1.58   msaitoh 
   1045  1.71   msaitoh #define WMREG_EEC	0x12010
   1046  1.71   msaitoh #define EEC_FLASH_DETECTED (1U << 19)	/* FLASH */
   1047  1.71   msaitoh #define EEC_FLUPD	(1U << 23)	/* Update FLASH */
   1048  1.71   msaitoh 
   1049  1.77   msaitoh #define WMREG_EEARBC_I210 0x12024
   1050  1.71   msaitoh 
   1051  1.58   msaitoh /*
   1052  1.58   msaitoh  * NVM related values.
   1053  1.58   msaitoh  *  Microwire, SPI, and flash
   1054  1.58   msaitoh  */
   1055  1.58   msaitoh #define	UWIRE_OPC_ERASE	0x04		/* MicroWire "erase" opcode */
   1056  1.58   msaitoh #define	UWIRE_OPC_WRITE	0x05		/* MicroWire "write" opcode */
   1057  1.58   msaitoh #define	UWIRE_OPC_READ	0x06		/* MicroWire "read" opcode */
   1058  1.58   msaitoh 
   1059  1.58   msaitoh #define	SPI_OPC_WRITE	0x02		/* SPI "write" opcode */
   1060  1.58   msaitoh #define	SPI_OPC_READ	0x03		/* SPI "read" opcode */
   1061  1.58   msaitoh #define	SPI_OPC_A8	0x08		/* opcode bit 3 == address bit 8 */
   1062  1.58   msaitoh #define	SPI_OPC_WREN	0x06		/* SPI "set write enable" opcode */
   1063  1.58   msaitoh #define	SPI_OPC_WRDI	0x04		/* SPI "clear write enable" opcode */
   1064  1.58   msaitoh #define	SPI_OPC_RDSR	0x05		/* SPI "read status" opcode */
   1065  1.58   msaitoh #define	SPI_OPC_WRSR	0x01		/* SPI "write status" opcode */
   1066  1.58   msaitoh #define	SPI_MAX_RETRIES	5000		/* max wait of 5ms for RDY signal */
   1067  1.58   msaitoh 
   1068  1.58   msaitoh #define	SPI_SR_RDY	0x01
   1069  1.58   msaitoh #define	SPI_SR_WEN	0x02
   1070  1.58   msaitoh #define	SPI_SR_BP0	0x04
   1071  1.58   msaitoh #define	SPI_SR_BP1	0x08
   1072  1.58   msaitoh #define	SPI_SR_WPEN	0x80
   1073  1.58   msaitoh 
   1074  1.61   msaitoh #define NVM_CHECKSUM		0xBABA
   1075  1.61   msaitoh #define NVM_SIZE		0x0040
   1076  1.62   msaitoh #define NVM_WORD_SIZE_BASE_SHIFT 6
   1077  1.61   msaitoh 
   1078  1.71   msaitoh #define	NVM_OFF_MACADDR		0x0000	/* MAC address offset 0 */
   1079  1.71   msaitoh #define	NVM_OFF_MACADDR1	0x0001	/* MAC address offset 1 */
   1080  1.71   msaitoh #define	NVM_OFF_MACADDR2	0x0002	/* MAC address offset 2 */
   1081  1.61   msaitoh #define NVM_OFF_COMPAT		0x0003
   1082  1.71   msaitoh #define NVM_OFF_ID_LED_SETTINGS	0x0004
   1083  1.76   msaitoh #define NVM_OFF_VERSION		0x0005
   1084  1.61   msaitoh #define	NVM_OFF_CFG1		0x000a	/* config word 1 */
   1085  1.61   msaitoh #define	NVM_OFF_CFG2		0x000f	/* config word 2 */
   1086  1.62   msaitoh #define	NVM_OFF_EEPROM_SIZE	0x0012	/* NVM SIZE */
   1087  1.71   msaitoh #define	NVM_OFF_CFG4		0x0013	/* config word 4 */
   1088  1.61   msaitoh #define	NVM_OFF_CFG3_PORTB	0x0014	/* config word 3 */
   1089  1.61   msaitoh #define NVM_OFF_FUTURE_INIT_WORD1 0x0019
   1090  1.61   msaitoh #define	NVM_OFF_INIT_3GIO_3	0x001a	/* PCIe Initial Configuration Word 3 */
   1091  1.61   msaitoh #define	NVM_OFF_K1_CONFIG	0x001b	/* NVM K1 Config */
   1092  1.71   msaitoh #define	NVM_OFF_LED_1_CFG	0x001c
   1093  1.71   msaitoh #define	NVM_OFF_LED_0_2_CFG	0x001f
   1094  1.61   msaitoh #define	NVM_OFF_SWDPIN		0x0020	/* SWD Pins (Cordova) */
   1095  1.61   msaitoh #define	NVM_OFF_CFG3_PORTA	0x0024	/* config word 3 */
   1096  1.61   msaitoh #define NVM_OFF_ALT_MAC_ADDR_PTR 0x0037	/* to the alternative MAC addresses */
   1097  1.76   msaitoh #define NVM_OFF_COMB_VER_PTR	0x003d
   1098  1.76   msaitoh #define NVM_OFF_IMAGE_UID0	0x0042
   1099  1.76   msaitoh #define NVM_OFF_IMAGE_UID1	0x0043
   1100  1.61   msaitoh 
   1101  1.61   msaitoh #define NVM_COMPAT_VALID_CHECKSUM	0x0001
   1102  1.61   msaitoh 
   1103  1.61   msaitoh #define	NVM_CFG1_LVDID		(1U << 0)
   1104  1.61   msaitoh #define	NVM_CFG1_LSSID		(1U << 1)
   1105  1.61   msaitoh #define	NVM_CFG1_PME_CLOCK	(1U << 2)
   1106  1.61   msaitoh #define	NVM_CFG1_PM		(1U << 3)
   1107  1.61   msaitoh #define	NVM_CFG1_ILOS		(1U << 4)
   1108  1.61   msaitoh #define	NVM_CFG1_SWDPIO_SHIFT	5
   1109  1.61   msaitoh #define	NVM_CFG1_SWDPIO_MASK	(0xf << NVM_CFG1_SWDPIO_SHIFT)
   1110  1.61   msaitoh #define	NVM_CFG1_IPS1		(1U << 8)
   1111  1.61   msaitoh #define	NVM_CFG1_LRST		(1U << 9)
   1112  1.61   msaitoh #define	NVM_CFG1_FD		(1U << 10)
   1113  1.61   msaitoh #define	NVM_CFG1_FRCSPD		(1U << 11)
   1114  1.61   msaitoh #define	NVM_CFG1_IPS0		(1U << 12)
   1115  1.61   msaitoh #define	NVM_CFG1_64_32_BAR	(1U << 13)
   1116  1.61   msaitoh 
   1117  1.61   msaitoh #define	NVM_CFG2_CSR_RD_SPLIT	(1U << 1)
   1118  1.61   msaitoh #define	NVM_CFG2_82544_APM_EN	(1U << 2)
   1119  1.61   msaitoh #define	NVM_CFG2_64_BIT		(1U << 3)
   1120  1.61   msaitoh #define	NVM_CFG2_MAX_READ	(1U << 4)
   1121  1.61   msaitoh #define	NVM_CFG2_DMCR_MAP	(1U << 5)
   1122  1.61   msaitoh #define	NVM_CFG2_133_CAP	(1U << 6)
   1123  1.61   msaitoh #define	NVM_CFG2_MSI_DIS	(1U << 7)
   1124  1.61   msaitoh #define	NVM_CFG2_FLASH_DIS	(1U << 8)
   1125  1.61   msaitoh #define	NVM_CFG2_FLASH_SIZE(x)	(((x) & 3) >> 9)
   1126  1.61   msaitoh #define	NVM_CFG2_APM_EN		(1U << 10)
   1127  1.61   msaitoh #define	NVM_CFG2_ANE		(1U << 11)
   1128  1.61   msaitoh #define	NVM_CFG2_PAUSE(x)	(((x) & 3) >> 12)
   1129  1.61   msaitoh #define	NVM_CFG2_ASDE		(1U << 14)
   1130  1.61   msaitoh #define	NVM_CFG2_APM_PME	(1U << 15)
   1131  1.61   msaitoh #define	NVM_CFG2_SWDPIO_SHIFT	4
   1132  1.61   msaitoh #define	NVM_CFG2_SWDPIO_MASK	(0xf << NVM_CFG2_SWDPIO_SHIFT)
   1133  1.61   msaitoh #define	NVM_CFG2_MNGM_SHIFT	13	/* Manageability Operation mode */
   1134  1.61   msaitoh #define	NVM_CFG2_MNGM_MASK	(3U << NVM_CFG2_MNGM_SHIFT)
   1135  1.61   msaitoh #define	NVM_CFG2_MNGM_DIS	0
   1136  1.61   msaitoh #define	NVM_CFG2_MNGM_NCSI	1
   1137  1.61   msaitoh #define	NVM_CFG2_MNGM_PT	2
   1138  1.61   msaitoh 
   1139  1.73   msaitoh #define	NVM_COMPAT_SERDES_FORCE_MODE	__BIT(14) /* Don't use autonego */
   1140  1.73   msaitoh 
   1141  1.61   msaitoh #define NVM_FUTURE_INIT_WORD1_VALID_CHECKSUM	0x0040
   1142  1.61   msaitoh 
   1143  1.61   msaitoh #define	NVM_K1_CONFIG_ENABLE	0x01
   1144  1.61   msaitoh 
   1145  1.61   msaitoh #define	NVM_SWDPIN_MASK		0xdf
   1146  1.61   msaitoh #define	NVM_SWDPIN_SWDPIN_SHIFT 0
   1147  1.61   msaitoh #define	NVM_SWDPIN_SWDPIO_SHIFT 8
   1148  1.61   msaitoh 
   1149  1.61   msaitoh #define NVM_3GIO_3_ASPM_MASK	(0x3 << 2)	/* Active State PM Support */
   1150  1.61   msaitoh 
   1151  1.61   msaitoh #define NVM_CFG3_APME		(1U << 10)
   1152  1.73   msaitoh #define NVM_CFG3_PORTA_EXT_MDIO	(1U << 2)	/* External MDIO Interface */
   1153  1.73   msaitoh #define NVM_CFG3_PORTA_COM_MDIO	(1U << 3)	/* MDIO Interface is shared */
   1154  1.61   msaitoh 
   1155  1.64   msaitoh #define	NVM_OFF_MACADDR_82571(x)	(3 * (x))
   1156  1.34   msaitoh 
   1157  1.58   msaitoh /*
   1158  1.58   msaitoh  * EEPROM Partitioning. See Table 6-1, "EEPROM Top Level Partitioning"
   1159  1.58   msaitoh  * in 82580's datasheet.
   1160  1.58   msaitoh  */
   1161  1.65   msaitoh #define NVM_OFF_LAN_FUNC_82580(x)	((x) ? (0x40 + (0x40 * (x))) : 0)
   1162  1.47   msaitoh 
   1163  1.76   msaitoh #define NVM_COMBO_VER_OFF	0x0083
   1164  1.76   msaitoh 
   1165  1.76   msaitoh #define NVM_MAJOR_MASK		0xf000
   1166  1.76   msaitoh #define NVM_MAJOR_SHIFT		12
   1167  1.76   msaitoh #define NVM_MINOR_MASK		0x0ff0
   1168  1.76   msaitoh #define NVM_MINOR_SHIFT		4
   1169  1.76   msaitoh #define NVM_BUILD_MASK		0x000f
   1170  1.76   msaitoh #define NVM_UID_VALID		0x8000
   1171  1.76   msaitoh 
   1172  1.71   msaitoh /* iNVM Registers for i21[01] */
   1173  1.77   msaitoh #define WM_INVM_DATA_REG(reg)	(0x12120 + 4*(reg))
   1174  1.71   msaitoh #define INVM_SIZE			64 /* Number of INVM Data Registers */
   1175  1.71   msaitoh 
   1176  1.71   msaitoh /* iNVM default vaule */
   1177  1.71   msaitoh #define NVM_INIT_CTRL_2_DEFAULT_I211	0x7243
   1178  1.71   msaitoh #define NVM_INIT_CTRL_4_DEFAULT_I211	0x00c1
   1179  1.71   msaitoh #define NVM_LED_1_CFG_DEFAULT_I211	0x0184
   1180  1.71   msaitoh #define NVM_LED_0_2_CFG_DEFAULT_I211	0x200c
   1181  1.71   msaitoh #define NVM_RESERVED_WORD		0xffff
   1182  1.71   msaitoh 
   1183  1.71   msaitoh #define INVM_DWORD_TO_RECORD_TYPE(dword)	((dword) & 0x7)
   1184  1.71   msaitoh #define INVM_DWORD_TO_WORD_ADDRESS(dword)	(((dword) & 0x0000FE00) >> 9)
   1185  1.71   msaitoh #define INVM_DWORD_TO_WORD_DATA(dword)		(((dword) & 0xFFFF0000) >> 16)
   1186  1.71   msaitoh 
   1187  1.71   msaitoh #define INVM_UNINITIALIZED_STRUCTURE		0x0
   1188  1.71   msaitoh #define INVM_WORD_AUTOLOAD_STRUCTURE		0x1
   1189  1.71   msaitoh #define INVM_CSR_AUTOLOAD_STRUCTURE		0x2
   1190  1.71   msaitoh #define INVM_PHY_REGISTER_AUTOLOAD_STRUCTURE	0x3
   1191  1.71   msaitoh #define INVM_RSA_KEY_SHA256_STRUCTURE		0x4
   1192  1.77   msaitoh #define INVM_INVALIDATED_STRUCTURE		0xf
   1193  1.71   msaitoh 
   1194  1.71   msaitoh #define INVM_RSA_KEY_SHA256_DATA_SIZE_IN_DWORDS	8
   1195  1.71   msaitoh #define INVM_CSR_AUTOLOAD_DATA_SIZE_IN_DWORDS	1
   1196  1.71   msaitoh 
   1197  1.77   msaitoh #define INVM_DEFAULT_AL		0x202f
   1198  1.77   msaitoh #define INVM_AUTOLOAD		0x0a
   1199  1.77   msaitoh #define INVM_PLL_WO_VAL		0x0010
   1200  1.77   msaitoh 
   1201  1.79   msaitoh /* Version and Image Type field */
   1202  1.79   msaitoh #define INVM_VER_1	__BITS(12,3)
   1203  1.79   msaitoh #define INVM_VER_2	__BITS(22,13)
   1204  1.79   msaitoh #define INVM_IMGTYPE	__BITS(28,23)
   1205  1.79   msaitoh #define INVM_MINOR	__BITS(3,0)
   1206  1.79   msaitoh #define INVM_MAJOR	__BITS(9,4)
   1207  1.79   msaitoh 
   1208  1.71   msaitoh /* Word definitions for ID LED Settings */
   1209  1.71   msaitoh #define ID_LED_RESERVED_FFFF 0xFFFF
   1210  1.71   msaitoh 
   1211  1.22    bouyer /* ich8 flash control */
   1212  1.22    bouyer #define ICH_FLASH_COMMAND_TIMEOUT            5000    /* 5000 uSecs - adjusted */
   1213  1.22    bouyer #define ICH_FLASH_ERASE_TIMEOUT              3000000 /* Up to 3 seconds - worst case */
   1214  1.22    bouyer #define ICH_FLASH_CYCLE_REPEAT_COUNT         10      /* 10 cycles */
   1215  1.22    bouyer #define ICH_FLASH_SEG_SIZE_256               256
   1216  1.22    bouyer #define ICH_FLASH_SEG_SIZE_4K                4096
   1217  1.22    bouyer #define ICH_FLASH_SEG_SIZE_64K               65536
   1218  1.22    bouyer 
   1219  1.22    bouyer #define ICH_CYCLE_READ                       0x0
   1220  1.22    bouyer #define ICH_CYCLE_RESERVED                   0x1
   1221  1.22    bouyer #define ICH_CYCLE_WRITE                      0x2
   1222  1.22    bouyer #define ICH_CYCLE_ERASE                      0x3
   1223  1.22    bouyer 
   1224  1.22    bouyer #define ICH_FLASH_GFPREG   0x0000
   1225  1.22    bouyer #define ICH_FLASH_HSFSTS   0x0004 /* Flash Status Register */
   1226  1.22    bouyer #define HSFSTS_DONE		0x0001 /* Flash Cycle Done */
   1227  1.22    bouyer #define HSFSTS_ERR		0x0002 /* Flash Cycle Error */
   1228  1.22    bouyer #define HSFSTS_DAEL		0x0004 /* Direct Access error Log */
   1229  1.22    bouyer #define HSFSTS_ERSZ_MASK	0x0018 /* Block/Sector Erase Size */
   1230  1.22    bouyer #define HSFSTS_ERSZ_SHIFT	3
   1231  1.22    bouyer #define HSFSTS_FLINPRO		0x0020 /* flash SPI cycle in Progress */
   1232  1.22    bouyer #define HSFSTS_FLDVAL		0x4000 /* Flash Descriptor Valid */
   1233  1.22    bouyer #define HSFSTS_FLLK		0x8000 /* Flash Configuration Lock-Down */
   1234  1.22    bouyer #define ICH_FLASH_HSFCTL   0x0006 /* Flash control Register */
   1235  1.22    bouyer #define HSFCTL_GO		0x0001 /* Flash Cycle Go */
   1236  1.22    bouyer #define HSFCTL_CYCLE_MASK	0x0006 /* Flash Cycle */
   1237  1.22    bouyer #define HSFCTL_CYCLE_SHIFT	1
   1238  1.22    bouyer #define HSFCTL_BCOUNT_MASK	0x0300 /* Data Byte Count */
   1239  1.22    bouyer #define HSFCTL_BCOUNT_SHIFT	8
   1240  1.22    bouyer #define ICH_FLASH_FADDR    0x0008
   1241  1.22    bouyer #define ICH_FLASH_FDATA0   0x0010
   1242  1.22    bouyer #define ICH_FLASH_FRACC    0x0050
   1243  1.22    bouyer #define ICH_FLASH_FREG0    0x0054
   1244  1.22    bouyer #define ICH_FLASH_FREG1    0x0058
   1245  1.22    bouyer #define ICH_FLASH_FREG2    0x005C
   1246  1.22    bouyer #define ICH_FLASH_FREG3    0x0060
   1247  1.22    bouyer #define ICH_FLASH_FPR0     0x0074
   1248  1.22    bouyer #define ICH_FLASH_FPR1     0x0078
   1249  1.22    bouyer #define ICH_FLASH_SSFSTS   0x0090
   1250  1.22    bouyer #define ICH_FLASH_SSFCTL   0x0092
   1251  1.22    bouyer #define ICH_FLASH_PREOP    0x0094
   1252  1.22    bouyer #define ICH_FLASH_OPTYPE   0x0096
   1253  1.22    bouyer #define ICH_FLASH_OPMENU   0x0098
   1254  1.22    bouyer 
   1255  1.22    bouyer #define ICH_FLASH_REG_MAPSIZE      0x00A0
   1256  1.22    bouyer #define ICH_FLASH_SECTOR_SIZE      4096
   1257  1.22    bouyer #define ICH_GFPREG_BASE_MASK       0x1FFF
   1258  1.22    bouyer #define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
   1259  1.25   msaitoh 
   1260  1.25   msaitoh #define ICH_NVM_SIG_WORD	0x13
   1261  1.25   msaitoh #define ICH_NVM_SIG_MASK	0xc000
   1262  1.50   msaitoh #define ICH_NVM_VALID_SIG_MASK	0xc0
   1263  1.50   msaitoh #define ICH_NVM_SIG_VALUE	0x80
   1264  1.38   msaitoh 
   1265  1.89   msaitoh #define NVM_SIZE_MULTIPLIER 4096	/* multiplier for NVMS field */
   1266  1.89   msaitoh #define WM_PCH_SPT_FLASHOFFSET	0xe000	/* offset of NVM access regs(PCH_SPT)*/
   1267  1.89   msaitoh 
   1268  1.38   msaitoh /* for PCI express Capability registers */
   1269  1.52   msaitoh #define	WM_PCIE_DCSR2_16MS	0x00000005
   1270  1.48    bouyer 
   1271  1.63   msaitoh /* SFF SFP ROM data */
   1272  1.63   msaitoh #define SFF_SFP_ID_OFF		0x00
   1273  1.63   msaitoh #define SFF_SFP_ID_UNKNOWN	0x00	/* Unknown */
   1274  1.63   msaitoh #define SFF_SFP_ID_SFF		0x02	/* Module soldered to motherboard */
   1275  1.63   msaitoh #define SFF_SFP_ID_SFP		0x03	/* SFP transceiver */
   1276  1.63   msaitoh 
   1277  1.63   msaitoh #define SFF_SFP_ETH_FLAGS_OFF	0x06
   1278  1.63   msaitoh #define SFF_SFP_ETH_FLAGS_1000SX	0x01
   1279  1.63   msaitoh #define SFF_SFP_ETH_FLAGS_1000LX	0x02
   1280  1.63   msaitoh #define SFF_SFP_ETH_FLAGS_1000CX	0x04
   1281  1.63   msaitoh #define SFF_SFP_ETH_FLAGS_1000T		0x08
   1282  1.63   msaitoh #define SFF_SFP_ETH_FLAGS_100FX		0x10
   1283  1.63   msaitoh 
   1284  1.77   msaitoh /* I21[01] PHY related definitions */
   1285  1.77   msaitoh #define GS40G_PAGE_SELECT	0x16
   1286  1.77   msaitoh #define GS40G_PAGE_SHIFT	16
   1287  1.77   msaitoh #define GS40G_OFFSET_MASK	0xffff
   1288  1.77   msaitoh #define GS40G_PHY_PLL_FREQ_PAGE	0xfc0000
   1289  1.77   msaitoh #define GS40G_PHY_PLL_FREQ_REG	0x000e
   1290  1.77   msaitoh #define GS40G_PHY_PLL_UNCONF	0xff
   1291  1.63   msaitoh 
   1292  1.48    bouyer /* advanced TX descriptor for 82575 and newer */
   1293  1.48    bouyer typedef union nq_txdesc {
   1294  1.48    bouyer 	struct {
   1295  1.48    bouyer 		uint64_t nqtxd_addr;
   1296  1.48    bouyer 		uint32_t nqtxd_cmdlen;
   1297  1.48    bouyer 		uint32_t nqtxd_fields;
   1298  1.48    bouyer 	} nqtx_data;
   1299  1.48    bouyer 	struct {
   1300  1.48    bouyer 		uint32_t nqtxc_vl_len;
   1301  1.48    bouyer 		uint32_t nqtxc_sn;
   1302  1.48    bouyer 		uint32_t nqtxc_cmd;
   1303  1.48    bouyer 		uint32_t nqtxc_mssidx;
   1304  1.48    bouyer 	} nqrx_ctx;
   1305  1.48    bouyer } __packed nq_txdesc_t;
   1306  1.48    bouyer 
   1307  1.48    bouyer 
   1308  1.48    bouyer /* Commands for nqtxd_cmdlen and nqtxc_cmd */
   1309  1.48    bouyer #define	NQTX_CMD_EOP	(1U << 24)	/* end of packet */
   1310  1.48    bouyer #define	NQTX_CMD_IFCS	(1U << 25)	/* insert FCS */
   1311  1.48    bouyer #define	NQTX_CMD_RS	(1U << 27)	/* report status */
   1312  1.48    bouyer #define	NQTX_CMD_DEXT	(1U << 29)	/* descriptor extension */
   1313  1.48    bouyer #define	NQTX_CMD_VLE	(1U << 30)	/* VLAN enable */
   1314  1.48    bouyer #define	NQTX_CMD_TSE	(1U << 31)	/* TCP segmentation enable */
   1315  1.48    bouyer 
   1316  1.48    bouyer /* Descriptor types (if DEXT is set) */
   1317  1.48    bouyer #define	NQTX_DTYP_C	(2U << 20)	/* context */
   1318  1.48    bouyer #define	NQTX_DTYP_D	(3U << 20)	/* data */
   1319  1.48    bouyer 
   1320  1.48    bouyer #define NQTXD_FIELDS_IDX_SHIFT		4	/* context index shift */
   1321  1.48    bouyer #define NQTXD_FIELDS_IDX_MASK		0xf
   1322  1.48    bouyer #define NQTXD_FIELDS_PAYLEN_SHIFT	14	/* payload len shift */
   1323  1.48    bouyer #define NQTXD_FIELDS_PAYLEN_MASK	0x3ffff
   1324  1.48    bouyer 
   1325  1.48    bouyer #define NQTXD_FIELDS_IXSM		(1U << 8) /* do IP checksum */
   1326  1.48    bouyer #define NQTXD_FIELDS_TUXSM		(1U << 9) /* do TCP/UDP checksum */
   1327  1.48    bouyer 
   1328  1.48    bouyer #define NQTXC_VLLEN_IPLEN_SHIFT		0	/* IP header len */
   1329  1.48    bouyer #define NQTXC_VLLEN_IPLEN_MASK		0x1ff
   1330  1.48    bouyer #define NQTXC_VLLEN_MACLEN_SHIFT	9	/* MAC header len */
   1331  1.48    bouyer #define NQTXC_VLLEN_MACLEN_MASK		0x7f
   1332  1.48    bouyer #define NQTXC_VLLEN_VLAN_SHIFT		16	/* vlan number */
   1333  1.48    bouyer #define NQTXC_VLLEN_VLAN_MASK		0xffff
   1334  1.48    bouyer 
   1335  1.48    bouyer #define NQTXC_CMD_MKRLOC_SHIFT		0	/* IP checksum offset */
   1336  1.48    bouyer #define NQTXC_CMD_MKRLOC_MASK		0x1ff
   1337  1.48    bouyer #define NQTXC_CMD_SNAP			(1U << 9)
   1338  1.48    bouyer #define NQTXC_CMD_IP4			(1U << 10)
   1339  1.48    bouyer #define NQTXC_CMD_IP6			(0U << 10)
   1340  1.48    bouyer #define NQTXC_CMD_TCP			(1U << 11)
   1341  1.48    bouyer #define NQTXC_CMD_UDP			(0U << 11)
   1342  1.48    bouyer #define NQTXC_MSSIDX_IDX_SHIFT		4	/* context index shift */
   1343  1.48    bouyer #define NQTXC_MSSIDX_IDX_MASK		0xf
   1344  1.48    bouyer #define NQTXC_MSSIDX_L4LEN_SHIFT	8	/* L4 header len shift */
   1345  1.48    bouyer #define NQTXC_MSSIDX_L4LEN_MASK		0xff
   1346  1.48    bouyer #define NQTXC_MSSIDX_MSS_SHIFT		16	/* MSS */
   1347  1.48    bouyer #define NQTXC_MSSIDX_MSS_MASK		0xffff
   1348