This commit was generated by cvs2svn to compensate for changes in r26790,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
Peter Wemm 1997-06-22 09:32:32 +00:00
commit 172d6524df
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=26791
2 changed files with 1564 additions and 0 deletions

597
sys/pci/dc21040reg.h Normal file
View File

@ -0,0 +1,597 @@
/*-
* Copyright (c) 1994, 1995, 1996 Matt Thomas <matt@3am-software.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: dc21040.h,v 1.23 1997/03/15 17:28:19 thomas Exp $
*/
#if !defined(_DC21040_H)
#define _DC21040_H
#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
#define TULIP_BITFIELD2(a, b) b, a
#define TULIP_BITFIELD3(a, b, c) c, b, a
#define TULIP_BITFIELD4(a, b, c, d) d, c, b, a
#else
#define TULIP_BITFIELD2(a, b) a, b
#define TULIP_BITFIELD3(a, b, c) a, b, c
#define TULIP_BITFIELD4(a, b, c, d) a, b, c, d
#endif
typedef struct {
u_int32_t d_status;
u_int32_t TULIP_BITFIELD3(d_length1 : 11,
d_length2 : 11,
d_flag : 10);
u_int32_t d_addr1;
u_int32_t d_addr2;
} tulip_desc_t;
#define TULIP_DSTS_OWNER 0x80000000 /* Owner (1 = 21040) */
#define TULIP_DSTS_ERRSUM 0x00008000 /* Error Summary */
/*
* Transmit Status
*/
#define TULIP_DSTS_TxBABBLE 0x00004000 /* Transmitter Babbled */
#define TULIP_DSTS_TxCARRLOSS 0x00000800 /* Carrier Loss */
#define TULIP_DSTS_TxNOCARR 0x00000400 /* No Carrier */
#define TULIP_DSTS_TxLATECOLL 0x00000200 /* Late Collision */
#define TULIP_DSTS_TxEXCCOLL 0x00000100 /* Excessive Collisions */
#define TULIP_DSTS_TxNOHRTBT 0x00000080 /* No Heartbeat */
#define TULIP_DSTS_TxCOLLMASK 0x00000078 /* Collision Count (mask) */
#define TULIP_DSTS_V_TxCOLLCNT 0x00000003 /* Collision Count (bit) */
#define TULIP_DSTS_TxLINKFAIL 0x00000004 /* Link Failure */
#define TULIP_DSTS_TxUNDERFLOW 0x00000002 /* Underflow Error */
#define TULIP_DSTS_TxDEFERRED 0x00000001 /* Initially Deferred */
/*
* Receive Status
*/
#define TULIP_DSTS_RxBADLENGTH 0x00004000 /* Length Error */
#define TULIP_DSTS_RxDATATYPE 0x00003000 /* Data Type */
#define TULIP_DSTS_RxRUNT 0x00000800 /* Runt Frame */
#define TULIP_DSTS_RxMULTICAST 0x00000400 /* Multicast Frame */
#define TULIP_DSTS_RxFIRSTDESC 0x00000200 /* First Descriptor */
#define TULIP_DSTS_RxLASTDESC 0x00000100 /* Last Descriptor */
#define TULIP_DSTS_RxTOOLONG 0x00000080 /* Frame Too Long */
#define TULIP_DSTS_RxCOLLSEEN 0x00000040 /* Collision Seen */
#define TULIP_DSTS_RxFRAMETYPE 0x00000020 /* Frame Type */
#define TULIP_DSTS_RxWATCHDOG 0x00000010 /* Receive Watchdog */
#define TULIP_DSTS_RxDRBBLBIT 0x00000004 /* Dribble Bit */
#define TULIP_DSTS_RxBADCRC 0x00000002 /* CRC Error */
#define TULIP_DSTS_RxOVERFLOW 0x00000001 /* Overflow */
#define TULIP_DFLAG_ENDRING 0x0008 /* End of Transmit Ring */
#define TULIP_DFLAG_CHAIN 0x0004 /* Chain using d_addr2 */
#define TULIP_DFLAG_TxWANTINTR 0x0200 /* Signal Interrupt on Completion */
#define TULIP_DFLAG_TxLASTSEG 0x0100 /* Last Segment */
#define TULIP_DFLAG_TxFIRSTSEG 0x0080 /* First Segment */
#define TULIP_DFLAG_TxINVRSFILT 0x0040 /* Inverse Filtering */
#define TULIP_DFLAG_TxSETUPPKT 0x0020 /* Setup Packet */
#define TULIP_DFLAG_TxHASCRC 0x0010 /* Don't Append the CRC */
#define TULIP_DFLAG_TxNOPADDING 0x0002 /* Don't AutoPad */
#define TULIP_DFLAG_TxHASHFILT 0x0001 /* Hash/Perfect Filtering */
/*
* The 21040 Registers (IO Space Addresses)
*/
#define TULIP_REG_BUSMODE 0x00 /* CSR0 -- Bus Mode */
#define TULIP_REG_TXPOLL 0x08 /* CSR1 -- Transmit Poll Demand */
#define TULIP_REG_RXPOLL 0x10 /* CSR2 -- Receive Poll Demand */
#define TULIP_REG_RXLIST 0x18 /* CSR3 -- Receive List Base Addr */
#define TULIP_REG_TXLIST 0x20 /* CSR4 -- Transmit List Base Addr */
#define TULIP_REG_STATUS 0x28 /* CSR5 -- Status */
#define TULIP_REG_CMD 0x30 /* CSR6 -- Command */
#define TULIP_REG_INTR 0x38 /* CSR7 -- Interrupt Control */
#define TULIP_REG_MISSES 0x40 /* CSR8 -- Missed Frame Counter */
#define TULIP_REG_ADDRROM 0x48 /* CSR9 -- ENET ROM Register */
#define TULIP_REG_RSRVD 0x50 /* CSR10 -- Reserved */
#define TULIP_REG_FULL_DUPLEX 0x58 /* CSR11 -- Full Duplex */
#define TULIP_REG_SIA_STATUS 0x60 /* CSR12 -- SIA Status */
#define TULIP_REG_SIA_CONN 0x68 /* CSR13 -- SIA Connectivity */
#define TULIP_REG_SIA_TXRX 0x70 /* CSR14 -- SIA Tx Rx */
#define TULIP_REG_SIA_GEN 0x78 /* CSR15 -- SIA General */
/*
* CSR5 -- Status Register
* CSR7 -- Interrupt Control
*/
#define TULIP_STS_ERRORMASK 0x03800000L /* ( R) Error Bits (Valid when SYSERROR is set) */
#define TULIP_STS_ERR_PARITY 0x00000000L /* 000 - Parity Error (Perform Reset) */
#define TULIP_STS_ERR_MASTER 0x00800000L /* 001 - Master Abort */
#define TULIP_STS_ERR_TARGET 0x01000000L /* 010 - Target Abort */
#define TULIP_STS_ERR_SHIFT 23
#define TULIP_STS_TXSTATEMASK 0x00700000L /* ( R) Transmission Process State */
#define TULIP_STS_TXS_RESET 0x00000000L /* 000 - Rset or transmit jabber expired */
#define TULIP_STS_TXS_FETCH 0x00100000L /* 001 - Fetching transmit descriptor */
#define TULIP_STS_TXS_WAITEND 0x00200000L /* 010 - Wait for end of transmission */
#define TULIP_STS_TXS_READING 0x00300000L /* 011 - Read buffer and enqueue data */
#define TULIP_STS_TXS_RSRVD 0x00400000L /* 100 - Reserved */
#define TULIP_STS_TXS_SETUP 0x00500000L /* 101 - Setup Packet */
#define TULIP_STS_TXS_SUSPEND 0x00600000L /* 110 - Transmit FIFO underflow or an
unavailable transmit descriptor */
#define TULIP_STS_TXS_CLOSE 0x00700000L /* 111 - Close transmit descriptor */
#define TULIP_STS_RXSTATEMASK 0x000E0000L /* ( R) Receive Process State*/
#define TULIP_STS_RXS_STOPPED 0x00000000L /* 000 - Stopped */
#define TULIP_STS_RXS_FETCH 0x00020000L /* 001 - Running -- Fetch receive descriptor */
#define TULIP_STS_RXS_ENDCHECK 0x00040000L /* 010 - Running -- Check for end of receive
packet before prefetch of next descriptor */
#define TULIP_STS_RXS_WAIT 0x00060000L /* 011 - Running -- Wait for receive packet */
#define TULIP_STS_RXS_SUSPEND 0x00080000L /* 100 - Suspended -- As a result of
unavailable receive buffers */
#define TULIP_STS_RXS_CLOSE 0x000A0000L /* 101 - Running -- Close receive descriptor */
#define TULIP_STS_RXS_FLUSH 0x000C0000L /* 110 - Running -- Flush the current frame
from the receive FIFO as a result of
an unavailable receive buffer */
#define TULIP_STS_RXS_DEQUEUE 0x000E0000L /* 111 - Running -- Dequeue the receive frame
from the receive FIFO into the receive
buffer. */
#define TULIP_STS_NORMALINTR 0x00010000L /* (RW) Normal Interrupt */
#define TULIP_STS_ABNRMLINTR 0x00008000L /* (RW) Abnormal Interrupt */
#define TULIP_STS_SYSERROR 0x00002000L /* (RW) System Error */
#define TULIP_STS_LINKFAIL 0x00001000L /* (RW) Link Failure (21040) */
#define TULIP_STS_FULDPLXSHRT 0x00000800L /* (RW) Full Duplex Short Fram Rcvd (21040) */
#define TULIP_STS_GPTIMEOUT 0x00000800L /* (RW) General Purpose Timeout (21140) */
#define TULIP_STS_AUI 0x00000400L /* (RW) AUI/TP Switch (21040) */
#define TULIP_STS_RXTIMEOUT 0x00000200L /* (RW) Receive Watchbog Timeout */
#define TULIP_STS_RXSTOPPED 0x00000100L /* (RW) Receive Process Stopped */
#define TULIP_STS_RXNOBUF 0x00000080L /* (RW) Receive Buffer Unavailable */
#define TULIP_STS_RXINTR 0x00000040L /* (RW) Receive Interrupt */
#define TULIP_STS_TXUNDERFLOW 0x00000020L /* (RW) Transmit Underflow */
#define TULIP_STS_LINKPASS 0x00000010L /* (RW) LinkPass (21041) */
#define TULIP_STS_TXBABBLE 0x00000008L /* (RW) Transmit Jabber Timeout */
#define TULIP_STS_TXNOBUF 0x00000004L /* (RW) Transmit Buffer Unavailable */
#define TULIP_STS_TXSTOPPED 0x00000002L /* (RW) Transmit Process Stopped */
#define TULIP_STS_TXINTR 0x00000001L /* (RW) Transmit Interrupt */
/*
* CSR6 -- Command (Operation Mode) Register
*/
#define TULIP_CMD_MUSTBEONE 0x02000000L /* (RW) Must Be One (21140) */
#define TULIP_CMD_SCRAMBLER 0x01000000L /* (RW) Scrambler Mode (21140) */
#define TULIP_CMD_PCSFUNCTION 0x00800000L /* (RW) PCS Function (21140) */
#define TULIP_CMD_TXTHRSHLDCTL 0x00400000L /* (RW) Transmit Threshold Mode (21140) */
#define TULIP_CMD_STOREFWD 0x00200000L /* (RW) Store and Foward (21140) */
#define TULIP_CMD_NOHEARTBEAT 0x00080000L /* (RW) No Heartbeat (21140) */
#define TULIP_CMD_PORTSELECT 0x00040000L /* (RW) Post Select (100Mb) (21140) */
#define TULIP_CMD_ENHCAPTEFFCT 0x00040000L /* (RW) Enhanced Capture Effecty (21041) */
#define TULIP_CMD_CAPTREFFCT 0x00020000L /* (RW) Capture Effect (!802.3) */
#define TULIP_CMD_BACKPRESSURE 0x00010000L /* (RW) Back Pressure (!802.3) (21040) */
#define TULIP_CMD_THRESHOLDCTL 0x0000C000L /* (RW) Threshold Control */
#define TULIP_CMD_THRSHLD72 0x00000000L /* 00 - 72 Bytes */
#define TULIP_CMD_THRSHLD96 0x00004000L /* 01 - 96 Bytes */
#define TULIP_CMD_THRSHLD128 0x00008000L /* 10 - 128 bytes */
#define TULIP_CMD_THRSHLD160 0x0000C000L /* 11 - 160 Bytes */
#define TULIP_CMD_TXRUN 0x00002000L /* (RW) Start/Stop Transmitter */
#define TULIP_CMD_FORCECOLL 0x00001000L /* (RW) Force Collisions */
#define TULIP_CMD_OPERMODE 0x00000C00L /* (RW) Operating Mode */
#define TULIP_CMD_FULLDUPLEX 0x00000200L /* (RW) Full Duplex Mode */
#define TULIP_CMD_FLAKYOSCDIS 0x00000100L /* (RW) Flakey Oscillator Disable */
#define TULIP_CMD_ALLMULTI 0x00000080L /* (RW) Pass All Multicasts */
#define TULIP_CMD_PROMISCUOUS 0x00000040L /* (RW) Promiscuous Mode */
#define TULIP_CMD_BACKOFFCTR 0x00000020L /* (RW) Start/Stop Backoff Counter (!802.3) */
#define TULIP_CMD_INVFILTER 0x00000010L /* (R ) Inverse Filtering */
#define TULIP_CMD_PASSBADPKT 0x00000008L /* (RW) Pass Bad Frames */
#define TULIP_CMD_HASHONLYFLTR 0x00000004L /* (R ) Hash Only Filtering */
#define TULIP_CMD_RXRUN 0x00000002L /* (RW) Start/Stop Receive Filtering */
#define TULIP_CMD_HASHPRFCTFLTR 0x00000001L /* (R ) Hash/Perfect Receive Filtering */
#define TULIP_SIASTS_OTHERRXACTIVITY 0x00000200L
#define TULIP_SIASTS_RXACTIVITY 0x00000100L
#define TULIP_SIASTS_LINKFAIL 0x00000004L
#define TULIP_SIACONN_RESET 0x00000000L
/*
* 21040 SIA definitions
*/
#define TULIP_21040_PROBE_10BASET_TIMEOUT 2500
#define TULIP_21040_PROBE_AUIBNC_TIMEOUT 300
#define TULIP_21040_PROBE_EXTSIA_TIMEOUT 300
#define TULIP_21040_SIACONN_10BASET 0x00008F01L
#define TULIP_21040_SIATXRX_10BASET 0x0000FFFFL
#define TULIP_21040_SIAGEN_10BASET 0x00000000L
#define TULIP_21040_SIACONN_10BASET_FD 0x00008F01L
#define TULIP_21040_SIATXRX_10BASET_FD 0x0000FFFDL
#define TULIP_21040_SIAGEN_10BASET_FD 0x00000000L
#define TULIP_21040_SIACONN_AUIBNC 0x00008F09L
#define TULIP_21040_SIATXRX_AUIBNC 0x00000705L
#define TULIP_21040_SIAGEN_AUIBNC 0x00000006L
#define TULIP_21040_SIACONN_EXTSIA 0x00003041L
#define TULIP_21040_SIATXRX_EXTSIA 0x00000000L
#define TULIP_21040_SIAGEN_EXTSIA 0x00000006L
/*
* 21041 SIA definitions
*/
#define TULIP_21041_PROBE_10BASET_TIMEOUT 2500
#define TULIP_21041_PROBE_AUIBNC_TIMEOUT 300
#define TULIP_21041_SIACONN_10BASET 0x0000EF01L
#define TULIP_21041_SIATXRX_10BASET 0x0000FF3FL
#define TULIP_21041_SIAGEN_10BASET 0x00000000L
#define TULIP_21041P2_SIACONN_10BASET 0x0000EF01L
#define TULIP_21041P2_SIATXRX_10BASET 0x0000FFFFL
#define TULIP_21041P2_SIAGEN_10BASET 0x00000000L
#define TULIP_21041_SIACONN_10BASET_FD 0x0000EF01L
#define TULIP_21041_SIATXRX_10BASET_FD 0x0000FF3DL
#define TULIP_21041_SIAGEN_10BASET_FD 0x00000000L
#define TULIP_21041P2_SIACONN_10BASET_FD 0x0000EF01L
#define TULIP_21041P2_SIATXRX_10BASET_FD 0x0000FFFFL
#define TULIP_21041P2_SIAGEN_10BASET_FD 0x00000000L
#define TULIP_21041_SIACONN_AUI 0x0000EF09L
#define TULIP_21041_SIATXRX_AUI 0x0000F73DL
#define TULIP_21041_SIAGEN_AUI 0x0000000EL
#define TULIP_21041P2_SIACONN_AUI 0x0000EF09L
#define TULIP_21041P2_SIATXRX_AUI 0x0000F7FDL
#define TULIP_21041P2_SIAGEN_AUI 0x0000000EL
#define TULIP_21041_SIACONN_BNC 0x0000EF09L
#define TULIP_21041_SIATXRX_BNC 0x0000F73DL
#define TULIP_21041_SIAGEN_BNC 0x00000006L
#define TULIP_21041P2_SIACONN_BNC 0x0000EF09L
#define TULIP_21041P2_SIATXRX_BNC 0x0000F7FDL
#define TULIP_21041P2_SIAGEN_BNC 0x00000006L
/*
* 21142 SIA definitions
*/
#define TULIP_21142_PROBE_10BASET_TIMEOUT 2500
#define TULIP_21142_PROBE_AUIBNC_TIMEOUT 300
#define TULIP_21142_SIACONN_10BASET 0x00000001L
#define TULIP_21142_SIATXRX_10BASET 0x0000F3FFL
#define TULIP_21142_SIAGEN_10BASET 0x00000000L
#define TULIP_21142_SIACONN_10BASET_FD 0x00000001L
#define TULIP_21142_SIATXRX_10BASET_FD 0x0000F3FDL
#define TULIP_21142_SIAGEN_10BASET_FD 0x00000000L
#define TULIP_21142_SIACONN_AUI 0x00000009L
#define TULIP_21142_SIATXRX_AUI 0x0000F3FDL
#define TULIP_21142_SIAGEN_AUI 0x0000000EL
#define TULIP_21142_SIACONN_BNC 0x00000009L
#define TULIP_21142_SIATXRX_BNC 0x0000F3FDL
#define TULIP_21142_SIAGEN_BNC 0x00000006L
#define TULIP_WATCHDOG_TXDISABLE 0x00000001L
#define TULIP_WATCHDOG_RXDISABLE 0x00000010L
#define TULIP_BUSMODE_SWRESET 0x00000001L
#define TULIP_BUSMODE_DESCSKIPLEN_MASK 0x0000007CL
#define TULIP_BUSMODE_BIGENDIAN 0x00000080L
#define TULIP_BUSMODE_BURSTLEN_MASK 0x00003F00L
#define TULIP_BUSMODE_BURSTLEN_DEFAULT 0x00000000L
#define TULIP_BUSMODE_BURSTLEN_1LW 0x00000100L
#define TULIP_BUSMODE_BURSTLEN_2LW 0x00000200L
#define TULIP_BUSMODE_BURSTLEN_4LW 0x00000400L
#define TULIP_BUSMODE_BURSTLEN_8LW 0x00000800L
#define TULIP_BUSMODE_BURSTLEN_16LW 0x00001000L
#define TULIP_BUSMODE_BURSTLEN_32LW 0x00002000L
#define TULIP_BUSMODE_CACHE_NOALIGN 0x00000000L
#define TULIP_BUSMODE_CACHE_ALIGN8 0x00004000L
#define TULIP_BUSMODE_CACHE_ALIGN16 0x00008000L
#define TULIP_BUSMODE_CACHE_ALIGN32 0x0000C000L
#define TULIP_BUSMODE_TXPOLL_NEVER 0x00000000L
#define TULIP_BUSMODE_TXPOLL_200000ns 0x00020000L
#define TULIP_BUSMODE_TXPOLL_800000ns 0x00040000L
#define TULIP_BUSMODE_TXPOLL_1600000ns 0x00060000L
#define TULIP_BUSMODE_TXPOLL_12800ns 0x00080000L /* 21041 only */
#define TULIP_BUSMODE_TXPOLL_25600ns 0x000A0000L /* 21041 only */
#define TULIP_BUSMODE_TXPOLL_51200ns 0x000C0000L /* 21041 only */
#define TULIP_BUSMODE_TXPOLL_102400ns 0x000E0000L /* 21041 only */
#define TULIP_BUSMODE_DESC_BIGENDIAN 0x00100000L /* 21041 only */
#define TULIP_BUSMODE_READMULTIPLE 0x00200000L /* */
#define TULIP_REG_CFDA 0x40
#define TULIP_CFDA_SLEEP 0x80000000L
#define TULIP_CFDA_SNOOZE 0x40000000L
#define TULIP_GP_PINSET 0x00000100L
/*
* These are the defintitions used for the DEC 21140
* evaluation board.
*/
#define TULIP_GP_EB_PINS 0x0000001F /* General Purpose Pin directions */
#define TULIP_GP_EB_OK10 0x00000080 /* 10 Mb/sec Signal Detect gep<7> */
#define TULIP_GP_EB_OK100 0x00000040 /* 100 Mb/sec Signal Detect gep<6> */
#define TULIP_GP_EB_INIT 0x0000000B /* No loopback --- point-to-point */
/*
* These are the defintitions used for the SMC9332 (21140) board.
*/
#define TULIP_GP_SMC_9332_PINS 0x0000003F /* General Purpose Pin directions */
#define TULIP_GP_SMC_9332_OK10 0x00000080 /* 10 Mb/sec Signal Detect gep<7> */
#define TULIP_GP_SMC_9332_OK100 0x00000040 /* 100 Mb/sec Signal Detect gep<6> */
#define TULIP_GP_SMC_9332_INIT 0x00000009 /* No loopback --- point-to-point */
#define TULIP_OUI_SMC_0 0x00
#define TULIP_OUI_SMC_1 0x00
#define TULIP_OUI_SMC_2 0xC0
/*
* There are the definitions used for the DEC DE500
* 10/100 family of boards
*/
#define TULIP_GP_DE500_PINS 0x0000001FL
#define TULIP_GP_DE500_LINK_PASS 0x00000080L
#define TULIP_GP_DE500_SYM_LINK 0x00000040L
#define TULIP_GP_DE500_SIGNAL_DETECT 0x00000020L
#define TULIP_GP_DE500_PHY_RESET 0x00000010L
#define TULIP_GP_DE500_HALFDUPLEX 0x00000008L
#define TULIP_GP_DE500_PHY_LOOPBACK 0x00000004L
#define TULIP_GP_DE500_FORCE_LED 0x00000002L
#define TULIP_GP_DE500_FORCE_100 0x00000001L
/*
* These are the defintitions used for the Cogent EM100
* 21140 board.
*/
#define TULIP_GP_EM100_PINS 0x0000003F /* General Purpose Pin directions */
#define TULIP_GP_EM100_INIT 0x00000009 /* No loopback --- point-to-point */
#define TULIP_OUI_COGENT_0 0x00
#define TULIP_OUI_COGENT_1 0x00
#define TULIP_OUI_COGENT_2 0x92
#define TULIP_COGENT_EM100_ID 0x12
/*
* These are the defintitions used for the Znyx ZX342
* 10/100 board
*/
#define TULIP_OUI_ZNYX_0 0x00
#define TULIP_OUI_ZNYX_1 0xC0
#define TULIP_OUI_ZNYX_2 0x95
#define TULIP_ZNYX_ID_ZX312 0x0602
#define TULIP_ZNYX_ID_ZX312T 0x0622
#define TULIP_ZNYX_ID_ZX314_INTA 0x0701
#define TULIP_ZNYX_ID_ZX314 0x0711
#define TULIP_ZNYX_ID_ZX315_INTA 0x0801
#define TULIP_ZNYX_ID_ZX315 0x0811
#define TULIP_ZNYX_ID_ZX342 0x0901
#define TULIP_ZNYX_ID_ZX342B 0x0921
#define TULIP_ZNYX_ID_ZX342_X3 0x0902
#define TULIP_ZNYX_ID_ZX342_X4 0x0903
#define TULIP_ZNYX_ID_ZX344 0x0A01
#define TULIP_ZNYX_ID_ZX351 0x0B01
#define TULIP_ZNYX_ID_ZX345 0x0C01
#define TULIP_ZNYX_ID_ZX311 0x0D01
#define TULIP_ZNYX_ID_ZX346 0x0E01
#define TULIP_GP_ZX34X_PINS 0x0000001F /* General Purpose Pin directions */
#define TULIP_GP_ZX344_PINS 0x0000000B /* General Purpose Pin directions */
#define TULIP_GP_ZX345_PINS 0x00000003 /* General Purpose Pin directions */
#define TULIP_GP_ZX346_PINS 0x00000043 /* General Purpose Pin directions */
#define TULIP_GP_ZX34X_LNKFAIL 0x00000080 /* 10Mb/s Link Failure */
#define TULIP_GP_ZX34X_SYMDET 0x00000040 /* 100Mb/s Symbol Detect */
#define TULIP_GP_ZX345_PHYACT 0x00000040 /* PHY Activity */
#define TULIP_GP_ZX34X_SIGDET 0x00000020 /* 100Mb/s Signal Detect */
#define TULIP_GP_ZX346_AUTONEG_ENABLED 0x00000020 /* 802.3u autoneg enabled */
#define TULIP_GP_ZX342_COLENA 0x00000008 /* 10t Ext LB */
#define TULIP_GP_ZX344_ROTINT 0x00000008 /* PPB IRQ rotation */
#define TULIP_GP_ZX345_SPEED10 0x00000008 /* 10Mb speed detect */
#define TULIP_GP_ZX346_SPEED100 0x00000008 /* 100Mb speed detect */
#define TULIP_GP_ZX34X_NCOLENA 0x00000004 /* 10t Int LB */
#define TULIP_GP_ZX34X_RXMATCH 0x00000004 /* RX Match */
#define TULIP_GP_ZX346_FULLDUPLEX 0x00000004 /* Full Duplex Sensed */
#define TULIP_GP_ZX34X_LB102 0x00000002 /* 100tx twister LB */
#define TULIP_GP_ZX34X_NLB101 0x00000001 /* PDT/PDR LB */
#define TULIP_GP_ZX34X_INIT 0x00000009
/*
* Compex's OUI. We need to twiddle a bit on their 21041 card.
*/
#define TULIP_OUI_COMPEX_0 0x00
#define TULIP_OUI_COMPEX_1 0x80
#define TULIP_OUI_COMPEX_2 0x48
#define TULIP_21041_COMPEX_XREGDATA 1
/*
* Asante's OUI and stuff...
*/
#define TULIP_OUI_ASANTE_0 0x00
#define TULIP_OUI_ASANTE_1 0x00
#define TULIP_OUI_ASANTE_2 0x94
#define TULIP_GP_ASANTE_PINS 0x000000bf /* GP pin config */
#define TULIP_GP_ASANTE_PHYRESET 0x00000008 /* Reset PHY */
/*
* SROM definitions for the 21140 and 21041.
*/
#define SROMXREG 0x0400
#define SROMSEL 0x0800
#define SROMRD 0x4000
#define SROMWR 0x2000
#define SROMDIN 0x0008
#define SROMDOUT 0x0004
#define SROMDOUTON 0x0004
#define SROMDOUTOFF 0x0004
#define SROMCLKON 0x0002
#define SROMCLKOFF 0x0002
#define SROMCSON 0x0001
#define SROMCSOFF 0x0001
#define SROMCS 0x0001
#define SROMCMD_MODE 4
#define SROMCMD_WR 5
#define SROMCMD_RD 6
#define SROM_BITWIDTH 6
/*
* MII Definitions for the 21041 and 21140/21140A/21142
*/
#define MII_PREAMBLE (~0)
#define MII_TEST 0xAAAAAAAA
#define MII_RDCMD 0xF6 /* 1111.0110 */
#define MII_WRCMD 0xF5 /* 1111.0101 */
#define MII_DIN 0x00080000
#define MII_RD 0x00040000
#define MII_WR 0x00000000
#define MII_DOUT 0x00020000
#define MII_CLK 0x00010000
#define MII_CLKON MII_CLK
#define MII_CLKOFF MII_CLK
#define PHYREG_CONTROL 0
#define PHYREG_STATUS 1
#define PHYREG_IDLOW 2
#define PHYREG_IDHIGH 3
#define PHYREG_AUTONEG_ADVERTISEMENT 4
#define PHYREG_AUTONEG_ABILITIES 5
#define PHYREG_AUTONEG_EXPANSION 6
#define PHYREG_AUTONEG_NEXTPAGE 7
#define PHYSTS_100BASET4 0x8000
#define PHYSTS_100BASETX_FD 0x4000
#define PHYSTS_100BASETX 0x2000
#define PHYSTS_10BASET_FD 0x1000
#define PHYSTS_10BASET 0x0800
#define PHYSTS_AUTONEG_DONE 0x0020
#define PHYSTS_REMOTE_FAULT 0x0010
#define PHYSTS_CAN_AUTONEG 0x0008
#define PHYSTS_LINK_UP 0x0004
#define PHYSTS_JABBER_DETECT 0x0002
#define PHYSTS_EXTENDED_REGS 0x0001
#define PHYCTL_RESET 0x8000
#define PHYCTL_SELECT_100MB 0x2000
#define PHYCTL_AUTONEG_ENABLE 0x1000
#define PHYCTL_ISOLATE 0x0400
#define PHYCTL_AUTONEG_RESTART 0x0200
#define PHYCTL_FULL_DUPLEX 0x0100
#define MII_RD 0x00040000
#define MII_WR 0x00000000
#define MII_DIN 0x00080000
#define MII_DOUT 0x00020000
#define MII_DOUTON MII_DOUT
#define MII_DOUTOFF MII_DOUT
#define MII_CLK 0x00010000
#define MII_CLKON MII_CLK
#define MII_CLKOFF MII_CLK
/*
* Definitions for the DE425.
*/
#define DE425_CFID 0x08 /* Configuration Id */
#define DE425_CFCS 0x0C /* Configuration Command-Status */
#define DE425_CFRV 0x18 /* Configuration Revision */
#define DE425_CFLT 0x1C /* Configuration Latency Timer */
#define DE425_CBIO 0x28 /* Configuration Base IO Address */
#define DE425_CFDA 0x2C /* Configuration Driver Area */
#define DE425_ENETROM_OFFSET 0xC90 /* Offset in I/O space for ENETROM */
#define DE425_CFG0 0xC88 /* IRQ register */
#define DE425_EISAID 0x10a34250 /* EISA device id */
#define DE425_EISA_IOSIZE 0x100
#define DEC_VENDORID 0x1011
#define CHIPID_21040 0x0002
#define CHIPID_21140 0x0009
#define CHIPID_21041 0x0014
#define CHIPID_21142 0x0019
#define PCI_VENDORID(x) ((x) & 0xFFFF)
#define PCI_CHIPID(x) (((x) >> 16) & 0xFFFF)
/*
* Generic SROM Format
*
*
*/
typedef struct {
u_int8_t sh_idbuf[18];
u_int8_t sh_version;
u_int8_t sh_adapter_count;
u_int8_t sh_ieee802_address[6];
} tulip_srom_header_t;
typedef struct {
u_int8_t sai_device;
u_int8_t sai_leaf_offset_lowbyte;
u_int8_t sai_leaf_offset_highbyte;
} tulip_srom_adapter_info_t;
typedef enum {
TULIP_SROM_CONNTYPE_10BASET =0x0000,
TULIP_SROM_CONNTYPE_BNC =0x0001,
TULIP_SROM_CONNTYPE_AUI =0x0002,
TULIP_SROM_CONNTYPE_100BASETX =0x0003,
TULIP_SROM_CONNTYPE_100BASET4 =0x0006,
TULIP_SROM_CONNTYPE_100BASEFX =0x0007,
TULIP_SROM_CONNTYPE_MII_10BASET =0x0009,
TULIP_SROM_CONNTYPE_MII_100BASETX =0x000D,
TULIP_SROM_CONNTYPE_MII_100BASET4 =0x000F,
TULIP_SROM_CONNTYPE_MII_100BASEFX =0x0010,
TULIP_SROM_CONNTYPE_10BASET_NWAY =0x0100,
TULIP_SROM_CONNTYPE_10BASET_FD =0x0204,
TULIP_SROM_CONNTYPE_MII_10BASET_FD =0x020A,
TULIP_SROM_CONNTYPE_100BASETX_FD =0x020E,
TULIP_SROM_CONNTYPE_MII_100BASETX_FD =0x0211,
TULIP_SROM_CONNTYPE_10BASET_NOLINKPASS =0x0400,
TULIP_SROM_CONNTYPE_AUTOSENSE =0x0800,
TULIP_SROM_CONNTYPE_AUTOSENSE_POWERUP =0x8800,
TULIP_SROM_CONNTYPE_AUTOSENSE_NWAY =0x9000,
TULIP_SROM_CONNTYPE_NOT_USED =0xFFFF
} tulip_srom_connection_t;
typedef enum {
TULIP_SROM_MEDIA_10BASET =0x0000,
TULIP_SROM_MEDIA_BNC =0x0001,
TULIP_SROM_MEDIA_AUI =0x0002,
TULIP_SROM_MEDIA_100BASETX =0x0003,
TULIP_SROM_MEDIA_10BASET_FD =0x0004,
TULIP_SROM_MEDIA_100BASETX_FD =0x0005,
TULIP_SROM_MEDIA_100BASET4 =0x0006,
TULIP_SROM_MEDIA_100BASEFX =0x0007,
TULIP_SROM_MEDIA_100BASEFX_FD =0x0008
} tulip_srom_media_t;
#define TULIP_SROM_21041_EXTENDED 0x40
#define TULIP_SROM_2114X_NOINDICATOR 0x8000
#define TULIP_SROM_2114X_DEFAULT 0x4000
#define TULIP_SROM_2114X_POLARITY 0x0080
#define TULIP_SROM_2114X_CMDBITS(n) (((n) & 0x0071) << 18)
#define TULIP_SROM_2114X_BITPOS(b) (1 << (((b) & 0x0E) >> 1))
#endif /* !defined(_DC21040_H) */

