1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Intel i82586 Ethernet definitions
4  *
5  * This is an extension to the Linux operating system, and is covered by the
6  * same Gnu Public License that covers that work.
7  *
8  * copyrights (c) 1994 by Michael Hipp (hippm@informatik.uni-tuebingen.de)
9  *
10  * I have done a look in the following sources:
11  *   crynwr-packet-driver by Russ Nelson
12  *   Garret A. Wollman's i82586-driver for BSD
13  */
14 
15 /*
16  * Cloned from ni52.h, copyright as above.
17  *
18  * Modified for Sun3 OBIO i82586 by Sam Creasey (sammy@sammy.net)
19  */
20 
21 
22 /* defines for the obio chip (not vme) */
23 #define IEOB_NORSET 0x80        /* don't reset the board */
24 #define IEOB_ONAIR  0x40        /* put us on the air */
25 #define IEOB_ATTEN  0x20        /* attention! */
26 #define IEOB_IENAB  0x10        /* interrupt enable */
27 #define IEOB_XXXXX  0x08        /* free bit */
28 #define IEOB_XCVRL2 0x04        /* level 2 transceiver? */
29 #define IEOB_BUSERR 0x02        /* bus error */
30 #define IEOB_INT    0x01        /* interrupt */
31 
32 /* where the obio one lives */
33 #define IE_OBIO 0xc0000
34 #define IE_IRQ 3
35 
36 /*
37  * where to find the System Configuration Pointer (SCP)
38  */
39 #define SCP_DEFAULT_ADDRESS 0xfffff4
40 
41 
42 /*
43  * System Configuration Pointer Struct
44  */
45 
46 struct scp_struct
47 {
48   unsigned short zero_dum0;	/* has to be zero */
49   unsigned char  sysbus;	/* 0=16Bit,1=8Bit */
50   unsigned char  zero_dum1;	/* has to be zero for 586 */
51   unsigned short zero_dum2;
52   unsigned short zero_dum3;
53   char          *iscp;		/* pointer to the iscp-block */
54 };
55 
56 
57 /*
58  * Intermediate System Configuration Pointer (ISCP)
59  */
60 struct iscp_struct
61 {
62   unsigned char  busy;          /* 586 clears after successful init */
63   unsigned char  zero_dummy;    /* has to be zero */
64   unsigned short scb_offset;    /* pointeroffset to the scb_base */
65   char          *scb_base;      /* base-address of all 16-bit offsets */
66 };
67 
68 /*
69  * System Control Block (SCB)
70  */
71 struct scb_struct
72 {
73   unsigned char rus;
74   unsigned char cus;
75   unsigned char cmd_ruc;           /* command word: RU part */
76   unsigned char cmd_cuc;           /* command word: CU part & ACK */
77   unsigned short cbl_offset;    /* pointeroffset, command block list */
78   unsigned short rfa_offset;    /* pointeroffset, receive frame area */
79   unsigned short crc_errs;      /* CRC-Error counter */
80   unsigned short aln_errs;      /* allignmenterror counter */
81   unsigned short rsc_errs;      /* Resourceerror counter */
82   unsigned short ovrn_errs;     /* OVerrunerror counter */
83 };
84 
85 /*
86  * possible command values for the command word
87  */
88 #define RUC_MASK	0x0070	/* mask for RU commands */
89 #define RUC_NOP		0x0000	/* NOP-command */
90 #define RUC_START	0x0010	/* start RU */
91 #define RUC_RESUME	0x0020	/* resume RU after suspend */
92 #define RUC_SUSPEND	0x0030	/* suspend RU */
93 #define RUC_ABORT	0x0040	/* abort receiver operation immediately */
94 
95 #define CUC_MASK        0x07  /* mask for CU command */
96 #define CUC_NOP         0x00  /* NOP-command */
97 #define CUC_START       0x01  /* start execution of 1. cmd on the CBL */
98 #define CUC_RESUME      0x02  /* resume after suspend */
99 #define CUC_SUSPEND     0x03  /* Suspend CU */
100 #define CUC_ABORT       0x04  /* abort command operation immediately */
101 
102 #define ACK_MASK        0xf0  /* mask for ACK command */
103 #define ACK_CX          0x80  /* acknowledges STAT_CX */
104 #define ACK_FR          0x40  /* ack. STAT_FR */
105 #define ACK_CNA         0x20  /* ack. STAT_CNA */
106 #define ACK_RNR         0x10  /* ack. STAT_RNR */
107 
108 /*
109  * possible status values for the status word
110  */
111 #define STAT_MASK       0xf0  /* mask for cause of interrupt */
112 #define STAT_CX         0x80  /* CU finished cmd with its I bit set */
113 #define STAT_FR         0x40  /* RU finished receiving a frame */
114 #define STAT_CNA        0x20  /* CU left active state */
115 #define STAT_RNR        0x10  /* RU left ready state */
116 
117 #define CU_STATUS       0x7   /* CU status, 0=idle */
118 #define CU_SUSPEND      0x1   /* CU is suspended */
119 #define CU_ACTIVE       0x2   /* CU is active */
120 
121 #define RU_STATUS	0x70	/* RU status, 0=idle */
122 #define RU_SUSPEND	0x10	/* RU suspended */
123 #define RU_NOSPACE	0x20	/* RU no resources */
124 #define RU_READY	0x40	/* RU is ready */
125 
126 /*
127  * Receive Frame Descriptor (RFD)
128  */
129 struct rfd_struct
130 {
131   unsigned char  stat_low;	/* status word */
132   unsigned char  stat_high;	/* status word */
133   unsigned char  rfd_sf;	/* 82596 mode only */
134   unsigned char  last;		/* Bit15,Last Frame on List / Bit14,suspend */
135   unsigned short next;		/* linkoffset to next RFD */
136   unsigned short rbd_offset;	/* pointeroffset to RBD-buffer */
137   unsigned char  dest[ETH_ALEN];	/* ethernet-address, destination */
138   unsigned char  source[ETH_ALEN];	/* ethernet-address, source */
139   unsigned short length;	/* 802.3 frame-length */
140   unsigned short zero_dummy;	/* dummy */
141 };
142 
143 #define RFD_LAST     0x80	/* last: last rfd in the list */
144 #define RFD_SUSP     0x40	/* last: suspend RU after  */
145 #define RFD_COMPL    0x80
146 #define RFD_OK       0x20
147 #define RFD_BUSY     0x40
148 #define RFD_ERR_LEN  0x10     /* Length error (if enabled length-checking */
149 #define RFD_ERR_CRC  0x08     /* CRC error */
150 #define RFD_ERR_ALGN 0x04     /* Alignment error */
151 #define RFD_ERR_RNR  0x02     /* status: receiver out of resources */
152 #define RFD_ERR_OVR  0x01     /* DMA Overrun! */
153 
154 #define RFD_ERR_FTS  0x0080	/* Frame too short */
155 #define RFD_ERR_NEOP 0x0040	/* No EOP flag (for bitstuffing only) */
156 #define RFD_ERR_TRUN 0x0020	/* (82596 only/SF mode) indicates truncated frame */
157 #define RFD_MATCHADD 0x0002     /* status: Destinationaddress !matches IA (only 82596) */
158 #define RFD_COLLDET  0x0001	/* Detected collision during reception */
159 
160 /*
161  * Receive Buffer Descriptor (RBD)
162  */
163 struct rbd_struct
164 {
165   unsigned short status;	/* status word,number of used bytes in buff */
166   unsigned short next;		/* pointeroffset to next RBD */
167   char          *buffer;	/* receive buffer address pointer */
168   unsigned short size;		/* size of this buffer */
169   unsigned short zero_dummy;    /* dummy */
170 };
171 
172 #define RBD_LAST	0x8000	/* last buffer */
173 #define RBD_USED	0x4000	/* this buffer has data */
174 #define RBD_MASK	0x3fff	/* size-mask for length */
175 
176 /*
177  * Statusvalues for Commands/RFD
178  */
179 #define STAT_COMPL   0x8000	/* status: frame/command is complete */
180 #define STAT_BUSY    0x4000	/* status: frame/command is busy */
181 #define STAT_OK      0x2000	/* status: frame/command is ok */
182 
183 /*
184  * Action-Commands
185  */
186 #define CMD_NOP		0x0000	/* NOP */
187 #define CMD_IASETUP	0x0001	/* initial address setup command */
188 #define CMD_CONFIGURE	0x0002	/* configure command */
189 #define CMD_MCSETUP	0x0003	/* MC setup command */
190 #define CMD_XMIT	0x0004	/* transmit command */
191 #define CMD_TDR		0x0005	/* time domain reflectometer (TDR) command */
192 #define CMD_DUMP	0x0006	/* dump command */
193 #define CMD_DIAGNOSE	0x0007	/* diagnose command */
194 
195 /*
196  * Action command bits
197  */
198 #define CMD_LAST	0x8000	/* indicates last command in the CBL */
199 #define CMD_SUSPEND	0x4000	/* suspend CU after this CB */
200 #define CMD_INT		0x2000	/* generate interrupt after execution */
201 
202 /*
203  * NOP - command
204  */
205 struct nop_cmd_struct
206 {
207   unsigned short cmd_status;	/* status of this command */
208   unsigned short cmd_cmd;       /* the command itself (+bits) */
209   unsigned short cmd_link;      /* offsetpointer to next command */
210 };
211 
212 /*
213  * IA Setup command
214  */
215 struct iasetup_cmd_struct
216 {
217   unsigned short cmd_status;
218   unsigned short cmd_cmd;
219   unsigned short cmd_link;
220   unsigned char  iaddr[6];
221 };
222 
223 /*
224  * Configure command
225  */
226 struct configure_cmd_struct
227 {
228   unsigned short cmd_status;
229   unsigned short cmd_cmd;
230   unsigned short cmd_link;
231   unsigned char  byte_cnt;   /* size of the config-cmd */
232   unsigned char  fifo;       /* fifo/recv monitor */
233   unsigned char  sav_bf;     /* save bad frames (bit7=1)*/
234   unsigned char  adr_len;    /* adr_len(0-2),al_loc(3),pream(4-5),loopbak(6-7)*/
235   unsigned char  priority;   /* lin_prio(0-2),exp_prio(4-6),bof_metd(7) */
236   unsigned char  ifs;        /* inter frame spacing */
237   unsigned char  time_low;   /* slot time low */
238   unsigned char  time_high;  /* slot time high(0-2) and max. retries(4-7) */
239   unsigned char  promisc;    /* promisc-mode(0) , et al (1-7) */
240   unsigned char  carr_coll;  /* carrier(0-3)/collision(4-7) stuff */
241   unsigned char  fram_len;   /* minimal frame len */
242   unsigned char  dummy;	     /* dummy */
243 };
244 
245 /*
246  * Multicast Setup command
247  */
248 struct mcsetup_cmd_struct
249 {
250   unsigned short cmd_status;
251   unsigned short cmd_cmd;
252   unsigned short cmd_link;
253   unsigned short mc_cnt;		/* number of bytes in the MC-List */
254   unsigned char  mc_list[][6];  	/* pointer to 6 bytes entries */
255 };
256 
257 /*
258  * DUMP command
259  */
260 struct dump_cmd_struct
261 {
262   unsigned short cmd_status;
263   unsigned short cmd_cmd;
264   unsigned short cmd_link;
265   unsigned short dump_offset;    /* pointeroffset to DUMP space */
266 };
267 
268 /*
269  * transmit command
270  */
271 struct transmit_cmd_struct
272 {
273   unsigned short cmd_status;
274   unsigned short cmd_cmd;
275   unsigned short cmd_link;
276   unsigned short tbd_offset;	/* pointeroffset to TBD */
277   unsigned char  dest[6];       /* destination address of the frame */
278   unsigned short length;	/* user defined: 802.3 length / Ether type */
279 };
280 
281 #define TCMD_ERRMASK     0x0fa0
282 #define TCMD_MAXCOLLMASK 0x000f
283 #define TCMD_MAXCOLL     0x0020
284 #define TCMD_HEARTBEAT   0x0040
285 #define TCMD_DEFERRED    0x0080
286 #define TCMD_UNDERRUN    0x0100
287 #define TCMD_LOSTCTS     0x0200
288 #define TCMD_NOCARRIER   0x0400
289 #define TCMD_LATECOLL    0x0800
290 
291 struct tdr_cmd_struct
292 {
293   unsigned short cmd_status;
294   unsigned short cmd_cmd;
295   unsigned short cmd_link;
296   unsigned short status;
297 };
298 
299 #define TDR_LNK_OK	0x8000	/* No link problem identified */
300 #define TDR_XCVR_PRB	0x4000	/* indicates a transceiver problem */
301 #define TDR_ET_OPN	0x2000	/* open, no correct termination */
302 #define TDR_ET_SRT	0x1000	/* TDR detected a short circuit */
303 #define TDR_TIMEMASK	0x07ff	/* mask for the time field */
304 
305 /*
306  * Transmit Buffer Descriptor (TBD)
307  */
308 struct tbd_struct
309 {
310   unsigned short size;		/* size + EOF-Flag(15) */
311   unsigned short next;          /* pointeroffset to next TBD */
312   char          *buffer;        /* pointer to buffer */
313 };
314 
315 #define TBD_LAST 0x8000         /* EOF-Flag, indicates last buffer in list */
316 
317 
318 
319 
320