1 |
1275 |
phoenix |
/*
|
2 |
|
|
net-3-driver for the 3c523 Etherlink/MC card (i82586 Ethernet chip)
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
This is an extension to the Linux operating system, and is covered by the
|
6 |
|
|
same GNU General Public License that covers that work.
|
7 |
|
|
|
8 |
|
|
Copyright 1995, 1996 by Chris Beauregard (cpbeaure@undergrad.math.uwaterloo.ca)
|
9 |
|
|
|
10 |
|
|
This is basically Michael Hipp's ni52 driver, with a new probing
|
11 |
|
|
algorithm and some minor changes to the 82586 CA and reset routines.
|
12 |
|
|
Thanks a lot Michael for a really clean i82586 implementation! Unless
|
13 |
|
|
otherwise documented in ni52.c, any bugs are mine.
|
14 |
|
|
|
15 |
|
|
Contrary to the Ethernet-HOWTO, this isn't based on the 3c507 driver in
|
16 |
|
|
any way. The ni52 is a lot easier to modify.
|
17 |
|
|
|
18 |
|
|
sources:
|
19 |
|
|
ni52.c
|
20 |
|
|
|
21 |
|
|
Crynwr packet driver collection was a great reference for my first
|
22 |
|
|
attempt at this sucker. The 3c507 driver also helped, until I noticed
|
23 |
|
|
that ni52.c was a lot nicer.
|
24 |
|
|
|
25 |
|
|
EtherLink/MC: Micro Channel Ethernet Adapter Technical Reference
|
26 |
|
|
Manual, courtesy of 3Com CardFacts, documents the 3c523-specific
|
27 |
|
|
stuff. Information on CardFacts is found in the Ethernet HOWTO.
|
28 |
|
|
Also see <a href="http://www.3com.com/">
|
29 |
|
|
|
30 |
|
|
Microprocessor Communications Support Chips, T.J. Byers, ISBN
|
31 |
|
|
0-444-01224-9, has a section on the i82586. It tells you just enough
|
32 |
|
|
to know that you really don't want to learn how to program the chip.
|
33 |
|
|
|
34 |
|
|
The original device probe code was stolen from ps2esdi.c
|
35 |
|
|
|
36 |
|
|
Known Problems:
|
37 |
|
|
Since most of the code was stolen from ni52.c, you'll run across the
|
38 |
|
|
same bugs in the 0.62 version of ni52.c, plus maybe a few because of
|
39 |
|
|
the 3c523 idiosynchacies. The 3c523 has 16K of RAM though, so there
|
40 |
|
|
shouldn't be the overrun problem that the 8K ni52 has.
|
41 |
|
|
|
42 |
|
|
This driver is for a 16K adapter. It should work fine on the 64K
|
43 |
|
|
adapters, but it will only use one of the 4 banks of RAM. Modifying
|
44 |
|
|
this for the 64K version would require a lot of heinous bank
|
45 |
|
|
switching, which I'm sure not interested in doing. If you try to
|
46 |
|
|
implement a bank switching version, you'll basically have to remember
|
47 |
|
|
what bank is enabled and do a switch everytime you access a memory
|
48 |
|
|
location that's not current. You'll also have to remap pointers on
|
49 |
|
|
the driver side, because it only knows about 16K of the memory.
|
50 |
|
|
Anyone desperate or masochistic enough to try?
|
51 |
|
|
|
52 |
|
|
It seems to be stable now when multiple transmit buffers are used. I
|
53 |
|
|
can't see any performance difference, but then I'm working on a 386SX.
|
54 |
|
|
|
55 |
|
|
Multicast doesn't work. It doesn't even pretend to work. Don't use
|
56 |
|
|
it. Don't compile your kernel with multicast support. I don't know
|
57 |
|
|
why.
|
58 |
|
|
|
59 |
|
|
Features:
|
60 |
|
|
This driver is useable as a loadable module. If you try to specify an
|
61 |
|
|
IRQ or a IO address (via insmod 3c523.o irq=xx io=0xyyy), it will
|
62 |
|
|
search the MCA slots until it finds a 3c523 with the specified
|
63 |
|
|
parameters.
|
64 |
|
|
|
65 |
|
|
This driver does support multiple ethernet cards when used as a module
|
66 |
|
|
(up to MAX_3C523_CARDS, the default being 4)
|
67 |
|
|
|
68 |
|
|
This has been tested with both BNC and TP versions, internal and
|
69 |
|
|
external transceivers. Haven't tested with the 64K version (that I
|
70 |
|
|
know of).
|
71 |
|
|
|
72 |
|
|
History:
|
73 |
|
|
Jan 1st, 1996
|
74 |
|
|
first public release
|
75 |
|
|
Feb 4th, 1996
|
76 |
|
|
update to 1.3.59, incorporated multicast diffs from ni52.c
|
77 |
|
|
Feb 15th, 1996
|
78 |
|
|
added shared irq support
|
79 |
|
|
Apr 1999
|
80 |
|
|
added support for multiple cards when used as a module
|
81 |
|
|
added option to disable multicast as is causes problems
|
82 |
|
|
Ganesh Sittampalam <ganesh.sittampalam@magdalen.oxford.ac.uk>
|
83 |
|
|
Stuart Adamson <stuart.adamson@compsoc.net>
|
84 |
|
|
Nov 2001
|
85 |
|
|
added support for ethtool (jgarzik)
|
86 |
|
|
|
87 |
|
|
$Header: /home/marcus/revision_ctrl_test/oc_cvs/cvs/or1k/linux/linux-2.4/drivers/net/3c523.c,v 1.1.1.1 2004-04-15 01:44:38 phoenix Exp $
|
88 |
|
|
*/
|
89 |
|
|
|
90 |
|
|
#define DRV_NAME "3c523"
|
91 |
|
|
#define DRV_VERSION "17-Nov-2001"
|
92 |
|
|
|
93 |
|
|
#include <linux/module.h>
|
94 |
|
|
#include <linux/kernel.h>
|
95 |
|
|
#include <linux/sched.h>
|
96 |
|
|
#include <linux/string.h>
|
97 |
|
|
#include <linux/errno.h>
|
98 |
|
|
#include <linux/ioport.h>
|
99 |
|
|
#include <linux/slab.h>
|
100 |
|
|
#include <linux/interrupt.h>
|
101 |
|
|
#include <linux/delay.h>
|
102 |
|
|
#include <linux/mca.h>
|
103 |
|
|
#include <linux/ethtool.h>
|
104 |
|
|
|
105 |
|
|
#include <asm/uaccess.h>
|
106 |
|
|
#include <asm/processor.h>
|
107 |
|
|
#include <asm/bitops.h>
|
108 |
|
|
#include <asm/io.h>
|
109 |
|
|
|
110 |
|
|
#include <linux/netdevice.h>
|
111 |
|
|
#include <linux/etherdevice.h>
|
112 |
|
|
#include <linux/skbuff.h>
|
113 |
|
|
#include <linux/init.h>
|
114 |
|
|
|
115 |
|
|
#include "3c523.h"
|
116 |
|
|
|
117 |
|
|
/*************************************************************************/
|
118 |
|
|
#define DEBUG /* debug on */
|
119 |
|
|
#define SYSBUSVAL 0 /* 1 = 8 Bit, 0 = 16 bit - 3c523 only does 16 bit */
|
120 |
|
|
#undef ELMC_MULTICAST /* Disable multicast support as it is somewhat seriously broken at the moment */
|
121 |
|
|
|
122 |
|
|
#define make32(ptr16) (p->memtop + (short) (ptr16) )
|
123 |
|
|
#define make24(ptr32) ((char *) (ptr32) - p->base)
|
124 |
|
|
#define make16(ptr32) ((unsigned short) ((unsigned long) (ptr32) - (unsigned long) p->memtop ))
|
125 |
|
|
|
126 |
|
|
/*************************************************************************/
|
127 |
|
|
/*
|
128 |
|
|
Tables to which we can map values in the configuration registers.
|
129 |
|
|
*/
|
130 |
|
|
static int irq_table[] __initdata = {
|
131 |
|
|
12, 7, 3, 9
|
132 |
|
|
};
|
133 |
|
|
|
134 |
|
|
static int csr_table[] __initdata = {
|
135 |
|
|
0x300, 0x1300, 0x2300, 0x3300
|
136 |
|
|
};
|
137 |
|
|
|
138 |
|
|
static int shm_table[] __initdata = {
|
139 |
|
|
0x0c0000, 0x0c8000, 0x0d0000, 0x0d8000
|
140 |
|
|
};
|
141 |
|
|
|
142 |
|
|
/******************* how to calculate the buffers *****************************
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
* IMPORTANT NOTE: if you configure only one NUM_XMIT_BUFFS, the driver works
|
146 |
|
|
* --------------- in a different (more stable?) mode. Only in this mode it's
|
147 |
|
|
* possible to configure the driver with 'NO_NOPCOMMANDS'
|
148 |
|
|
|
149 |
|
|
sizeof(scp)=12; sizeof(scb)=16; sizeof(iscp)=8;
|
150 |
|
|
sizeof(scp)+sizeof(iscp)+sizeof(scb) = 36 = INIT
|
151 |
|
|
sizeof(rfd) = 24; sizeof(rbd) = 12;
|
152 |
|
|
sizeof(tbd) = 8; sizeof(transmit_cmd) = 16;
|
153 |
|
|
sizeof(nop_cmd) = 8;
|
154 |
|
|
|
155 |
|
|
* if you don't know the driver, better do not change this values: */
|
156 |
|
|
|
157 |
|
|
#define RECV_BUFF_SIZE 1524 /* slightly oversized */
|
158 |
|
|
#define XMIT_BUFF_SIZE 1524 /* slightly oversized */
|
159 |
|
|
#define NUM_XMIT_BUFFS 1 /* config for both, 8K and 16K shmem */
|
160 |
|
|
#define NUM_RECV_BUFFS_8 4 /* config for 8K shared mem */
|
161 |
|
|
#define NUM_RECV_BUFFS_16 9 /* config for 16K shared mem */
|
162 |
|
|
|
163 |
|
|
#if (NUM_XMIT_BUFFS == 1)
|
164 |
|
|
#define NO_NOPCOMMANDS /* only possible with NUM_XMIT_BUFFS=1 */
|
165 |
|
|
#endif
|
166 |
|
|
|
167 |
|
|
/**************************************************************************/
|
168 |
|
|
|
169 |
|
|
#define DELAY(x) { mdelay(32 * x); }
|
170 |
|
|
|
171 |
|
|
/* a much shorter delay: */
|
172 |
|
|
#define DELAY_16(); { udelay(16) ; }
|
173 |
|
|
|
174 |
|
|
/* wait for command with timeout: */
|
175 |
|
|
#define WAIT_4_SCB_CMD() { int i; \
|
176 |
|
|
for(i=0;i<1024;i++) { \
|
177 |
|
|
if(!p->scb->cmd) break; \
|
178 |
|
|
DELAY_16(); \
|
179 |
|
|
if(i == 1023) { \
|
180 |
|
|
printk(KERN_WARNING "%s:%d: scb_cmd timed out .. resetting i82586\n",\
|
181 |
|
|
dev->name,__LINE__); \
|
182 |
|
|
elmc_id_reset586(); } } }
|
183 |
|
|
|
184 |
|
|
static void elmc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr);
|
185 |
|
|
static int elmc_open(struct net_device *dev);
|
186 |
|
|
static int elmc_close(struct net_device *dev);
|
187 |
|
|
static int elmc_send_packet(struct sk_buff *, struct net_device *);
|
188 |
|
|
static struct net_device_stats *elmc_get_stats(struct net_device *dev);
|
189 |
|
|
static void elmc_timeout(struct net_device *dev);
|
190 |
|
|
#ifdef ELMC_MULTICAST
|
191 |
|
|
static void set_multicast_list(struct net_device *dev);
|
192 |
|
|
#endif
|
193 |
|
|
static struct ethtool_ops netdev_ethtool_ops;
|
194 |
|
|
|
195 |
|
|
/* helper-functions */
|
196 |
|
|
static int init586(struct net_device *dev);
|
197 |
|
|
static int check586(struct net_device *dev, unsigned long where, unsigned size);
|
198 |
|
|
static void alloc586(struct net_device *dev);
|
199 |
|
|
static void startrecv586(struct net_device *dev);
|
200 |
|
|
static void *alloc_rfa(struct net_device *dev, void *ptr);
|
201 |
|
|
static void elmc_rcv_int(struct net_device *dev);
|
202 |
|
|
static void elmc_xmt_int(struct net_device *dev);
|
203 |
|
|
static void elmc_rnr_int(struct net_device *dev);
|
204 |
|
|
|
205 |
|
|
struct priv {
|
206 |
|
|
struct net_device_stats stats;
|
207 |
|
|
unsigned long base;
|
208 |
|
|
char *memtop;
|
209 |
|
|
unsigned long mapped_start; /* Start of ioremap */
|
210 |
|
|
volatile struct rfd_struct *rfd_last, *rfd_top, *rfd_first;
|
211 |
|
|
volatile struct scp_struct *scp; /* volatile is important */
|
212 |
|
|
volatile struct iscp_struct *iscp; /* volatile is important */
|
213 |
|
|
volatile struct scb_struct *scb; /* volatile is important */
|
214 |
|
|
volatile struct tbd_struct *xmit_buffs[NUM_XMIT_BUFFS];
|
215 |
|
|
#if (NUM_XMIT_BUFFS == 1)
|
216 |
|
|
volatile struct transmit_cmd_struct *xmit_cmds[2];
|
217 |
|
|
volatile struct nop_cmd_struct *nop_cmds[2];
|
218 |
|
|
#else
|
219 |
|
|
volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
|
220 |
|
|
volatile struct nop_cmd_struct *nop_cmds[NUM_XMIT_BUFFS];
|
221 |
|
|
#endif
|
222 |
|
|
volatile int nop_point, num_recv_buffs;
|
223 |
|
|
volatile char *xmit_cbuffs[NUM_XMIT_BUFFS];
|
224 |
|
|
volatile int xmit_count, xmit_last;
|
225 |
|
|
volatile int slot;
|
226 |
|
|
};
|
227 |
|
|
|
228 |
|
|
#define elmc_attn586() {elmc_do_attn586(dev->base_addr,ELMC_CTRL_INTE);}
|
229 |
|
|
#define elmc_reset586() {elmc_do_reset586(dev->base_addr,ELMC_CTRL_INTE);}
|
230 |
|
|
|
231 |
|
|
/* with interrupts disabled - this will clear the interrupt bit in the
|
232 |
|
|
3c523 control register, and won't put it back. This effectively
|
233 |
|
|
disables interrupts on the card. */
|
234 |
|
|
#define elmc_id_attn586() {elmc_do_attn586(dev->base_addr,0);}
|
235 |
|
|
#define elmc_id_reset586() {elmc_do_reset586(dev->base_addr,0);}
|
236 |
|
|
|
237 |
|
|
/*************************************************************************/
|
238 |
|
|
/*
|
239 |
|
|
Do a Channel Attention on the 3c523. This is extremely board dependent.
|
240 |
|
|
*/
|
241 |
|
|
static void elmc_do_attn586(int ioaddr, int ints)
|
242 |
|
|
{
|
243 |
|
|
/* the 3c523 requires a minimum of 500 ns. The delays here might be
|
244 |
|
|
a little too large, and hence they may cut the performance of the
|
245 |
|
|
card slightly. If someone who knows a little more about Linux
|
246 |
|
|
timing would care to play with these, I'd appreciate it. */
|
247 |
|
|
|
248 |
|
|
/* this bit masking stuff is crap. I'd rather have separate
|
249 |
|
|
registers with strobe triggers for each of these functions. <sigh>
|
250 |
|
|
Ya take what ya got. */
|
251 |
|
|
|
252 |
|
|
outb(ELMC_CTRL_RST | 0x3 | ELMC_CTRL_CA | ints, ioaddr + ELMC_CTRL);
|
253 |
|
|
DELAY_16(); /* > 500 ns */
|
254 |
|
|
outb(ELMC_CTRL_RST | 0x3 | ints, ioaddr + ELMC_CTRL);
|
255 |
|
|
}
|
256 |
|
|
|
257 |
|
|
/*************************************************************************/
|
258 |
|
|
/*
|
259 |
|
|
Reset the 82586 on the 3c523. Also very board dependent.
|
260 |
|
|
*/
|
261 |
|
|
static void elmc_do_reset586(int ioaddr, int ints)
|
262 |
|
|
{
|
263 |
|
|
/* toggle the RST bit low then high */
|
264 |
|
|
outb(0x3 | ELMC_CTRL_LBK, ioaddr + ELMC_CTRL);
|
265 |
|
|
DELAY_16(); /* > 500 ns */
|
266 |
|
|
outb(ELMC_CTRL_RST | ELMC_CTRL_LBK | 0x3, ioaddr + ELMC_CTRL);
|
267 |
|
|
|
268 |
|
|
elmc_do_attn586(ioaddr, ints);
|
269 |
|
|
}
|
270 |
|
|
|
271 |
|
|
/**********************************************
|
272 |
|
|
* close device
|
273 |
|
|
*/
|
274 |
|
|
|
275 |
|
|
static int elmc_close(struct net_device *dev)
|
276 |
|
|
{
|
277 |
|
|
netif_stop_queue(dev);
|
278 |
|
|
elmc_id_reset586(); /* the hard way to stop the receiver */
|
279 |
|
|
free_irq(dev->irq, dev);
|
280 |
|
|
return 0;
|
281 |
|
|
}
|
282 |
|
|
|
283 |
|
|
/**********************************************
|
284 |
|
|
* open device
|
285 |
|
|
*/
|
286 |
|
|
|
287 |
|
|
static int elmc_open(struct net_device *dev)
|
288 |
|
|
{
|
289 |
|
|
int ret;
|
290 |
|
|
|
291 |
|
|
elmc_id_attn586(); /* disable interrupts */
|
292 |
|
|
|
293 |
|
|
ret = request_irq(dev->irq, &elmc_interrupt, SA_SHIRQ | SA_SAMPLE_RANDOM,
|
294 |
|
|
dev->name, dev);
|
295 |
|
|
if (ret) {
|
296 |
|
|
printk(KERN_ERR "%s: couldn't get irq %d\n", dev->name, dev->irq);
|
297 |
|
|
elmc_id_reset586();
|
298 |
|
|
return ret;
|
299 |
|
|
}
|
300 |
|
|
alloc586(dev);
|
301 |
|
|
init586(dev);
|
302 |
|
|
startrecv586(dev);
|
303 |
|
|
netif_start_queue(dev);
|
304 |
|
|
return 0; /* most done by init */
|
305 |
|
|
}
|
306 |
|
|
|
307 |
|
|
/**********************************************
|
308 |
|
|
* Check to see if there's an 82586 out there.
|
309 |
|
|
*/
|
310 |
|
|
|
311 |
|
|
static int __init check586(struct net_device *dev, unsigned long where, unsigned size)
|
312 |
|
|
{
|
313 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
314 |
|
|
char *iscp_addrs[2];
|
315 |
|
|
int i = 0;
|
316 |
|
|
|
317 |
|
|
p->base = (unsigned long) bus_to_virt((unsigned long)where) + size - 0x01000000;
|
318 |
|
|
p->memtop = bus_to_virt((unsigned long)where) + size;
|
319 |
|
|
p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
|
320 |
|
|
memset((char *) p->scp, 0, sizeof(struct scp_struct));
|
321 |
|
|
p->scp->sysbus = SYSBUSVAL; /* 1 = 8Bit-Bus, 0 = 16 Bit */
|
322 |
|
|
|
323 |
|
|
iscp_addrs[0] = bus_to_virt((unsigned long)where);
|
324 |
|
|
iscp_addrs[1] = (char *) p->scp - sizeof(struct iscp_struct);
|
325 |
|
|
|
326 |
|
|
for (i = 0; i < 2; i++) {
|
327 |
|
|
p->iscp = (struct iscp_struct *) iscp_addrs[i];
|
328 |
|
|
memset((char *) p->iscp, 0, sizeof(struct iscp_struct));
|
329 |
|
|
|
330 |
|
|
p->scp->iscp = make24(p->iscp);
|
331 |
|
|
p->iscp->busy = 1;
|
332 |
|
|
|
333 |
|
|
elmc_id_reset586();
|
334 |
|
|
|
335 |
|
|
/* reset586 does an implicit CA */
|
336 |
|
|
|
337 |
|
|
/* apparently, you sometimes have to kick the 82586 twice... */
|
338 |
|
|
elmc_id_attn586();
|
339 |
|
|
DELAY(1);
|
340 |
|
|
|
341 |
|
|
if (p->iscp->busy) { /* i82586 clears 'busy' after successful init */
|
342 |
|
|
return 0;
|
343 |
|
|
}
|
344 |
|
|
}
|
345 |
|
|
return 1;
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
/******************************************************************
|
349 |
|
|
* set iscp at the right place, called by elmc_probe and open586.
|
350 |
|
|
*/
|
351 |
|
|
|
352 |
|
|
void alloc586(struct net_device *dev)
|
353 |
|
|
{
|
354 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
355 |
|
|
|
356 |
|
|
elmc_id_reset586();
|
357 |
|
|
DELAY(2);
|
358 |
|
|
|
359 |
|
|
p->scp = (struct scp_struct *) (p->base + SCP_DEFAULT_ADDRESS);
|
360 |
|
|
p->scb = (struct scb_struct *) bus_to_virt(dev->mem_start);
|
361 |
|
|
p->iscp = (struct iscp_struct *) ((char *) p->scp - sizeof(struct iscp_struct));
|
362 |
|
|
|
363 |
|
|
memset((char *) p->iscp, 0, sizeof(struct iscp_struct));
|
364 |
|
|
memset((char *) p->scp, 0, sizeof(struct scp_struct));
|
365 |
|
|
|
366 |
|
|
p->scp->iscp = make24(p->iscp);
|
367 |
|
|
p->scp->sysbus = SYSBUSVAL;
|
368 |
|
|
p->iscp->scb_offset = make16(p->scb);
|
369 |
|
|
|
370 |
|
|
p->iscp->busy = 1;
|
371 |
|
|
elmc_id_reset586();
|
372 |
|
|
elmc_id_attn586();
|
373 |
|
|
|
374 |
|
|
DELAY(2);
|
375 |
|
|
|
376 |
|
|
if (p->iscp->busy) {
|
377 |
|
|
printk(KERN_ERR "%s: Init-Problems (alloc).\n", dev->name);
|
378 |
|
|
}
|
379 |
|
|
memset((char *) p->scb, 0, sizeof(struct scb_struct));
|
380 |
|
|
}
|
381 |
|
|
|
382 |
|
|
/*****************************************************************/
|
383 |
|
|
|
384 |
|
|
static int elmc_getinfo(char *buf, int slot, void *d)
|
385 |
|
|
{
|
386 |
|
|
int len = 0;
|
387 |
|
|
struct net_device *dev = (struct net_device *) d;
|
388 |
|
|
int i;
|
389 |
|
|
|
390 |
|
|
if (dev == NULL)
|
391 |
|
|
return len;
|
392 |
|
|
|
393 |
|
|
len += sprintf(buf + len, "Revision: 0x%x\n",
|
394 |
|
|
inb(dev->base_addr + ELMC_REVISION) & 0xf);
|
395 |
|
|
len += sprintf(buf + len, "IRQ: %d\n", dev->irq);
|
396 |
|
|
len += sprintf(buf + len, "IO Address: %#lx-%#lx\n", dev->base_addr,
|
397 |
|
|
dev->base_addr + ELMC_IO_EXTENT);
|
398 |
|
|
len += sprintf(buf + len, "Memory: %#lx-%#lx\n", dev->mem_start,
|
399 |
|
|
dev->mem_end - 1);
|
400 |
|
|
len += sprintf(buf + len, "Transceiver: %s\n", dev->if_port ?
|
401 |
|
|
"External" : "Internal");
|
402 |
|
|
len += sprintf(buf + len, "Device: %s\n", dev->name);
|
403 |
|
|
len += sprintf(buf + len, "Hardware Address:");
|
404 |
|
|
for (i = 0; i < 6; i++) {
|
405 |
|
|
len += sprintf(buf + len, " %02x", dev->dev_addr[i]);
|
406 |
|
|
}
|
407 |
|
|
buf[len++] = '\n';
|
408 |
|
|
buf[len] = 0;
|
409 |
|
|
|
410 |
|
|
return len;
|
411 |
|
|
} /* elmc_getinfo() */
|
412 |
|
|
|
413 |
|
|
/*****************************************************************/
|
414 |
|
|
|
415 |
|
|
int __init elmc_probe(struct net_device *dev)
|
416 |
|
|
{
|
417 |
|
|
static int slot;
|
418 |
|
|
int base_addr = dev->base_addr;
|
419 |
|
|
int irq = dev->irq;
|
420 |
|
|
u_char status = 0;
|
421 |
|
|
u_char revision = 0;
|
422 |
|
|
int i = 0;
|
423 |
|
|
unsigned int size = 0;
|
424 |
|
|
int retval;
|
425 |
|
|
struct priv *pr;
|
426 |
|
|
|
427 |
|
|
SET_MODULE_OWNER(dev);
|
428 |
|
|
if (MCA_bus == 0) {
|
429 |
|
|
return -ENODEV;
|
430 |
|
|
}
|
431 |
|
|
/* search through the slots for the 3c523. */
|
432 |
|
|
slot = mca_find_adapter(ELMC_MCA_ID, 0);
|
433 |
|
|
while (slot != -1) {
|
434 |
|
|
status = mca_read_stored_pos(slot, 2);
|
435 |
|
|
|
436 |
|
|
dev->irq=irq_table[(status & ELMC_STATUS_IRQ_SELECT) >> 6];
|
437 |
|
|
dev->base_addr=csr_table[(status & ELMC_STATUS_CSR_SELECT) >> 1];
|
438 |
|
|
|
439 |
|
|
/*
|
440 |
|
|
If we're trying to match a specified irq or IO address,
|
441 |
|
|
we'll reject a match unless it's what we're looking for.
|
442 |
|
|
Also reject it if the card is already in use.
|
443 |
|
|
*/
|
444 |
|
|
|
445 |
|
|
if ((irq && irq != dev->irq) ||
|
446 |
|
|
(base_addr && base_addr != dev->base_addr)) {
|
447 |
|
|
slot = mca_find_adapter(ELMC_MCA_ID, slot + 1);
|
448 |
|
|
continue;
|
449 |
|
|
}
|
450 |
|
|
if (!request_region(dev->base_addr, ELMC_IO_EXTENT, dev->name)) {
|
451 |
|
|
slot = mca_find_adapter(ELMC_MCA_ID, slot + 1);
|
452 |
|
|
continue;
|
453 |
|
|
}
|
454 |
|
|
|
455 |
|
|
/* found what we're looking for... */
|
456 |
|
|
break;
|
457 |
|
|
}
|
458 |
|
|
|
459 |
|
|
/* we didn't find any 3c523 in the slots we checked for */
|
460 |
|
|
if (slot == MCA_NOTFOUND) {
|
461 |
|
|
retval = ((base_addr || irq) ? -ENXIO : -ENODEV);
|
462 |
|
|
goto err_out;
|
463 |
|
|
}
|
464 |
|
|
mca_set_adapter_name(slot, "3Com 3c523 Etherlink/MC");
|
465 |
|
|
mca_set_adapter_procfn(slot, (MCA_ProcFn) elmc_getinfo, dev);
|
466 |
|
|
|
467 |
|
|
/* if we get this far, adapter has been found - carry on */
|
468 |
|
|
printk(KERN_INFO "%s: 3c523 adapter found in slot %d\n", dev->name, slot + 1);
|
469 |
|
|
|
470 |
|
|
/* Now we extract configuration info from the card.
|
471 |
|
|
The 3c523 provides information in two of the POS registers, but
|
472 |
|
|
the second one is only needed if we want to tell the card what IRQ
|
473 |
|
|
to use. I suspect that whoever sets the thing up initially would
|
474 |
|
|
prefer we don't screw with those things.
|
475 |
|
|
|
476 |
|
|
Note that we read the status info when we found the card...
|
477 |
|
|
|
478 |
|
|
See 3c523.h for more details.
|
479 |
|
|
*/
|
480 |
|
|
|
481 |
|
|
/* revision is stored in the first 4 bits of the revision register */
|
482 |
|
|
revision = inb(dev->base_addr + ELMC_REVISION) & 0xf;
|
483 |
|
|
|
484 |
|
|
/* according to docs, we read the interrupt and write it back to
|
485 |
|
|
the IRQ select register, since the POST might not configure the IRQ
|
486 |
|
|
properly. */
|
487 |
|
|
switch (dev->irq) {
|
488 |
|
|
case 3:
|
489 |
|
|
mca_write_pos(slot, 3, 0x04);
|
490 |
|
|
break;
|
491 |
|
|
case 7:
|
492 |
|
|
mca_write_pos(slot, 3, 0x02);
|
493 |
|
|
break;
|
494 |
|
|
case 9:
|
495 |
|
|
mca_write_pos(slot, 3, 0x08);
|
496 |
|
|
break;
|
497 |
|
|
case 12:
|
498 |
|
|
mca_write_pos(slot, 3, 0x01);
|
499 |
|
|
break;
|
500 |
|
|
}
|
501 |
|
|
|
502 |
|
|
pr = dev->priv = kmalloc(sizeof(struct priv), GFP_KERNEL);
|
503 |
|
|
if (dev->priv == NULL) {
|
504 |
|
|
retval = -ENOMEM;
|
505 |
|
|
goto err_out;
|
506 |
|
|
}
|
507 |
|
|
memset(pr, 0, sizeof(struct priv));
|
508 |
|
|
|
509 |
|
|
pr->slot = slot;
|
510 |
|
|
|
511 |
|
|
printk(KERN_INFO "%s: 3Com 3c523 Rev 0x%x at %#lx\n", dev->name, (int) revision,
|
512 |
|
|
dev->base_addr);
|
513 |
|
|
|
514 |
|
|
/* Determine if we're using the on-board transceiver (i.e. coax) or
|
515 |
|
|
an external one. The information is pretty much useless, but I
|
516 |
|
|
guess it's worth brownie points. */
|
517 |
|
|
dev->if_port = (status & ELMC_STATUS_DISABLE_THIN);
|
518 |
|
|
|
519 |
|
|
/* The 3c523 has a 24K chunk of memory. The first 16K is the
|
520 |
|
|
shared memory, while the last 8K is for the EtherStart BIOS ROM.
|
521 |
|
|
Which we don't care much about here. We'll just tell Linux that
|
522 |
|
|
we're using 16K. MCA won't permit address space conflicts caused
|
523 |
|
|
by not mapping the other 8K. */
|
524 |
|
|
dev->mem_start = shm_table[(status & ELMC_STATUS_MEMORY_SELECT) >> 3];
|
525 |
|
|
|
526 |
|
|
/* We're using MCA, so it's a given that the information about memory
|
527 |
|
|
size is correct. The Crynwr drivers do something like this. */
|
528 |
|
|
|
529 |
|
|
elmc_id_reset586(); /* seems like a good idea before checking it... */
|
530 |
|
|
|
531 |
|
|
size = 0x4000; /* check for 16K mem */
|
532 |
|
|
if (!check586(dev, dev->mem_start, size)) {
|
533 |
|
|
printk(KERN_ERR "%s: memprobe, Can't find memory at 0x%lx!\n", dev->name,
|
534 |
|
|
dev->mem_start);
|
535 |
|
|
kfree(dev->priv);
|
536 |
|
|
dev->priv = NULL;
|
537 |
|
|
retval = -ENODEV;
|
538 |
|
|
goto err_out;
|
539 |
|
|
}
|
540 |
|
|
dev->mem_end = dev->mem_start + size; /* set mem_end showed by 'ifconfig' */
|
541 |
|
|
|
542 |
|
|
pr->memtop = bus_to_virt(dev->mem_start) + size;
|
543 |
|
|
pr->base = (unsigned long) bus_to_virt(dev->mem_start) + size - 0x01000000;
|
544 |
|
|
alloc586(dev);
|
545 |
|
|
|
546 |
|
|
elmc_id_reset586(); /* make sure it doesn't generate spurious ints */
|
547 |
|
|
|
548 |
|
|
/* set number of receive-buffs according to memsize */
|
549 |
|
|
pr->num_recv_buffs = NUM_RECV_BUFFS_16;
|
550 |
|
|
|
551 |
|
|
/* dump all the assorted information */
|
552 |
|
|
printk(KERN_INFO "%s: IRQ %d, %sternal xcvr, memory %#lx-%#lx.\n", dev->name,
|
553 |
|
|
dev->irq, dev->if_port ? "ex" : "in",
|
554 |
|
|
dev->mem_start, dev->mem_end - 1);
|
555 |
|
|
|
556 |
|
|
/* The hardware address for the 3c523 is stored in the first six
|
557 |
|
|
bytes of the IO address. */
|
558 |
|
|
printk(KERN_INFO "%s: hardware address ", dev->name);
|
559 |
|
|
for (i = 0; i < 6; i++) {
|
560 |
|
|
dev->dev_addr[i] = inb(dev->base_addr + i);
|
561 |
|
|
printk(" %02x", dev->dev_addr[i]);
|
562 |
|
|
}
|
563 |
|
|
printk("\n");
|
564 |
|
|
|
565 |
|
|
dev->open = &elmc_open;
|
566 |
|
|
dev->stop = &elmc_close;
|
567 |
|
|
dev->get_stats = &elmc_get_stats;
|
568 |
|
|
dev->hard_start_xmit = &elmc_send_packet;
|
569 |
|
|
dev->tx_timeout = &elmc_timeout;
|
570 |
|
|
dev->watchdog_timeo = HZ;
|
571 |
|
|
#ifdef ELMC_MULTICAST
|
572 |
|
|
dev->set_multicast_list = &set_multicast_list;
|
573 |
|
|
#else
|
574 |
|
|
dev->set_multicast_list = NULL;
|
575 |
|
|
#endif
|
576 |
|
|
dev->ethtool_ops = &netdev_ethtool_ops;
|
577 |
|
|
|
578 |
|
|
ether_setup(dev);
|
579 |
|
|
|
580 |
|
|
/* note that we haven't actually requested the IRQ from the kernel.
|
581 |
|
|
That gets done in elmc_open(). I'm not sure that's such a good idea,
|
582 |
|
|
but it works, so I'll go with it. */
|
583 |
|
|
|
584 |
|
|
#ifndef ELMC_MULTICAST
|
585 |
|
|
dev->flags&=~IFF_MULTICAST; /* Multicast doesn't work */
|
586 |
|
|
#endif
|
587 |
|
|
|
588 |
|
|
return 0;
|
589 |
|
|
err_out:
|
590 |
|
|
release_region(dev->base_addr, ELMC_IO_EXTENT);
|
591 |
|
|
return retval;
|
592 |
|
|
}
|
593 |
|
|
|
594 |
|
|
/**********************************************
|
595 |
|
|
* init the chip (elmc-interrupt should be disabled?!)
|
596 |
|
|
* needs a correct 'allocated' memory
|
597 |
|
|
*/
|
598 |
|
|
|
599 |
|
|
static int init586(struct net_device *dev)
|
600 |
|
|
{
|
601 |
|
|
void *ptr;
|
602 |
|
|
unsigned long s;
|
603 |
|
|
int i, result = 0;
|
604 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
605 |
|
|
volatile struct configure_cmd_struct *cfg_cmd;
|
606 |
|
|
volatile struct iasetup_cmd_struct *ias_cmd;
|
607 |
|
|
volatile struct tdr_cmd_struct *tdr_cmd;
|
608 |
|
|
volatile struct mcsetup_cmd_struct *mc_cmd;
|
609 |
|
|
struct dev_mc_list *dmi = dev->mc_list;
|
610 |
|
|
int num_addrs = dev->mc_count;
|
611 |
|
|
|
612 |
|
|
ptr = (void *) ((char *) p->scb + sizeof(struct scb_struct));
|
613 |
|
|
|
614 |
|
|
cfg_cmd = (struct configure_cmd_struct *) ptr; /* configure-command */
|
615 |
|
|
cfg_cmd->cmd_status = 0;
|
616 |
|
|
cfg_cmd->cmd_cmd = CMD_CONFIGURE | CMD_LAST;
|
617 |
|
|
cfg_cmd->cmd_link = 0xffff;
|
618 |
|
|
|
619 |
|
|
cfg_cmd->byte_cnt = 0x0a; /* number of cfg bytes */
|
620 |
|
|
cfg_cmd->fifo = 0x08; /* fifo-limit (8=tx:32/rx:64) */
|
621 |
|
|
cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */
|
622 |
|
|
cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */
|
623 |
|
|
cfg_cmd->priority = 0x00;
|
624 |
|
|
cfg_cmd->ifs = 0x60;
|
625 |
|
|
cfg_cmd->time_low = 0x00;
|
626 |
|
|
cfg_cmd->time_high = 0xf2;
|
627 |
|
|
cfg_cmd->promisc = 0;
|
628 |
|
|
if (dev->flags & (IFF_ALLMULTI | IFF_PROMISC)) {
|
629 |
|
|
cfg_cmd->promisc = 1;
|
630 |
|
|
dev->flags |= IFF_PROMISC;
|
631 |
|
|
}
|
632 |
|
|
cfg_cmd->carr_coll = 0x00;
|
633 |
|
|
|
634 |
|
|
p->scb->cbl_offset = make16(cfg_cmd);
|
635 |
|
|
|
636 |
|
|
p->scb->cmd = CUC_START; /* cmd.-unit start */
|
637 |
|
|
elmc_id_attn586();
|
638 |
|
|
|
639 |
|
|
s = jiffies; /* warning: only active with interrupts on !! */
|
640 |
|
|
while (!(cfg_cmd->cmd_status & STAT_COMPL)) {
|
641 |
|
|
if (jiffies - s > 30*HZ/100)
|
642 |
|
|
break;
|
643 |
|
|
}
|
644 |
|
|
|
645 |
|
|
if ((cfg_cmd->cmd_status & (STAT_OK | STAT_COMPL)) != (STAT_COMPL | STAT_OK)) {
|
646 |
|
|
printk(KERN_WARNING "%s (elmc): configure command failed: %x\n", dev->name, cfg_cmd->cmd_status);
|
647 |
|
|
return 1;
|
648 |
|
|
}
|
649 |
|
|
/*
|
650 |
|
|
* individual address setup
|
651 |
|
|
*/
|
652 |
|
|
ias_cmd = (struct iasetup_cmd_struct *) ptr;
|
653 |
|
|
|
654 |
|
|
ias_cmd->cmd_status = 0;
|
655 |
|
|
ias_cmd->cmd_cmd = CMD_IASETUP | CMD_LAST;
|
656 |
|
|
ias_cmd->cmd_link = 0xffff;
|
657 |
|
|
|
658 |
|
|
memcpy((char *) &ias_cmd->iaddr, (char *) dev->dev_addr, ETH_ALEN);
|
659 |
|
|
|
660 |
|
|
p->scb->cbl_offset = make16(ias_cmd);
|
661 |
|
|
|
662 |
|
|
p->scb->cmd = CUC_START; /* cmd.-unit start */
|
663 |
|
|
elmc_id_attn586();
|
664 |
|
|
|
665 |
|
|
s = jiffies;
|
666 |
|
|
while (!(ias_cmd->cmd_status & STAT_COMPL)) {
|
667 |
|
|
if (jiffies - s > 30*HZ/100)
|
668 |
|
|
break;
|
669 |
|
|
}
|
670 |
|
|
|
671 |
|
|
if ((ias_cmd->cmd_status & (STAT_OK | STAT_COMPL)) != (STAT_OK | STAT_COMPL)) {
|
672 |
|
|
printk(KERN_WARNING "%s (elmc): individual address setup command failed: %04x\n", dev->name, ias_cmd->cmd_status);
|
673 |
|
|
return 1;
|
674 |
|
|
}
|
675 |
|
|
/*
|
676 |
|
|
* TDR, wire check .. e.g. no resistor e.t.c
|
677 |
|
|
*/
|
678 |
|
|
tdr_cmd = (struct tdr_cmd_struct *) ptr;
|
679 |
|
|
|
680 |
|
|
tdr_cmd->cmd_status = 0;
|
681 |
|
|
tdr_cmd->cmd_cmd = CMD_TDR | CMD_LAST;
|
682 |
|
|
tdr_cmd->cmd_link = 0xffff;
|
683 |
|
|
tdr_cmd->status = 0;
|
684 |
|
|
|
685 |
|
|
p->scb->cbl_offset = make16(tdr_cmd);
|
686 |
|
|
|
687 |
|
|
p->scb->cmd = CUC_START; /* cmd.-unit start */
|
688 |
|
|
elmc_attn586();
|
689 |
|
|
|
690 |
|
|
s = jiffies;
|
691 |
|
|
while (!(tdr_cmd->cmd_status & STAT_COMPL)) {
|
692 |
|
|
if (jiffies - s > 30*HZ/100) {
|
693 |
|
|
printk(KERN_WARNING "%s: %d Problems while running the TDR.\n", dev->name, __LINE__);
|
694 |
|
|
result = 1;
|
695 |
|
|
break;
|
696 |
|
|
}
|
697 |
|
|
}
|
698 |
|
|
|
699 |
|
|
if (!result) {
|
700 |
|
|
DELAY(2); /* wait for result */
|
701 |
|
|
result = tdr_cmd->status;
|
702 |
|
|
|
703 |
|
|
p->scb->cmd = p->scb->status & STAT_MASK;
|
704 |
|
|
elmc_id_attn586(); /* ack the interrupts */
|
705 |
|
|
|
706 |
|
|
if (result & TDR_LNK_OK) {
|
707 |
|
|
/* empty */
|
708 |
|
|
} else if (result & TDR_XCVR_PRB) {
|
709 |
|
|
printk(KERN_WARNING "%s: TDR: Transceiver problem!\n", dev->name);
|
710 |
|
|
} else if (result & TDR_ET_OPN) {
|
711 |
|
|
printk(KERN_WARNING "%s: TDR: No correct termination %d clocks away.\n", dev->name, result & TDR_TIMEMASK);
|
712 |
|
|
} else if (result & TDR_ET_SRT) {
|
713 |
|
|
if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */
|
714 |
|
|
printk(KERN_WARNING "%s: TDR: Detected a short circuit %d clocks away.\n", dev->name, result & TDR_TIMEMASK);
|
715 |
|
|
} else {
|
716 |
|
|
printk(KERN_WARNING "%s: TDR: Unknown status %04x\n", dev->name, result);
|
717 |
|
|
}
|
718 |
|
|
}
|
719 |
|
|
/*
|
720 |
|
|
* ack interrupts
|
721 |
|
|
*/
|
722 |
|
|
p->scb->cmd = p->scb->status & STAT_MASK;
|
723 |
|
|
elmc_id_attn586();
|
724 |
|
|
|
725 |
|
|
/*
|
726 |
|
|
* alloc nop/xmit-cmds
|
727 |
|
|
*/
|
728 |
|
|
#if (NUM_XMIT_BUFFS == 1)
|
729 |
|
|
for (i = 0; i < 2; i++) {
|
730 |
|
|
p->nop_cmds[i] = (struct nop_cmd_struct *) ptr;
|
731 |
|
|
p->nop_cmds[i]->cmd_cmd = CMD_NOP;
|
732 |
|
|
p->nop_cmds[i]->cmd_status = 0;
|
733 |
|
|
p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
|
734 |
|
|
ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
|
735 |
|
|
}
|
736 |
|
|
p->xmit_cmds[0] = (struct transmit_cmd_struct *) ptr; /* transmit cmd/buff 0 */
|
737 |
|
|
ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
|
738 |
|
|
#else
|
739 |
|
|
for (i = 0; i < NUM_XMIT_BUFFS; i++) {
|
740 |
|
|
p->nop_cmds[i] = (struct nop_cmd_struct *) ptr;
|
741 |
|
|
p->nop_cmds[i]->cmd_cmd = CMD_NOP;
|
742 |
|
|
p->nop_cmds[i]->cmd_status = 0;
|
743 |
|
|
p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
|
744 |
|
|
ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
|
745 |
|
|
p->xmit_cmds[i] = (struct transmit_cmd_struct *) ptr; /*transmit cmd/buff 0 */
|
746 |
|
|
ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
|
747 |
|
|
}
|
748 |
|
|
#endif
|
749 |
|
|
|
750 |
|
|
ptr = alloc_rfa(dev, (void *) ptr); /* init receive-frame-area */
|
751 |
|
|
|
752 |
|
|
/*
|
753 |
|
|
* Multicast setup
|
754 |
|
|
*/
|
755 |
|
|
|
756 |
|
|
if (dev->mc_count) {
|
757 |
|
|
/* I don't understand this: do we really need memory after the init? */
|
758 |
|
|
int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
|
759 |
|
|
if (len <= 0) {
|
760 |
|
|
printk(KERN_ERR "%s: Ooooops, no memory for MC-Setup!\n", dev->name);
|
761 |
|
|
} else {
|
762 |
|
|
if (len < num_addrs) {
|
763 |
|
|
num_addrs = len;
|
764 |
|
|
printk(KERN_WARNING "%s: Sorry, can only apply %d MC-Address(es).\n",
|
765 |
|
|
dev->name, num_addrs);
|
766 |
|
|
}
|
767 |
|
|
mc_cmd = (struct mcsetup_cmd_struct *) ptr;
|
768 |
|
|
mc_cmd->cmd_status = 0;
|
769 |
|
|
mc_cmd->cmd_cmd = CMD_MCSETUP | CMD_LAST;
|
770 |
|
|
mc_cmd->cmd_link = 0xffff;
|
771 |
|
|
mc_cmd->mc_cnt = num_addrs * 6;
|
772 |
|
|
for (i = 0; i < num_addrs; i++) {
|
773 |
|
|
memcpy((char *) mc_cmd->mc_list[i], dmi->dmi_addr, 6);
|
774 |
|
|
dmi = dmi->next;
|
775 |
|
|
}
|
776 |
|
|
p->scb->cbl_offset = make16(mc_cmd);
|
777 |
|
|
p->scb->cmd = CUC_START;
|
778 |
|
|
elmc_id_attn586();
|
779 |
|
|
s = jiffies;
|
780 |
|
|
while (!(mc_cmd->cmd_status & STAT_COMPL)) {
|
781 |
|
|
if (jiffies - s > 30*HZ/100)
|
782 |
|
|
break;
|
783 |
|
|
}
|
784 |
|
|
if (!(mc_cmd->cmd_status & STAT_COMPL)) {
|
785 |
|
|
printk(KERN_WARNING "%s: Can't apply multicast-address-list.\n", dev->name);
|
786 |
|
|
}
|
787 |
|
|
}
|
788 |
|
|
}
|
789 |
|
|
/*
|
790 |
|
|
* alloc xmit-buffs / init xmit_cmds
|
791 |
|
|
*/
|
792 |
|
|
for (i = 0; i < NUM_XMIT_BUFFS; i++) {
|
793 |
|
|
p->xmit_cbuffs[i] = (char *) ptr; /* char-buffs */
|
794 |
|
|
ptr = (char *) ptr + XMIT_BUFF_SIZE;
|
795 |
|
|
p->xmit_buffs[i] = (struct tbd_struct *) ptr; /* TBD */
|
796 |
|
|
ptr = (char *) ptr + sizeof(struct tbd_struct);
|
797 |
|
|
if ((void *) ptr > (void *) p->iscp) {
|
798 |
|
|
printk(KERN_ERR "%s: not enough shared-mem for your configuration!\n", dev->name);
|
799 |
|
|
return 1;
|
800 |
|
|
}
|
801 |
|
|
memset((char *) (p->xmit_cmds[i]), 0, sizeof(struct transmit_cmd_struct));
|
802 |
|
|
memset((char *) (p->xmit_buffs[i]), 0, sizeof(struct tbd_struct));
|
803 |
|
|
p->xmit_cmds[i]->cmd_status = STAT_COMPL;
|
804 |
|
|
p->xmit_cmds[i]->cmd_cmd = CMD_XMIT | CMD_INT;
|
805 |
|
|
p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i]));
|
806 |
|
|
p->xmit_buffs[i]->next = 0xffff;
|
807 |
|
|
p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i]));
|
808 |
|
|
}
|
809 |
|
|
|
810 |
|
|
p->xmit_count = 0;
|
811 |
|
|
p->xmit_last = 0;
|
812 |
|
|
#ifndef NO_NOPCOMMANDS
|
813 |
|
|
p->nop_point = 0;
|
814 |
|
|
#endif
|
815 |
|
|
|
816 |
|
|
/*
|
817 |
|
|
* 'start transmitter' (nop-loop)
|
818 |
|
|
*/
|
819 |
|
|
#ifndef NO_NOPCOMMANDS
|
820 |
|
|
p->scb->cbl_offset = make16(p->nop_cmds[0]);
|
821 |
|
|
p->scb->cmd = CUC_START;
|
822 |
|
|
elmc_id_attn586();
|
823 |
|
|
WAIT_4_SCB_CMD();
|
824 |
|
|
#else
|
825 |
|
|
p->xmit_cmds[0]->cmd_link = 0xffff;
|
826 |
|
|
p->xmit_cmds[0]->cmd_cmd = CMD_XMIT | CMD_LAST | CMD_INT;
|
827 |
|
|
#endif
|
828 |
|
|
|
829 |
|
|
return 0;
|
830 |
|
|
}
|
831 |
|
|
|
832 |
|
|
/******************************************************
|
833 |
|
|
* This is a helper routine for elmc_rnr_int() and init586().
|
834 |
|
|
* It sets up the Receive Frame Area (RFA).
|
835 |
|
|
*/
|
836 |
|
|
|
837 |
|
|
static void *alloc_rfa(struct net_device *dev, void *ptr)
|
838 |
|
|
{
|
839 |
|
|
volatile struct rfd_struct *rfd = (struct rfd_struct *) ptr;
|
840 |
|
|
volatile struct rbd_struct *rbd;
|
841 |
|
|
int i;
|
842 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
843 |
|
|
|
844 |
|
|
memset((char *) rfd, 0, sizeof(struct rfd_struct) * p->num_recv_buffs);
|
845 |
|
|
p->rfd_first = rfd;
|
846 |
|
|
|
847 |
|
|
for (i = 0; i < p->num_recv_buffs; i++) {
|
848 |
|
|
rfd[i].next = make16(rfd + (i + 1) % p->num_recv_buffs);
|
849 |
|
|
}
|
850 |
|
|
rfd[p->num_recv_buffs - 1].last = RFD_SUSP; /* RU suspend */
|
851 |
|
|
|
852 |
|
|
ptr = (void *) (rfd + p->num_recv_buffs);
|
853 |
|
|
|
854 |
|
|
rbd = (struct rbd_struct *) ptr;
|
855 |
|
|
ptr = (void *) (rbd + p->num_recv_buffs);
|
856 |
|
|
|
857 |
|
|
/* clr descriptors */
|
858 |
|
|
memset((char *) rbd, 0, sizeof(struct rbd_struct) * p->num_recv_buffs);
|
859 |
|
|
|
860 |
|
|
for (i = 0; i < p->num_recv_buffs; i++) {
|
861 |
|
|
rbd[i].next = make16((rbd + (i + 1) % p->num_recv_buffs));
|
862 |
|
|
rbd[i].size = RECV_BUFF_SIZE;
|
863 |
|
|
rbd[i].buffer = make24(ptr);
|
864 |
|
|
ptr = (char *) ptr + RECV_BUFF_SIZE;
|
865 |
|
|
}
|
866 |
|
|
|
867 |
|
|
p->rfd_top = p->rfd_first;
|
868 |
|
|
p->rfd_last = p->rfd_first + p->num_recv_buffs - 1;
|
869 |
|
|
|
870 |
|
|
p->scb->rfa_offset = make16(p->rfd_first);
|
871 |
|
|
p->rfd_first->rbd_offset = make16(rbd);
|
872 |
|
|
|
873 |
|
|
return ptr;
|
874 |
|
|
}
|
875 |
|
|
|
876 |
|
|
|
877 |
|
|
/**************************************************
|
878 |
|
|
* Interrupt Handler ...
|
879 |
|
|
*/
|
880 |
|
|
|
881 |
|
|
static void elmc_interrupt(int irq, void *dev_id, struct pt_regs *reg_ptr)
|
882 |
|
|
{
|
883 |
|
|
struct net_device *dev = (struct net_device *) dev_id;
|
884 |
|
|
unsigned short stat;
|
885 |
|
|
struct priv *p;
|
886 |
|
|
|
887 |
|
|
if (dev == NULL) {
|
888 |
|
|
printk(KERN_ERR "elmc-interrupt: irq %d for unknown device.\n", (int) -(((struct pt_regs *) reg_ptr)->orig_eax + 2));
|
889 |
|
|
return;
|
890 |
|
|
} else if (!netif_running(dev)) {
|
891 |
|
|
/* The 3c523 has this habit of generating interrupts during the
|
892 |
|
|
reset. I'm not sure if the ni52 has this same problem, but it's
|
893 |
|
|
really annoying if we haven't finished initializing it. I was
|
894 |
|
|
hoping all the elmc_id_* commands would disable this, but I
|
895 |
|
|
might have missed a few. */
|
896 |
|
|
|
897 |
|
|
elmc_id_attn586(); /* ack inter. and disable any more */
|
898 |
|
|
return;
|
899 |
|
|
} else if (!(ELMC_CTRL_INT & inb(dev->base_addr + ELMC_CTRL))) {
|
900 |
|
|
/* wasn't this device */
|
901 |
|
|
return;
|
902 |
|
|
}
|
903 |
|
|
/* reading ELMC_CTRL also clears the INT bit. */
|
904 |
|
|
|
905 |
|
|
p = (struct priv *) dev->priv;
|
906 |
|
|
|
907 |
|
|
while ((stat = p->scb->status & STAT_MASK))
|
908 |
|
|
{
|
909 |
|
|
p->scb->cmd = stat;
|
910 |
|
|
elmc_attn586(); /* ack inter. */
|
911 |
|
|
|
912 |
|
|
if (stat & STAT_CX) {
|
913 |
|
|
/* command with I-bit set complete */
|
914 |
|
|
elmc_xmt_int(dev);
|
915 |
|
|
}
|
916 |
|
|
if (stat & STAT_FR) {
|
917 |
|
|
/* received a frame */
|
918 |
|
|
elmc_rcv_int(dev);
|
919 |
|
|
}
|
920 |
|
|
#ifndef NO_NOPCOMMANDS
|
921 |
|
|
if (stat & STAT_CNA) {
|
922 |
|
|
/* CU went 'not ready' */
|
923 |
|
|
if (netif_running(dev)) {
|
924 |
|
|
printk(KERN_WARNING "%s: oops! CU has left active state. stat: %04x/%04x.\n", dev->name, (int) stat, (int) p->scb->status);
|
925 |
|
|
}
|
926 |
|
|
}
|
927 |
|
|
#endif
|
928 |
|
|
|
929 |
|
|
if (stat & STAT_RNR) {
|
930 |
|
|
/* RU went 'not ready' */
|
931 |
|
|
|
932 |
|
|
if (p->scb->status & RU_SUSPEND) {
|
933 |
|
|
/* special case: RU_SUSPEND */
|
934 |
|
|
|
935 |
|
|
WAIT_4_SCB_CMD();
|
936 |
|
|
p->scb->cmd = RUC_RESUME;
|
937 |
|
|
elmc_attn586();
|
938 |
|
|
} else {
|
939 |
|
|
printk(KERN_WARNING "%s: Receiver-Unit went 'NOT READY': %04x/%04x.\n", dev->name, (int) stat, (int) p->scb->status);
|
940 |
|
|
elmc_rnr_int(dev);
|
941 |
|
|
}
|
942 |
|
|
}
|
943 |
|
|
WAIT_4_SCB_CMD(); /* wait for ack. (elmc_xmt_int can be faster than ack!!) */
|
944 |
|
|
if (p->scb->cmd) { /* timed out? */
|
945 |
|
|
break;
|
946 |
|
|
}
|
947 |
|
|
}
|
948 |
|
|
}
|
949 |
|
|
|
950 |
|
|
/*******************************************************
|
951 |
|
|
* receive-interrupt
|
952 |
|
|
*/
|
953 |
|
|
|
954 |
|
|
static void elmc_rcv_int(struct net_device *dev)
|
955 |
|
|
{
|
956 |
|
|
int status;
|
957 |
|
|
unsigned short totlen;
|
958 |
|
|
struct sk_buff *skb;
|
959 |
|
|
struct rbd_struct *rbd;
|
960 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
961 |
|
|
|
962 |
|
|
for (; (status = p->rfd_top->status) & STAT_COMPL;) {
|
963 |
|
|
rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
|
964 |
|
|
|
965 |
|
|
if (status & STAT_OK) { /* frame received without error? */
|
966 |
|
|
if ((totlen = rbd->status) & RBD_LAST) { /* the first and the last buffer? */
|
967 |
|
|
totlen &= RBD_MASK; /* length of this frame */
|
968 |
|
|
rbd->status = 0;
|
969 |
|
|
skb = (struct sk_buff *) dev_alloc_skb(totlen + 2);
|
970 |
|
|
if (skb != NULL) {
|
971 |
|
|
skb->dev = dev;
|
972 |
|
|
skb_reserve(skb, 2); /* 16 byte alignment */
|
973 |
|
|
skb_put(skb,totlen);
|
974 |
|
|
eth_copy_and_sum(skb, (char *) p->base+(unsigned long) rbd->buffer,totlen,0);
|
975 |
|
|
skb->protocol = eth_type_trans(skb, dev);
|
976 |
|
|
netif_rx(skb);
|
977 |
|
|
dev->last_rx = jiffies;
|
978 |
|
|
p->stats.rx_packets++;
|
979 |
|
|
p->stats.rx_bytes += totlen;
|
980 |
|
|
} else {
|
981 |
|
|
p->stats.rx_dropped++;
|
982 |
|
|
}
|
983 |
|
|
} else {
|
984 |
|
|
printk(KERN_WARNING "%s: received oversized frame.\n", dev->name);
|
985 |
|
|
p->stats.rx_dropped++;
|
986 |
|
|
}
|
987 |
|
|
} else { /* frame !(ok), only with 'save-bad-frames' */
|
988 |
|
|
printk(KERN_WARNING "%s: oops! rfd-error-status: %04x\n", dev->name, status);
|
989 |
|
|
p->stats.rx_errors++;
|
990 |
|
|
}
|
991 |
|
|
p->rfd_top->status = 0;
|
992 |
|
|
p->rfd_top->last = RFD_SUSP;
|
993 |
|
|
p->rfd_last->last = 0; /* delete RU_SUSP */
|
994 |
|
|
p->rfd_last = p->rfd_top;
|
995 |
|
|
p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */
|
996 |
|
|
}
|
997 |
|
|
}
|
998 |
|
|
|
999 |
|
|
/**********************************************************
|
1000 |
|
|
* handle 'Receiver went not ready'.
|
1001 |
|
|
*/
|
1002 |
|
|
|
1003 |
|
|
static void elmc_rnr_int(struct net_device *dev)
|
1004 |
|
|
{
|
1005 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
1006 |
|
|
|
1007 |
|
|
p->stats.rx_errors++;
|
1008 |
|
|
|
1009 |
|
|
WAIT_4_SCB_CMD(); /* wait for the last cmd */
|
1010 |
|
|
p->scb->cmd = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */
|
1011 |
|
|
elmc_attn586();
|
1012 |
|
|
WAIT_4_SCB_CMD(); /* wait for accept cmd. */
|
1013 |
|
|
|
1014 |
|
|
alloc_rfa(dev, (char *) p->rfd_first);
|
1015 |
|
|
startrecv586(dev); /* restart RU */
|
1016 |
|
|
|
1017 |
|
|
printk(KERN_WARNING "%s: Receive-Unit restarted. Status: %04x\n", dev->name, p->scb->status);
|
1018 |
|
|
|
1019 |
|
|
}
|
1020 |
|
|
|
1021 |
|
|
/**********************************************************
|
1022 |
|
|
* handle xmit - interrupt
|
1023 |
|
|
*/
|
1024 |
|
|
|
1025 |
|
|
static void elmc_xmt_int(struct net_device *dev)
|
1026 |
|
|
{
|
1027 |
|
|
int status;
|
1028 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
1029 |
|
|
|
1030 |
|
|
status = p->xmit_cmds[p->xmit_last]->cmd_status;
|
1031 |
|
|
if (!(status & STAT_COMPL)) {
|
1032 |
|
|
printk(KERN_WARNING "%s: strange .. xmit-int without a 'COMPLETE'\n", dev->name);
|
1033 |
|
|
}
|
1034 |
|
|
if (status & STAT_OK) {
|
1035 |
|
|
p->stats.tx_packets++;
|
1036 |
|
|
p->stats.collisions += (status & TCMD_MAXCOLLMASK);
|
1037 |
|
|
} else {
|
1038 |
|
|
p->stats.tx_errors++;
|
1039 |
|
|
if (status & TCMD_LATECOLL) {
|
1040 |
|
|
printk(KERN_WARNING "%s: late collision detected.\n", dev->name);
|
1041 |
|
|
p->stats.collisions++;
|
1042 |
|
|
} else if (status & TCMD_NOCARRIER) {
|
1043 |
|
|
p->stats.tx_carrier_errors++;
|
1044 |
|
|
printk(KERN_WARNING "%s: no carrier detected.\n", dev->name);
|
1045 |
|
|
} else if (status & TCMD_LOSTCTS) {
|
1046 |
|
|
printk(KERN_WARNING "%s: loss of CTS detected.\n", dev->name);
|
1047 |
|
|
} else if (status & TCMD_UNDERRUN) {
|
1048 |
|
|
p->stats.tx_fifo_errors++;
|
1049 |
|
|
printk(KERN_WARNING "%s: DMA underrun detected.\n", dev->name);
|
1050 |
|
|
} else if (status & TCMD_MAXCOLL) {
|
1051 |
|
|
printk(KERN_WARNING "%s: Max. collisions exceeded.\n", dev->name);
|
1052 |
|
|
p->stats.collisions += 16;
|
1053 |
|
|
}
|
1054 |
|
|
}
|
1055 |
|
|
|
1056 |
|
|
#if (NUM_XMIT_BUFFS != 1)
|
1057 |
|
|
if ((++p->xmit_last) == NUM_XMIT_BUFFS) {
|
1058 |
|
|
p->xmit_last = 0;
|
1059 |
|
|
}
|
1060 |
|
|
#endif
|
1061 |
|
|
|
1062 |
|
|
netif_wake_queue(dev);
|
1063 |
|
|
}
|
1064 |
|
|
|
1065 |
|
|
/***********************************************************
|
1066 |
|
|
* (re)start the receiver
|
1067 |
|
|
*/
|
1068 |
|
|
|
1069 |
|
|
static void startrecv586(struct net_device *dev)
|
1070 |
|
|
{
|
1071 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
1072 |
|
|
|
1073 |
|
|
p->scb->rfa_offset = make16(p->rfd_first);
|
1074 |
|
|
p->scb->cmd = RUC_START;
|
1075 |
|
|
elmc_attn586(); /* start cmd. */
|
1076 |
|
|
WAIT_4_SCB_CMD(); /* wait for accept cmd. (no timeout!!) */
|
1077 |
|
|
}
|
1078 |
|
|
|
1079 |
|
|
/******************************************************
|
1080 |
|
|
* timeout
|
1081 |
|
|
*/
|
1082 |
|
|
|
1083 |
|
|
static void elmc_timeout(struct net_device *dev)
|
1084 |
|
|
{
|
1085 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
1086 |
|
|
/* COMMAND-UNIT active? */
|
1087 |
|
|
if (p->scb->status & CU_ACTIVE) {
|
1088 |
|
|
#ifdef DEBUG
|
1089 |
|
|
printk("%s: strange ... timeout with CU active?!?\n", dev->name);
|
1090 |
|
|
printk("%s: X0: %04x N0: %04x N1: %04x %d\n", dev->name, (int) p->xmit_cmds[0]->cmd_status, (int) p->nop_cmds[0]->cmd_status, (int) p->nop_cmds[1]->cmd_status, (int) p->nop_point);
|
1091 |
|
|
#endif
|
1092 |
|
|
p->scb->cmd = CUC_ABORT;
|
1093 |
|
|
elmc_attn586();
|
1094 |
|
|
WAIT_4_SCB_CMD();
|
1095 |
|
|
p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]);
|
1096 |
|
|
p->scb->cmd = CUC_START;
|
1097 |
|
|
elmc_attn586();
|
1098 |
|
|
WAIT_4_SCB_CMD();
|
1099 |
|
|
netif_wake_queue(dev);
|
1100 |
|
|
} else {
|
1101 |
|
|
#ifdef DEBUG
|
1102 |
|
|
printk("%s: xmitter timed out, try to restart! stat: %04x\n", dev->name, p->scb->status);
|
1103 |
|
|
printk("%s: command-stats: %04x %04x\n", dev->name, p->xmit_cmds[0]->cmd_status, p->xmit_cmds[1]->cmd_status);
|
1104 |
|
|
#endif
|
1105 |
|
|
elmc_close(dev);
|
1106 |
|
|
elmc_open(dev);
|
1107 |
|
|
}
|
1108 |
|
|
}
|
1109 |
|
|
|
1110 |
|
|
/******************************************************
|
1111 |
|
|
* send frame
|
1112 |
|
|
*/
|
1113 |
|
|
|
1114 |
|
|
static int elmc_send_packet(struct sk_buff *skb, struct net_device *dev)
|
1115 |
|
|
{
|
1116 |
|
|
int len;
|
1117 |
|
|
int i;
|
1118 |
|
|
#ifndef NO_NOPCOMMANDS
|
1119 |
|
|
int next_nop;
|
1120 |
|
|
#endif
|
1121 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
1122 |
|
|
|
1123 |
|
|
netif_stop_queue(dev);
|
1124 |
|
|
|
1125 |
|
|
len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
|
1126 |
|
|
|
1127 |
|
|
if(len != skb->len)
|
1128 |
|
|
memset((char *) p->xmit_cbuffs[p->xmit_count], 0, ETH_ZLEN);
|
1129 |
|
|
memcpy((char *) p->xmit_cbuffs[p->xmit_count], (char *) (skb->data), skb->len);
|
1130 |
|
|
|
1131 |
|
|
#if (NUM_XMIT_BUFFS == 1)
|
1132 |
|
|
#ifdef NO_NOPCOMMANDS
|
1133 |
|
|
p->xmit_buffs[0]->size = TBD_LAST | len;
|
1134 |
|
|
for (i = 0; i < 16; i++) {
|
1135 |
|
|
p->scb->cbl_offset = make16(p->xmit_cmds[0]);
|
1136 |
|
|
p->scb->cmd = CUC_START;
|
1137 |
|
|
p->xmit_cmds[0]->cmd_status = 0;
|
1138 |
|
|
elmc_attn586();
|
1139 |
|
|
dev->trans_start = jiffies;
|
1140 |
|
|
if (!i) {
|
1141 |
|
|
dev_kfree_skb(skb);
|
1142 |
|
|
}
|
1143 |
|
|
WAIT_4_SCB_CMD();
|
1144 |
|
|
if ((p->scb->status & CU_ACTIVE)) { /* test it, because CU sometimes doesn't start immediately */
|
1145 |
|
|
break;
|
1146 |
|
|
}
|
1147 |
|
|
if (p->xmit_cmds[0]->cmd_status) {
|
1148 |
|
|
break;
|
1149 |
|
|
}
|
1150 |
|
|
if (i == 15) {
|
1151 |
|
|
printk(KERN_WARNING "%s: Can't start transmit-command.\n", dev->name);
|
1152 |
|
|
}
|
1153 |
|
|
}
|
1154 |
|
|
#else
|
1155 |
|
|
next_nop = (p->nop_point + 1) & 0x1;
|
1156 |
|
|
p->xmit_buffs[0]->size = TBD_LAST | len;
|
1157 |
|
|
|
1158 |
|
|
p->xmit_cmds[0]->cmd_link = p->nop_cmds[next_nop]->cmd_link
|
1159 |
|
|
= make16((p->nop_cmds[next_nop]));
|
1160 |
|
|
p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;
|
1161 |
|
|
|
1162 |
|
|
p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0]));
|
1163 |
|
|
dev->trans_start = jiffies;
|
1164 |
|
|
p->nop_point = next_nop;
|
1165 |
|
|
dev_kfree_skb(skb);
|
1166 |
|
|
#endif
|
1167 |
|
|
#else
|
1168 |
|
|
p->xmit_buffs[p->xmit_count]->size = TBD_LAST | len;
|
1169 |
|
|
if ((next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS) {
|
1170 |
|
|
next_nop = 0;
|
1171 |
|
|
}
|
1172 |
|
|
p->xmit_cmds[p->xmit_count]->cmd_status = 0;
|
1173 |
|
|
p->xmit_cmds[p->xmit_count]->cmd_link = p->nop_cmds[next_nop]->cmd_link
|
1174 |
|
|
= make16((p->nop_cmds[next_nop]));
|
1175 |
|
|
p->nop_cmds[next_nop]->cmd_status = 0;
|
1176 |
|
|
p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count]));
|
1177 |
|
|
dev->trans_start = jiffies;
|
1178 |
|
|
p->xmit_count = next_nop;
|
1179 |
|
|
if (p->xmit_count != p->xmit_last)
|
1180 |
|
|
netif_wake_queue(dev);
|
1181 |
|
|
dev_kfree_skb(skb);
|
1182 |
|
|
#endif
|
1183 |
|
|
return 0;
|
1184 |
|
|
}
|
1185 |
|
|
|
1186 |
|
|
/*******************************************
|
1187 |
|
|
* Someone wanna have the statistics
|
1188 |
|
|
*/
|
1189 |
|
|
|
1190 |
|
|
static struct net_device_stats *elmc_get_stats(struct net_device *dev)
|
1191 |
|
|
{
|
1192 |
|
|
struct priv *p = (struct priv *) dev->priv;
|
1193 |
|
|
unsigned short crc, aln, rsc, ovrn;
|
1194 |
|
|
|
1195 |
|
|
crc = p->scb->crc_errs; /* get error-statistic from the ni82586 */
|
1196 |
|
|
p->scb->crc_errs -= crc;
|
1197 |
|
|
aln = p->scb->aln_errs;
|
1198 |
|
|
p->scb->aln_errs -= aln;
|
1199 |
|
|
rsc = p->scb->rsc_errs;
|
1200 |
|
|
p->scb->rsc_errs -= rsc;
|
1201 |
|
|
ovrn = p->scb->ovrn_errs;
|
1202 |
|
|
p->scb->ovrn_errs -= ovrn;
|
1203 |
|
|
|
1204 |
|
|
p->stats.rx_crc_errors += crc;
|
1205 |
|
|
p->stats.rx_fifo_errors += ovrn;
|
1206 |
|
|
p->stats.rx_frame_errors += aln;
|
1207 |
|
|
p->stats.rx_dropped += rsc;
|
1208 |
|
|
|
1209 |
|
|
return &p->stats;
|
1210 |
|
|
}
|
1211 |
|
|
|
1212 |
|
|
/********************************************************
|
1213 |
|
|
* Set MC list ..
|
1214 |
|
|
*/
|
1215 |
|
|
|
1216 |
|
|
#ifdef ELMC_MULTICAST
|
1217 |
|
|
static void set_multicast_list(struct net_device *dev)
|
1218 |
|
|
{
|
1219 |
|
|
if (!dev->start) {
|
1220 |
|
|
/* without a running interface, promiscuous doesn't work */
|
1221 |
|
|
return;
|
1222 |
|
|
}
|
1223 |
|
|
dev->start = 0;
|
1224 |
|
|
alloc586(dev);
|
1225 |
|
|
init586(dev);
|
1226 |
|
|
startrecv586(dev);
|
1227 |
|
|
dev->start = 1;
|
1228 |
|
|
}
|
1229 |
|
|
#endif
|
1230 |
|
|
|
1231 |
|
|
static void netdev_get_drvinfo(struct net_device *dev,
|
1232 |
|
|
struct ethtool_drvinfo *info)
|
1233 |
|
|
{
|
1234 |
|
|
strcpy(info->driver, DRV_NAME);
|
1235 |
|
|
strcpy(info->version, DRV_VERSION);
|
1236 |
|
|
sprintf(info->bus_info, "MCA 0x%lx", dev->base_addr);
|
1237 |
|
|
}
|
1238 |
|
|
|
1239 |
|
|
static struct ethtool_ops netdev_ethtool_ops = {
|
1240 |
|
|
.get_drvinfo = netdev_get_drvinfo,
|
1241 |
|
|
};
|
1242 |
|
|
|
1243 |
|
|
#ifdef MODULE
|
1244 |
|
|
|
1245 |
|
|
/* Increase if needed ;) */
|
1246 |
|
|
#define MAX_3C523_CARDS 4
|
1247 |
|
|
|
1248 |
|
|
static struct net_device dev_elmc[MAX_3C523_CARDS];
|
1249 |
|
|
static int irq[MAX_3C523_CARDS];
|
1250 |
|
|
static int io[MAX_3C523_CARDS];
|
1251 |
|
|
MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_3C523_CARDS) "i");
|
1252 |
|
|
MODULE_PARM(io, "1-" __MODULE_STRING(MAX_3C523_CARDS) "i");
|
1253 |
|
|
MODULE_PARM_DESC(io, "EtherLink/MC I/O base address(es)");
|
1254 |
|
|
MODULE_PARM_DESC(irq, "EtherLink/MC IRQ number(s)");
|
1255 |
|
|
|
1256 |
|
|
int init_module(void)
|
1257 |
|
|
{
|
1258 |
|
|
int this_dev,found = 0;
|
1259 |
|
|
|
1260 |
|
|
/* Loop until we either can't find any more cards, or we have MAX_3C523_CARDS */
|
1261 |
|
|
for(this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++)
|
1262 |
|
|
{
|
1263 |
|
|
struct net_device *dev = &dev_elmc[this_dev];
|
1264 |
|
|
dev->irq=irq[this_dev];
|
1265 |
|
|
dev->base_addr=io[this_dev];
|
1266 |
|
|
dev->init=elmc_probe;
|
1267 |
|
|
if(register_netdev(dev)!=0) {
|
1268 |
|
|
if(io[this_dev]==0) break;
|
1269 |
|
|
printk(KERN_WARNING "3c523.c: No 3c523 card found at io=%#x\n",io[this_dev]);
|
1270 |
|
|
} else found++;
|
1271 |
|
|
}
|
1272 |
|
|
|
1273 |
|
|
if(found==0) {
|
1274 |
|
|
if(io[0]==0) printk(KERN_NOTICE "3c523.c: No 3c523 cards found\n");
|
1275 |
|
|
return -ENXIO;
|
1276 |
|
|
} else return 0;
|
1277 |
|
|
}
|
1278 |
|
|
|
1279 |
|
|
void cleanup_module(void)
|
1280 |
|
|
{
|
1281 |
|
|
int this_dev;
|
1282 |
|
|
for(this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {
|
1283 |
|
|
|
1284 |
|
|
struct net_device *dev = &dev_elmc[this_dev];
|
1285 |
|
|
if(dev->priv) {
|
1286 |
|
|
/* shutdown interrupts on the card */
|
1287 |
|
|
elmc_id_reset586();
|
1288 |
|
|
if (dev->irq != 0) {
|
1289 |
|
|
/* this should be done by close, but if we failed to
|
1290 |
|
|
initialize properly something may have gotten hosed. */
|
1291 |
|
|
free_irq(dev->irq, dev);
|
1292 |
|
|
dev->irq = 0;
|
1293 |
|
|
}
|
1294 |
|
|
if (dev->base_addr != 0) {
|
1295 |
|
|
release_region(dev->base_addr, ELMC_IO_EXTENT);
|
1296 |
|
|
dev->base_addr = 0;
|
1297 |
|
|
}
|
1298 |
|
|
irq[this_dev] = 0;
|
1299 |
|
|
io[this_dev] = 0;
|
1300 |
|
|
unregister_netdev(dev);
|
1301 |
|
|
|
1302 |
|
|
mca_set_adapter_procfn(((struct priv *) (dev->priv))->slot,
|
1303 |
|
|
NULL, NULL);
|
1304 |
|
|
|
1305 |
|
|
kfree(dev->priv);
|
1306 |
|
|
dev->priv = NULL;
|
1307 |
|
|
}
|
1308 |
|
|
}
|
1309 |
|
|
}
|
1310 |
|
|
|
1311 |
|
|
#endif /* MODULE */
|