FreeBSD/Linux Kernel Cross Reference
sys/drivers/dpeth/dp.h
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: dp.h,v $
9 ** Revision 1.4 2005/09/04 18:52:16 beng
10 ** Giovanni's fixes to dpeth:
11 ** Date: Sat, 03 Sep 2005 11:05:22 +0200
12 ** Subject: Minix 3.0.8
13 **
14 ** Revision 1.3 2005/08/03 11:53:34 jnherder
15 ** Miscellaneous cleanups.
16 **
17 ** Revision 1.2 2005/08/02 15:30:35 jnherder
18 ** Various updates to support dynamically starting drivers.
19 ** Output during initialization should be suppressed. Unless an error occurs.
20 ** Note that main() can now be main(int argc, char **argv) and arguments can
21 ** be passed when bringing up the driver.
22 **
23 ** Revision 1.1 2005/06/29 10:16:46 beng
24 ** Import of dpeth 3c501/3c509b/.. ethernet driver by
25 ** Giovanni Falzoni <fgalzoni@inwind.it>.
26 **
27 ** Revision 2.0 2005/06/26 16:16:46 lsodgf0
28 ** Initial revision for Minix 3.0.6
29 **
30 ** $Id: dp.h,v 1.4 2005/09/04 18:52:16 beng Exp $
31 */
32
33 #undef ENABLE_3C501
34 #undef ENABLE_3C503
35 #undef ENABLE_3C509
36 #undef ENABLE_NE2000
37 #undef ENABLE_WDETH
38 #undef ENABLE_DP8390
39
40 #define ENABLE_3C501 1 /* enable 3Com Etherlink I board */
41 #define ENABLE_3C503 1 /* enable 3Com Etherlink II board */
42 #define ENABLE_3C509 1 /* enable 3Com Etherlink III board */
43 #define ENABLE_NE2000 1 /* enable Novell N2000 board */
44 #define ENABLE_WDETH 1 /* enable Western Digital WD80x3 */
45
46 #define ENABLE_DP8390 (ENABLE_3C503|ENABLE_WDETH|ENABLE_NE2000)
47 #define HAVE_BUFFERS (ENABLE_3C501|ENABLE_3C509)
48
49 #undef NULL
50 #define NULL ((void *)0)
51 #define NOT(x) (~(x))
52
53 #if debug == 1
54 # define DEBUG(statm) statm
55 #else
56 # define DEBUG(statm)
57 #endif
58
59 typedef struct _m_hdr_t { /* Buffer handling header */
60 struct _m_hdr_t *next;
61 int size;
62 } m_hdr_t;
63
64 typedef struct _buff_t { /* Receive/Transmit buffer header */
65 struct _buff_t *next;
66 int size;
67 int client;
68 char buffer[2];
69 } buff_t;
70
71 struct dpeth;
72 struct iovec_dat;
73 typedef void (*dp_eth_t) (struct dpeth *);
74 typedef void (*dp_send_recv_t) (struct dpeth *, int, int);
75
76 #if ENABLE_DP8390 == 1
77 typedef void (*dp_user2nicf_t) (struct dpeth *, int, int);
78 typedef void (*dp_nic2userf_t) (struct dpeth *, int, int);
79 typedef void (*dp_getblock_t) (struct dpeth *, u16_t, int, void *);
80 #endif
81
82 #define DE_PORT_NR 2 /* Number of devices supported */
83 #define SENDQ_NR 2 /* Size of the send queue */
84 #define IOVEC_NR 16 /* Number of IOVEC entries at a time */
85
86 typedef struct iovec_dat {
87 iovec_t iod_iovec[IOVEC_NR];
88 int iod_iovec_s;
89 int iod_proc_nr;
90 vir_bytes iod_iovec_addr;
91 } iovec_dat_t;
92
93 typedef struct dpeth {
94 /* The de_base_port field is the starting point of the probe. The
95 * conf routine also fills de_linmem and de_irq. If the probe routine
96 * knows the irq and/or memory address because they are hardwired in
97 * the board, the probe should modify these fields. Futhermore, the
98 * probe routine should also fill in de_initf and de_stopf fields
99 * with the appropriate function pointers and set de_prog_IO iff
100 * programmed I/O is to be used.
101 *
102 * The initf function fills the following fields. Only cards that do
103 * programmed I/O fill in the de_data_port field. In addition, the
104 * init routine has to fill in the sendq data structures. */
105
106 /* Board hardware interface */
107 port_t de_base_port;
108 port_t de_data_port; /* For boards using Prog. I/O for xmit/recv */
109
110 int de_irq;
111 int de_int_pending;
112 int de_hook; /* interrupt hook at kernel */
113
114 char de_name[8];
115
116 #define DEI_DEFAULT 0x8000
117
118 phys_bytes de_linmem; /* For boards using shared memory */
119 unsigned short de_memsegm;
120 vir_bytes de_memoffs;
121 int de_ramsize; /* Size of on board memory */
122 int de_offset_page; /* Offset of shared memory page */
123
124 /* Board specific functions */
125 dp_eth_t de_initf;
126 dp_eth_t de_stopf;
127 dp_eth_t de_resetf;
128 dp_eth_t de_flagsf;
129 dp_eth_t de_getstatsf;
130 dp_eth_t de_dumpstatsf;
131 dp_eth_t de_interruptf;
132 dp_send_recv_t de_recvf;
133 dp_send_recv_t de_sendf;
134
135 ether_addr_t de_address; /* Ethernet Address */
136 eth_stat_t de_stat; /* Ethernet Statistics */
137 unsigned long bytes_Tx; /* Total bytes sent/received */
138 unsigned long bytes_Rx;
139
140 #define SA_ADDR_LEN sizeof(ether_addr_t)
141
142 int de_flags; /* Send/Receive mode (Configuration) */
143
144 #define DEF_EMPTY 0x0000
145 #define DEF_READING 0x0001
146 #define DEF_RECV_BUSY 0x0002
147 #define DEF_ACK_RECV 0x0004
148 #define DEF_SENDING 0x0010
149 #define DEF_XMIT_BUSY 0x0020
150 #define DEF_ACK_SEND 0x0040
151 #define DEF_PROMISC 0x0100
152 #define DEF_MULTI 0x0200
153 #define DEF_BROAD 0x0400
154 #define DEF_ENABLED 0x2000
155 #define DEF_STOPPED 0x4000
156
157 int de_mode; /* Status of the Interface */
158
159 #define DEM_DISABLED 0x0000
160 #define DEM_SINK 0x0001
161 #define DEM_ENABLED 0x0002
162
163 /* Temporary storage for RECV/SEND requests */
164 iovec_dat_t de_read_iovec;
165 iovec_dat_t de_write_iovec;
166 vir_bytes de_read_s;
167 vir_bytes de_send_s;
168 int de_client;
169 /*
170 message de_sendmsg;
171 iovec_dat_t de_tmp_iovec;
172 */
173 #if ENABLE_DP8390 == 1
174 /* For use by NS DP8390 driver */
175 port_t de_dp8390_port;
176 int de_prog_IO;
177 int de_16bit;
178 int de_startpage;
179 int de_stoppage;
180
181 /* Do it yourself send queue */
182 struct sendq {
183 int sq_filled; /* This buffer contains a packet */
184 int sq_size; /* with this size */
185 int sq_sendpage; /* starting page of the buffer */
186 } de_sendq[SENDQ_NR];
187 int de_sendq_nr;
188 int de_sendq_head; /* Enqueue at the head */
189 int de_sendq_tail; /* Dequeue at the tail */
190
191 dp_user2nicf_t de_user2nicf;
192 dp_nic2userf_t de_nic2userf;
193 dp_getblock_t de_getblockf;
194 #endif
195
196 #if ENABLE_3C509 == 1
197 /* For use by 3Com Etherlink III (3c509) driver */
198 port_t de_id_port;
199 port_t de_if_port;
200 #endif
201
202 #if ENABLE_3C501 == 1 || ENABLE_3C509 == 1
203 /* For use by 3Com Etherlink (3c501 and 3c509) driver */
204 buff_t *de_recvq_head;
205 buff_t *de_recvq_tail;
206 buff_t *de_xmitq_head;
207 buff_t *de_xmitq_tail;
208 u16_t de_recv_mode;
209 clock_t de_xmit_start;
210 #endif
211
212 } dpeth_t;
213
214 /*
215 * Function definitions
216 */
217
218 /* dp.c */
219 void dp_next_iovec(iovec_dat_t * iovp);
220
221 /* devio.c */
222 #if defined USE_IOPL
223 #include <ibm/portio.h>
224 #else
225 unsigned int inb(unsigned short int);
226 unsigned int inw(unsigned short int);
227 void insb(unsigned short int, int, void *, int);
228 void insw(unsigned short int, int, void *, int);
229 void outb(unsigned short int, unsigned long);
230 void outw(unsigned short int, unsigned long);
231 void outsb(unsigned short int, int, void *, int);
232 void outsw(unsigned short int, int, void *, int);
233 #endif
234
235 /* netbuff.c */
236 void *alloc_buff(dpeth_t *, int);
237 void free_buff(dpeth_t *, void *);
238 void init_buff(dpeth_t *, buff_t **);
239 void mem2user(dpeth_t *, buff_t *);
240 void user2mem(dpeth_t *, buff_t *);
241
242 /* 3c501.c */
243 #if ENABLE_3C501 == 1
244 int el1_probe(dpeth_t *);
245 #else
246 #define el1_probe(x) (0)
247 #endif
248
249 /* 3c503.c */
250 #if ENABLE_3C503 == 1
251 int el2_probe(dpeth_t *);
252 #else
253 #define el2_probe(x) (0)
254 #endif
255
256 /* 3c509.c */
257 #if ENABLE_3C509 == 1
258 int el3_probe(dpeth_t *);
259 #else
260 #define el3_probe(x) (0)
261 #endif
262
263 /* ne.c */
264 #if ENABLE_NE2000 == 1
265 int ne_probe(dpeth_t * dep);
266 #else
267 #define ne_probe(x) (0)
268 #endif
269
270 /* wd.c */
271 #if ENABLE_WDETH == 1
272 int wdeth_probe(dpeth_t * dep);
273 #else
274 #define wdeth_probe(x) (0)
275 #endif
276
277 #define lock() (++dep->de_int_pending,sys_irqdisable(&dep->de_hook))
278 #define unlock() do{int i=(--dep->de_int_pending)?0:sys_irqenable(&dep->de_hook);}while(0)
279 #define milli_delay(t) tickdelay(1)
280
281 /** dp.h **/
Cache object: daf5a0849eeef644a2a82a3522e736e1
|