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

Cache object: 1acae22d54e35180c55ef76c139f607b


[ 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.