xref: /minix/minix/drivers/net/dpeth/dp.h (revision e3b78ef1)
1 /*
2 **  File:	eth.h	Version 1.00,	Jan. 14, 1997
3 **
4 **  Author:	Giovanni Falzoni <gfalzoni@inwind.it>
5 **
6 **  Interface description for ethernet device driver
7 **
8 **  $Log$
9 **  Revision 1.5  2006/07/10 12:43:38  philip
10 **  Safecopy support in ethernet drivers.
11 **
12 **  Revision 1.4  2005/09/04 18:52:16  beng
13 **  Giovanni's fixes to dpeth:
14 **  Date: Sat, 03 Sep 2005 11:05:22 +0200
15 **  Subject: Minix 3.0.8
16 **
17 **  Revision 1.3  2005/08/03 11:53:34  jnherder
18 **  Miscellaneous cleanups.
19 **
20 **  Revision 1.2  2005/08/02 15:30:35  jnherder
21 **  Various updates to support dynamically starting drivers.
22 **  Output during initialization should be suppressed. Unless an error occurs.
23 **  Note that main() can now be main(int argc, char **argv) and arguments can
24 **  be passed when bringing up the driver.
25 **
26 **  Revision 1.1  2005/06/29 10:16:46  beng
27 **  Import of dpeth 3c501/3c509b/.. ethernet driver by
28 **  Giovanni Falzoni <fgalzoni@inwind.it>.
29 **
30 **  Revision 2.0  2005/06/26 16:16:46  lsodgf0
31 **  Initial revision for Minix 3.0.6
32 */
33 
34 #include <sys/null.h>
35 
36 #undef  ENABLE_3C501
37 #undef  ENABLE_3C503
38 #undef  ENABLE_3C509
39 #undef  ENABLE_NE2000
40 #undef  ENABLE_WDETH
41 #undef  ENABLE_DP8390
42 
43 #define ENABLE_3C501	1	/* enable 3Com Etherlink I board	 */
44 #define ENABLE_3C503	1	/* enable 3Com Etherlink II board 	 */
45 #define ENABLE_3C509	1	/* enable 3Com Etherlink III board 	 */
46 #define ENABLE_NE2000	1	/* enable Novell N2000 board      	 */
47 #define ENABLE_WDETH	1	/* enable Western Digital WD80x3  	 */
48 
49 #define ENABLE_DP8390	(ENABLE_3C503|ENABLE_WDETH|ENABLE_NE2000)
50 #define	HAVE_BUFFERS	(ENABLE_3C501|ENABLE_3C509)
51 
52 #define NOT(x) (~(x))
53 
54 #if VERBOSE == 1
55 #	define DEBUG(statm) statm
56 #else
57 #	define DEBUG(statm)
58 #endif
59 
60 typedef struct _m_hdr_t {	/* Buffer handling header */
61   struct _m_hdr_t *next;
62   int size;
63 } m_hdr_t;
64 
65 typedef struct _buff_t {	/* Receive/Transmit buffer header */
66   struct _buff_t *next;
67   int size;
68   int client;
69   char buffer[2];
70 } buff_t;
71 
72 struct dpeth;
73 typedef void (*dp_eth_t)(struct dpeth *);
74 typedef int (*dp_send_t)(struct dpeth *, struct netdriver_data *, size_t);
75 typedef ssize_t (*dp_recv_t)(struct dpeth *, struct netdriver_data *, size_t);
76 
77 #if ENABLE_DP8390 == 1
78 typedef void (*dp_user2nicf_t)(struct dpeth *, int, struct netdriver_data *,
79 	size_t);
80 typedef void (*dp_nic2userf_t)(struct dpeth *, int, struct netdriver_data *,
81 	size_t);
82 typedef void (*dp_getblock_t)(struct dpeth *, u16_t, int, void *);
83 #endif
84 
85 #define SENDQ_NR	2	/* Size of the send queue	 */
86 
87 typedef struct dpeth {
88   /* The de_base_port field is the starting point of the probe. The
89    * conf routine also fills de_linmem and de_irq. If the probe routine
90    * knows the irq and/or memory address because they are hardwired in
91    * the board, the probe should modify these fields. Futhermore, the
92    * probe routine should also fill in de_initf and de_stopf fields
93    * with the appropriate function pointers and set de_prog_IO iff
94    * programmed I/O is to be used.
95    *
96    * The initf function fills the following fields. Only cards that do
97    * programmed I/O fill in the de_data_port field. In addition, the
98    * init routine has to fill in the sendq data structures. */
99 
100   /* Board hardware interface */
101   port_t de_base_port;
102   port_t de_data_port;		/* For boards using Prog. I/O for xmit/recv */
103 
104   int de_irq;
105   int de_hook;			/* interrupt hook at kernel */
106 
107   char de_name[8];
108 
109 #define DEI_DEFAULT	0x8000
110 
111   phys_bytes de_linmem;		/* For boards using shared memory */
112   char *de_locmem;		/* Locally mapped (virtual) address */
113   int de_ramsize;		/* Size of on board memory	 */
114   int de_offset_page;		/* Offset of shared memory page	 */
115 
116   /* Board specific functions */
117   dp_eth_t de_initf;
118   dp_eth_t de_stopf;
119   dp_eth_t de_resetf;
120   dp_eth_t de_flagsf;
121   dp_eth_t de_getstatsf;
122   dp_eth_t de_dumpstatsf;
123   dp_eth_t de_interruptf;
124   dp_recv_t de_recvf;
125   dp_send_t de_sendf;
126 
127   ether_addr_t de_address;	/* Ethernet Address */
128   eth_stat_t de_stat;		/* Ethernet Statistics */
129   unsigned long bytes_Tx;	/* Total bytes sent/received */
130   unsigned long bytes_Rx;
131 
132 #define	SA_ADDR_LEN	sizeof(ether_addr_t)
133 
134   int de_flags;			/* Send/Receive mode (Configuration) */
135 
136 #define DEF_EMPTY	0x00
137 #define DEF_XMIT_BUSY	0x01
138 #define DEF_PROMISC	0x02
139 #define DEF_MULTI	0x04
140 #define DEF_BROAD	0x08
141 
142 #if ENABLE_DP8390 == 1
143   /* For use by NS DP8390 driver */
144   port_t de_dp8390_port;
145   int de_prog_IO;
146   int de_16bit;
147   int de_startpage;
148   int de_stoppage;
149 
150   /* Do it yourself send queue */
151   struct sendq {
152 	int sq_filled;		/* This buffer contains a packet */
153 	int sq_size;		/* with this size */
154 	int sq_sendpage;	/* starting page of the buffer */
155   } de_sendq[SENDQ_NR];
156   int de_sendq_nr;
157   int de_sendq_head;		/* Enqueue at the head */
158   int de_sendq_tail;		/* Dequeue at the tail */
159 
160   dp_user2nicf_t de_user2nicf;
161   dp_nic2userf_t de_nic2userf;
162   dp_getblock_t de_getblockf;
163 #endif
164 
165 #if ENABLE_3C509 == 1
166   /* For use by 3Com Etherlink III (3c509) driver */
167   port_t de_id_port;
168   port_t de_if_port;
169 #endif
170 
171 #if ENABLE_3C501 == 1 ||  ENABLE_3C509 == 1
172   /* For use by 3Com Etherlink (3c501 and 3c509) driver */
173   buff_t *de_recvq_head;
174   buff_t *de_recvq_tail;
175   u16_t de_recv_mode;
176   clock_t de_xmit_start;
177 #endif
178 
179 } dpeth_t;
180 
181 /*
182  *	Function definitions
183  */
184 
185 /* devio.c */
186 #if defined USE_IOPL
187 #include <machine/portio.h>
188 #else
189 unsigned int inb(unsigned short int);
190 unsigned int inw(unsigned short int);
191 void insb(unsigned short int, void *, int);
192 void insw(unsigned short int, void *, int);
193 void outb(unsigned short int, unsigned long);
194 void outw(unsigned short int, unsigned long);
195 void outsb(unsigned short int, void *, int);
196 #endif
197 
198 /* netbuff.c */
199 void *alloc_buff(dpeth_t *, int);
200 void free_buff(dpeth_t *, void *);
201 void init_buff(dpeth_t *, buff_t **);
202 
203 /* 3c501.c */
204 #if ENABLE_3C501 == 1
205 int el1_probe(dpeth_t *);
206 #else
207 #define el1_probe(x) (0)
208 #endif
209 
210 /* 3c503.c */
211 #if ENABLE_3C503 == 1
212 int el2_probe(dpeth_t *);
213 #else
214 #define el2_probe(x) (0)
215 #endif
216 
217 /* 3c509.c */
218 #if ENABLE_3C509 == 1
219 int el3_probe(dpeth_t *);
220 #else
221 #define el3_probe(x) (0)
222 #endif
223 
224 /* ne.c */
225 #if ENABLE_NE2000 == 1
226 int ne_probe(dpeth_t * dep);
227 #else
228 #define ne_probe(x) (0)
229 #endif
230 
231 /* wd.c */
232 #if ENABLE_WDETH == 1
233 int wdeth_probe(dpeth_t * dep);
234 #else
235 #define wdeth_probe(x) (0)
236 #endif
237 
238 /** dp.h **/
239