[BACK]Return to if_devar.h CVS log [TXT][DIR] Up to [local] / sys / dev / pci

Annotation of sys/dev/pci/if_devar.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: if_devar.h,v 1.27 2006/07/08 04:15:36 brad Exp $      */
        !             2: /*     $NetBSD: if_devar.h,v 1.13 1997/06/08 18:46:36 thorpej Exp $    */
        !             3:
        !             4: /*-
        !             5:  * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms, with or without
        !             9:  * modification, are permitted provided that the following conditions
        !            10:  * are met:
        !            11:  * 1. Redistributions of source code must retain the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer.
        !            13:  * 2. The name of the author may not be used to endorse or promote products
        !            14:  *    derived from this software without specific prior written permission
        !            15:  *
        !            16:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            17:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            18:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            19:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            20:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            21:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            22:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            23:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            24:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            25:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            26:  *
        !            27:  * Id: if_devar.h,v 1.23 1997/06/03 18:51:16 thomas Exp
        !            28:  */
        !            29:
        !            30: #define TULIP_CSR_READ(sc, csr) \
        !            31:     bus_space_read_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr)
        !            32: #define TULIP_CSR_WRITE(sc, csr, val) \
        !            33:     bus_space_write_4((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val))
        !            34:
        !            35: #define TULIP_CSR_READBYTE(sc, csr) \
        !            36:     bus_space_read_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr)
        !            37: #define TULIP_CSR_WRITEBYTE(sc, csr, val) \
        !            38:     bus_space_write_1((sc)->tulip_bustag, (sc)->tulip_bushandle, (sc)->tulip_csrs.csr, (val))
        !            39:
        !            40: #ifdef TULIP_IOMAPPED
        !            41: #define        TULIP_PCI_CSRSIZE       8
        !            42: #define        TULIP_PCI_CSROFFSET     0
        !            43: #else /* TULIP_IOMAPPED */
        !            44: #define        TULIP_PCI_CSRSIZE       8
        !            45: #define        TULIP_PCI_CSROFFSET     0
        !            46: #endif /* TULIP_IOMAPPED */
        !            47:
        !            48: /*
        !            49:  * This structure contains "pointers" for the registers on
        !            50:  * the various 21x4x chips.  CSR0 through CSR8 are common
        !            51:  * to all chips.  After that, it gets messy...
        !            52:  */
        !            53: typedef struct {
        !            54:     bus_size_t csr_busmode;                    /* CSR0 */
        !            55:     bus_size_t csr_txpoll;                     /* CSR1 */
        !            56:     bus_size_t csr_rxpoll;                     /* CSR2 */
        !            57:     bus_size_t csr_rxlist;                     /* CSR3 */
        !            58:     bus_size_t csr_txlist;                     /* CSR4 */
        !            59:     bus_size_t csr_status;                     /* CSR5 */
        !            60:     bus_size_t csr_command;                    /* CSR6 */
        !            61:     bus_size_t csr_intr;                       /* CSR7 */
        !            62:     bus_size_t csr_missed_frames;              /* CSR8 */
        !            63:     bus_size_t csr_9;                  /* CSR9 */
        !            64:     bus_size_t csr_10;                 /* CSR10 */
        !            65:     bus_size_t csr_11;                 /* CSR11 */
        !            66:     bus_size_t csr_12;                 /* CSR12 */
        !            67:     bus_size_t csr_13;                 /* CSR13 */
        !            68:     bus_size_t csr_14;                 /* CSR14 */
        !            69:     bus_size_t csr_15;                 /* CSR15 */
        !            70: } tulip_regfile_t;
        !            71:
        !            72: #define        csr_enetrom             csr_9   /* 21040 */
        !            73: #define        csr_reserved            csr_10  /* 21040 */
        !            74: #define        csr_full_duplex         csr_11  /* 21040 */
        !            75: #define        csr_bootrom             csr_10  /* 21041/21140A/?? */
        !            76: #define        csr_gp                  csr_12  /* 21140* */
        !            77: #define        csr_watchdog            csr_15  /* 21140* */
        !            78: #define        csr_gp_timer            csr_11  /* 21041/21140* */
        !            79: #define        csr_srom_mii            csr_9   /* 21041/21140* */
        !            80: #define        csr_sia_status          csr_12  /* 2104x */
        !            81: #define csr_sia_connectivity   csr_13  /* 2104x */
        !            82: #define csr_sia_tx_rx          csr_14  /* 2104x */
        !            83: #define csr_sia_general                csr_15  /* 2104x */
        !            84:
        !            85: /*
        !            86:  * While 21x4x allows chaining of its descriptors, this driver
        !            87:  * doesn't take advantage of it.  We keep the descriptors in a
        !            88:  * traditional FIFO ring.
        !            89:  */
        !            90: typedef struct {
        !            91:     tulip_desc_t *ri_first;    /* first entry in ring */
        !            92:     tulip_desc_t *ri_last;     /* one after last entry */
        !            93:     tulip_desc_t *ri_nextin;   /* next to processed by host */
        !            94:     tulip_desc_t *ri_nextout;  /* next to processed by adapter */
        !            95:     int ri_max;
        !            96:     int ri_free;
        !            97: } tulip_ringinfo_t;
        !            98:
        !            99: /*
        !           100:  * The 21040 has a stupid restriction in that the receive
        !           101:  * buffers must be longword aligned.  But since Ethernet
        !           102:  * headers are not a multiple of longwords in size this forces
        !           103:  * the data to non-longword aligned.  Since IP requires the
        !           104:  * data to be longword aligned, we need to copy it after it has
        !           105:  * been DMA'ed in our memory.
        !           106:  *
        !           107:  * Since we have to copy it anyways, we might as well as allocate
        !           108:  * dedicated receive space for the input.  This allows to use a
        !           109:  * small receive buffer size and more ring entries to be able to
        !           110:  * better keep with a flood of tiny Ethernet packets.
        !           111:  *
        !           112:  * The receive space MUST ALWAYS be a multiple of the page size.
        !           113:  * And the number of receive descriptors multiplied by the size
        !           114:  * of the receive buffers must equal the recevive space.  This
        !           115:  * is so that we can manipulate the page tables so that even if a
        !           116:  * packet wraps around the end of the receive space, we can
        !           117:  * treat it as virtually contiguous.
        !           118:  *
        !           119:  * The above used to be true (the stupid restriction is still true)
        !           120:  * but we gone to directly DMA'ing into MBUFs (unless it's on an
        !           121:  * architecture which can't handle unaligned accesses) because with
        !           122:  * 100Mb/s cards the copying is just too much of a hit.
        !           123:  */
        !           124: #if !defined(__i386__)
        !           125: #define        TULIP_COPY_RXDATA       1
        !           126: #endif
        !           127:
        !           128: #define        TULIP_DATA_PER_DESC     2032
        !           129: #define        TULIP_TXTIMER           4
        !           130: #define        TULIP_RXDESCS           48
        !           131: #define        TULIP_TXDESCS           32
        !           132: #define        TULIP_RXQ_TARGET        32
        !           133: #if TULIP_RXQ_TARGET >= TULIP_RXDESCS
        !           134: #error TULIP_RXQ_TARGET must be less than TULIP_RXDESCS
        !           135: #endif
        !           136: #define        TULIP_RX_BUFLEN         ((MCLBYTES < 2048 ? MCLBYTES : 2048) - 16)
        !           137:
        !           138: /*
        !           139:  * Forward reference to make C happy.
        !           140:  */
        !           141: typedef struct _tulip_softc_t tulip_softc_t;
        !           142:
        !           143: /*
        !           144:  * The various controllers support.  Technically the DE425 is just
        !           145:  * a 21040 on EISA.  But since it remarkably difference from normal
        !           146:  * 21040s, we give it its own chip id.
        !           147:  */
        !           148:
        !           149: typedef enum {
        !           150:     TULIP_21040, TULIP_DE425,
        !           151:     TULIP_21041,
        !           152:     TULIP_21140, TULIP_21140A, TULIP_21142,
        !           153:     TULIP_21143,
        !           154:     TULIP_CHIPID_UNKNOWN
        !           155: } tulip_chipid_t;
        !           156:
        !           157: /*
        !           158:  * Various physical media types supported.
        !           159:  * BNCAUI is BNC or AUI since on the 21040 you can't really tell
        !           160:  * which is in use.
        !           161:  */
        !           162: typedef enum {
        !           163:     TULIP_MEDIA_UNKNOWN,
        !           164:     TULIP_MEDIA_10BASET,
        !           165:     TULIP_MEDIA_10BASET_FD,
        !           166:     TULIP_MEDIA_BNC,
        !           167:     TULIP_MEDIA_AUI,
        !           168:     TULIP_MEDIA_EXTSIA,
        !           169:     TULIP_MEDIA_AUIBNC,
        !           170:     TULIP_MEDIA_100BASETX,
        !           171:     TULIP_MEDIA_100BASETX_FD,
        !           172:     TULIP_MEDIA_100BASET4,
        !           173:     TULIP_MEDIA_100BASEFX,
        !           174:     TULIP_MEDIA_100BASEFX_FD,
        !           175:     TULIP_MEDIA_MAX
        !           176: } tulip_media_t;
        !           177:
        !           178: #define        TULIP_BIT(b)            (1L << ((int)(b)))
        !           179: #define        TULIP_FDBIT(m)          (1L << ((int)TULIP_MEDIA_ ## m ## _FD))
        !           180: #define        TULIP_MBIT(m)           (1L << ((int)TULIP_MEDIA_ ## m ))
        !           181: #define        TULIP_IS_MEDIA_FD(m)    (TULIP_BIT(m) & \
        !           182:                                 (TULIP_FDBIT(10BASET) \
        !           183:                                  |TULIP_FDBIT(100BASETX) \
        !           184:                                  |TULIP_FDBIT(100BASEFX)))
        !           185: #define        TULIP_CAN_MEDIA_FD(m)   (TULIP_BIT(m) & \
        !           186:                                 (TULIP_MBIT(10BASET) \
        !           187:                                  |TULIP_MBIT(100BASETX) \
        !           188:                                  |TULIP_MBIT(100BASEFX)))
        !           189: #define        TULIP_FD_MEDIA_OF(m)    ((tulip_media_t)((m) + 1))
        !           190: #define        TULIP_HD_MEDIA_OF(m)    ((tulip_media_t)((m) - 1))
        !           191: #define        TULIP_IS_MEDIA_100MB(m) ((m) >= TULIP_MEDIA_100BASETX)
        !           192: #define        TULIP_IS_MEDIA_TP(m)    ((TULIP_BIT(m) & \
        !           193:                                  (TULIP_MBIT(BNC) \
        !           194:                                   |TULIP_MBIT(AUI) \
        !           195:                                   |TULIP_MBIT(AUIBNC) \
        !           196:                                   |TULIP_MBIT(EXTSIA))) == 0)
        !           197:
        !           198: #define        TULIP_SROM_ATTR_MII             0x0100
        !           199: #define        TULIP_SROM_ATTR_NWAY            0x0200
        !           200: #define        TULIP_SROM_ATTR_AUTOSENSE       0x0400
        !           201: #define        TULIP_SROM_ATTR_POWERUP         0x0800
        !           202: #define        TULIP_SROM_ATTR_NOLINKPASS      0x1000
        !           203:
        !           204: typedef struct {
        !           205:     enum {
        !           206:        TULIP_MEDIAINFO_NONE,
        !           207:        TULIP_MEDIAINFO_SIA,
        !           208:        TULIP_MEDIAINFO_GPR,
        !           209:        TULIP_MEDIAINFO_MII,
        !           210:        TULIP_MEDIAINFO_RESET,
        !           211:        TULIP_MEDIAINFO_SYM
        !           212:     } mi_type;
        !           213:     union {
        !           214:        struct {
        !           215:            u_int16_t sia_connectivity;
        !           216:            u_int16_t sia_tx_rx;
        !           217:            u_int16_t sia_general;
        !           218:            u_int32_t sia_gp_control;   /* 21142/21143 */
        !           219:            u_int32_t sia_gp_data;      /* 21142/21143 */
        !           220:        } un_sia;
        !           221:        struct {
        !           222:            u_int32_t gpr_cmdmode;
        !           223:            u_int32_t gpr_gpcontrol;    /* 21142/21143 */
        !           224:            u_int32_t gpr_gpdata;
        !           225:            u_int8_t gpr_actmask;
        !           226:            u_int8_t gpr_actdata;
        !           227:            u_int8_t gpr_default : 1;
        !           228:        } un_gpr;
        !           229:        struct {
        !           230:            u_int32_t mii_mediamask;
        !           231:            u_int16_t mii_capabilities;
        !           232:            u_int16_t mii_advertisement;
        !           233:            u_int16_t mii_full_duplex;
        !           234:            u_int16_t mii_tx_threshold;
        !           235:            u_int16_t mii_interrupt;    /* 21142/21143 */
        !           236:            u_int8_t mii_phyaddr;
        !           237:            u_int8_t mii_gpr_length;
        !           238:            u_int8_t mii_gpr_offset;
        !           239:            u_int8_t mii_reset_length;
        !           240:            u_int8_t mii_reset_offset;
        !           241:            u_int32_t mii_phyid;
        !           242:        } un_mii;
        !           243:     } mi_un;
        !           244: } tulip_media_info_t;
        !           245:
        !           246: #define        mi_sia_connectivity     mi_un.un_sia.sia_connectivity
        !           247: #define        mi_sia_tx_rx            mi_un.un_sia.sia_tx_rx
        !           248: #define mi_sia_general         mi_un.un_sia.sia_general
        !           249: #define        mi_sia_gp_control       mi_un.un_sia.sia_gp_control
        !           250: #define        mi_sia_gp_data          mi_un.un_sia.sia_gp_data
        !           251:
        !           252: #define        mi_gpcontrol            mi_un.un_gpr.gpr_gpcontrol
        !           253: #define        mi_gpdata               mi_un.un_gpr.gpr_gpdata
        !           254: #define        mi_actmask              mi_un.un_gpr.gpr_actmask
        !           255: #define        mi_actdata              mi_un.un_gpr.gpr_actdata
        !           256: #define        mi_default              mi_un.un_gpr.gpr_default
        !           257: #define        mi_cmdmode              mi_un.un_gpr.gpr_cmdmode
        !           258:
        !           259: #define        mi_phyaddr              mi_un.un_mii.mii_phyaddr
        !           260: #define        mi_gpr_length           mi_un.un_mii.mii_gpr_length
        !           261: #define        mi_gpr_offset           mi_un.un_mii.mii_gpr_offset
        !           262: #define        mi_reset_length         mi_un.un_mii.mii_reset_length
        !           263: #define        mi_reset_offset         mi_un.un_mii.mii_reset_offset
        !           264: #define        mi_capabilities         mi_un.un_mii.mii_capabilities
        !           265: #define        mi_advertisement        mi_un.un_mii.mii_advertisement
        !           266: #define        mi_full_duplex          mi_un.un_mii.mii_full_duplex
        !           267: #define        mi_tx_threshold         mi_un.un_mii.mii_tx_threshold
        !           268: #define        mi_mediamask            mi_un.un_mii.mii_mediamask
        !           269: #define        mi_mii_interrupt        mi_un.un_mii.mii_interrupt
        !           270: #define        mi_phyid                mi_un.un_mii.mii_phyid
        !           271:
        !           272: #define        TULIP_MEDIAINFO_SIA_INIT(sc, mi, chipid, media) do { \
        !           273:     (mi)->mi_type = TULIP_MEDIAINFO_SIA; \
        !           274:     sc->tulip_mediums[TULIP_MEDIA_ ## media] = (mi); \
        !           275:     (mi)->mi_sia_connectivity = TULIP_ ## chipid ## _SIACONN_ ## media; \
        !           276:     (mi)->mi_sia_tx_rx        = TULIP_ ## chipid ## _SIATXRX_ ## media; \
        !           277:     (mi)->mi_sia_general      = TULIP_ ## chipid ## _SIAGEN_ ## media; \
        !           278: } while (0)
        !           279:
        !           280: #define TULIP_MEDIAINFO_ADD_CAPABILITY(sc, mi, media) do {     \
        !           281:     if ((sc)->tulip_mediums[TULIP_MEDIA_ ## media] == NULL     \
        !           282:            && ((mi)->mi_capabilities & PHYSTS_ ## media)) {    \
        !           283:        (sc)->tulip_mediums[TULIP_MEDIA_ ## media] = (mi);      \
        !           284:        (mi)->mi_mediamask |= TULIP_BIT(TULIP_MEDIA_ ## media); \
        !           285:     } \
        !           286: } while (0)
        !           287:
        !           288: #define        TULIP_MII_NOPHY         32
        !           289: /*
        !           290:  * Some boards need to treated specially.  The following enumeration
        !           291:  * identifies the cards with quirks (or those we just want to single
        !           292:  * out for special merit or scorn).
        !           293:  */
        !           294: typedef enum {
        !           295:     TULIP_21040_GENERIC,               /* Generic 21040 (works with most any board) */
        !           296:     TULIP_21140_ISV,                   /* Digital Semicondutor 21140 ISV SROM Format */
        !           297:     TULIP_21142_ISV,                   /* Digital Semicondutor 21142 ISV SROM Format */
        !           298:     TULIP_21143_ISV,                   /* Digital Semicondutor 21143 ISV SROM Format */
        !           299:     TULIP_21140_DEC_EB,                        /* Digital Semicondutor 21140 Evaluation Board */
        !           300:     TULIP_21140_MII,                   /* 21140[A] with MII */
        !           301:     TULIP_21140_DEC_DE500,             /* Digital DE500-?? 10/100 */
        !           302:     TULIP_21140_SMC_9332,              /* SMC 9332 */
        !           303:     TULIP_21140_COGENT_EM100,          /* Cogent EM100 100 only */
        !           304:     TULIP_21140_ZNYX_ZX34X,            /* ZNYX ZX342 10/100 */
        !           305:     TULIP_21140_ASANTE,                        /* AsanteFast 10/100 */
        !           306:     TULIP_21140_EN1207,                        /* Accton EN2107 10/100 BNC */
        !           307:     TULIP_21041_GENERIC                        /* Generic 21041 card */
        !           308: } tulip_board_t;
        !           309:
        !           310: typedef enum {
        !           311:     TULIP_MEDIAPOLL_TIMER,             /* 100ms timer fired */
        !           312:     TULIP_MEDIAPOLL_FASTTIMER,         /* <100ms timer fired */
        !           313:     TULIP_MEDIAPOLL_LINKFAIL,          /* called from interrupt routine */
        !           314:     TULIP_MEDIAPOLL_LINKPASS,          /* called from interrupt routine */
        !           315:     TULIP_MEDIAPOLL_START,             /* start a media probe (called from reset) */
        !           316:     TULIP_MEDIAPOLL_TXPROBE_OK,                /* txprobe succeeded */
        !           317:     TULIP_MEDIAPOLL_TXPROBE_FAILED,    /* txprobe failed */
        !           318:     TULIP_MEDIAPOLL_MAX
        !           319: } tulip_mediapoll_event_t;
        !           320:
        !           321: typedef enum {
        !           322:     TULIP_LINK_DOWN,                   /* Link is down */
        !           323:     TULIP_LINK_UP,                     /* link is ok */
        !           324:     TULIP_LINK_UNKNOWN                 /* we can't tell either way */
        !           325: } tulip_link_status_t;
        !           326:
        !           327: /*
        !           328:  * This data structure is used to abstract out the quirks.
        !           329:  * media_probe  = tries to determine the media type.
        !           330:  * media_select = enables the current media (or autosenses)
        !           331:  * media_poll  = autosenses media
        !           332:  * media_preset = 21140, etal requires bit to set before the
        !           333:  *               the software reset; hence pre-set.  Should be
        !           334:  *               pre-reset but that's ugly.
        !           335:  */
        !           336:
        !           337: typedef struct {
        !           338:     tulip_board_t bd_type;
        !           339:     void (*bd_media_probe)(tulip_softc_t * const sc);
        !           340:     void (*bd_media_select)(tulip_softc_t * const sc);
        !           341:     void (*bd_media_poll)(tulip_softc_t * const sc, tulip_mediapoll_event_t event);
        !           342:     void (*bd_media_preset)(tulip_softc_t * const sc);
        !           343: } tulip_boardsw_t;
        !           344:
        !           345: /*
        !           346:  * The next few declarations are for MII/PHY based board.
        !           347:  *
        !           348:  *    The first enumeration identifies a superset of various datums
        !           349:  * that can be obtained from various PHY chips.  Not all PHYs will
        !           350:  * support all datums.
        !           351:  *    The modedata structure indicates what register contains
        !           352:  * a datum, what mask is applied the register contents, and what the
        !           353:  * result should be.
        !           354:  *    The attr structure records information about a supported PHY.
        !           355:  *    The phy structure records information about a PHY instance.
        !           356:  */
        !           357:
        !           358: typedef enum {
        !           359:     PHY_MODE_10T,
        !           360:     PHY_MODE_100TX,
        !           361:     PHY_MODE_100T4,
        !           362:     PHY_MODE_FULLDUPLEX,
        !           363:     PHY_MODE_MAX
        !           364: } tulip_phy_mode_t;
        !           365:
        !           366: typedef struct {
        !           367:     u_int16_t pm_regno;
        !           368:     u_int16_t pm_mask;
        !           369:     u_int16_t pm_value;
        !           370: } tulip_phy_modedata_t;
        !           371:
        !           372: typedef struct {
        !           373:     u_int32_t attr_id;
        !           374:     u_int16_t attr_flags;
        !           375: #define        PHY_NEED_HARD_RESET     0x0001
        !           376: #define        PHY_DUAL_CYCLE_TA       0x0002
        !           377:     tulip_phy_modedata_t attr_modes[PHY_MODE_MAX];
        !           378: #ifdef TULIP_DEBUG
        !           379:     const char *attr_name;
        !           380: #endif
        !           381: } tulip_phy_attr_t;
        !           382:
        !           383: /*
        !           384:  * Various probe states used when trying to autosense the media.
        !           385:  */
        !           386:
        !           387: typedef enum {
        !           388:     TULIP_PROBE_INACTIVE,
        !           389:     TULIP_PROBE_PHYRESET,
        !           390:     TULIP_PROBE_PHYAUTONEG,
        !           391:     TULIP_PROBE_GPRTEST,
        !           392:     TULIP_PROBE_MEDIATEST,
        !           393:     TULIP_PROBE_FAILED
        !           394: } tulip_probe_state_t;
        !           395:
        !           396: typedef struct {
        !           397:     /*
        !           398:      * Transmit Statistics
        !           399:      */
        !           400:     u_int32_t dot3StatsSingleCollisionFrames;
        !           401:     u_int32_t dot3StatsMultipleCollisionFrames;
        !           402:     u_int32_t dot3StatsSQETestErrors;
        !           403:     u_int32_t dot3StatsDeferredTransmissions;
        !           404:     u_int32_t dot3StatsLateCollisions;
        !           405:     u_int32_t dot3StatsExcessiveCollisions;
        !           406:     u_int32_t dot3StatsCarrierSenseErrors;
        !           407:     u_int32_t dot3StatsInternalMacTransmitErrors;
        !           408:     u_int32_t dot3StatsInternalTransmitUnderflows;     /* not in rfc1650! */
        !           409:     u_int32_t dot3StatsInternalTransmitBabbles;                /* not in rfc1650! */
        !           410:     /*
        !           411:      * Receive Statistics
        !           412:      */
        !           413:     u_int32_t dot3StatsMissedFrames;   /* not in rfc1650! */
        !           414:     u_int32_t dot3StatsAlignmentErrors;
        !           415:     u_int32_t dot3StatsFCSErrors;
        !           416:     u_int32_t dot3StatsFrameTooLongs;
        !           417:     u_int32_t dot3StatsInternalMacReceiveErrors;
        !           418: } tulip_dot3_stats_t;
        !           419:
        !           420: /*
        !           421:  * Now to important stuff.  This is softc structure (where does softc
        !           422:  * come from??? No idea) for the tulip device.
        !           423:  *
        !           424:  */
        !           425: struct _tulip_softc_t {
        !           426:     struct device tulip_dev;           /* base device */
        !           427:     void *tulip_ih;                    /* intrrupt vectoring */
        !           428:     void *tulip_ats;                   /* shutdown hook */
        !           429:
        !           430:     bus_space_tag_t tulip_bustag;      /* tag of CSR region being used */
        !           431:     bus_space_handle_t tulip_bushandle;        /* handle for CSR region being used */
        !           432:     pci_chipset_tag_t tulip_pc;
        !           433:     u_int8_t tulip_enaddr[ETHER_ADDR_LEN];
        !           434:     struct ifmedia tulip_ifmedia;
        !           435:     bus_dma_tag_t tulip_dmatag;                /* bus DMA tag */
        !           436:     bus_dmamap_t tulip_setupmap;
        !           437:     bus_dmamap_t tulip_txdescmap;
        !           438:     bus_dmamap_t tulip_txmaps[TULIP_TXDESCS];
        !           439:     unsigned tulip_txmaps_free;
        !           440:     bus_dmamap_t tulip_rxdescmap;
        !           441:     bus_dmamap_t tulip_rxmaps[TULIP_RXDESCS];
        !           442:     unsigned tulip_rxmaps_free;
        !           443:     struct arpcom tulip_ac;
        !           444:     struct timeout tulip_ftmo, tulip_stmo;
        !           445:     tulip_regfile_t tulip_csrs;
        !           446:     u_int32_t tulip_flags;
        !           447: #define        TULIP_WANTSETUP         0x00000001
        !           448: #define        TULIP_WANTHASHPERFECT   0x00000002
        !           449: #define        TULIP_WANTHASHONLY      0x00000004
        !           450: #define        TULIP_DOINGSETUP        0x00000008
        !           451: #define        TULIP_PRINTMEDIA        0x00000010
        !           452: #define        TULIP_TXPROBE_ACTIVE    0x00000020
        !           453: #define        TULIP_ALLMULTI          0x00000040
        !           454: #define        TULIP_WANTRXACT         0x00000080
        !           455: #define        TULIP_RXACT             0x00000100
        !           456: #define        TULIP_INRESET           0x00000200
        !           457: #define        TULIP_NEEDRESET         0x00000400
        !           458: #define        TULIP_SQETEST           0x00000800
        !           459: #define        TULIP_FULLDUPLEX        0x00001000
        !           460: #define        TULIP_xxxxxx1           0x00002000
        !           461: #define        TULIP_WANTTXSTART       0x00004000
        !           462: #define        TULIP_NEWTXTHRESH       0x00008000
        !           463: #define        TULIP_NOAUTOSENSE       0x00010000
        !           464: #define        TULIP_PRINTLINKUP       0x00020000
        !           465: #define        TULIP_LINKUP            0x00040000
        !           466: #define        TULIP_RXBUFSLOW         0x00080000
        !           467: #define        TULIP_NOMESSAGES        0x00100000
        !           468: #define        TULIP_SYSTEMERROR       0x00200000
        !           469: #define        TULIP_TIMEOUTPENDING    0x00400000
        !           470: #define        TULIP_xxxxxx2           0x00800000
        !           471: #define        TULIP_TRYNWAY           0x01000000
        !           472: #define        TULIP_DIDNWAY           0x02000000
        !           473: #define        TULIP_RXIGNORE          0x04000000
        !           474: #define        TULIP_PROBE1STPASS      0x08000000
        !           475: #define        TULIP_DEVICEPROBE       0x10000000
        !           476: #define        TULIP_PROMISC           0x20000000
        !           477: #define        TULIP_HASHONLY          0x40000000
        !           478: #define        TULIP_xxxxxx3           0x80000000
        !           479:     /* only 4 bits left! */
        !           480:     u_int32_t tulip_features;  /* static bits indicating features of chip */
        !           481: #define        TULIP_HAVE_GPR          0x00000001      /* have gp register (140[A]) */
        !           482: #define        TULIP_HAVE_RXBADOVRFLW  0x00000002      /* RX corrupts on overflow */
        !           483: #define        TULIP_HAVE_POWERMGMT    0x00000004      /* Snooze/sleep modes */
        !           484: #define        TULIP_HAVE_MII          0x00000008      /* Some medium on MII */
        !           485: #define        TULIP_HAVE_SIANWAY      0x00000010      /* SIA does NWAY */
        !           486: #define        TULIP_HAVE_DUALSENSE    0x00000020      /* SIA senses both AUI & TP */
        !           487: #define        TULIP_HAVE_SIAGP        0x00000040      /* SIA has a GP port */
        !           488: #define        TULIP_HAVE_BROKEN_HASH  0x00000080      /* Broken Multicast Hash */
        !           489: #define        TULIP_HAVE_ISVSROM      0x00000100      /* uses ISV SROM Format */
        !           490: #define        TULIP_HAVE_BASEROM      0x00000200      /* Board ROM can be cloned */
        !           491: #define        TULIP_HAVE_SLAVEDROM    0x00000400      /* Board ROM cloned */
        !           492: #define        TULIP_HAVE_SLAVEDINTR   0x00000800      /* Board slaved interrupt */
        !           493: #define        TULIP_HAVE_SHAREDINTR   0x00001000      /* Board shares interrupts */
        !           494: #define        TULIP_HAVE_OKROM        0x00002000      /* ROM was recognized */
        !           495: #define        TULIP_HAVE_NOMEDIA      0x00004000      /* did not detect any media */
        !           496: #define        TULIP_HAVE_STOREFWD     0x00008000      /* have CMD_STOREFWD */
        !           497: #define        TULIP_HAVE_SIA100       0x00010000      /* has LS100 in SIA status */
        !           498: #define        TULIP_HAVE_OKSROM       0x00020000      /* SROM CRC is OK */
        !           499:     u_int32_t tulip_intrmask;  /* our copy of csr_intr */
        !           500:     u_int32_t tulip_cmdmode;   /* our copy of csr_cmdmode */
        !           501:     u_int32_t tulip_last_system_error : 3;     /* last system error (only value is
        !           502:                                                   TULIP_SYSTEMERROR is also set) */
        !           503:     u_int32_t tulip_txtimer;           /* transmission timer */
        !           504:     u_int32_t tulip_system_errors;     /* number of system errors encountered */
        !           505:     u_int32_t tulip_statusbits;        /* status bits from CSR5 that may need to be printed */
        !           506:
        !           507:     tulip_media_info_t *tulip_mediums[TULIP_MEDIA_MAX];        /* indexes into mediainfo */
        !           508:     tulip_media_t tulip_media;                 /* current media type */
        !           509:     u_int32_t tulip_abilities; /* remote system's abiltities (as defined in IEEE 802.3u) */
        !           510:
        !           511:     u_int8_t tulip_revinfo;                    /* revision of chip */
        !           512:     u_int8_t tulip_phyaddr;                    /* 0..31 -- address of current phy */
        !           513:     u_int8_t tulip_gpinit;                     /* active pins on 21140 */
        !           514:     u_int8_t tulip_gpdata;                     /* default gpdata for 21140 */
        !           515:
        !           516:     struct {
        !           517:        u_int8_t probe_count;                   /* count of probe operations */
        !           518:        int32_t probe_timeout;                  /* time in ms of probe timeout */
        !           519:        tulip_probe_state_t probe_state;        /* current media probe state */
        !           520:        tulip_media_t probe_media;              /* current media being probed */
        !           521:        u_int32_t probe_mediamask;              /* medias checked */
        !           522:        u_int32_t probe_passes;                 /* times autosense failed */
        !           523:        u_int32_t probe_txprobes;               /* txprobes attempted */
        !           524:     } tulip_probe;
        !           525: #define        tulip_probe_count       tulip_probe.probe_count
        !           526: #define        tulip_probe_timeout     tulip_probe.probe_timeout
        !           527: #define        tulip_probe_state       tulip_probe.probe_state
        !           528: #define        tulip_probe_media       tulip_probe.probe_media
        !           529: #define        tulip_probe_mediamask   tulip_probe.probe_mediamask
        !           530: #define        tulip_probe_passes      tulip_probe.probe_passes
        !           531:
        !           532:     tulip_chipid_t tulip_chipid;               /* type of chip we are using */
        !           533:     const tulip_boardsw_t *tulip_boardsw;      /* board/chip characteristics */
        !           534:     tulip_softc_t *tulip_slaves;               /* slaved devices (ZX3xx) */
        !           535: #if defined(TULIP_DEBUG)
        !           536:     /*
        !           537:      * Debugging/Statistical information
        !           538:      */
        !           539:     struct {
        !           540:        tulip_media_t dbg_last_media;
        !           541:        u_int32_t dbg_intrs;
        !           542:        u_int32_t dbg_media_probes;
        !           543:        u_int32_t dbg_txprobe_nocarr;
        !           544:        u_int32_t dbg_txprobe_exccoll;
        !           545:        u_int32_t dbg_link_downed;
        !           546:        u_int32_t dbg_link_suspected;
        !           547:        u_int32_t dbg_link_intrs;
        !           548:        u_int32_t dbg_link_pollintrs;
        !           549:        u_int32_t dbg_link_failures;
        !           550:        u_int32_t dbg_nway_starts;
        !           551:        u_int32_t dbg_nway_failures;
        !           552:        u_int16_t dbg_phyregs[32][4];
        !           553:        u_int32_t dbg_rxlowbufs;
        !           554:        u_int32_t dbg_rxintrs;
        !           555:        u_int32_t dbg_last_rxintrs;
        !           556:        u_int32_t dbg_high_rxintrs_hz;
        !           557:        u_int32_t dbg_no_txmaps;
        !           558:        u_int32_t dbg_txput_finishes[8];
        !           559:        u_int32_t dbg_txprobes_ok[TULIP_MEDIA_MAX];
        !           560:        u_int32_t dbg_txprobes_failed[TULIP_MEDIA_MAX];
        !           561:        u_int32_t dbg_events[TULIP_MEDIAPOLL_MAX];
        !           562:        u_int32_t dbg_rxpktsperintr[TULIP_RXDESCS];
        !           563:     } tulip_dbg;
        !           564: #endif
        !           565: #if defined(TULIP_PERFSTATS)
        !           566: #define        TULIP_PERF_CURRENT      0
        !           567: #define        TULIP_PERF_PREVIOUS     1
        !           568: #define        TULIP_PERF_TOTAL        2
        !           569: #define        TULIP_PERF_MAX          3
        !           570:     struct tulip_perfstats {
        !           571:        u_quad_t perf_intr_cycles;
        !           572:        u_quad_t perf_ifstart_cycles;
        !           573:        u_quad_t perf_ifioctl_cycles;
        !           574:        u_quad_t perf_ifwatchdog_cycles;
        !           575:        u_quad_t perf_timeout_cycles;
        !           576:        u_quad_t perf_txput_cycles;
        !           577:        u_quad_t perf_txintr_cycles;
        !           578:        u_quad_t perf_rxintr_cycles;
        !           579:        u_quad_t perf_rxget_cycles;
        !           580:        unsigned perf_intr;
        !           581:        unsigned perf_ifstart;
        !           582:        unsigned perf_ifioctl;
        !           583:        unsigned perf_ifwatchdog;
        !           584:        unsigned perf_timeout;
        !           585:        unsigned perf_txput;
        !           586:        unsigned perf_txintr;
        !           587:        unsigned perf_rxintr;
        !           588:        unsigned perf_rxget;
        !           589:     } tulip_perfstats[TULIP_PERF_MAX];
        !           590: #define        tulip_curperfstats              tulip_perfstats[TULIP_PERF_CURRENT]
        !           591: #endif
        !           592:     struct ifqueue tulip_txq;
        !           593:     struct ifqueue tulip_rxq;
        !           594:     tulip_dot3_stats_t tulip_dot3stats;
        !           595:     tulip_ringinfo_t tulip_rxinfo;
        !           596:     tulip_ringinfo_t tulip_txinfo;
        !           597:     tulip_media_info_t tulip_mediainfo[10];
        !           598:     /*
        !           599:      * The setup buffers for sending the setup frame to the chip.
        !           600:      * one is the one being sent while the other is the one being
        !           601:      * filled.
        !           602:      */
        !           603:     u_int32_t tulip_setupbuf[192/sizeof(u_int32_t)];
        !           604:     u_int32_t tulip_setupdata[192/sizeof(u_int32_t)];
        !           605:     char tulip_boardid[16];            /* buffer for board ID */
        !           606:     u_int8_t tulip_rombuf[128];
        !           607:     struct device *tulip_pci_busno;    /* needed for multiport boards */
        !           608:     u_int8_t tulip_pci_devno;          /* needed for multiport boards */
        !           609:     u_int8_t tulip_connidx;
        !           610:     tulip_srom_connection_t tulip_conntype;
        !           611:     tulip_desc_t *tulip_rxdescs;
        !           612:     tulip_desc_t *tulip_txdescs;
        !           613: };
        !           614:
        !           615: #define        TULIP_DO_AUTOSENSE(sc)  (IFM_SUBTYPE((sc)->tulip_ifmedia.ifm_media) == IFM_AUTO)
        !           616:
        !           617: static const char * const tulip_chipdescs[] = {
        !           618:     "21040",
        !           619:     NULL,
        !           620:     "21041",
        !           621:     "21140",
        !           622:     "21140A",
        !           623:     "21142",
        !           624:     "21143",
        !           625:     "82C168",
        !           626: };
        !           627:
        !           628: #ifdef TULIP_DEBUG
        !           629: static const char * const tulip_mediums[] = {
        !           630:     "unknown",                 /* TULIP_MEDIA_UNKNOWN */
        !           631:     "10baseT",                 /* TULIP_MEDIA_10BASET */
        !           632:     "Full Duplex 10baseT",     /* TULIP_MEDIA_10BASET_FD */
        !           633:     "BNC",                     /* TULIP_MEDIA_BNC */
        !           634:     "AUI",                     /* TULIP_MEDIA_AUI */
        !           635:     "External SIA",            /* TULIP_MEDIA_EXTSIA */
        !           636:     "AUI/BNC",                 /* TULIP_MEDIA_AUIBNC */
        !           637:     "100baseTX",               /* TULIP_MEDIA_100BASET */
        !           638:     "Full Duplex 100baseTX",   /* TULIP_MEDIA_100BASET_FD */
        !           639:     "100baseT4",               /* TULIP_MEDIA_100BASET4 */
        !           640:     "100baseFX",               /* TULIP_MEDIA_100BASEFX */
        !           641:     "Full Duplex 100baseFX",   /* TULIP_MEDIA_100BASEFX_FD */
        !           642: };
        !           643: #endif
        !           644:
        !           645: static const int tulip_media_to_ifmedia[] = {
        !           646:     IFM_ETHER | IFM_NONE,              /* TULIP_MEDIA_UNKNOWN */
        !           647:     IFM_ETHER | IFM_10_T,              /* TULIP_MEDIA_10BASET */
        !           648:     IFM_ETHER | IFM_10_T | IFM_FDX,    /* TULIP_MEDIA_10BASET_FD */
        !           649:     IFM_ETHER | IFM_10_2,              /* TULIP_MEDIA_BNC */
        !           650:     IFM_ETHER | IFM_10_5,              /* TULIP_MEDIA_AUI */
        !           651:     IFM_ETHER | IFM_MANUAL,            /* TULIP_MEDIA_EXTSIA */
        !           652:     IFM_ETHER | IFM_10_5,              /* TULIP_MEDIA_AUIBNC */
        !           653:     IFM_ETHER | IFM_100_TX,            /* TULIP_MEDIA_100BASET */
        !           654:     IFM_ETHER | IFM_100_TX | IFM_FDX,  /* TULIP_MEDIA_100BASET_FD */
        !           655:     IFM_ETHER | IFM_100_T4,            /* TULIP_MEDIA_100BASET4 */
        !           656:     IFM_ETHER | IFM_100_FX,            /* TULIP_MEDIA_100BASEFX */
        !           657:     IFM_ETHER | IFM_100_FX | IFM_FDX,  /* TULIP_MEDIA_100BASEFX_FD */
        !           658: };
        !           659:
        !           660: #ifdef TULIP_DEBUG
        !           661: static const char * const tulip_system_errors[] = {
        !           662:     "parity error",
        !           663:     "master abort",
        !           664:     "target abort",
        !           665:     "reserved #3",
        !           666:     "reserved #4",
        !           667:     "reserved #5",
        !           668:     "reserved #6",
        !           669:     "reserved #7",
        !           670: };
        !           671:
        !           672: static const char * const tulip_status_bits[] = {
        !           673:     NULL,
        !           674:     "transmit process stopped",
        !           675:     NULL,
        !           676:     "transmit jabber timeout",
        !           677:
        !           678:     NULL,
        !           679:     "transmit underflow",
        !           680:     NULL,
        !           681:     "receive underflow",
        !           682:
        !           683:     "receive process stopped",
        !           684:     "receive watchdog timeout",
        !           685:     NULL,
        !           686:     NULL,
        !           687:
        !           688:     "link failure",
        !           689:     NULL,
        !           690:     NULL,
        !           691: };
        !           692: #endif
        !           693:
        !           694: static const struct {
        !           695:     tulip_srom_connection_t sc_type;
        !           696:     tulip_media_t sc_media;
        !           697:     u_int32_t sc_attrs;
        !           698: } tulip_srom_conninfo[] = {
        !           699:     { TULIP_SROM_CONNTYPE_10BASET,             TULIP_MEDIA_10BASET },
        !           700:     { TULIP_SROM_CONNTYPE_BNC,                 TULIP_MEDIA_BNC },
        !           701:     { TULIP_SROM_CONNTYPE_AUI,                 TULIP_MEDIA_AUI },
        !           702:     { TULIP_SROM_CONNTYPE_100BASETX,           TULIP_MEDIA_100BASETX },
        !           703:     { TULIP_SROM_CONNTYPE_100BASET4,           TULIP_MEDIA_100BASET4 },
        !           704:     { TULIP_SROM_CONNTYPE_100BASEFX,           TULIP_MEDIA_100BASEFX },
        !           705:     { TULIP_SROM_CONNTYPE_MII_10BASET,         TULIP_MEDIA_10BASET,
        !           706:                TULIP_SROM_ATTR_MII },
        !           707:     { TULIP_SROM_CONNTYPE_MII_100BASETX,       TULIP_MEDIA_100BASETX,
        !           708:                TULIP_SROM_ATTR_MII },
        !           709:     { TULIP_SROM_CONNTYPE_MII_100BASET4,       TULIP_MEDIA_100BASET4,
        !           710:                TULIP_SROM_ATTR_MII },
        !           711:     { TULIP_SROM_CONNTYPE_MII_100BASEFX,       TULIP_MEDIA_100BASEFX,
        !           712:                TULIP_SROM_ATTR_MII },
        !           713:     { TULIP_SROM_CONNTYPE_10BASET_NWAY,                TULIP_MEDIA_10BASET,
        !           714:                TULIP_SROM_ATTR_NWAY },
        !           715:     { TULIP_SROM_CONNTYPE_10BASET_FD,          TULIP_MEDIA_10BASET_FD },
        !           716:     { TULIP_SROM_CONNTYPE_MII_10BASET_FD,      TULIP_MEDIA_10BASET_FD,
        !           717:                TULIP_SROM_ATTR_MII },
        !           718:     { TULIP_SROM_CONNTYPE_100BASETX_FD,                TULIP_MEDIA_100BASETX_FD },
        !           719:     { TULIP_SROM_CONNTYPE_MII_100BASETX_FD,    TULIP_MEDIA_100BASETX_FD,
        !           720:                TULIP_SROM_ATTR_MII },
        !           721:     { TULIP_SROM_CONNTYPE_10BASET_NOLINKPASS,  TULIP_MEDIA_10BASET,
        !           722:                TULIP_SROM_ATTR_NOLINKPASS },
        !           723:     { TULIP_SROM_CONNTYPE_AUTOSENSE,           TULIP_MEDIA_UNKNOWN,
        !           724:                TULIP_SROM_ATTR_AUTOSENSE },
        !           725:     { TULIP_SROM_CONNTYPE_AUTOSENSE_POWERUP,   TULIP_MEDIA_UNKNOWN,
        !           726:                TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_POWERUP },
        !           727:     { TULIP_SROM_CONNTYPE_AUTOSENSE_NWAY,      TULIP_MEDIA_UNKNOWN,
        !           728:                TULIP_SROM_ATTR_AUTOSENSE|TULIP_SROM_ATTR_NWAY },
        !           729:     { TULIP_SROM_CONNTYPE_NOT_USED,            TULIP_MEDIA_UNKNOWN }
        !           730: };
        !           731: #define        TULIP_SROM_LASTCONNIDX  \
        !           732:                (sizeof(tulip_srom_conninfo)/sizeof(tulip_srom_conninfo[0]) - 1)
        !           733:
        !           734: static const struct {
        !           735:     tulip_media_t sm_type;
        !           736:     tulip_srom_media_t sm_srom_type;
        !           737: } tulip_srom_mediums[] = {
        !           738:     {  TULIP_MEDIA_100BASEFX_FD,       TULIP_SROM_MEDIA_100BASEFX_FD   },
        !           739:     {  TULIP_MEDIA_100BASEFX,          TULIP_SROM_MEDIA_100BASEFX      },
        !           740:     {  TULIP_MEDIA_100BASET4,          TULIP_SROM_MEDIA_100BASET4      },
        !           741:     {  TULIP_MEDIA_100BASETX_FD,       TULIP_SROM_MEDIA_100BASETX_FD   },
        !           742:     {  TULIP_MEDIA_100BASETX,          TULIP_SROM_MEDIA_100BASETX      },
        !           743:     {  TULIP_MEDIA_10BASET_FD,         TULIP_SROM_MEDIA_10BASET_FD     },
        !           744:     {  TULIP_MEDIA_AUI,                TULIP_SROM_MEDIA_AUI            },
        !           745:     {  TULIP_MEDIA_BNC,                TULIP_SROM_MEDIA_BNC            },
        !           746:     {  TULIP_MEDIA_10BASET,            TULIP_SROM_MEDIA_10BASET        },
        !           747:     {  TULIP_MEDIA_UNKNOWN                                             }
        !           748: };
        !           749:
        !           750: /*
        !           751:  * This driver supports a maximum of 32 tulip boards.
        !           752:  * This should be enough for the forseeable future.
        !           753:  */
        !           754: #define        TULIP_MAX_DEVICES       32
        !           755:
        !           756: #define TULIP_RXDESC_PRESYNC(sc, di, s)        \
        !           757:        bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_rxdescmap, \
        !           758:                   (caddr_t) di - (caddr_t) (sc)->tulip_rxdescs, \
        !           759:                   (s), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
        !           760: #define TULIP_RXDESC_POSTSYNC(sc, di, s)       \
        !           761:        bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_rxdescmap, \
        !           762:                   (caddr_t) di - (caddr_t) (sc)->tulip_rxdescs, \
        !           763:                   (s), BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
        !           764: #define        TULIP_RXMAP_PRESYNC(sc, map) \
        !           765:        bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
        !           766:                        BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
        !           767: #define        TULIP_RXMAP_POSTSYNC(sc, map) \
        !           768:        bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
        !           769:                        BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
        !           770: #define        TULIP_RXMAP_CREATE(sc, mapp) \
        !           771:        bus_dmamap_create((sc)->tulip_dmatag, TULIP_RX_BUFLEN, 2, \
        !           772:                          TULIP_DATA_PER_DESC, 0, \
        !           773:                          BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, (mapp))
        !           774:
        !           775: #define TULIP_TXDESC_PRESYNC(sc, di, s)        \
        !           776:        bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_txdescmap, \
        !           777:                        (caddr_t) di - (caddr_t) (sc)->tulip_txdescs, \
        !           778:                        (s), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
        !           779: #define TULIP_TXDESC_POSTSYNC(sc, di, s)       \
        !           780:        bus_dmamap_sync((sc)->tulip_dmatag, (sc)->tulip_txdescmap, \
        !           781:                        (caddr_t) di - (caddr_t) (sc)->tulip_txdescs, \
        !           782:                        (s), BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
        !           783: #define        TULIP_TXMAP_PRESYNC(sc, map) \
        !           784:        bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
        !           785:                        BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
        !           786: #define        TULIP_TXMAP_POSTSYNC(sc, map) \
        !           787:        bus_dmamap_sync((sc)->tulip_dmatag, (map), 0, (map)->dm_mapsize, \
        !           788:                        BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
        !           789: #define        TULIP_TXMAP_CREATE(sc, mapp) \
        !           790:        bus_dmamap_create((sc)->tulip_dmatag, TULIP_DATA_PER_DESC, \
        !           791:                          TULIP_MAX_TXSEG, TULIP_DATA_PER_DESC, \
        !           792:                          0, BUS_DMA_NOWAIT, (mapp))
        !           793:
        !           794: extern struct cfattach de_ca;
        !           795: extern struct cfdriver de_cd;
        !           796: #define        TULIP_UNIT_TO_SOFTC(unit)       ((tulip_softc_t *) de_cd.cd_devs[unit])
        !           797: #define TULIP_IFP_TO_SOFTC(ifp)         ((tulip_softc_t *)((ifp)->if_softc))
        !           798: #define        tulip_unit                      tulip_dev.dv_unit
        !           799: #define tulip_xname                     tulip_dev.dv_cfdata->cf_driver->cd_name
        !           800:
        !           801: #define        TULIP_PRINTF_FMT                "%s%d"
        !           802: #define        TULIP_PRINTF_ARGS               sc->tulip_xname, sc->tulip_unit
        !           803:
        !           804: #define        TULIP_BURSTSIZE(unit)           3
        !           805:
        !           806: #define        tulip_if        tulip_ac.ac_if
        !           807: #define        tulip_name      tulip_if.if_name
        !           808: #define        tulip_enaddr    tulip_ac.ac_enaddr
        !           809: #define        tulip_multicnt  tulip_ac.ac_multicnt
        !           810:
        !           811: #define        tulip_bpf       tulip_if.if_bpf
        !           812:
        !           813: #define        tulip_intrfunc_t        int
        !           814:
        !           815: #if defined(TULIP_PERFSTATS)
        !           816: #define        TULIP_PERFMERGE(sc, member) \
        !           817:        do { (sc)->tulip_perfstats[TULIP_PERF_TOTAL].member \
        !           818:             += (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \
        !           819:         (sc)->tulip_perfstats[TULIP_PERF_PREVIOUS].member \
        !           820:              = (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member; \
        !           821:            (sc)->tulip_perfstats[TULIP_PERF_CURRENT].member = 0; } while (0)
        !           822: #define        TULIP_PERFSTART(name) const tulip_cycle_t perfstart_ ## name = TULIP_PERFREAD();
        !           823: #define        TULIP_PERFEND(name)     do { \
        !           824:            (sc)->tulip_curperfstats.perf_ ## name ## _cycles += TULIP_PERFDIFF(perfstart_ ## name, TULIP_PERFREAD()); \
        !           825:            (sc)->tulip_curperfstats.perf_ ## name++; \
        !           826:        } while (0)
        !           827: #if defined(__i386__)
        !           828: typedef u_quad_t tulip_cycle_t;
        !           829: static __inline__ tulip_cycle_t
        !           830: TULIP_PERFREAD(
        !           831:     void)
        !           832: {
        !           833:     tulip_cycle_t x;
        !           834:     __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
        !           835:     return x;
        !           836: }
        !           837: #define        TULIP_PERFDIFF(s, f)    ((f) - (s))
        !           838: #elif defined(__alpha__)
        !           839: typedef unsigned long tulip_cycle_t;
        !           840: static __inline__ tulip_cycle_t
        !           841: TULIP_PERFREAD(
        !           842:     void)
        !           843: {
        !           844:     tulip_cycle_t x;
        !           845:     __asm__ volatile ("rpcc %0" : "=r" (x));
        !           846:     return x;
        !           847: }
        !           848: #define        TULIP_PERFDIFF(s, f)    ((unsigned int) ((f) - (s)))
        !           849: #endif
        !           850: #else
        !           851: #define        TULIP_PERFSTART(name)
        !           852: #define        TULIP_PERFEND(name)     do { } while (0)
        !           853: #define        TULIP_PERFMERGE(s,n)    do { } while (0)
        !           854: #endif /* TULIP_PERFSTATS */
        !           855:
        !           856: #define        TULIP_MAX_TXSEG         30
        !           857:
        !           858: #define        TULIP_ADDREQUAL(a1, a2) \
        !           859:        (((u_int16_t *)a1)[0] == ((u_int16_t *)a2)[0] \
        !           860:         && ((u_int16_t *)a1)[1] == ((u_int16_t *)a2)[1] \
        !           861:         && ((u_int16_t *)a1)[2] == ((u_int16_t *)a2)[2])
        !           862: #define        TULIP_ADDRBRDCST(a1) \
        !           863:        (((u_int16_t *)a1)[0] == 0xFFFFU \
        !           864:         && ((u_int16_t *)a1)[1] == 0xFFFFU \
        !           865:         && ((u_int16_t *)a1)[2] == 0xFFFFU)
        !           866:
        !           867: #define TULIP_GETCTX(m, t)     ((t) (m)->m_pkthdr.rcvif + 0)
        !           868: #define TULIP_SETCTX(m, c)     ((void) ((m)->m_pkthdr.rcvif = (void *) (c)))

CVSweb