The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/pci/if_devar.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

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

Cache object: f97a461a7659c12e478cdc583f14163a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.