/* $NetBSD: i82586.h,v 1.6 1997/03/15 18:10:48 is Exp $ */
/*-
* Copyright (c) 1992, University of Vermont and State Agricultural College.
* Copyright (c) 1992, Garrett A. Wollman.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* Vermont and State Agricultural College and Garrett A. Wollman.
* 4. Neither the name of the University nor the name of the author
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR AUTHOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Intel 82586 Ethernet chip
* Register, bit, and structure definitions.
*
* Written by GAW with reference to the Clarkson Packet Driver code for this
* chip written by Russ Nelson and others.
*
* Sun support added by Charles D. Cranor, 25-Oct-94
*
* XXX: This is very much like dev/ic/i82586reg.h except for
* XXX: the SWAP() macro used here to byte-swap word constants.
* XXX: (This should probably replace the version in dev/ic)
*/
struct ie_en_addr {
u_char data[6];
};
/*
* This is the master configuration block. It tells the hardware where all
* the rest of the stuff is.
*/
struct ie_sys_conf_ptr {
u_short mbz; /* must be zero (alignment) */
u_char ie_bus_use; /* true if 8-bit only */
u_char mbz2[5]; /* must be zero */
u_int ie_iscp_ptr; /* 24-bit physaddr of ISCP */
};
/*
* Note that this is wired in hardware; the SCP is always located here, no
* matter what.
*/
#define IE_SCP_ADDR 0xfffff4
/*
* The tells the hardware where all the rest of the stuff is, too.
* FIXME: some of these should be re-commented after we figure out their
* REAL function.
*/
struct ie_int_sys_conf_ptr {
u_char ie_busy; /* zeroed after init */
u_char mbz;
u_short ie_scb_offset; /* 16-bit physaddr of next struct */
u_int ie_base; /* 24-bit physaddr for all 16-bit vars */
};
/*
* This FINALLY tells the hardware what to do and where to put it.
*/
struct ie_sys_ctl_block {
u_short ie_status; /* status word */
u_short ie_command; /* command word */
u_short ie_command_list; /* 16-pointer to command block list */
u_short ie_recv_list; /* 16-pointer to receive frame list */
u_short ie_err_crc; /* CRC errors */
u_short ie_err_align; /* Alignment errors */
u_short ie_err_resource; /* Resource errors */
u_short ie_err_overrun; /* Overrun errors */
};
#define IE_ACTION_COMMAND(x) (((x) & IE_CU_COMMAND) == IE_CU_START)
/* is this command an action command? */
/* Status values */
#define IE_ST_WHENCE SWAP(0xf000) /* mask for cause of interrupt */
#define IE_ST_DONE SWAP(0x8000) /* command with I bit completed */
#define IE_ST_RECV SWAP(0x4000) /* frame received */
#define IE_ST_ALLDONE SWAP(0x2000) /* all commands completed */
#define IE_ST_RNR SWAP(0x1000) /* receive not ready */
#define IE_CU_STATUS SWAP(0x700) /* mask for command unit status */
#define IE_CU_ACTIVE SWAP(0x200) /* command unit is active */
#define IE_CU_SUSPEND SWAP(0x100) /* command unit is suspended */
#define IE_RU_STATUS SWAP(0x70) /* mask for receiver unit status */
#define IE_RU_SUSPEND SWAP(0x10) /* receiver is suspended */
#define IE_RU_NOSPACE SWAP(0x20) /* receiver has no resources */
#define IE_RU_READY SWAP(0x40) /* reveiver is ready */
/*
* This is filled in partially by the chip, partially by us.
*/
struct ie_recv_frame_desc {
u_short ie_fd_status; /* status for this frame */
u_short ie_fd_last; /* end of frame list flag */
u_short ie_fd_next; /* 16-pointer to next RFD */
u_short ie_fd_buf_desc; /* 16-pointer to list of buffer desc's */
struct ie_en_addr dest; /* destination ether */
struct ie_en_addr src; /* source ether */
u_short ie_length; /* 802 length/Ether type */
u_short mbz; /* must be zero */
};
#define IE_FD_LAST SWAP(0x8000) /* last rfd in list */
#define IE_FD_SUSP SWAP(0x4000) /* suspend RU after receipt */
#define IE_FD_COMPLETE SWAP(0x8000) /* frame is complete */
#define IE_FD_BUSY SWAP(0x4000) /* frame is busy */
#define IE_FD_OK SWAP(0x2000) /* frame is bad */
#define IE_FD_RNR SWAP(0x0200) /* receiver out of resources here */
/*
* linked list of buffers...
*/
struct ie_recv_buf_desc {
u_short ie_rbd_actual; /* status for this buffer */
u_short ie_rbd_next; /* 16-pointer to next RBD */
u_int ie_rbd_buffer; /* 24-pointer to buffer for this RBD */
u_short ie_rbd_length; /* length of the buffer */
u_short mbz; /* must be zero */
};
#define IE_RBD_LAST SWAP(0x8000) /* last buffer */
#define IE_RBD_USED SWAP(0x4000) /* this buffer has data */
/*
* All commands share this in common.
*/
struct ie_cmd_common {
u_short ie_cmd_status; /* status of this command */
u_short ie_cmd_cmd; /* command word */
u_short ie_cmd_link; /* link to next command */
};
#define IE_STAT_COMPL SWAP(0x8000) /* command is completed */
#define IE_STAT_BUSY SWAP(0x4000) /* command is running now */
#define IE_STAT_OK SWAP(0x2000) /* command completed successfully */
#define IE_STAT_ABORT SWAP(0x1000) /* command was aborted */
#define IE_CMD_LAST SWAP(0x8000) /* this is the last command in the list */
#define IE_CMD_SUSPEND SWAP(0x4000) /* suspend CU after this command */
#define IE_CMD_INTR SWAP(0x2000) /* post an interrupt after completion */
/*
* This is the command to transmit a frame.
*/
struct ie_xmit_cmd {
struct ie_cmd_common com; /* common part */
#define ie_xmit_status com.ie_cmd_status
u_short ie_xmit_length; /* 802.3 length/Ether type field */
};
#define IE_XS_MAXCOLL SWAP(0x000f) /* number of collisions during transmit */
#define IE_XS_EXCMAX SWAP(0x0020) /* exceeded maximum number of collisions */
#define IE_XS_SQE SWAP(0x0040) /* SQE positive */
#define IE_XS_DEFERRED SWAP(0x0080) /* transmission deferred */
#define IE_XS_UNDERRUN SWAP(0x0100) /* DMA underrun */
#define IE_XS_LOSTCTS SWAP(0x0200) /* Lost CTS */
#define IE_XS_NOCARRIER SWAP(0x0400) /* No Carrier */
#define IE_XS_LATECOLL SWAP(0x0800) /* Late collision */
/*
* This is a buffer descriptor for a frame to be transmitted.
*/
struct ie_xmit_buf {
u_short ie_xmit_flags; /* see below */
u_short ie_xmit_next; /* 16-pointer to next desc. */
u_int ie_xmit_buf; /* 24-pointer to the actual buffer */
};
#define IE_XMIT_LAST SWAP(0x8000) /* this TBD is the last one */
/* The rest of the `flags' word is actually the length. */
/*
* Multicast setup command.
* The command must fit in a transmit buffer (1536).
* Also, would like size of ie_mcast_addrs to be even.
*/
#define MAXMCAST 247
struct ie_mcast_cmd {
struct ie_cmd_common com; /* common part */
#define ie_mcast_status com.ie_cmd_status
u_short ie_mcast_bytes; /* size (in bytes) of multicast addresses */
struct ie_en_addr ie_mcast_addrs[MAXMCAST + 1]; /* space for them */
};
/*
* Time Domain Reflectometer command.
*/
struct ie_tdr_cmd {
struct ie_cmd_common com; /* common part */
#define ie_tdr_status com.ie_cmd_status
u_short ie_tdr_time; /* error bits and time */
};
#define IE_TDR_SUCCESS SWAP(0x8000) /* TDR succeeded without error */
#define IE_TDR_XCVR SWAP(0x4000) /* detected a transceiver problem */
#define IE_TDR_OPEN SWAP(0x2000) /* detected an open */
#define IE_TDR_SHORT SWAP(0x1000) /* TDR detected a short */
#define IE_TDR_TIME SWAP(0x07ff) /* mask for reflection time */