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/i82586var.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: i82586var.h,v 1.23 2011/06/03 16:28:40 tsutsui Exp $   */
    2 
    3 /*-
    4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Paul Kranenburg and Charles M. Hannum.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 /*-
   33  * Copyright (c) 1992, 1993, University of Vermont and State
   34  *  Agricultural College.
   35  * Copyright (c) 1992, 1993, Garrett A. Wollman.
   36  *
   37  * Portions:
   38  * Copyright (c) 1994, 1995, Rafal K. Boni
   39  * Copyright (c) 1990, 1991, William F. Jolitz
   40  * Copyright (c) 1990, The Regents of the University of California
   41  *
   42  * All rights reserved.
   43  *
   44  * Redistribution and use in source and binary forms, with or without
   45  * modification, are permitted provided that the following conditions
   46  * are met:
   47  * 1. Redistributions of source code must retain the above copyright
   48  *    notice, this list of conditions and the following disclaimer.
   49  * 2. Redistributions in binary form must reproduce the above copyright
   50  *    notice, this list of conditions and the following disclaimer in the
   51  *    documentation and/or other materials provided with the distribution.
   52  * 3. All advertising materials mentioning features or use of this software
   53  *    must display the following acknowledgement:
   54  *      This product includes software developed by the University of Vermont
   55  *      and State Agricultural College and Garrett A. Wollman, by William F.
   56  *      Jolitz, and by the University of California, Berkeley, Lawrence
   57  *      Berkeley Laboratory, and its contributors.
   58  * 4. Neither the names of the Universities nor the names of the authors
   59  *    may be used to endorse or promote products derived from this software
   60  *    without specific prior written permission.
   61  *
   62  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   63  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   65  * ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR AUTHORS BE LIABLE
   66  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   67  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   68  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   69  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   70  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   71  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   72  * SUCH DAMAGE.
   73  */
   74 
   75 /*
   76  * Intel 82586 Ethernet chip
   77  * Register, bit, and structure definitions.
   78  *
   79  * Original StarLAN driver written by Garrett Wollman with reference to the
   80  * Clarkson Packet Driver code for this chip written by Russ Nelson and others.
   81  *
   82  * BPF support code taken from hpdev/if_le.c, supplied with tcpdump.
   83  *
   84  * 3C507 support is loosely based on code donated to NetBSD by Rafal Boni.
   85  *
   86  * Majorly cleaned up and 3C507 code merged by Charles Hannum.
   87  *
   88  * Converted to SUN ie driver by Charles D. Cranor,
   89  *              October 1994, January 1995.
   90  * This sun version based on i386 version 1.30.
   91  */
   92 
   93 #ifndef I82586_DEBUG
   94 #define I82586_DEBUG 0
   95 #endif
   96 
   97 /* Debug elements */
   98 #define IED_RINT        0x01
   99 #define IED_TINT        0x02
  100 #define IED_RNR         0x04
  101 #define IED_CNA         0x08
  102 #define IED_READFRAME   0x10
  103 #define IED_ENQ         0x20
  104 #define IED_XMIT        0x40
  105 #define IED_ALL         0x7f
  106 
  107 #define B_PER_F         3               /* recv buffers per frame */
  108 #define IE_RBUF_SIZE    256             /* size of each receive buffer;
  109                                                 MUST BE POWER OF TWO */
  110 #define NTXBUF          2               /* number of transmit commands */
  111 #define IE_TBUF_SIZE    ETHER_MAX_LEN   /* length of transmit buffer */
  112 
  113 #define IE_MAXMCAST     (IE_TBUF_SIZE/6)/* must fit in transmit buffer */
  114 
  115 
  116 #define INTR_ENTER      0               /* intr hook called on ISR entry */
  117 #define INTR_EXIT       1               /* intr hook called on ISR exit */
  118 #define INTR_LOOP       2               /* intr hook called on ISR loop */
  119 #define INTR_ACK        3               /* intr hook called on ie_ack */
  120 
  121 #define CHIP_PROBE      0               /* reset called from chip probe */
  122 #define CARD_RESET      1               /* reset called from card reset */
  123 
  124 /*
  125  * Ethernet status, per interface.
  126  *
  127  * The chip uses two types of pointers: 16 bit and 24 bit
  128  *   24 bit pointers cover the board's memory.
  129  *   16 bit pointers are offsets from the ISCP's `ie_base'
  130  *
  131  * The board's memory is represented by the bus handle `bh'. The MI
  132  * i82586 driver deals exclusively with offsets relative to the
  133  * board memory bus handle. The `ie_softc' fields below that are marked
  134  * `MD' are in the domain of the front-end driver; they opaque to the
  135  * MI driver part.
  136  *
  137  * The front-end is required to manage the SCP and ISCP structures. i.e.
  138  * allocate room for them on the board's memory, and arrange to point the
  139  * chip at the SCB structure, the offset of which is passed to the MI
  140  * driver in `sc_scb'.
  141  *
  142  * The following functions provide the glue necessary to deal with
  143  * host and bus idiosyncracies:
  144  *
  145  *      hwreset         - board reset
  146  *      hwinit          - board initialization
  147  *      chan_attn       - get chip to look at prepared commands
  148  *      intrhook        - board dependent interrupt processing
  149  *
  150  *      All of the following shared-memory access function use an offset
  151  *      relative to the bus handle to indicate the shared memory location.
  152  *      The bus_{read/write}N function take or return offset into the
  153  *      shared memory in the host's byte-order.
  154  *
  155  *      memcopyin       - copy device memory: board to KVA
  156  *      memcopyout      - copy device memory: KVA to board
  157  *      bus_read16      - read a 16-bit i82586 pointer
  158                           `offset' argument will be 16-bit aligned
  159  *      bus_write16     - write a 16-bit i82586 pointer
  160                           `offset' argument will be 16-bit aligned
  161  *      bus_write24     - write a 24-bit i82586 pointer
  162                           `offset' argument will be 32-bit aligned
  163  *      bus_barrier     - perform a bus barrier operation, forcing
  164                           all outstanding reads/writes to complete
  165  *
  166  */
  167 
  168 struct ie_softc {
  169         device_t sc_dev;        /* device structure */
  170 
  171         bus_space_tag_t bt;     /* bus-space tag of card memory */
  172         bus_space_handle_t bh;  /* bus-space handle of card memory */
  173 
  174         bus_dmamap_t    sc_dmamap;      /* bus dma handle */
  175 
  176         void    *sc_iobase;     /* (MD) KVA of base of 24 bit addr space */
  177         void    *sc_maddr;      /* (MD) KVA of base of chip's RAM
  178                                    (16bit addr space) */
  179         u_int   sc_msize;       /* (MD) how much RAM we have/use */
  180         void    *sc_reg;        /* (MD) KVA of car's register */
  181 
  182         struct  ethercom sc_ethercom;   /* system ethercom structure */
  183         struct  ifmedia sc_media;       /* supported media information */
  184 
  185         /* Bus glue */
  186         void    (*hwreset)(struct ie_softc *, int);
  187         void    (*hwinit)(struct ie_softc *);
  188         void    (*chan_attn)(struct ie_softc *, int);
  189         int     (*intrhook)(struct ie_softc *, int);
  190 
  191         void    (*memcopyin)(struct ie_softc *, void *, int, size_t);
  192         void    (*memcopyout)(struct ie_softc *, const void *, int, size_t);
  193         u_int16_t (*ie_bus_read16)(struct ie_softc *, int);
  194         void    (*ie_bus_write16)(struct ie_softc *, int, u_int16_t);
  195         void    (*ie_bus_write24)(struct ie_softc *, int, int);
  196         void    (*ie_bus_barrier)(struct ie_softc *, int, int, int);
  197 
  198         /* Media management */
  199         int  (*sc_mediachange)(struct ie_softc *);
  200                                 /* card dependent media change */
  201         void (*sc_mediastatus)(struct ie_softc *, struct ifmediareq *);
  202                                 /* card dependent media status */
  203 
  204 
  205         /*
  206          * Offsets (relative to bus handle) of the i82586 SYSTEM structures.
  207          */
  208         int     scp;            /* Offset to the SCP (set by front-end) */
  209         int     iscp;           /* Offset to the ISCP (set by front-end) */
  210         int     scb;            /* Offset to SCB (set by front-end) */
  211 
  212         /*
  213          * Offset and size of a block of board memory where the buffers
  214          * are to be allocated from (initialized by front-end).
  215          */
  216         int     buf_area;       /* Start of descriptors and buffers */
  217         int     buf_area_sz;    /* Size of above */
  218 
  219         /*
  220          * The buffers & descriptors (recv and xmit)
  221          */
  222         int     rframes;        /* Offset to `nrxbuf' frame descriptors */
  223         int     rbds;           /* Offset to `nrxbuf' buffer descriptors */
  224         int     rbufs;          /* Offset to `nrxbuf' receive buffers */
  225 #define IE_RBUF_ADDR(sc, i)     (sc->rbufs + ((i) * IE_RBUF_SIZE))
  226         int     rfhead, rftail;
  227         int     rbhead, rbtail;
  228         int     nframes;        /* number of frames in use */
  229         int     nrxbuf;         /* number of recv buffs in use */
  230         int     rnr_expect;     /* XXX - expect a RCVR not ready interrupt */
  231 
  232         int     nop_cmds;       /* Offset to NTXBUF no-op commands */
  233         int     xmit_cmds;      /* Offset to NTXBUF transmit commands */
  234         int     xbds;           /* Offset to NTXBUF buffer descriptors */
  235         int     xbufs;          /* Offset to NTXBUF transmit buffers */
  236 #define IE_XBUF_ADDR(sc, i)     (sc->xbufs + ((i) * IE_TBUF_SIZE))
  237 
  238         int     xchead, xctail;
  239         int     xmit_busy;
  240         int     do_xmitnopchain;        /* Controls use of xmit NOP chains */
  241 
  242         /* Multicast addresses */
  243         char    *mcast_addrs;           /* Current MC filter addresses */
  244         int     mcast_addrs_size;       /* Current size of MC buffer */
  245         int     mcast_count;            /* Current # of addrs in buffer */
  246         int     want_mcsetup;           /* run mcsetup at next opportunity */
  247 
  248         int     promisc;                /* are we in promisc mode? */
  249         int     async_cmd_inprogress;   /* we didn't wait for 586 to accept
  250                                            a command */
  251 
  252 #if I82586_DEBUG
  253         int     sc_debug;
  254 #endif
  255 };
  256 
  257 /* Exported functions */
  258 int     i82586_intr(void *);
  259 int     i82586_proberam(struct ie_softc *);
  260 void    i82586_attach(struct ie_softc *, const char *, u_int8_t *, int*, int,
  261     int);
  262 
  263 /* Shortcut macros to optional (driver uses default if unspecified) callbacks */
  264 #define IE_BUS_BARRIER(sc, offset, length, flags)                         \
  265 do {                                                                      \
  266         if ((sc)->ie_bus_barrier)                                         \
  267                 ((sc)->ie_bus_barrier)((sc), (offset), (length), (flags));\
  268         else                                                              \
  269                 bus_space_barrier((sc)->bt, (sc)->bh, (offset), (length), \
  270                                                                 (flags)); \
  271 } while (0)
  272 

Cache object: f8de6dc38824fd5950526d3b78b97bf2


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