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