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/dev/ic/tulipvar.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: tulipvar.h,v 1.58 2006/03/25 23:10:50 rpaulo Exp $     */
    2 
    3 /*-
    4  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
    9  * NASA Ames Research Center.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  * 3. All advertising materials mentioning features or use of this software
   20  *    must display the following acknowledgement:
   21  *      This product includes software developed by the NetBSD
   22  *      Foundation, Inc. and its contributors.
   23  * 4. Neither the name of The NetBSD Foundation nor the names of its
   24  *    contributors may be used to endorse or promote products derived
   25  *    from this software without specific prior written permission.
   26  *
   27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 #ifndef _DEV_IC_TULIPVAR_H_
   41 #define _DEV_IC_TULIPVAR_H_
   42 
   43 #include "rnd.h"
   44 
   45 #include <sys/queue.h>
   46 #include <sys/callout.h>
   47 
   48 #if NRND > 0
   49 #include <sys/rnd.h>
   50 #endif
   51 
   52 /*
   53  * Misc. definitions for the Digital Semiconductor ``Tulip'' (21x4x)
   54  * Ethernet controller family driver.
   55  */
   56 
   57 /*
   58  * Transmit descriptor list size.  This is arbitrary, but allocate
   59  * enough descriptors for 64 pending transmissions and 16 segments
   60  * per packet.  Since a descriptor holds 2 buffer addresses, that's
   61  * 8 descriptors per packet.  This MUST work out to a power of 2.
   62  */
   63 #define TULIP_NTXSEGS           16
   64 
   65 #define TULIP_TXQUEUELEN        64
   66 #define TULIP_NTXDESC           (TULIP_TXQUEUELEN * TULIP_NTXSEGS)
   67 #define TULIP_NTXDESC_MASK      (TULIP_NTXDESC - 1)
   68 #define TULIP_NEXTTX(x)         ((x + 1) & TULIP_NTXDESC_MASK)
   69 
   70 /*
   71  * Receive descriptor list size.  We have one Rx buffer per incoming
   72  * packet, so this logic is a little simpler.
   73  */
   74 #define TULIP_NRXDESC           64
   75 #define TULIP_NRXDESC_MASK      (TULIP_NRXDESC - 1)
   76 #define TULIP_NEXTRX(x)         ((x + 1) & TULIP_NRXDESC_MASK)
   77 
   78 /*
   79  * Control structures are DMA'd to the TULIP chip.  We allocate them in
   80  * a single clump that maps to a single DMA segment to make several things
   81  * easier.
   82  */
   83 struct tulip_control_data {
   84         /*
   85          * The transmit descriptors.
   86          */
   87         struct tulip_desc tcd_txdescs[TULIP_NTXDESC];
   88 
   89         /*
   90          * The receive descriptors.
   91          */
   92         struct tulip_desc tcd_rxdescs[TULIP_NRXDESC];
   93 
   94         /*
   95          * The setup packet.
   96          */
   97         u_int32_t tcd_setup_packet[TULIP_SETUP_PACKET_LEN / sizeof(u_int32_t)];
   98 };
   99 
  100 #define TULIP_CDOFF(x)          offsetof(struct tulip_control_data, x)
  101 #define TULIP_CDTXOFF(x)        TULIP_CDOFF(tcd_txdescs[(x)])
  102 #define TULIP_CDRXOFF(x)        TULIP_CDOFF(tcd_rxdescs[(x)])
  103 #define TULIP_CDSPOFF           TULIP_CDOFF(tcd_setup_packet)
  104 
  105 /*
  106  * Software state for transmit jobs.
  107  */
  108 struct tulip_txsoft {
  109         struct mbuf *txs_mbuf;          /* head of our mbuf chain */
  110         bus_dmamap_t txs_dmamap;        /* our DMA map */
  111         int txs_firstdesc;              /* first descriptor in packet */
  112         int txs_lastdesc;               /* last descriptor in packet */
  113         int txs_ndescs;                 /* number of descriptors */
  114         SIMPLEQ_ENTRY(tulip_txsoft) txs_q;
  115 };
  116 
  117 SIMPLEQ_HEAD(tulip_txsq, tulip_txsoft);
  118 
  119 /*
  120  * Software state for receive jobs.
  121  */
  122 struct tulip_rxsoft {
  123         struct mbuf *rxs_mbuf;          /* head of our mbuf chain */
  124         bus_dmamap_t rxs_dmamap;        /* our DMA map */
  125 };
  126 
  127 /*
  128  * Type of Tulip chip we're dealing with.
  129  */
  130 typedef enum {
  131         TULIP_CHIP_INVALID   = 0,       /* invalid chip type */
  132         TULIP_CHIP_DE425     = 1,       /* DE-425 EISA */
  133         TULIP_CHIP_21040     = 2,       /* DECchip 21040 */
  134         TULIP_CHIP_21041     = 3,       /* DECchip 21041 */
  135         TULIP_CHIP_21140     = 4,       /* DECchip 21140 */
  136         TULIP_CHIP_21140A    = 5,       /* DECchip 21140A */
  137         TULIP_CHIP_21142     = 6,       /* DECchip 21142 */
  138         TULIP_CHIP_21143     = 7,       /* DECchip 21143 */
  139         TULIP_CHIP_82C168    = 8,       /* Lite-On 82C168 PNIC */
  140         TULIP_CHIP_82C169    = 9,       /* Lite-On 82C169 PNIC */
  141         TULIP_CHIP_82C115    = 10,      /* Lite-On 82C115 PNIC II */
  142         TULIP_CHIP_MX98713   = 11,      /* Macronix 98713 PMAC */
  143         TULIP_CHIP_MX98713A  = 12,      /* Macronix 98713A PMAC */
  144         TULIP_CHIP_MX98715   = 13,      /* Macronix 98715 PMAC */
  145         TULIP_CHIP_MX98715A  = 14,      /* Macronix 98715A PMAC */
  146         TULIP_CHIP_MX98715AEC_X = 15,   /* Macronix 98715AEC-C, -E PMAC */
  147         TULIP_CHIP_MX98725   = 16,      /* Macronix 98725 PMAC */
  148         TULIP_CHIP_WB89C840F = 17,      /* Winbond 89C840F */
  149         TULIP_CHIP_DM9102    = 18,      /* Davicom DM9102 */
  150         TULIP_CHIP_DM9102A   = 19,      /* Davicom DM9102A */
  151         TULIP_CHIP_AL981     = 20,      /* ADMtek AL981 */
  152         TULIP_CHIP_AN983     = 21,      /* ADMtek AN983 */
  153         TULIP_CHIP_AN985     = 22,      /* ADMtek AN985 */
  154         TULIP_CHIP_AX88140   = 23,      /* ASIX AX88140 */
  155         TULIP_CHIP_AX88141   = 24,      /* ASIX AX88141 */
  156         TULIP_CHIP_X3201_3   = 25,      /* Xircom X3201-3 */
  157         TULIP_CHIP_RS7112    = 26       /* Conexant RS7112 LANfinity */
  158 } tulip_chip_t;
  159 
  160 #define TULIP_CHIP_NAMES                                                \
  161 {                                                                       \
  162         NULL,                                                           \
  163         "DE-425",                                                       \
  164         "DECchip 21040",                                                \
  165         "DECchip 21041",                                                \
  166         "DECchip 21140",                                                \
  167         "DECchip 21140A",                                               \
  168         "DECchip 21142",                                                \
  169         "DECchip 21143",                                                \
  170         "Lite-On 82C168",                                               \
  171         "Lite-On 82C169",                                               \
  172         "Lite-On 82C115",                                               \
  173         "Macronix MX98713",                                             \
  174         "Macronix MX98713A",                                            \
  175         "Macronix MX98715",                                             \
  176         "Macronix MX98715A",                                            \
  177         "Macronix MX98715AEC-x",                                        \
  178         "Macronix MX98725",                                             \
  179         "Winbond 89C840F",                                              \
  180         "Davicom DM9102",                                               \
  181         "Davicom DM9102A",                                              \
  182         "ADMtek AL981",                                                 \
  183         "ADMtek AN983",                                                 \
  184         "ADMtek AN985",                                                 \
  185         "ASIX AX88140",                                                 \
  186         "ASIX AX88141",                                                 \
  187         "Xircom X3201-3",                                               \
  188         "Conexant RS7112",                                              \
  189 }
  190 
  191 struct tulip_softc;
  192 
  193 /*
  194  * Media init, change, status function pointers.
  195  */
  196 struct tulip_mediasw {
  197         void    (*tmsw_init)(struct tulip_softc *);
  198         void    (*tmsw_get)(struct tulip_softc *, struct ifmediareq *);
  199         int     (*tmsw_set)(struct tulip_softc *);
  200 };
  201 
  202 /*
  203  * Table which describes the transmit threshold mode.  We generally
  204  * start at index 0.  Whenever we get a transmit underrun, we increment
  205  * our index, falling back if we encounter the NULL terminator.
  206  */
  207 struct tulip_txthresh_tab {
  208         u_int32_t txth_opmode;          /* OPMODE bits */
  209         const char *txth_name;          /* name of mode */
  210 };
  211 
  212 #define TLP_TXTHRESH_TAB_10 {                                           \
  213         { OPMODE_TR_72,         "72 bytes" },                           \
  214         { OPMODE_TR_96,         "96 bytes" },                           \
  215         { OPMODE_TR_128,        "128 bytes" },                          \
  216         { OPMODE_TR_160,        "160 bytes" },                          \
  217         { 0,                    NULL },                                 \
  218 }
  219 
  220 #define TLP_TXTHRESH_TAB_10_100 {                                       \
  221         { OPMODE_TR_72,         "72/128 bytes" },                       \
  222         { OPMODE_TR_96,         "96/256 bytes" },                       \
  223         { OPMODE_TR_128,        "128/512 bytes" },                      \
  224         { OPMODE_TR_160,        "160/1024 bytes" },                     \
  225         { OPMODE_SF,            "store and forward mode" },             \
  226         { 0,                    NULL },                                 \
  227 }
  228 
  229 #define TXTH_72                 0
  230 #define TXTH_96                 1
  231 #define TXTH_128                2
  232 #define TXTH_160                3
  233 #define TXTH_SF                 4
  234 
  235 #define TLP_TXTHRESH_TAB_DM9102 {                                       \
  236         { OPMODE_TR_72,         "72/128 bytes" },                       \
  237         { OPMODE_TR_96,         "96/256 bytes" },                       \
  238         { OPMODE_TR_128,        "128/512 bytes" },                      \
  239         { OPMODE_SF,            "store and forward mode" },             \
  240         { 0,                    NULL },                                 \
  241 }
  242 
  243 #define TXTH_DM9102_72          0
  244 #define TXTH_DM9102_96          1
  245 #define TXTH_DM9102_128         2
  246 #define TXTH_DM9102_SF          3
  247 
  248 /*
  249  * The Winbond 89C840F does transmit threshold control totally
  250  * differently.  It simply has a 7-bit field which indicates
  251  * the threshold:
  252  *
  253  *      txth = ((OPMODE & OPMODE_WINB_TTH) >> OPMODE_WINB_TTH_SHIFT) * 16;
  254  *
  255  * However, we just do Store-and-Forward mode on these chips, since
  256  * the DMA engines seem to be flaky.
  257  */
  258 #define TLP_TXTHRESH_TAB_WINB {                                         \
  259         { 0,                    "store and forward mode" },             \
  260         { 0,                    NULL },                                 \
  261 }
  262 
  263 #define TXTH_WINB_SF            0
  264 
  265 /*
  266  * Settings for Tulip SIA media.
  267  */
  268 struct tulip_sia_media {
  269         u_int32_t       tsm_siaconn;    /* CSR13 value */
  270         u_int32_t       tsm_siatxrx;    /* CSR14 value */
  271         u_int32_t       tsm_siagen;     /* CSR15 value */
  272 };
  273 
  274 /*
  275  * Description of 2x14x media.
  276  */
  277 struct tulip_21x4x_media {
  278         int             tm_type;        /* type of media; see tulipreg.h */
  279         const char      *tm_name;       /* name of media */
  280 
  281         void            (*tm_get)(struct tulip_softc *, struct ifmediareq *);
  282         int             (*tm_set)(struct tulip_softc *);
  283 
  284         int             tm_phyno;       /* PHY # on MII */
  285 
  286         int             tm_gp_length;   /* MII select sequence length */
  287         int             tm_gp_offset;   /* MII select sequence offset */
  288 
  289         int             tm_reset_length;/* MII reset sequence length */
  290         int             tm_reset_offset;/* MII reset sequence offset */
  291 
  292         u_int32_t       tm_opmode;      /* OPMODE bits for this media */
  293         u_int32_t       tm_gpctl;       /* GPIO control bits for this media */
  294         u_int32_t       tm_gpdata;      /* GPIO bits for this media */
  295         u_int32_t       tm_actmask;     /* `active' bits for this data */
  296         u_int32_t       tm_actdata;     /* active high/low info */
  297 
  298         struct tulip_sia_media tm_sia;  /* SIA settings */
  299 #define tm_siaconn      tm_sia.tsm_siaconn
  300 #define tm_siatxrx      tm_sia.tsm_siatxrx
  301 #define tm_siagen       tm_sia.tsm_siagen
  302 };
  303 
  304 /*
  305  * Table for converting Tulip SROM media info into ifmedia data.
  306  */
  307 struct tulip_srom_to_ifmedia {
  308         u_int8_t        tsti_srom;      /* SROM media type */
  309         int             tsti_subtype;   /* ifmedia subtype */
  310         int             tsti_options;   /* ifmedia options */
  311         const char      *tsti_name;     /* media name */
  312 
  313         u_int32_t       tsti_opmode;    /* OPMODE bits for this media */
  314         u_int32_t       tsti_sia_cap;   /* "MII" capabilities for this media */
  315 
  316         /*
  317          * Settings for 21040, 21041, and 21142/21143 SIA, in the event
  318          * the SROM doesn't have them.
  319          */
  320         struct tulip_sia_media tsti_21040;
  321         struct tulip_sia_media tsti_21041;
  322         struct tulip_sia_media tsti_21142;
  323 };
  324 
  325 /*
  326  * Some misc. statics, useful for debugging.
  327  */
  328 struct tulip_stats {
  329         u_long          ts_tx_uf;       /* transmit underflow errors */
  330         u_long          ts_tx_to;       /* transmit jabber timeouts */
  331         u_long          ts_tx_ec;       /* excessive collision count */
  332         u_long          ts_tx_lc;       /* late collision count */
  333 };
  334 
  335 #ifndef _STANDALONE
  336 /*
  337  * Software state per device.
  338  */
  339 struct tulip_softc {
  340         struct device sc_dev;           /* generic device information */
  341         bus_space_tag_t sc_st;          /* bus space tag */
  342         bus_space_handle_t sc_sh;       /* bus space handle */
  343         bus_dma_tag_t sc_dmat;          /* bus DMA tag */
  344         struct ethercom sc_ethercom;    /* ethernet common data */
  345         void *sc_sdhook;                /* shutdown hook */
  346         void *sc_powerhook;             /* power management hook */
  347 
  348         struct tulip_stats sc_stats;    /* debugging stats */
  349 
  350         /*
  351          * Contents of the SROM.
  352          */
  353         u_int8_t *sc_srom;
  354         int sc_srom_addrbits;
  355 
  356         /*
  357          * Media access functions for this chip.
  358          */
  359         const struct tulip_mediasw *sc_mediasw;
  360         mii_bitbang_ops_t sc_bitbang_ops;
  361 
  362         /*
  363          * For chips with built-in NWay blocks, these are state
  364          * variables required for autonegotiation.
  365          */
  366         int             sc_nway_ticks;  /* tick counter */
  367         struct ifmedia_entry *sc_nway_active; /* the active media */
  368         struct callout  sc_nway_callout;
  369 
  370         tulip_chip_t    sc_chip;        /* chip type */
  371         int             sc_rev;         /* chip revision */
  372         int             sc_flags;       /* misc flags. */
  373         char            sc_name[32];    /* board name */
  374         u_int32_t       sc_cacheline;   /* cache line size */
  375         u_int32_t       sc_maxburst;    /* maximum burst length */
  376         int             sc_devno;       /* PCI device # */
  377 
  378         struct mii_data sc_mii;         /* MII/media information */
  379 
  380         const struct tulip_txthresh_tab *sc_txth;
  381         int             sc_txthresh;    /* current transmit threshold */
  382 
  383         u_int8_t        sc_gp_dir;      /* GPIO pin direction bits (21140) */
  384         int             sc_media_seen;  /* ISV media block types seen */
  385         int             sc_tlp_minst;   /* Tulip internal media instance */
  386         u_int32_t       sc_sia_cap;     /* SIA media capabilities (21143) */
  387 
  388         /* Reset function. */
  389         void            (*sc_reset)(struct tulip_softc *);
  390 
  391         /* Pre-init function. */
  392         void            (*sc_preinit)(struct tulip_softc *);
  393 
  394         /* Filter setup function. */
  395         void            (*sc_filter_setup)(struct tulip_softc *);
  396 
  397         /* Media status update function. */
  398         void            (*sc_statchg)(struct device *);
  399 
  400         /* Media tick function. */
  401         void            (*sc_tick)(void *);
  402         struct callout sc_tick_callout;
  403 
  404         /* Power management hooks. */
  405         int             (*sc_enable)(struct tulip_softc *);
  406         void            (*sc_disable)(struct tulip_softc *);
  407         void            (*sc_power)(struct tulip_softc *, int);
  408 
  409         /*
  410          * The Winbond 89C840F places registers 4 bytes apart, instead
  411          * of 8.
  412          */
  413         int             sc_regshift;
  414 
  415         u_int32_t       sc_busmode;     /* copy of CSR_BUSMODE */
  416         u_int32_t       sc_opmode;      /* copy of CSR_OPMODE */
  417         u_int32_t       sc_inten;       /* copy of CSR_INTEN */
  418 
  419         u_int32_t       sc_rxint_mask;  /* mask of Rx interrupts we want */
  420         u_int32_t       sc_txint_mask;  /* mask of Tx interrupts we want */
  421 
  422         u_int32_t       sc_filtmode;    /* filter mode we're using */
  423 
  424         bus_dma_segment_t sc_cdseg;     /* control data memory */
  425         int             sc_cdnseg;      /* number of segments */
  426         bus_dmamap_t sc_cddmamap;       /* control data DMA map */
  427 #define sc_cddma        sc_cddmamap->dm_segs[0].ds_addr
  428 
  429         /*
  430          * Software state for transmit and receive descriptors.
  431          */
  432         struct tulip_txsoft sc_txsoft[TULIP_TXQUEUELEN];
  433         struct tulip_rxsoft sc_rxsoft[TULIP_NRXDESC];
  434 
  435         /*
  436          * Control data structures.
  437          */
  438         struct tulip_control_data *sc_control_data;
  439 #define sc_txdescs      sc_control_data->tcd_txdescs
  440 #define sc_rxdescs      sc_control_data->tcd_rxdescs
  441 #define sc_setup_desc   sc_control_data->tcd_setup_desc
  442 
  443         int     sc_txfree;              /* number of free Tx descriptors */
  444         int     sc_txnext;              /* next ready Tx descriptor */
  445         int     sc_ntxsegs;             /* number of transmit segs per pkt */
  446 
  447         u_int32_t sc_tdctl_ch;          /* conditional desc chaining */
  448         u_int32_t sc_tdctl_er;          /* conditional desc end-of-ring */
  449 
  450         u_int32_t sc_setup_fsls;        /* FS|LS on setup descriptor */
  451 
  452         struct tulip_txsq sc_txfreeq;   /* free Tx descsofts */
  453         struct tulip_txsq sc_txdirtyq;  /* dirty Tx descsofts */
  454 
  455         short   sc_if_flags;
  456 
  457         int     sc_rxptr;               /* next ready RX descriptor/descsoft */
  458 
  459 #if NRND > 0
  460         rndsource_element_t sc_rnd_source; /* random source */
  461 #endif
  462 };
  463 #endif
  464 
  465 /* sc_flags */
  466 #define TULIPF_WANT_SETUP       0x00000001      /* want filter setup */
  467 #define TULIPF_DOING_SETUP      0x00000002      /* doing multicast setup */
  468 #define TULIPF_HAS_MII          0x00000004      /* has media on MII */
  469 #define TULIPF_IC_FS            0x00000008      /* IC bit on first tx seg */
  470 #define TULIPF_MRL              0x00000010      /* memory read line okay */
  471 #define TULIPF_MRM              0x00000020      /* memory read multi okay */
  472 #define TULIPF_MWI              0x00000040      /* memory write inval okay */
  473 #define TULIPF_AUTOPOLL         0x00000080      /* chip supports auto-poll */
  474 #define TULIPF_LINK_UP          0x00000100      /* link is up (non-MII) */
  475 #define TULIPF_LINK_VALID       0x00000200      /* link state valid */
  476 #define TULIPF_DOINGAUTO        0x00000400      /* doing autoneg (non-MII) */
  477 #define TULIPF_ATTACHED         0x00000800      /* attach has succeeded */
  478 #define TULIPF_ENABLED          0x00001000      /* chip is enabled */
  479 #define TULIPF_BLE              0x00002000      /* data is big endian */
  480 #define TULIPF_DBO              0x00004000      /* descriptor is big endian */
  481 #define TULIPF_VPC              0x00008000      /* Virtual PC Ethernet */
  482 
  483 #define TULIP_IS_ENABLED(sc)    ((sc)->sc_flags & TULIPF_ENABLED)
  484 
  485 /*
  486  * This macro returns the current media entry.
  487  */
  488 #define TULIP_CURRENT_MEDIA(sc) ((sc)->sc_mii.mii_media.ifm_cur)
  489 
  490 /*
  491  * This macro determines if a change to media-related OPMODE bits requires
  492  * a chip reset.
  493  */
  494 #define TULIP_MEDIA_NEEDSRESET(sc, newbits)                             \
  495         (((sc)->sc_opmode & OPMODE_MEDIA_BITS) !=                       \
  496          ((newbits) & OPMODE_MEDIA_BITS))
  497 
  498 #define TULIP_CDTXADDR(sc, x)   ((sc)->sc_cddma + TULIP_CDTXOFF((x)))
  499 #define TULIP_CDRXADDR(sc, x)   ((sc)->sc_cddma + TULIP_CDRXOFF((x)))
  500 
  501 #define TULIP_CDSPADDR(sc)      ((sc)->sc_cddma + TULIP_CDSPOFF)
  502 
  503 #define TULIP_CDSP(sc)          ((sc)->sc_control_data->tcd_setup_packet)
  504 
  505 #define TULIP_CDTXSYNC(sc, x, n, ops)                                   \
  506 do {                                                                    \
  507         int __x, __n;                                                   \
  508                                                                         \
  509         __x = (x);                                                      \
  510         __n = (n);                                                      \
  511                                                                         \
  512         /* If it will wrap around, sync to the end of the ring. */      \
  513         if ((__x + __n) > TULIP_NTXDESC) {                              \
  514                 bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,       \
  515                     TULIP_CDTXOFF(__x), sizeof(struct tulip_desc) *     \
  516                     (TULIP_NTXDESC - __x), (ops));                      \
  517                 __n -= (TULIP_NTXDESC - __x);                           \
  518                 __x = 0;                                                \
  519         }                                                               \
  520                                                                         \
  521         /* Now sync whatever is left. */                                \
  522         bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,               \
  523             TULIP_CDTXOFF(__x), sizeof(struct tulip_desc) * __n, (ops)); \
  524 } while (0)
  525 
  526 #define TULIP_CDRXSYNC(sc, x, ops)                                      \
  527         bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,               \
  528             TULIP_CDRXOFF((x)), sizeof(struct tulip_desc), (ops))
  529 
  530 #define TULIP_CDSPSYNC(sc, ops)                                         \
  531         bus_dmamap_sync((sc)->sc_dmat, (sc)->sc_cddmamap,               \
  532             TULIP_CDSPOFF, TULIP_SETUP_PACKET_LEN, (ops))
  533 
  534 /*
  535  * Note we rely on MCLBYTES being a power of two.  Because the `length'
  536  * field is only 11 bits, we must subtract 1 from the length to avoid
  537  * having it truncated to 0!
  538  */
  539 #define TULIP_INIT_RXDESC(sc, x)                                        \
  540 do {                                                                    \
  541         struct tulip_rxsoft *__rxs = &sc->sc_rxsoft[(x)];               \
  542         struct tulip_desc *__rxd = &sc->sc_rxdescs[(x)];                \
  543         struct mbuf *__m = __rxs->rxs_mbuf;                             \
  544                                                                         \
  545         __m->m_data = __m->m_ext.ext_buf;                               \
  546         __rxd->td_bufaddr1 =                                            \
  547             htole32(__rxs->rxs_dmamap->dm_segs[0].ds_addr);             \
  548         __rxd->td_bufaddr2 =                                            \
  549             htole32(TULIP_CDRXADDR((sc), TULIP_NEXTRX((x))));           \
  550         __rxd->td_ctl =                                                 \
  551             htole32((((__m->m_ext.ext_size - 1) & ~0x3U)                \
  552             << TDCTL_SIZE1_SHIFT) | (sc)->sc_tdctl_ch |                 \
  553             ((x) == (TULIP_NRXDESC - 1) ? sc->sc_tdctl_er : 0));        \
  554         __rxd->td_status = htole32(TDSTAT_OWN|TDSTAT_Rx_FS|TDSTAT_Rx_LS); \
  555         TULIP_CDRXSYNC((sc), (x), BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); \
  556 } while (0)
  557 
  558 /* CSR access */
  559 #define TULIP_CSR_OFFSET(sc, csr)                                       \
  560         (TULIP_CSR_INDEX(csr) << (sc)->sc_regshift)
  561 
  562 #define TULIP_READ(sc, reg)                                             \
  563         bus_space_read_4((sc)->sc_st, (sc)->sc_sh,                      \
  564             TULIP_CSR_OFFSET((sc), (reg)))
  565 
  566 #define TULIP_WRITE(sc, reg, val)                                       \
  567         bus_space_write_4((sc)->sc_st, (sc)->sc_sh,                     \
  568             TULIP_CSR_OFFSET((sc), (reg)), (val))
  569 
  570 #define TULIP_SET(sc, reg, mask)                                        \
  571         TULIP_WRITE((sc), (reg), TULIP_READ((sc), (reg)) | (mask))
  572 
  573 #define TULIP_CLR(sc, reg, mask)                                        \
  574         TULIP_WRITE((sc), (reg), TULIP_READ((sc), (reg)) & ~(mask))
  575 
  576 #define TULIP_ISSET(sc, reg, mask)                                      \
  577         (TULIP_READ((sc), (reg)) & (mask))
  578 
  579 #if BYTE_ORDER == BIG_ENDIAN
  580 #define TULIP_SP_FIELD_C(x)     ((x) << 16)
  581 #else
  582 #define TULIP_SP_FIELD_C(x)     (x)
  583 #endif
  584 #define TULIP_SP_FIELD(x, f)    TULIP_SP_FIELD_C(((u_int16_t *)(x))[(f)])
  585 
  586 #ifdef _KERNEL
  587 extern const char * const tlp_chip_names[];
  588 
  589 extern const struct tulip_mediasw tlp_21040_mediasw;
  590 extern const struct tulip_mediasw tlp_21040_tp_mediasw;
  591 extern const struct tulip_mediasw tlp_21040_auibnc_mediasw;
  592 extern const struct tulip_mediasw tlp_21041_mediasw;
  593 extern const struct tulip_mediasw tlp_2114x_isv_mediasw;
  594 extern const struct tulip_mediasw tlp_sio_mii_mediasw;
  595 extern const struct tulip_mediasw tlp_pnic_mediasw;
  596 extern const struct tulip_mediasw tlp_pmac_mediasw;
  597 extern const struct tulip_mediasw tlp_al981_mediasw;
  598 extern const struct tulip_mediasw tlp_an985_mediasw;
  599 extern const struct tulip_mediasw tlp_dm9102_mediasw;
  600 extern const struct tulip_mediasw tlp_asix_mediasw;
  601 extern const struct tulip_mediasw tlp_rs7112_mediasw;
  602 
  603 void    tlp_attach(struct tulip_softc *, const u_int8_t *);
  604 int     tlp_activate(struct device *, enum devact);
  605 int     tlp_detach(struct tulip_softc *);
  606 int     tlp_intr(void *);
  607 int     tlp_read_srom(struct tulip_softc *);
  608 int     tlp_srom_crcok(const u_int8_t *);
  609 int     tlp_isv_srom(const u_int8_t *);
  610 int     tlp_isv_srom_enaddr(struct tulip_softc *, u_int8_t *);
  611 int     tlp_parse_old_srom(struct tulip_softc *, u_int8_t *);
  612 void    tlp_reset(struct tulip_softc *);
  613 void    tlp_idle(struct tulip_softc *, u_int32_t);
  614 
  615 int     tlp_mediachange(struct ifnet *);
  616 void    tlp_mediastatus(struct ifnet *, struct ifmediareq *);
  617 
  618 void    tlp_21140_gpio_get(struct tulip_softc *sc, struct ifmediareq *ifmr);
  619 int     tlp_21140_gpio_set(struct tulip_softc *sc);
  620 
  621 #endif /* _KERNEL */
  622 
  623 #endif /* _DEV_IC_TULIPVAR_H_ */

Cache object: 633aebb7bbdac509229831c59e16511f


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