i82586.h revision 11961
1258945Sroberto/*- 2280849Scy * Copyright (c) 1992, University of Vermont and State Agricultural College. 3258945Sroberto * Copyright (c) 1992, Garrett A. Wollman. 4258945Sroberto * All rights reserved. 5258945Sroberto * 6258945Sroberto * Redistribution and use in source and binary forms, with or without 7258945Sroberto * modification, are permitted provided that the following conditions 8258945Sroberto * are met: 9258945Sroberto * 1. Redistributions of source code must retain the above copyright 10258945Sroberto * notice, this list of conditions and the following disclaimer. 11258945Sroberto * 2. Redistributions in binary form must reproduce the above copyright 12258945Sroberto * notice, this list of conditions and the following disclaimer in the 13258945Sroberto * documentation and/or other materials provided with the distribution. 14258945Sroberto * 3. All advertising materials mentioning features or use of this software 15258945Sroberto * must display the following acknowledgement: 16258945Sroberto * This product includes software developed by the University of 17258945Sroberto * Vermont and State Agricultural College and Garrett A. Wollman. 18280849Scy * 4. Neither the name of the University nor the name of the author 19258945Sroberto * may be used to endorse or promote products derived from this software 20258945Sroberto * without specific prior written permission. 21258945Sroberto * 22258945Sroberto * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23258945Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24258945Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25258945Sroberto * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR AUTHOR BE LIABLE 26258945Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27258945Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28258945Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29258945Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30258945Sroberto * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31258945Sroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32258945Sroberto * SUCH DAMAGE. 33258945Sroberto * 34258945Sroberto * $Id: i82586.h,v 1.1 1993/10/12 06:53:10 rgrimes Exp $ 35258945Sroberto */ 36258945Sroberto 37258945Sroberto/* 38258945Sroberto * Intel 82586 Ethernet chip 39258945Sroberto * Register, bit, and structure definitions. 40258945Sroberto * 41258945Sroberto * Written by GAW with reference to the Clarkson Packet Driver code for this 42258945Sroberto * chip written by Russ Nelson and others. 43258945Sroberto */ 44258945Sroberto 45258945Srobertostruct ie_en_addr { 46258945Sroberto u_char data[6]; 47258945Sroberto}; 48258945Sroberto 49258945Sroberto/* 50258945Sroberto * This is the master configuration block. It tells the hardware where all 51258945Sroberto * the rest of the stuff is. 52258945Sroberto */ 53258945Srobertostruct ie_sys_conf_ptr { 54258945Sroberto u_short mbz; /* must be zero */ 55258945Sroberto u_char ie_bus_use; /* true if 8-bit only */ 56258945Sroberto u_char mbz2[5]; /* must be zero */ 57258945Sroberto caddr_t ie_iscp_ptr; /* 24-bit physaddr of ISCP */ 58258945Sroberto}; 59258945Sroberto 60258945Sroberto/* 61258945Sroberto * Note that this is wired in hardware; the SCP is always located here, no 62258945Sroberto * matter what. 63258945Sroberto */ 64258945Sroberto#define IE_SCP_ADDR 0xfffff4 65258945Sroberto 66258945Sroberto/* 67258945Sroberto * The tells the hardware where all the rest of the stuff is, too. 68258945Sroberto * FIXME: some of these should be re-commented after we figure out their 69258945Sroberto * REAL function. 70258945Sroberto */ 71258945Srobertostruct ie_int_sys_conf_ptr { 72258945Sroberto u_char ie_busy; /* zeroed after init */ 73258945Sroberto u_char mbz; 74258945Sroberto u_short ie_scb_offset; /* 16-bit physaddr of next struct */ 75258945Sroberto caddr_t ie_base; /* 24-bit physaddr for all 16-bit vars */ 76258945Sroberto}; 77258945Sroberto 78258945Sroberto/* 79258945Sroberto * This FINALLY tells the hardware what to do and where to put it. 80258945Sroberto */ 81258945Srobertostruct ie_sys_ctl_block { 82258945Sroberto u_short ie_status; /* status word */ 83258945Sroberto u_short ie_command; /* command word */ 84258945Sroberto u_short ie_command_list; /* 16-pointer to command block list */ 85258945Sroberto u_short ie_recv_list; /* 16-pointer to receive frame list */ 86258945Sroberto u_short ie_err_crc; /* CRC errors */ 87258945Sroberto u_short ie_err_align; /* Alignment errors */ 88258945Sroberto u_short ie_err_resource; /* Resource errors */ 89258945Sroberto u_short ie_err_overrun; /* Overrun errors */ 90258945Sroberto}; 91258945Sroberto 92258945Sroberto/* Command values */ 93258945Sroberto#define IE_RU_COMMAND 0x0070 /* mask for RU command */ 94258945Sroberto#define IE_RU_NOP 0 /* for completeness */ 95258945Sroberto#define IE_RU_START 0x0010 /* start receive unit command */ 96258945Sroberto#define IE_RU_ENABLE 0x0020 /* enable receiver command */ 97258945Sroberto#define IE_RU_DISABLE 0x0030 /* disable receiver command */ 98258945Sroberto#define IE_RU_ABORT 0x0040 /* abort current receive operation */ 99258945Sroberto 100258945Sroberto#define IE_CU_COMMAND 0x0700 /* mask for CU command */ 101258945Sroberto#define IE_CU_NOP 0 /* included for completeness */ 102258945Sroberto#define IE_CU_START 0x0100 /* do-command command */ 103258945Sroberto#define IE_CU_RESUME 0x0200 /* resume a suspended cmd list */ 104258945Sroberto#define IE_CU_STOP 0x0300 /* SUSPEND was already taken */ 105258945Sroberto#define IE_CU_ABORT 0x0400 /* abort current command */ 106258945Sroberto 107258945Sroberto#define IE_ACK_COMMAND 0xf000 /* mask for ACK command */ 108258945Sroberto#define IE_ACK_CX 0x8000 /* ack IE_ST_DONE */ 109258945Sroberto#define IE_ACK_FR 0x4000 /* ack IE_ST_RECV */ 110258945Sroberto#define IE_ACK_CNA 0x2000 /* ack IE_ST_ALLDONE */ 111258945Sroberto#define IE_ACK_RNR 0x1000 /* ack IE_ST_RNR */ 112258945Sroberto 113258945Sroberto#define IE_ACTION_COMMAND(x) (((x) & IE_CU_COMMAND) == IE_CU_START) 114258945Sroberto /* is this command an action command? */ 115258945Sroberto 116258945Sroberto/* Status values */ 117258945Sroberto#define IE_ST_WHENCE 0xf000 /* mask for cause of interrupt */ 118258945Sroberto#define IE_ST_DONE 0x8000 /* command with I bit completed */ 119258945Sroberto#define IE_ST_RECV 0x4000 /* frame received */ 120258945Sroberto#define IE_ST_ALLDONE 0x2000 /* all commands completed */ 121258945Sroberto#define IE_ST_RNR 0x1000 /* receive not ready */ 122258945Sroberto 123258945Sroberto#define IE_CU_STATUS 0x700 /* mask for command unit status */ 124258945Sroberto#define IE_CU_ACTIVE 0x200 /* command unit is active */ 125258945Sroberto#define IE_CU_SUSPEND 0x100 /* command unit is suspended */ 126258945Sroberto 127258945Sroberto#define IE_RU_STATUS 0x70 /* mask for receiver unit status */ 128258945Sroberto#define IE_RU_SUSPEND 0x10 /* receiver is suspended */ 129258945Sroberto#define IE_RU_NOSPACE 0x20 /* receiver has no resources */ 130258945Sroberto#define IE_RU_READY 0x40 /* reveiver is ready */ 131258945Sroberto 132258945Sroberto/* 133258945Sroberto * This is filled in partially by the chip, partially by us. 134258945Sroberto */ 135258945Srobertostruct ie_recv_frame_desc { 136258945Sroberto u_short ie_fd_status; /* status for this frame */ 137258945Sroberto u_short ie_fd_last; /* end of frame list flag */ 138258945Sroberto u_short ie_fd_next; /* 16-pointer to next RFD */ 139258945Sroberto u_short ie_fd_buf_desc; /* 16-pointer to list of buffer desc's */ 140258945Sroberto struct ie_en_addr dest; /* destination ether */ 141258945Sroberto struct ie_en_addr src; /* source ether */ 142258945Sroberto u_short ie_length; /* 802 length/Ether type */ 143258945Sroberto u_short mbz; /* must be zero */ 144258945Sroberto}; 145258945Sroberto 146258945Sroberto#define IE_FD_LAST 0x8000 /* last rfd in list */ 147258945Sroberto#define IE_FD_SUSP 0x4000 /* suspend RU after receipt */ 148258945Sroberto 149258945Sroberto#define IE_FD_COMPLETE 0x8000 /* frame is complete */ 150258945Sroberto#define IE_FD_BUSY 0x4000 /* frame is busy */ 151258945Sroberto#define IE_FD_OK 0x2000 /* frame is bad */ 152258945Sroberto#define IE_FD_RNR 0x0200 /* receiver out of resources here */ 153258945Sroberto 154258945Sroberto/* 155258945Sroberto * linked list of buffers... 156258945Sroberto */ 157258945Srobertostruct ie_recv_buf_desc { 158258945Sroberto u_short ie_rbd_actual; /* status for this buffer */ 159258945Sroberto u_short ie_rbd_next; /* 16-pointer to next RBD */ 160258945Sroberto caddr_t ie_rbd_buffer; /* 24-pointer to buffer for this RBD */ 161258945Sroberto u_short ie_rbd_length; /* length of the buffer */ 162258945Sroberto u_short mbz; /* must be zero */ 163258945Sroberto}; 164258945Sroberto 165258945Sroberto#define IE_RBD_LAST 0x8000 /* last buffer */ 166258945Sroberto#define IE_RBD_USED 0x4000 /* this buffer has data */ 167258945Sroberto/* 168258945Sroberto * All commands share this in common. 169258945Sroberto */ 170258945Srobertostruct ie_cmd_common { 171258945Sroberto u_short ie_cmd_status; /* status of this command */ 172258945Sroberto u_short ie_cmd_cmd; /* command word */ 173258945Sroberto u_short ie_cmd_link; /* link to next command */ 174258945Sroberto}; 175258945Sroberto 176258945Sroberto#define IE_STAT_COMPL 0x8000 /* command is completed */ 177258945Sroberto#define IE_STAT_BUSY 0x4000 /* command is running now */ 178258945Sroberto#define IE_STAT_OK 0x2000 /* command completed successfully */ 179258945Sroberto 180258945Sroberto#define IE_CMD_NOP 0x0000 /* NOP */ 181258945Sroberto#define IE_CMD_IASETUP 0x0001 /* initial address setup */ 182258945Sroberto#define IE_CMD_CONFIG 0x0002 /* configure command */ 183258945Sroberto#define IE_CMD_MCAST 0x0003 /* multicast setup command */ 184258945Sroberto#define IE_CMD_XMIT 0x0004 /* transmit command */ 185258945Sroberto#define IE_CMD_TDR 0x0005 /* time-domain reflectometer command */ 186258945Sroberto#define IE_CMD_DUMP 0x0006 /* dump command */ 187258945Sroberto#define IE_CMD_DIAGNOSE 0x0007 /* diagnostics command */ 188258945Sroberto 189258945Sroberto#define IE_CMD_LAST 0x8000 /* this is the last command in the list */ 190258945Sroberto#define IE_CMD_SUSPEND 0x4000 /* suspend CU after this command */ 191258945Sroberto#define IE_CMD_INTR 0x2000 /* post an interrupt after completion */ 192258945Sroberto 193258945Sroberto/* 194258945Sroberto * This is the command to transmit a frame. 195258945Sroberto */ 196258945Srobertostruct ie_xmit_cmd { 197258945Sroberto struct ie_cmd_common com; /* common part */ 198258945Sroberto#define ie_xmit_status com.ie_cmd_status 199258945Sroberto 200258945Sroberto u_short ie_xmit_desc; /* 16-pointer to buffer descriptor */ 201258945Sroberto struct ie_en_addr ie_xmit_addr; /* destination address */ 202258945Sroberto 203258945Sroberto u_short ie_xmit_length; /* 802.3 length/Ether type field */ 204258945Sroberto}; 205258945Sroberto 206258945Sroberto#define IE_XS_MAXCOLL 0x000f /* number of collisions during transmit */ 207258945Sroberto#define IE_XS_EXCMAX 0x0020 /* exceeded maximum number of collisions */ 208258945Sroberto#define IE_XS_SQE 0x0040 /* SQE positive */ 209258945Sroberto#define IE_XS_DEFERRED 0x0080 /* transmission deferred */ 210258945Sroberto#define IE_XS_UNDERRUN 0x0100 /* DMA underrun */ 211258945Sroberto#define IE_XS_LOSTCTS 0x0200 /* Lost CTS */ 212258945Sroberto#define IE_XS_NOCARRIER 0x0400 /* No Carrier */ 213258945Sroberto#define IE_XS_LATECOLL 0x0800 /* Late collision */ 214258945Sroberto 215258945Sroberto/* 216258945Sroberto * This is a buffer descriptor for a frame to be transmitted. 217258945Sroberto */ 218258945Sroberto 219258945Srobertostruct ie_xmit_buf { 220258945Sroberto u_short ie_xmit_flags; /* see below */ 221258945Sroberto u_short ie_xmit_next; /* 16-pointer to next desc. */ 222258945Sroberto caddr_t ie_xmit_buf; /* 24-pointer to the actual buffer */ 223258945Sroberto}; 224258945Sroberto 225258945Sroberto#define IE_XMIT_LAST 0x8000 /* this TBD is the last one */ 226258945Sroberto/* The rest of the `flags' word is actually the length. */ 227258945Sroberto 228258945Sroberto/* 229258945Sroberto * Multicast setup command. 230258945Sroberto */ 231258945Sroberto 232258945Sroberto#define MAXMCAST 50 /* must fit in transmit buffer */ 233258945Sroberto 234258945Srobertostruct ie_mcast_cmd { 235258945Sroberto struct ie_cmd_common com; /* common part */ 236258945Sroberto#define ie_mcast_status com.ie_cmd_status 237258945Sroberto 238258945Sroberto u_short ie_mcast_bytes; /* size (in bytes) of multicast addresses */ 239258945Sroberto struct ie_en_addr ie_mcast_addrs[MAXMCAST + 1]; /* space for them */ 240258945Sroberto}; 241258945Sroberto 242258945Sroberto/* 243258945Sroberto * Time Domain Reflectometer command. 244258945Sroberto */ 245258945Sroberto 246258945Srobertostruct ie_tdr_cmd { 247258945Sroberto struct ie_cmd_common com; /* common part */ 248258945Sroberto#define ie_tdr_status com.ie_cmd_status 249258945Sroberto 250258945Sroberto u_short ie_tdr_time; /* error bits and time */ 251258945Sroberto}; 252258945Sroberto 253258945Sroberto#define IE_TDR_SUCCESS 0x8000 /* TDR succeeded without error */ 254258945Sroberto#define IE_TDR_XCVR 0x4000 /* detected a transceiver problem */ 255258945Sroberto#define IE_TDR_OPEN 0x2000 /* detected an open */ 256258945Sroberto#define IE_TDR_SHORT 0x1000 /* TDR detected a short */ 257258945Sroberto#define IE_TDR_TIME 0x07ff /* mask for reflection time */ 258258945Sroberto 259258945Sroberto/* 260258945Sroberto * Initial Address Setup command 261258945Sroberto */ 262258945Srobertostruct ie_iasetup_cmd { 263258945Sroberto struct ie_cmd_common com; 264258945Sroberto#define ie_iasetup_status com.ie_cmd_status 265258945Sroberto 266258945Sroberto struct ie_en_addr ie_address; 267258945Sroberto}; 268258945Sroberto 269258945Sroberto/* 270258945Sroberto * Configuration command 271258945Sroberto */ 272258945Srobertostruct ie_config_cmd { 273258945Sroberto struct ie_cmd_common com; /* common part */ 274258945Sroberto#define ie_config_status com.ie_cmd_status 275258945Sroberto 276258945Sroberto u_char ie_config_count; /* byte count (0x0c) */ 277258945Sroberto u_char ie_fifo; /* fifo (8) */ 278258945Sroberto u_char ie_save_bad; /* save bad frames (0x40) */ 279258945Sroberto u_char ie_addr_len; /* address length (0x2e) (AL-LOC == 1) */ 280258945Sroberto u_char ie_priority; /* priority and backoff (0x0) */ 281258945Sroberto u_char ie_ifs; /* inter-frame spacing (0x60) */ 282258945Sroberto u_char ie_slot_low; /* slot time, LSB (0x0) */ 283258945Sroberto u_char ie_slot_high; /* slot time, MSN, and retries (0xf2) */ 284258945Sroberto u_char ie_promisc; /* 1 if promiscuous, else 0 */ 285258945Sroberto u_char ie_crs_cdt; /* CSMA/CD parameters (0x0) */ 286258945Sroberto u_char ie_min_len; /* min frame length (0x40) */ 287258945Sroberto u_char ie_junk; /* stuff for 82596 (0xff) */ 288258945Sroberto}; 289258945Sroberto 290258945Sroberto/* 291258945Sroberto * Here are a few useful functions. We could have done these as macros, 292258945Sroberto * but since we have the inline facility, it makes sense to use that 293258945Sroberto * instead. 294258945Sroberto */ 295258945Srobertoinline void 296258945Srobertoie_setup_config(volatile struct ie_config_cmd *cmd, 297258945Sroberto int promiscuous, int manchester) { 298258945Sroberto cmd->ie_config_count = 0x0c; 299258945Sroberto cmd->ie_fifo = 8; 300258945Sroberto cmd->ie_save_bad = 0x40; 301258945Sroberto cmd->ie_addr_len = 0x2e; 302258945Sroberto cmd->ie_priority = 0; 303258945Sroberto cmd->ie_ifs = 0x60; 304258945Sroberto cmd->ie_slot_low = 0; 305258945Sroberto cmd->ie_slot_high = 0xf2; 306258945Sroberto cmd->ie_promisc = !!promiscuous | manchester << 2; 307258945Sroberto cmd->ie_crs_cdt = 0; 308258945Sroberto cmd->ie_min_len = 64; 309258945Sroberto cmd->ie_junk = 0xff; 310258945Sroberto} 311258945Sroberto 312258945Srobertostatic inline caddr_t 313258945SrobertoAlign(caddr_t ptr) { 314258945Sroberto unsigned long l = (unsigned long)ptr; 315258945Sroberto l = (l + 3) & ~3L; 316258945Sroberto return (caddr_t)l; 317258945Sroberto} 318258945Sroberto 319258945Srobertostatic inline void 320258945Srobertoie_ack(volatile struct ie_sys_ctl_block *scb, 321258945Sroberto u_int mask, int unit, 322280849Scy void (*ca)(int)) { 323258945Sroberto scb->ie_command = scb->ie_status & mask; 324258945Sroberto (*ca)(unit); 325258945Sroberto} 326258945Sroberto