967
sys/pci/if_devar.h Normal file
View File

@ -0,0 +1,967 @@
/*-
* Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. The name of the author may not be used to endorse or promote products
* derived from this software withough specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: if_devar.h,v 1.22 1997/05/08 16:50:06 thomas Exp $
*/
#if !defined(_DEVAR_H)
#define _DEVAR_H
#if defined(__NetBSD__)
typedef bus_addr_t tulip_csrptr_t;
#define TULIP_CSR_READ(sc, csr) \
bus_space_read_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr)
#define TULIP_CSR_WRITE(sc, csr, val) \
bus_space_write_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val))
#define TULIP_CSR_READBYTE(sc, csr) \
bus_space_read_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr)
#define TULIP_CSR_WRITEBYTE(sc, csr, val) \
bus_space_write_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val))
#endif /* __NetBSD__ */
#ifdef TULIP_IOMAPPED
#define TULIP_EISA_CSRSIZE 16
#define TULIP_EISA_CSROFFSET 0
#define TULIP_PCI_CSRSIZE 8
#define TULIP_PCI_CSROFFSET 0
#if !defined(__NetBSD__)
typedef u_int16_t tulip_csrptr_t;
#define TULIP_CSR_READ(sc, csr) (inl((sc)->tulip_csrs.csr))
#define TULIP_CSR_WRITE(sc, csr, val) outl((sc)->tulip_csrs.csr, val)
#define TULIP_CSR_READBYTE(sc, csr) (inb((sc)->tulip_csrs.csr))
#define TULIP_CSR_WRITEBYTE(sc, csr, val) outb((sc)->tulip_csrs.csr, val)
#endif /* __NetBSD__ */
#else /* TULIP_IOMAPPED */
#define TULIP_PCI_CSRSIZE 8
#define TULIP_PCI_CSROFFSET 0
#if !defined(__NetBSD__)
typedef volatile u_int32_t *tulip_csrptr_t;
/*
* macros to read and write CSRs. Note that the "0 +" in
* READ_CSR is to prevent the macro from being an lvalue
* and WRITE_CSR shouldn't be assigned from.
*/
#define TULIP_CSR_READ(sc, csr) (0 + *(sc)->tulip_csrs.csr)
#define TULIP_CSR_WRITE(sc, csr, val) ((void)(*(sc)->tulip_csrs.csr = (val)))
#endif /* __NetBSD__ */
#endif /* TULIP_IOMAPPED */
/*
* This structure contains "pointers" for the registers on
* the various 21x4x chips. CSR0 through CSR8 are common
* to all chips. After that, it gets messy...
*/
typedef struct {
tulip_csrptr_t csr_busmode; /* CSR0 */
tulip_csrptr_t csr_txpoll; /* CSR1 */
tulip_csrptr_t csr_rxpoll; /* CSR2 */
tulip_csrptr_t csr_rxlist; /* CSR3 */
tulip_csrptr_t csr_txlist; /* CSR4 */
tulip_csrptr_t csr_status; /* CSR5 */
tulip_csrptr_t csr_command; /* CSR6 */
tulip_csrptr_t csr_intr; /* CSR7 */
tulip_csrptr_t csr_missed_frames; /* CSR8 */
tulip_csrptr_t csr_9; /* CSR9 */
tulip_csrptr_t csr_10; /* CSR10 */
tulip_csrptr_t csr_11; /* CSR11 */
tulip_csrptr_t csr_12; /* CSR12 */
tulip_csrptr_t csr_13; /* CSR13 */
tulip_csrptr_t csr_14; /* CSR14 */
tulip_csrptr_t csr_15; /* CSR15 */
} tulip_regfile_t;
#define csr_enetrom csr_9 /* 21040 */
#define csr_reserved csr_10 /* 21040 */
#define csr_full_duplex csr_11 /* 21040 */
#define csr_bootrom csr_10 /* 21041/21140A/?? */
#define csr_gp csr_12 /* 21140* */
#define csr_watchdog csr_15 /* 21140* */
#define csr_gp_timer csr_11 /* 21041/21140* */
#define csr_srom_mii csr_9 /* 21041/21140* */
#define csr_sia_status csr_12 /* 2104x */
#define csr_sia_connectivity csr_13 /* 2104x */
#define csr_sia_tx_rx csr_14 /* 2104x */
#define csr_sia_general csr_15 /* 2104x */
/*
* While 21x4x allows chaining of its descriptors, this driver
* doesn't take advantage of it. We keep the descriptors in a
* traditional FIFO ring.
*/
typedef struct {
tulip_desc_t *ri_first; /* first entry in ring */
tulip_desc_t *ri_last; /* one after last entry */
tulip_desc_t *ri_nextin; /* next to processed by host */
tulip_desc_t *ri_nextout; /* next to processed by adapter */
int ri_max;
int ri_free;
} tulip_ringinfo_t;
/*
* The 21040 has a stupid restriction in that the receive
* buffers must be longword aligned. But since Ethernet
* headers are not a multiple of longwords in size this forces
* the data to non-longword aligned. Since IP requires the
* data to be longword aligned, we need to copy it after it has
* been DMA'ed in our memory.
*
* Since we have to copy it anyways, we might as well as allocate
* dedicated receive space for the input. This allows to use a
* small receive buffer size and more ring entries to be able to
* better keep with a flood of tiny Ethernet packets.
*
* The receive space MUST ALWAYS be a multiple of the page size.
* And the number of receive descriptors multiplied by the size
* of the receive buffers must equal the recevive space. This
* is so that we can manipulate the page tables so that even if a
* packet wraps around the end of the receive space, we can
* treat it as virtually contiguous.
*
* The above used to be true (the stupid restriction is still true)
* but we gone to directly DMA'ing into MBUFs (unless it's on an
* architecture which can't handle unaligned accesses) because with
* 100Mb/s cards the copying is just too much of a hit.
*/
#if defined(__alpha__)
#define TULIP_COPY_RXDATA 1
#endif
#define TULIP_TXTIMER 4
#define TULIP_RXDESCS 48
#define TULIP_TXDESCS 128
#define TULIP_RXQ_TARGET 32
#if TULIP_RXQ_TARGET >= TULIP_RXDESCS
#error TULIP_RXQ_TARGET must be less than TULIP_RXDESCS
#endif
#define TULIP_RX_BUFLEN ((MCLBYTES < 2048 ? MCLBYTES : 2048) - 16)
/*
* Forward reference to make C happy.
*/
typedef struct _tulip_softc_t tulip_softc_t;
/*
* The various controllers support. Technically the DE425 is just
* a 21040 on EISA. But since it remarkably difference from normal
* 21040s, we give it its own chip id.
*/
typedef enum {
TULIP_21040, TULIP_DE425,
TULIP_21041,
TULIP_21140, TULIP_21140A, TULIP_21142,
TULIP_21143,
TULIP_CHIPID_UNKNOWN
} tulip_chipid_t;
/*
* Various physical media types supported.
* BNCAUI is BNC or AUI since on the 21040 you can't really tell
* which is in use.
*/
typedef enum {
TULIP_MEDIA_UNKNOWN,
TULIP_MEDIA_10BASET,
TULIP_MEDIA_10BASET_FD,
TULIP_MEDIA_BNC,
TULIP_MEDIA_AUI,
TULIP_MEDIA_EXTSIA,
TULIP_MEDIA_AUIBNC,
TULIP_MEDIA_100BASETX,
TULIP_MEDIA_100BASETX_FD,
TULIP_MEDIA_100BASET4,
TULIP_MEDIA_100BASEFX,
TULIP_MEDIA_100BASEFX_FD,
TULIP_MEDIA_MAX
} tulip_media_t;
#define TULIP_BIT(b) (1L << ((int)(b)))
#define TULIP_FDBIT(m) (1L << ((int)TULIP_MEDIA_ ## m ## _FD))
#define TULIP_MBIT(m) (1L << ((int)TULIP_MEDIA_ ## m ))
#define TULIP_IS_MEDIA_FD(m) (TULIP_BIT(m) & \
(TULIP_FDBIT(10BASET) \
|TULIP_FDBIT(100BASETX) \
|TULIP_FDBIT(100BASEFX)))
#define TULIP_CAN_MEDIA_FD(m) (TULIP_BIT(m) & \
(TULIP_MBIT(10BASET) \
|TULIP_MBIT(100BASETX) \
|TULIP_MBIT(100BASEFX)))
#define TULIP_FD_MEDIA_OF(m) ((tulip_media_t)((m) + 1))
#define TULIP_HD_MEDIA_OF(m) ((tulip_media_t)((m) - 1))
#define TULIP_IS_MEDIA_100MB(m) ((m) >= TULIP_MEDIA_100BASETX)
#define TULIP_IS_MEDIA_TP(m) ((TULIP_BIT(m) & \
(TULIP_MBIT(BNC) \
|TULIP_MBIT(AUI) \
|TULIP_MBIT(AUIBNC) \
|TULIP_MBIT(EXTSIA))) == 0)
#define TULIP_SROM_ATTR_MII 0x0100
#define TULIP_SROM_ATTR_NWAY 0x0200
#define TULIP_SROM_ATTR_AUTOSENSE 0x0400
#define TULIP_SROM_ATTR_POWERUP 0x0800
#define TULIP_SROM_ATTR_NOLINKPASS 0x1000
typedef struct {
enum {
TULIP_MEDIAINFO_SIA,
TULIP_MEDIAINFO_GPR,
TULIP_MEDIAINFO_MII,
TULIP_MEDIAINFO_RESET,
TULIP_MEDIAINFO_SYM
} mi_type;
union {
struct {
u_int16_t sia_connectivity;
u_int16_t sia_tx_rx;
u_int16_t sia_general;
u_int32_t sia_gp_control; /* 21142/21143 */
u_int32_t sia_gp_data; /* 21142/21143 */
} un_sia;
struct {
u_int32_t gpr_cmdmode;
u_int32_t gpr_gpcontrol; /* 21142/21143 */
u_int32_t gpr_gpdata;
u_int8_t gpr_actmask;
u_int8_t gpr_actdata;
u_int8_t gpr_default : 1;
} un_gpr;
struct {
u_int32_t mii_mediamask;
u_int16_t mii_capabilities;
u_int16_t mii_advertisement;
u_int16_t mii_full_duplex;
u_int16_t mii_tx_threshold;
u_int16_t mii_interrupt; /* 21142/21143 */
u_int8_t mii_phyaddr;
u_int8_t mii_gpr_length;
u_int8_t mii_gpr_offset;
u_int8_t mii_reset_length;
u_int8_t mii_reset_offset;
u_int32_t mii_phyid;
} un_mii;
} mi_un;
} tulip_media_info_t;
#define mi_sia_connectivity mi_un.un_sia.sia_connectivity
#define mi_sia_tx_rx mi_un.un_sia.sia_tx_rx
#define mi_sia_general mi_un.un_sia.sia_general
#define mi_sia_gp_control mi_un.un_sia.sia_gp_control
#define mi_sia_gp_data mi_un.un_sia.sia_gp_data
#define mi_gpcontrol mi_un.un_gpr.gpr_gpcontrol
#define mi_gpdata mi_un.un_gpr.gpr_gpdata
#define mi_actmask mi_un.un_gpr.gpr_actmask
#define mi_actdata mi_un.un_gpr.gpr_actdata
#define mi_default mi_un.un_gpr.gpr_default
#define mi_cmdmode mi_un.un_gpr.gpr_cmdmode
#define mi_phyaddr mi_un.un_mii.mii_phyaddr
#define mi_gpr_length mi_un.un_mii.mii_gpr_length
#define mi_gpr_offset mi_un.un_mii.mii_gpr_offset
#define mi_reset_length mi_un.un_mii.mii_reset_length
#define mi_reset_offset mi_un.un_mii.mii_reset_offset
#define mi_capabilities mi_un.un_mii.mii_capabilities
#define mi_advertisement mi_un.un_mii.mii_advertisement
#define mi_full_duplex mi_un.un_mii.mii_full_duplex
#define mi_tx_threshold mi_un.un_mii.mii_tx_threshold
#define mi_mediamask mi_un.un_mii.mii_mediamask
#define mi_mii_interrupt mi_un.un_mii.mii_interrupt
#define mi_phyid mi_un.un_mii.mii_phyid
#define TULIP_MEDIAINFO_SIA_INIT(sc, mi, chipid, media) do { \
(mi)->mi_type = TULIP_MEDIAINFO_SIA; \
sc->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
(mi)->mi_sia_connectivity = TULIP_ ## chipid ## _SIACONN_ ## media; \
(mi)->mi_sia_tx_rx = TULIP_ ## chipid ## _SIATXRX_ ## media; \
(mi)->mi_sia_general = TULIP_ ## chipid ## _SIAGEN_ ## media; \
} while (0)
#define TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, media) do { \
if ((sc)->tulip_mediums[TULIP_MEDIA_ ## media] == NULL \
&& ((mi)->mi_capabilities & PHYSTS_ ## media)) { \
(sc)->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
(mi)->mi_mediamask |= TULIP_BIT(TULIP_MEDIA_ ## media); \
} \
} while (0)
#define TULIP_MII_NOPHY 32
/*
* Some boards need to treated specially. The following enumeration
* identifies the cards with quirks (or those we just want to single
* out for special merit or scorn).
*/
typedef enum {
TULIP_21040_GENERIC, /* Generic 21040 (works with most any board) */
TULIP_21140_ISV, /* Digital Semicondutor 21140 ISV SROM Format */
TULIP_21142_ISV, /* Digital Semicondutor 21142 ISV SROM Format */
TULIP_21143_ISV, /* Digital Semicondutor 21143 ISV SROM Format */
TULIP_21140_DEC_EB, /* Digital Semicondutor 21140 Evaluation Board */
TULIP_21140_MII, /* 21140[A] with MII */
TULIP_21140_DEC_DE500, /* Digital DE500-?? 10/100 */
TULIP_21140_SMC_9332, /* SMC 9332 */
TULIP_21140_COGENT_EM100, /* Cogent EM100 100 only */
TULIP_21140_ZNYX_ZX34X, /* ZNYX ZX342 10/100 */
TULIP_21140_ASANTE, /* AsanteFast 10/100 */
TULIP_21041_GENERIC /* Generic 21041 card */
} tulip_board_t;
typedef enum {
TULIP_MEDIAPOLL_TIMER, /* 100ms timer fired */
TULIP_MEDIAPOLL_FASTTIMER, /* <100ms timer fired */
TULIP_MEDIAPOLL_LINKFAIL, /* called from interrupt routine */
TULIP_MEDIAPOLL_LINKPASS, /* called from interrupt routine */
TULIP_MEDIAPOLL_START, /* start a media probe (called from reset) */
TULIP_MEDIAPOLL_TXPROBE_OK, /* txprobe succeeded */
TULIP_MEDIAPOLL_TXPROBE_FAILED, /* txprobe failed */
TULIP_MEDIAPOLL_MAX
} tulip_mediapoll_event_t;
typedef enum {
TULIP_LINK_DOWN, /* Link is down */
TULIP_LINK_UP, /* link is ok */
TULIP_LINK_UNKNOWN /* we can't tell either way */
} tulip_link_status_t;
/*
* This data structure is used to abstract out the quirks.
* media_probe = tries to determine the media type.
* media_select = enables the current media (or autosenses)
* media_poll = autosenses media
* media_preset = 21140, etal requires bit to set before the
* the software reset; hence pre-set. Should be
* pre-reset but that's ugly.
*/
typedef struct {
tulip_board_t bd_type;
void (*bd_media_probe)(tulip_softc_t * const sc);
void (*bd_media_select)(tulip_softc_t * const sc);
void (*bd_media_poll)(tulip_softc_t * const sc, tulip_mediapoll_event_t event);
void (*bd_media_preset)(tulip_softc_t * const sc);
#if defined(__bsdi__) && _BSDI_VERSION >= 199701
struct ifmedia_entry *bd_media_list;
int bd_media_cnt;
int bd_media_options_mask;
#endif
} tulip_boardsw_t;
/*
* The next few declarations are for MII/PHY based board.
*
* The first enumeration identifies a superset of various datums
* that can be obtained from various PHY chips. Not all PHYs will
* support all datums.
* The modedata structure indicates what register contains
* a datum, what mask is applied the register contents, and what the
* result should be.
* The attr structure records information about a supported PHY.
* The phy structure records information about a PHY instance.
*/
typedef enum {
PHY_MODE_10T,
PHY_MODE_100TX,
PHY_MODE_100T4,
PHY_MODE_FULLDUPLEX,
PHY_MODE_MAX
} tulip_phy_mode_t;
typedef struct {
u_int16_t pm_regno;
u_int16_t pm_mask;
u_int16_t pm_value;
} tulip_phy_modedata_t;
typedef struct {
u_int32_t attr_id;
u_int16_t attr_flags;
#define PHY_NEED_HARD_RESET 0x0001
#define PHY_DUAL_CYCLE_TA 0x0002
tulip_phy_modedata_t attr_modes[PHY_MODE_MAX];
#ifdef TULIP_DEBUG
const char *attr_name;
#endif
} tulip_phy_attr_t;
/*
* Various probe states used when trying to autosense the media.
*/
typedef enum {
TULIP_PROBE_INACTIVE,
TULIP_PROBE_PHYRESET,
TULIP_PROBE_PHYAUTONEG,
TULIP_PROBE_GPRTEST,
TULIP_PROBE_MEDIATEST,
TULIP_PROBE_FAILED
} tulip_probe_state_t;
typedef struct {
/*
* Transmit Statistics
*/
u_int32_t dot3StatsSingleCollisionFrames;
u_int32_t dot3StatsMultipleCollisionFrames;
u_int32_t dot3StatsSQETestErrors;
u_int32_t dot3StatsDeferredTransmissions;
u_int32_t dot3StatsLateCollisions;
u_int32_t dot3StatsExcessiveCollisions;
u_int32_t dot3StatsInternalMacTransmitErrors;
u_int32_t dot3StatsCarrierSenseErrors;
/*
* Receive Statistics
*/
u_int32_t dot3StatsMissedFrames; /* not in rfc1650! */
u_int32_t dot3StatsAlignmentErrors;
u_int32_t dot3StatsFCSErrors;
u_int32_t dot3StatsFrameTooLongs;
u_int32_t dot3StatsInternalMacReceiveErrors;
} tulip_dot3_stats_t;
/*
* Now to important stuff. This is softc structure (where does softc
* come from??? No idea) for the tulip device.
*
*/
struct _tulip_softc_t {
#if defined(__bsdi__)
struct device tulip_dev; /* base device */
struct isadev tulip_id; /* ISA device */
struct intrhand tulip_ih; /* intrrupt vectoring */
struct atshutdown tulip_ats; /* shutdown hook */
#if _BSDI_VERSION < 199401
caddr_t tulip_bpf; /* for BPF */
#else
prf_t tulip_pf; /* printf function */
#if _BSDI_VERSION >= 199701
struct mii_data tulip_mii; /* Generic MII and media data */
#define tulip_ifmedia tulip_mii.mii_media
#endif /* _BSDI_VERSION >= 199701 */
#endif /* _BSDI_VERSION < 199401 */
#endif /* __bsdi__ */
#if defined(__NetBSD__)
struct device tulip_dev; /* base device */
void *tulip_ih; /* intrrupt vectoring */
void *tulip_ats; /* shutdown hook */
bus_space_tag_t tulip_bustag;
bus_space_handle_t tulip_bushandle; /* CSR region handle */
pci_chipset_tag_t tulip_pc;
struct ethercom tulip_ec;
u_int8_t tulip_enaddr[ETHER_ADDR_LEN];
#endif
#if !defined(tulip_ifmedia) && defined(IFM_ETHER)
struct ifmedia tulip_ifmedia;
#endif
#if !defined(__NetBSD__)
struct arpcom tulip_ac;
#endif
tulip_regfile_t tulip_csrs;
u_int32_t tulip_flags;
#define TULIP_WANTSETUP 0x00000001
#define TULIP_WANTHASHPERFECT 0x00000002
#define TULIP_WANTHASHONLY 0x00000004
#define TULIP_DOINGSETUP 0x00000008
#define TULIP_PRINTMEDIA 0x00000010
#define TULIP_TXPROBE_ACTIVE 0x00000020
#define TULIP_ALLMULTI 0x00000040
#define TULIP_WANTRXACT 0x00000080
#define TULIP_RXACT 0x00000100
#define TULIP_INRESET 0x00000200
#define TULIP_NEEDRESET 0x00000400
#define TULIP_SQETEST 0x00000800
#define TULIP_xxxxxx0 0x00001000
#define TULIP_xxxxxx1 0x00002000
#define TULIP_xxxxxx2 0x00004000
#define TULIP_xxxxxx3 0x00008000
#define TULIP_NOAUTOSENSE 0x00010000
#define TULIP_PRINTLINKUP 0x00020000
#define TULIP_LINKUP 0x00040000
#define TULIP_RXBUFSLOW 0x00080000
#define TULIP_NOMESSAGES 0x00100000
#define TULIP_SYSTEMERROR 0x00200000
#define TULIP_TIMEOUTPENDING 0x00400000
#define TULIP_FASTTIMEOUTPENDING 0x00800000
#define TULIP_TRYNWAY 0x01000000
#define TULIP_DIDNWAY 0x02000000
#define TULIP_RXIGNORE 0x04000000
#define TULIP_PROBE1STPASS 0x08000000
#define TULIP_DEVICEPROBE 0x10000000
#define TULIP_PROMISC 0x20000000
#define TULIP_HASHONLY 0x40000000
/* only 1 bit left! */
u_int32_t tulip_features; /* static bits indicating features of chip */
#define TULIP_HAVE_GPR 0x00000001 /* have gp register (140[A]) */
#define TULIP_HAVE_RXBADOVRFLW 0x00000002 /* RX corrupts on overflow */
#define TULIP_HAVE_POWERMGMT 0x00000004 /* Snooze/sleep modes */
#define TULIP_HAVE_MII 0x00000008 /* Some medium on MII */
#define TULIP_HAVE_SIANWAY 0x00000010 /* SIA does NWAY */
#define TULIP_HAVE_DUALSENSE 0x00000020 /* SIA senses both AUI & TP */
#define TULIP_HAVE_SIAGP 0x00000040 /* SIA has a GP port */
#define TULIP_HAVE_BROKEN_HASH 0x00000080 /* Broken Multicast Hash */
#define TULIP_HAVE_ISVSROM 0x00000100 /* uses ISV SROM Format */
#define TULIP_HAVE_BASEROM 0x00000200 /* Board ROM can be cloned */
#define TULIP_HAVE_SLAVEDROM 0x00000400 /* Board ROM cloned */
#define TULIP_HAVE_SLAVEDINTR 0x00000800 /* Board slaved interrupt */
#define TULIP_HAVE_SHAREDINTR 0x00001000 /* Board shares interrupts */
#define TULIP_HAVE_OKROM 0x00002000 /* ROM was recognized */
#define TULIP_HAVE_NOMEDIA 0x00004000 /* did not detect any media */
u_int32_t tulip_intrmask; /* our copy of csr_intr */
u_int32_t tulip_cmdmode; /* our copy of csr_cmdmode */
u_int32_t tulip_last_system_error : 3; /* last system error (only value is TULIP_SYSTEMERROR is also set) */
u_int32_t tulip_txtimer : 2; /* transmission timer */
u_int32_t tulip_system_errors; /* number of system errors encountered */
u_int32_t tulip_statusbits; /* status bits from CSR5 that may need to be printed */
tulip_media_info_t *tulip_mediums[TULIP_MEDIA_MAX]; /* indexes into mediainfo */
tulip_media_t tulip_media; /* current media type */
u_int32_t tulip_abilities; /* remote system's abiltities (as defined in IEEE 802.3u) */
u_int8_t tulip_revinfo; /* revision of chip */
u_int8_t tulip_phyaddr; /* 0..31 -- address of current phy */
u_int8_t tulip_gpinit; /* active pins on 21140 */
u_int8_t tulip_gpdata; /* default gpdata for 21140 */
struct {
u_int8_t probe_count; /* count of probe operations */
int32_t probe_timeout; /* time in ms of probe timeout */
tulip_probe_state_t probe_state; /* current media probe state */
tulip_media_t probe_media; /* current media being probed */
u_int32_t probe_mediamask; /* medias checked */
u_int32_t probe_passes; /* times autosense failed */
u_int32_t probe_txprobes; /* txprobes attempted */
} tulip_probe;
#define tulip_probe_count tulip_probe.probe_count
#define tulip_probe_timeout tulip_probe.probe_timeout
#define tulip_probe_state tulip_probe.probe_state
#define tulip_probe_media tulip_probe.probe_media
#define tulip_probe_mediamask tulip_probe.probe_mediamask
#define tulip_probe_passes tulip_probe.probe_passes
tulip_chipid_t tulip_chipid; /* type of chip we are using */
const tulip_boardsw_t *tulip_boardsw; /* board/chip characteristics */
tulip_softc_t *tulip_slaves; /* slaved devices (ZX3xx) */
#if defined(TULIP_DEBUG)
/*
* Debugging/Statistical information
*/
struct {
tulip_media_t dbg_last_media;
u_int32_t dbg_intrs;
u_int32_t dbg_media_probes;
u_int32_t dbg_txprobe_nocarr;
u_int32_t dbg_txprobe_exccoll;
u_int32_t dbg_link_downed;
u_int32_t dbg_link_suspected;
u_int32_t dbg_link_intrs;
u_int32_t dbg_link_pollintrs;
u_int32_t dbg_link_failures;
u_int32_t dbg_nway_starts;
u_int32_t dbg_nway_failures;
u_int16_t dbg_phyregs[32][4];
u_int32_t dbg_rxlowbufs;
u_int32_t dbg_rxintrs;
u_int32_t dbg_last_rxintrs;
u_int32_t dbg_high_rxintrs_hz;
u_int32_t dbg_txprobes_ok[TULIP_MEDIA_MAX];
u_int32_t dbg_txprobes_failed[TULIP_MEDIA_MAX];
u_int32_t dbg_events[TULIP_MEDIAPOLL_MAX];
u_int32_t dbg_rxpktsperintr[TULIP_RXDESCS];
} tulip_dbg;
#endif
struct ifqueue tulip_txq;
struct ifqueue tulip_rxq;
tulip_dot3_stats_t tulip_dot3stats;
tulip_ringinfo_t tulip_rxinfo;
tulip_ringinfo_t tulip_txinfo;
tulip_media_info_t tulip_mediainfo[10];
/*
* The setup buffers for sending the setup frame to the chip.
* one is the one being sent while the other is the one being
* filled.
*/
u_int32_t tulip_setupbuf[192/sizeof(u_int32_t)];
u_int32_t tulip_setupdata[192/sizeof(u_int32_t)];
char tulip_boardid[16]; /* buffer for board ID */
u_int8_t tulip_rombuf[128];
u_int8_t tulip_pci_busno; /* needed for multiport boards */
u_int8_t tulip_pci_devno; /* needed for multiport boards */
u_int8_t tulip_connidx;
tulip_srom_connection_t tulip_conntype;
tulip_desc_t tulip_rxdescs[TULIP_RXDESCS];
tulip_desc_t tulip_txdescs[TULIP_TXDESCS];
};
#if defined(IFM_ETHER)
#define TULIP_DO_AUTOSENSE(sc) (IFM_SUBTYPE((sc)->tulip_ifmedia.ifm_media) == IFM_AUTO)
#else
#define TULIP_DO_AUTOSENSE(sc) (((sc)->tulip_flags & TULIP_NOAUTOSENSE) == 0)
#endif
#if defined(TULIP_HDR_DATA)
static const char * const tulip_chipdescs[] = {
"21040 [10Mb/s]",
#if defined(TULIP_EISA)
"DE425 [10Mb/s]",
#else
NULL,
#endif
"21041 [10Mb/s]",
"21140 [10-100Mb/s]",
"21140A [10-100Mb/s]",
"21142 [10-100Mb/s]",
"21143 [10-100Mb/s]",
};
static const char * const tulip_mediums[] = {
"unknown", /* TULIP_MEDIA_UNKNOWN */
"10baseT", /* TULIP_MEDIA_10BASET */
"Full Duplex 10baseT", /* TULIP_MEDIA_10BASET_FD */
"BNC", /* TULIP_MEDIA_BNC */
"AUI", /* TULIP_MEDIA_AUI */
"External SIA", /* TULIP_MEDIA_EXTSIA */
"AUI/BNC", /* TULIP_MEDIA_AUIBNC */
"100baseTX", /* TULIP_MEDIA_100BASET */
"Full Duplex 100baseTX", /* TULIP_MEDIA_100BASET_FD */
"100baseT4", /* TULIP_MEDIA_100BASET4 */
"100baseFX", /* TULIP_MEDIA_100BASEFX */
"Full Duplex 100baseFX", /* TULIP_MEDIA_100BASEFX_FD */
};
#if defined(IFM_ETHER)
static const int tulip_media_to_ifmedia[] = {
IFM_ETHER | IFM_NONE, /* TULIP_MEDIA_UNKNOWN */
IFM_ETHER | IFM_10_T, /* TULIP_MEDIA_10BASET */
IFM_ETHER | IFM_10_T | IFM_FDX, /* TULIP_MEDIA_10BASET_FD */
IFM_ETHER | IFM_10_2, /* TULIP_MEDIA_BNC */
IFM_ETHER | IFM_10_5, /* TULIP_MEDIA_AUI */
IFM_ETHER | IFM_MANUAL, /* TULIP_MEDIA_EXTSIA */
IFM_ETHER | IFM_10_5, /* TULIP_MEDIA_AUIBNC */
IFM_ETHER | IFM_100_TX, /* TULIP_MEDIA_100BASET */
IFM_ETHER | IFM_100_TX | IFM_FDX, /* TULIP_MEDIA_100BASET_FD */
IFM_ETHER | IFM_100_T4, /* TULIP_MEDIA_100BASET4 */
IFM_ETHER | IFM_100_FX, /* TULIP_MEDIA_100BASEFX */
IFM_ETHER | IFM_100_FX | IFM_FDX, /* TULIP_MEDIA_100BASEFX_FD */
};
#endif /* defined(IFM_ETHER) */
static const char * const tulip_system_errors[] = {
"parity error",
"master abort",
"target abort",
"reserved #3",
"reserved #4",
"reserved #5",
"reserved #6",
"reserved #7",
};
static const char * const tulip_status_bits[] = {
NULL,
"transmit process stopped",
NULL,
"transmit jabber timeout",
NULL,
"transmit underflow",
NULL,
"receive underflow",
"receive process stopped",
"receive watchdog timeout",
NULL,
NULL,
"link failure",
NULL,
NULL,
};
static const struct {
tulip_srom_connection_t sc_type;
tulip_media_t sc_media;
u_int32_t sc_attrs;
} tulip_srom_conninfo[] = {
{ TULIP_SROM_CONNTYPE_10BASET, TULIP_MEDIA_10BASET },
{ TULIP_SROM_CONNTYPE_BNC, TULIP_MEDIA_BNC },
{ TULIP_SROM_CONNTYPE_AUI, TULIP_MEDIA_AUI },
{ TULIP_SROM_CONNTYPE_100BASETX, TULIP_MEDIA_100BASETX },
{ TULIP_SROM_CONNTYPE_100BASET4, TULIP_MEDIA_100BASET4 },
{ TULIP_SROM_CONNTYPE_100BASEFX, TULIP_MEDIA_100BASEFX },
{ TULIP_SROM_CONNTYPE_MII_10BASET, TULIP_MEDIA_10BASET,
TULIP_SROM_ATTR_MII },
{ TULIP_SROM_CONNTYPE_MII_100BASETX, TULIP_MEDIA_100BASETX,
TULIP_SROM_ATTR_MII },
{ TULIP_SROM_CONNTYPE_MII_100BASET4, TULIP_MEDIA_100BASET4,
TULIP_SROM_ATTR_MII },
{ TULIP_SROM_CONNTYPE_MII_100BASEFX, TULIP_MEDIA_100BASEFX,
TULIP_SROM_ATTR_MII },
{ TULIP_SROM_CONNTYPE_10BASET_NWAY, TULIP_MEDIA_10BASET,
TULIP_SROM_ATTR_NWAY },
{ TULIP_SROM_CONNTYPE_10BASET_FD, TULIP_MEDIA_10BASET_FD },
{ TULIP_SROM_CONNTYPE_MII_10BASET_FD, TULIP_MEDIA_10BASET_FD,
TULIP_SROM_ATTR_MII },
{ TULIP_SROM_CONNTYPE_100BASETX_FD, TULIP_MEDIA_100BASETX_FD },
{ TULIP_SROM_CONNTYPE_MII_100BASETX_FD, TULIP_MEDIA_100BASETX_FD,
TULIP_SROM_ATTR_MII },
{ TULIP_SROM_CONNTYPE_10BASET_NOLINKPASS, TULIP_MEDIA_10BASET,
TULIP_SROM_ATTR_NOLINKPASS },
{ TULIP_SROM_CONNTYPE_AUTOSENSE, TULIP_MEDIA_UNKNOWN,
TULIP_SROM_ATTR_AUTOSENSE },
{ TULIP_SROM_CONNTYPE_AUTOSENSE_POWERUP, TULIP_MEDIA_UNKNOWN,
TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_POWERUP },
{ TULIP_SROM_CONNTYPE_AUTOSENSE_NWAY, TULIP_MEDIA_UNKNOWN,
TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_NWAY },
{ TULIP_SROM_CONNTYPE_NOT_USED, TULIP_MEDIA_UNKNOWN }
};
#define TULIP_SROM_LASTCONNIDX \
(sizeof(tulip_srom_conninfo)/sizeof(tulip_srom_conninfo[0]) - 1)
static const struct {
tulip_media_t sm_type;
tulip_srom_media_t sm_srom_type;
} tulip_srom_mediums[] = {
{ TULIP_MEDIA_100BASEFX_FD, TULIP_SROM_MEDIA_100BASEFX_FD },
{ TULIP_MEDIA_100BASEFX, TULIP_SROM_MEDIA_100BASEFX },
{ TULIP_MEDIA_100BASET4, TULIP_SROM_MEDIA_100BASET4 },
{ TULIP_MEDIA_100BASETX_FD, TULIP_SROM_MEDIA_100BASETX_FD },
{ TULIP_MEDIA_100BASETX, TULIP_SROM_MEDIA_100BASETX },
{ TULIP_MEDIA_10BASET_FD, TULIP_SROM_MEDIA_10BASET_FD },
{ TULIP_MEDIA_AUI, TULIP_SROM_MEDIA_AUI },
{ TULIP_MEDIA_BNC, TULIP_SROM_MEDIA_BNC },
{ TULIP_MEDIA_10BASET, TULIP_SROM_MEDIA_10BASET },
{ TULIP_MEDIA_UNKNOWN }
};
#endif /* TULIP_HDR_DATA */
/*
* This driver supports a maximum of 32 tulip boards.
* This should be enough for the forseeable future.
*/
#define TULIP_MAX_DEVICES 32
#if defined(TULIP_USE_SOFTINTR) && defined(TULIP_HDR_DATA)
static u_int32_t tulip_softintr_mask;
static int tulip_softintr_last_unit;
static int tulip_softintr_max_unit;
static void tulip_softintr(void);
#endif
#ifdef notyet
#define SIOCGADDRROM _IOW('i', 240, struct ifreq) /* get 128 bytes of ROM */
#define SIOCGCHIPID _IOWR('i', 241, struct ifreq) /* get chipid */
#endif
#if defined(__FreeBSD__)
typedef void ifnet_ret_t;
typedef int ioctl_cmd_t;
#if defined(TULIP_HDR_DATA)
static tulip_softc_t *tulips[TULIP_MAX_DEVICES];
#endif
#if BSD >= 199506
#define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc))
#if NBPFILTER > 0
#define TULIP_BPF_MTAP(sc, m) bpf_mtap(&(sc)->tulip_if, m)
#define TULIP_BPF_TAP(sc, p, l) bpf_tap(&(sc)->tulip_if, p, l)
#define TULIP_BPF_ATTACH(sc) bpfattach(&(sc)->tulip_if, DLT_EN10MB, sizeof(struct ether_header))
#endif
#define tulip_intrfunc_t void
#define TULIP_VOID_INTRFUNC
#define IFF_NOTRAILERS 0
#define CLBYTES PAGE_SIZE
#if 0
#define TULIP_KVATOPHYS(sc, va) kvtop(va)
#endif
#define TULIP_EADDR_FMT "%6D"
#define TULIP_EADDR_ARGS(addr) addr, ":"
#else
extern int bootverbose;
#define TULIP_IFP_TO_SOFTC(ifp) (TULIP_UNIT_TO_SOFTC((ifp)->if_unit))
#include <sys/devconf.h>
#define TULIP_DEVCONF
#endif
#if defined(TULIP_USE_SOFTINTR)
NETISR_SET(NETISR_DE, tulip_softintr);
#endif
#define TULIP_UNIT_TO_SOFTC(unit) (tulips[unit])
#define TULIP_BURSTSIZE(unit) pci_max_burst_len
#define loudprintf if (bootverbose) printf
#endif
#if defined(__bsdi__)
typedef int ifnet_ret_t;
typedef u_long ioctl_cmd_t;
extern struct cfdriver decd;
#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) decd.cd_devs[unit])
#define TULIP_IFP_TO_SOFTC(ifp) (TULIP_UNIT_TO_SOFTC((ifp)->if_unit))
#if _BSDI_VERSION >= 199510
#if 0
#define TULIP_BURSTSIZE(unit) log2_burst_size
#endif
#define loudprintf aprint_verbose
#define printf (*sc->tulip_pf)
#define MCNT(x) (sizeof(x) / sizeof(struct ifmedia_entry))
#elif _BSDI_VERSION <= 199401
#define DRQNONE 0
#define loudprintf printf
static void
arp_ifinit(
struct arpcom *ac,
struct ifaddr *ifa)
{
ac->ac_ipaddr = IA_SIN(ifa)->sin_addr;
arpwhohas(ac, &ac->ac_ipaddr);
}
#endif
#endif /* __bsdi__ */
#if defined(__NetBSD__)
typedef void ifnet_ret_t;
typedef u_long ioctl_cmd_t;
extern struct cfattach de_ca;
extern struct cfdriver de_cd;
#define TULIP_UNIT_TO_SOFTC(unit) ((tulip_softc_t *) de_cd.cd_devs[unit])
#define TULIP_IFP_TO_SOFTC(ifp) ((tulip_softc_t *)((ifp)->if_softc))
#define tulip_unit tulip_dev.dv_unit
#define tulip_xname tulip_if.if_xname
#define TULIP_RAISESPL() splnet()
#define TULIP_RAISESOFTSPL() splsoftnet()
#define TULIP_RESTORESPL(s) splx(s)
#define tulip_if tulip_ec.ec_if
#define tulip_enaddr tulip_enaddr
#define tulip_multicnt tulip_ec.ec_multicnt
#define TULIP_ETHERCOM(sc) (&(sc)->tulip_ec)
#define TULIP_ARP_IFINIT(sc, ifa) arp_ifinit(&(sc)->tulip_if, (ifa))
#define TULIP_ETHER_IFATTACH(sc) ether_ifattach(&(sc)->tulip_if, (sc)->tulip_enaddr)
#define loudprintf printf
#define TULIP_PRINTF_FMT "%s"
#define TULIP_PRINTF_ARGS sc->tulip_xname
#if defined(__alpha__)
/* XXX XXX NEED REAL DMA MAPPING SUPPORT XXX XXX */
#define TULIP_KVATOPHYS(sc, va) alpha_XXX_dmamap((vm_offset_t)(va))
#endif
#endif /* __NetBSD__ */
#ifndef TULIP_PRINTF_FMT
#define TULIP_PRINTF_FMT "%s%d"
#endif
#ifndef TULIP_PRINTF_ARGS
#define TULIP_PRINTF_ARGS sc->tulip_name, sc->tulip_unit
#endif
#ifndef TULIP_BURSTSIZE
#define TULIP_BURSTSIZE(unit) 3
#endif
#ifndef tulip_if
#define tulip_if tulip_ac.ac_if
#endif
#ifndef tulip_unit
#define tulip_unit tulip_if.if_unit
#endif
#define tulip_name tulip_if.if_name
#ifndef tulip_enaddr
#define tulip_enaddr tulip_ac.ac_enaddr
#endif
#ifndef tulip_multicnt
#define tulip_multicnt tulip_ac.ac_multicnt
#endif
#if !defined(TULIP_ETHERCOM)
#define TULIP_ETHERCOM(sc) (&(sc)->tulip_ac)
#endif
#if !defined(TULIP_ARP_IFINIT)
#define TULIP_ARP_IFINIT(sc, ifa) arp_ifinit(TULIP_ETHERCOM(sc), (ifa))
#endif
#if !defined(TULIP_ETHER_IFATTACH)
#define TULIP_ETHER_IFATTACH(sc) ether_ifattach(&(sc)->tulip_if)
#endif
#if !defined(tulip_bpf) && (!defined(__bsdi__) || _BSDI_VERSION >= 199401)
#define tulip_bpf tulip_if.if_bpf
#endif
#if !defined(tulip_intrfunc_t)
#define tulip_intrfunc_t int
#endif
#if !defined(TULIP_KVATOPHYS)
#define TULIP_KVATOPHYS(sc, va) vtophys(va)
#endif
#ifndef TULIP_RAISESPL
#define TULIP_RAISESPL() splimp()
#endif
#ifndef TULIP_RAISESOFTSPL
#define TULIP_RAISESOFTSPL() splnet()
#endif
#ifndef TULUP_RESTORESPL
#define TULIP_RESTORESPL(s) splx(s)
#endif
/*
* While I think FreeBSD's 2.2 change to the bpf is a nice simplification,
* it does add yet more conditional code to this driver. Sigh.
*/
#if !defined(TULIP_BPF_MTAP) && NBPFILTER > 0
#define TULIP_BPF_MTAP(sc, m) bpf_mtap((sc)->tulip_bpf, m)
#define TULIP_BPF_TAP(sc, p, l) bpf_tap((sc)->tulip_bpf, p, l)
#define TULIP_BPF_ATTACH(sc) bpfattach(&(sc)->tulip_bpf, &(sc)->tulip_if, DLT_EN10MB, sizeof(struct ether_header))
#endif
/*
* However, this change to FreeBSD I am much less enamored with.
*/
#if !defined(TULIP_EADDR_FMT)
#define TULIP_EADDR_FMT "%s"
#define TULIP_EADDR_ARGS(addr) ether_sprintf(addr)
#endif
#define TULIP_CRC32_POLY 0xEDB88320UL /* CRC-32 Poly -- Little Endian */
#define TULIP_MAX_TXSEG 30
#define TULIP_ADDREQUAL(a1, a2) \
(((u_int16_t *)a1)[0] == ((u_int16_t *)a2)[0] \
&& ((u_int16_t *)a1)[1] == ((u_int16_t *)a2)[1] \
&& ((u_int16_t *)a1)[2] == ((u_int16_t *)a2)[2])
#define TULIP_ADDRBRDCST(a1) \
(((u_int16_t *)a1)[0] == 0xFFFFU \
&& ((u_int16_t *)a1)[1] == 0xFFFFU \
&& ((u_int16_t *)a1)[2] == 0xFFFFU)
typedef int tulip_spl_t;
#endif /* !defined(_DEVAR_H) */