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

Cache object: 59342f904676128ef631b381936d2959


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