i82586.h revision 1.2 1 1.2 agc /* $NetBSD: i82586.h,v 1.2 2003/12/10 12:06:25 agc Exp $ */
2 1.1 chuck
3 1.1 chuck /*-
4 1.1 chuck * Copyright (c) 1992, University of Vermont and State Agricultural College.
5 1.1 chuck * Copyright (c) 1992, Garrett A. Wollman.
6 1.1 chuck * All rights reserved.
7 1.1 chuck *
8 1.1 chuck * Redistribution and use in source and binary forms, with or without
9 1.1 chuck * modification, are permitted provided that the following conditions
10 1.1 chuck * are met:
11 1.1 chuck * 1. Redistributions of source code must retain the above copyright
12 1.1 chuck * notice, this list of conditions and the following disclaimer.
13 1.1 chuck * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 chuck * notice, this list of conditions and the following disclaimer in the
15 1.1 chuck * documentation and/or other materials provided with the distribution.
16 1.1 chuck * 3. All advertising materials mentioning features or use of this software
17 1.1 chuck * must display the following acknowledgement:
18 1.1 chuck * This product includes software developed by the University of
19 1.1 chuck * Vermont and State Agricultural College and Garrett A. Wollman.
20 1.1 chuck * 4. Neither the name of the University nor the name of the author
21 1.1 chuck * may be used to endorse or promote products derived from this software
22 1.1 chuck * without specific prior written permission.
23 1.1 chuck *
24 1.1 chuck * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.1 chuck * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.1 chuck * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.1 chuck * ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR AUTHOR BE LIABLE
28 1.1 chuck * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.1 chuck * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.1 chuck * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.1 chuck * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.1 chuck * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.1 chuck * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.1 chuck * SUCH DAMAGE.
35 1.2 agc */
36 1.2 agc
37 1.2 agc /*-
38 1.2 agc * Copyright (c) 1995 Theo de Raadt. All rights reserved.
39 1.2 agc *
40 1.2 agc * Redistribution and use in source and binary forms, with or without
41 1.2 agc * modification, are permitted provided that the following conditions
42 1.2 agc * are met:
43 1.2 agc * 1. Redistributions of source code must retain the above copyright
44 1.2 agc * notice, this list of conditions and the following disclaimer.
45 1.2 agc * 2. Redistributions in binary form must reproduce the above copyright
46 1.2 agc * notice, this list of conditions and the following disclaimer in the
47 1.2 agc * documentation and/or other materials provided with the distribution.
48 1.2 agc *
49 1.2 agc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
50 1.2 agc * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
51 1.2 agc * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
52 1.2 agc * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
53 1.2 agc * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
54 1.2 agc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55 1.2 agc * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
56 1.2 agc * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57 1.2 agc * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
58 1.2 agc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 1.1 chuck */
60 1.1 chuck
61 1.1 chuck /*
62 1.1 chuck * Intel 82586 Ethernet chip
63 1.1 chuck * Register, bit, and structure definitions.
64 1.1 chuck *
65 1.1 chuck * Written by GAW with reference to the Clarkson Packet Driver code for this
66 1.1 chuck * chip written by Russ Nelson and others.
67 1.1 chuck */
68 1.1 chuck
69 1.1 chuck struct ie_en_addr {
70 1.1 chuck u_char data[6];
71 1.1 chuck };
72 1.1 chuck /*
73 1.1 chuck * the only actual IE registers.
74 1.1 chuck */
75 1.1 chuck struct iereg {
76 1.1 chuck u_short ie_porthigh;
77 1.1 chuck u_short ie_portlow;
78 1.1 chuck u_long ie_attention;
79 1.1 chuck };
80 1.1 chuck #define IE_PORT_NEWSCP 0x00000002
81 1.1 chuck #define IE_PORT_RESET 0x00000000
82 1.1 chuck
83 1.1 chuck /*
84 1.1 chuck * This is the master configuration block. It tells the hardware where
85 1.1 chuck * all the rest of the stuff is.
86 1.1 chuck */
87 1.1 chuck struct ie_scp {
88 1.1 chuck u_char mbz1[3]; /* must be zero */
89 1.1 chuck u_char scp_sysbus; /* true if 8-bit only */
90 1.1 chuck u_char mbz2[4]; /* must be zero */
91 1.1 chuck u_short scp_iscp_low; /* 24-bit physaddr of ISCP */
92 1.1 chuck u_char mbz3[1];
93 1.1 chuck u_char scp_iscp_high; /* the rest of the physaddr.. */
94 1.1 chuck };
95 1.1 chuck /*
96 1.1 chuck * The tells the hardware where all the rest of the stuff is, too.
97 1.1 chuck * FIXME: some of these should be re-commented after we figure out their
98 1.1 chuck * REAL function.
99 1.1 chuck */
100 1.1 chuck struct ie_iscp {
101 1.1 chuck u_char mbz1[1];
102 1.1 chuck u_char iscp_busy; /* zeroed after init */
103 1.1 chuck u_short iscp_scboffset; /* 16-bit physaddr of next struct */
104 1.1 chuck u_short iscp_base_low; /* 24-bit physaddr for all 16-bit vars */
105 1.1 chuck u_char mbz2[1];
106 1.1 chuck u_char iscp_base_high; /* rest of physaddr ... */
107 1.1 chuck };
108 1.1 chuck /*
109 1.1 chuck * This FINALLY tells the hardware what to do and where to put it.
110 1.1 chuck */
111 1.1 chuck struct ie_scb {
112 1.1 chuck u_short ie_status; /* status word */
113 1.1 chuck u_short ie_command; /* command word */
114 1.1 chuck u_short ie_command_list;/* 16-pointer to command block list */
115 1.1 chuck u_short ie_recv_list; /* 16-pointer to receive frame list */
116 1.1 chuck u_short ie_err_crc; /* CRC errors */
117 1.1 chuck u_short ie_err_align; /* Alignment errors */
118 1.1 chuck u_short ie_err_resource;/* Resource errors */
119 1.1 chuck u_short ie_err_overrun; /* Overrun errors */
120 1.1 chuck };
121 1.1 chuck /* Command values */
122 1.1 chuck #define IE_RU_COMMAND 0x0070 /* mask for RU command */
123 1.1 chuck #define IE_RU_NOP 0 /* for completeness */
124 1.1 chuck #define IE_RU_START 0x0010 /* start receive unit command */
125 1.1 chuck #define IE_RU_ENABLE 0x0020 /* enable receiver command */
126 1.1 chuck #define IE_RU_DISABLE 0x0030 /* disable receiver command */
127 1.1 chuck #define IE_RU_ABORT 0x0040 /* abort current receive operation */
128 1.1 chuck
129 1.1 chuck #define IE_CU_COMMAND 0x0700 /* mask for CU command */
130 1.1 chuck #define IE_CU_NOP 0 /* included for completeness */
131 1.1 chuck #define IE_CU_START 0x0100 /* do-command command */
132 1.1 chuck #define IE_CU_RESUME 0x0200 /* resume a suspended cmd list */
133 1.1 chuck #define IE_CU_STOP 0x0300 /* SUSPEND was already taken */
134 1.1 chuck #define IE_CU_ABORT 0x0400 /* abort current command */
135 1.1 chuck
136 1.1 chuck #define IE_ACK_COMMAND 0xf000 /* mask for ACK command */
137 1.1 chuck #define IE_ACK_CX 0x8000 /* ack IE_ST_DONE */
138 1.1 chuck #define IE_ACK_FR 0x4000 /* ack IE_ST_RECV */
139 1.1 chuck #define IE_ACK_CNA 0x2000 /* ack IE_ST_ALLDONE */
140 1.1 chuck #define IE_ACK_RNR 0x1000 /* ack IE_ST_RNR */
141 1.1 chuck
142 1.1 chuck #define IE_ACTION_COMMAND(x) (((x) & IE_CU_COMMAND) == IE_CU_START)
143 1.1 chuck /* is this command an action command? */
144 1.1 chuck
145 1.1 chuck /* Status values */
146 1.1 chuck #define IE_ST_WHENCE 0xf000 /* mask for cause of interrupt */
147 1.1 chuck #define IE_ST_DONE 0x8000 /* command with I bit completed */
148 1.1 chuck #define IE_ST_RECV 0x4000 /* frame received */
149 1.1 chuck #define IE_ST_ALLDONE 0x2000 /* all commands completed */
150 1.1 chuck #define IE_ST_RNR 0x1000 /* receive not ready */
151 1.1 chuck
152 1.1 chuck #define IE_CU_STATUS 0x700 /* mask for command unit status */
153 1.1 chuck #define IE_CU_ACTIVE 0x200 /* command unit is active */
154 1.1 chuck #define IE_CU_SUSPEND 0x100 /* command unit is suspended */
155 1.1 chuck
156 1.1 chuck #define IE_RU_STATUS 0x70 /* mask for receiver unit status */
157 1.1 chuck #define IE_RU_SUSPEND 0x10 /* receiver is suspended */
158 1.1 chuck #define IE_RU_NOSPACE 0x20 /* receiver has no resources */
159 1.1 chuck #define IE_RU_READY 0x40 /* receiver is ready */
160 1.1 chuck
161 1.1 chuck /*
162 1.1 chuck * This is filled in partially by the chip, partially by us.
163 1.1 chuck */
164 1.1 chuck struct ie_recv_frame_desc {
165 1.1 chuck u_short ie_fd_status; /* status for this frame */
166 1.1 chuck u_short ie_fd_last; /* end of frame list flag */
167 1.1 chuck u_short ie_fd_next; /* 16-pointer to next RFD */
168 1.1 chuck u_short ie_fd_buf_desc; /* 16-pointer to list of buffer desc's */
169 1.1 chuck struct ie_en_addr dest; /* destination ether */
170 1.1 chuck struct ie_en_addr src; /* source ether */
171 1.1 chuck u_short ie_length; /* 802 length/Ether type */
172 1.1 chuck u_short mbz; /* must be zero */
173 1.1 chuck };
174 1.1 chuck #define IE_FD_LAST 0x8000 /* last rfd in list */
175 1.1 chuck #define IE_FD_SUSP 0x4000 /* suspend RU after receipt */
176 1.1 chuck
177 1.1 chuck #define IE_FD_COMPLETE 0x8000 /* frame is complete */
178 1.1 chuck #define IE_FD_BUSY 0x4000 /* frame is busy */
179 1.1 chuck #define IE_FD_OK 0x2000 /* frame is bad */
180 1.1 chuck #define IE_FD_RNR 0x0200 /* receiver out of resources here */
181 1.1 chuck
182 1.1 chuck /*
183 1.1 chuck * linked list of buffers...
184 1.1 chuck */
185 1.1 chuck struct ie_recv_buf_desc {
186 1.1 chuck u_short ie_rbd_actual; /* status for this buffer */
187 1.1 chuck u_short ie_rbd_next; /* 16-pointer to next RBD */
188 1.1 chuck u_short ie_rbd_buffer_low; /* 24-pointer to buffer for this RBD */
189 1.1 chuck u_short ie_rbd_buffer_high; /* 24-pointer to buffer for this RBD */
190 1.1 chuck u_short ie_rbd_length; /* length of the buffer */
191 1.1 chuck u_short mbz; /* must be zero */
192 1.1 chuck };
193 1.1 chuck #define IE_RBD_LAST 0x8000 /* last buffer */
194 1.1 chuck #define IE_RBD_USED 0x4000 /* this buffer has data */
195 1.1 chuck /*
196 1.1 chuck * All commands share this in common.
197 1.1 chuck */
198 1.1 chuck struct ie_cmd_common {
199 1.1 chuck u_short ie_cmd_status; /* status of this command */
200 1.1 chuck u_short ie_cmd_cmd; /* command word */
201 1.1 chuck u_short ie_cmd_link; /* link to next command */
202 1.1 chuck };
203 1.1 chuck #define IE_STAT_COMPL 0x8000 /* command is completed */
204 1.1 chuck #define IE_STAT_BUSY 0x4000 /* command is running now */
205 1.1 chuck #define IE_STAT_OK 0x2000 /* command completed successfully */
206 1.1 chuck #define IE_STAT_ABORT 0x1000 /* command was aborted */
207 1.1 chuck
208 1.1 chuck
209 1.1 chuck #define IE_CMD_NOP 0x0000 /* NOP */
210 1.1 chuck #define IE_CMD_IASETUP 0x0001 /* initial address setup */
211 1.1 chuck #define IE_CMD_CONFIG 0x0002 /* configure command */
212 1.1 chuck #define IE_CMD_MCAST 0x0003 /* multicast setup command */
213 1.1 chuck #define IE_CMD_XMIT 0x0004 /* transmit command */
214 1.1 chuck #define IE_CMD_TDR 0x0005 /* time-domain reflectometer command */
215 1.1 chuck #define IE_CMD_DUMP 0x0006 /* dump command */
216 1.1 chuck #define IE_CMD_DIAGNOSE 0x0007 /* diagnostics command */
217 1.1 chuck
218 1.1 chuck #define IE_CMD_LAST 0x8000 /* this is the last command in the list */
219 1.1 chuck #define IE_CMD_SUSPEND 0x4000 /* suspend CU after this command */
220 1.1 chuck #define IE_CMD_INTR 0x2000 /* post an interrupt after completion */
221 1.1 chuck
222 1.1 chuck /*
223 1.1 chuck * This is the command to transmit a frame.
224 1.1 chuck */
225 1.1 chuck struct ie_xmit_cmd {
226 1.1 chuck struct ie_cmd_common com; /* common part */
227 1.1 chuck #define ie_xmit_status com.ie_cmd_status
228 1.1 chuck
229 1.1 chuck u_short ie_xmit_desc; /* 16-pointer to buffer descriptor */
230 1.1 chuck struct ie_en_addr ie_xmit_addr; /* destination address */
231 1.1 chuck
232 1.1 chuck u_short ie_xmit_length; /* 802.3 length/Ether type field */
233 1.1 chuck };
234 1.1 chuck #define IE_XS_MAXCOLL 0x000f /* number of collisions during transmit */
235 1.1 chuck #define IE_XS_EXCMAX 0x0020 /* exceeded maximum number of collisions */
236 1.1 chuck #define IE_XS_SQE 0x0040 /* SQE positive */
237 1.1 chuck #define IE_XS_DEFERRED 0x0080 /* transmission deferred */
238 1.1 chuck #define IE_XS_UNDERRUN 0x0100 /* DMA underrun */
239 1.1 chuck #define IE_XS_LOSTCTS 0x0200 /* Lost CTS */
240 1.1 chuck #define IE_XS_NOCARRIER 0x0400 /* No Carrier */
241 1.1 chuck
242 1.1 chuck /*
243 1.1 chuck * This is a buffer descriptor for a frame to be transmitted.
244 1.1 chuck */
245 1.1 chuck
246 1.1 chuck struct ie_xmit_buf {
247 1.1 chuck u_short ie_xmit_flags; /* see below */
248 1.1 chuck u_short ie_xmit_next; /* 16-pointer to next desc. */
249 1.1 chuck u_short ie_xmit_buf_low;/* 24-pointer to the actual buffer */
250 1.1 chuck u_short ie_xmit_buf_high; /* 24-pointer to the actual buffer */
251 1.1 chuck };
252 1.1 chuck #define IE_XMIT_LAST 0x8000 /* this TBD is the last one */
253 1.1 chuck /* The rest of the `flags' word is actually the length. */
254 1.1 chuck
255 1.1 chuck /*
256 1.1 chuck * Multicast setup command.
257 1.1 chuck */
258 1.1 chuck
259 1.1 chuck #define MAXMCAST 250 /* must fit in transmit buffer */
260 1.1 chuck
261 1.1 chuck struct ie_mcast_cmd {
262 1.1 chuck struct ie_cmd_common com; /* common part */
263 1.1 chuck #define ie_mcast_status com.ie_cmd_status
264 1.1 chuck
265 1.1 chuck u_short ie_mcast_bytes; /* size (in bytes) of multicast addresses */
266 1.1 chuck struct ie_en_addr ie_mcast_addrs[MAXMCAST + 1]; /* space for them */
267 1.1 chuck };
268 1.1 chuck /*
269 1.1 chuck * Time Domain Reflectometer command.
270 1.1 chuck */
271 1.1 chuck
272 1.1 chuck struct ie_tdr_cmd {
273 1.1 chuck struct ie_cmd_common com; /* common part */
274 1.1 chuck #define ie_tdr_status com.ie_cmd_status
275 1.1 chuck
276 1.1 chuck u_short ie_tdr_time; /* error bits and time */
277 1.1 chuck };
278 1.1 chuck #define IE_TDR_SUCCESS 0x8000 /* TDR succeeded without error */
279 1.1 chuck #define IE_TDR_XCVR 0x4000 /* detected a transceiver problem */
280 1.1 chuck #define IE_TDR_OPEN 0x2000 /* detected an open */
281 1.1 chuck #define IE_TDR_SHORT 0x1000 /* TDR detected a short */
282 1.1 chuck #define IE_TDR_TIME 0x07ff /* mask for reflection time */
283 1.1 chuck
284 1.1 chuck /*
285 1.1 chuck * Initial Address Setup command
286 1.1 chuck */
287 1.1 chuck struct ie_iasetup_cmd {
288 1.1 chuck struct ie_cmd_common com;
289 1.1 chuck #define ie_iasetup_status com.ie_cmd_status
290 1.1 chuck
291 1.1 chuck struct ie_en_addr ie_address;
292 1.1 chuck };
293 1.1 chuck /*
294 1.1 chuck * Configuration command
295 1.1 chuck */
296 1.1 chuck struct ie_config_cmd {
297 1.1 chuck struct ie_cmd_common com; /* common part */
298 1.1 chuck #define ie_config_status com.ie_cmd_status
299 1.1 chuck
300 1.1 chuck u_char ie_config_count;/* byte count (0x0c) */
301 1.1 chuck u_char ie_fifo; /* fifo (8) */
302 1.1 chuck u_char ie_save_bad; /* save bad frames (0x40) */
303 1.1 chuck u_char ie_addr_len; /* address length (0x2e) (AL-LOC == 1) */
304 1.1 chuck u_char ie_priority; /* priority and backoff (0x0) */
305 1.1 chuck u_char ie_ifs; /* inter-frame spacing (0x60) */
306 1.1 chuck u_char ie_slot_low; /* slot time, LSB (0x0) */
307 1.1 chuck u_char ie_slot_high; /* slot time, MSN, and retries (0xf2) */
308 1.1 chuck u_char ie_promisc; /* 1 if promiscuous, else 0 */
309 1.1 chuck u_char ie_crs_cdt; /* CSMA/CD parameters (0x0) */
310 1.1 chuck u_char ie_min_len; /* min frame length (0x40) */
311 1.1 chuck u_char ie_junk; /* stuff for 82596 (0xff) */
312 1.1 chuck };
313 1.1 chuck
314 1.1 chuck struct iemem {
315 1.1 chuck volatile struct ie_scp im_scp;
316 1.1 chuck u_char xx1[4];
317 1.1 chuck volatile struct ie_iscp im_iscp;
318 1.1 chuck
319 1.1 chuck volatile struct ie_scb im_scb;
320 1.1 chuck volatile struct ie_config_cmd im_cc;
321 1.1 chuck volatile struct ie_iasetup_cmd im_ic;
322 1.1 chuck volatile struct ie_recv_frame_desc im_rfd[NRXBUF];
323 1.1 chuck volatile struct ie_recv_buf_desc im_rbd[NRXBUF];
324 1.1 chuck volatile struct ie_xmit_cmd im_xc[NTXBUF];
325 1.1 chuck volatile struct ie_xmit_buf im_xd[NTXBUF];
326 1.1 chuck volatile u_char im_rxbuf[NRXBUF * IE_RBUF_SIZE];
327 1.1 chuck volatile u_char im_txbuf[NTXBUF * ETHER_MAX_LEN];
328 1.1 chuck
329 1.1 chuck };
330