Import 2.1.81
[davej-history.git] / drivers / net / dgrs.c
blob4e29cb6abc21262e3880ae764f0d34787df04058
1 /*
2 * Digi RightSwitch SE-X loadable device driver for Linux
4 * The RightSwitch is a 4 (EISA) or 6 (PCI) port etherswitch and
5 * a NIC on an internal board.
7 * Author: Rick Richardson, rick@dgii.com, rick_richardson@dgii.com
8 * Derived from the SVR4.2 (UnixWare) driver for the same card.
10 * Copyright 1995-1996 Digi International Inc.
12 * This software may be used and distributed according to the terms
13 * of the GNU General Public License, incorporated herein by reference.
15 * For information on purchasing a RightSwitch SE-4 or SE-6
16 * board, please contact Digi's sales department at 1-612-912-3444
17 * or 1-800-DIGIBRD. Outside the U.S., please check our Web page
18 * at http://www.dgii.com for sales offices worldwide.
20 * OPERATION:
21 * When compiled as a loadable module, this driver can operate
22 * the board as either a 4/6 port switch with a 5th or 7th port
23 * that is a conventional NIC interface as far as the host is
24 * concerned, OR as 4/6 independant NICs. To select multi-NIC
25 * mode, add "nicmode=1" on the insmod load line for the driver.
27 * This driver uses the "dev" common ethernet device structure
28 * and a private "priv" (dev->priv) structure that contains
29 * mostly DGRS-specific information and statistics. To keep
30 * the code for both the switch mode and the multi-NIC mode
31 * as similar as possible, I have introduced the concept of
32 * "dev0"/"priv0" and "devN"/"privN" pointer pairs in subroutines
33 * where needed. The first pair of pointers points to the
34 * "dev" and "priv" structures of the zeroth (0th) device
35 * interface associated with a board. The second pair of
36 * pointers points to the current (Nth) device interface
37 * for the board: the one for which we are processing data.
39 * In switch mode, the pairs of pointers are always the same,
40 * that is, dev0 == devN and priv0 == privN. This is just
41 * like previous releases of this driver which did not support
42 * NIC mode.
44 * In multi-NIC mode, the pairs of pointers may be different.
45 * We use the devN and privN pointers to reference just the
46 * name, port number, and statistics for the current interface.
47 * We use the dev0 and priv0 pointers to access the variables
48 * that control access to the board, such as board address
49 * and simulated 82596 variables. This is because there is
50 * only one "fake" 82596 that serves as the interface to
51 * the board. We do not want to try to keep the variables
52 * associated with this 82596 in sync across all devices.
54 * This scheme works well. As you will see, except for
55 * initialization, there is very little difference between
56 * the two modes as far as this driver is concerned. On the
57 * receive side in NIC mode, the interrupt *always* comes in on
58 * the 0th interface (dev0/priv0). We then figure out which
59 * real 82596 port it came in on from looking at the "chan"
60 * member that the board firmware adds at the end of each
61 * RBD (a.k.a. TBD). We get the channel number like this:
62 * int chan = ((I596_RBD *) S2H(cbp->xmit.tbdp))->chan;
64 * On the transmit side in multi-NIC mode, we specify the
65 * output 82596 port by setting the new "dstchan" structure
66 * member that is at the end of the RFD, like this:
67 * priv0->rfdp->dstchan = privN->chan;
69 * TODO:
70 * - Multi-NIC mode is not yet supported when the driver is linked
71 * into the kernel.
72 * - Better handling of multicast addresses.
76 static char *version = "$Id: dgrs.c,v 1.12 1996/12/21 13:43:58 rick Exp $";
78 #include <linux/version.h>
79 #include <linux/module.h>
81 #include <linux/kernel.h>
82 #include <linux/sched.h>
83 #include <linux/string.h>
84 #include <linux/delay.h>
85 #include <linux/errno.h>
86 #include <linux/ioport.h>
87 #include <linux/malloc.h>
88 #include <linux/interrupt.h>
89 #include <linux/pci.h>
90 #include <linux/bios32.h>
91 #include <linux/init.h>
92 #include <asm/bitops.h>
93 #include <asm/io.h>
94 #include <asm/byteorder.h>
96 #include <linux/netdevice.h>
97 #include <linux/etherdevice.h>
98 #include <linux/skbuff.h>
100 #include <linux/types.h>
103 * API changed at linux version 2.1.0
105 #if LINUX_VERSION_CODE >= 0x20100
106 #include <asm/uaccess.h>
107 #define IOREMAP(ADDR, LEN) ioremap(ADDR, LEN)
108 #define IOUNMAP(ADDR) iounmap(ADDR)
109 #define COPY_FROM_USER(DST,SRC,LEN) copy_from_user(DST,SRC,LEN)
110 #define COPY_TO_USER(DST,SRC,LEN) copy_to_user(DST,SRC,LEN)
111 #else
112 #define IOREMAP(ADDR, LEN) vremap(ADDR, LEN)
113 #define IOUNMAP(ADDR) vfree(ADDR)
114 #define COPY_FROM_USER(DST,SRC,LEN) memcpy_fromfs(DST,SRC,LEN)
115 #define COPY_TO_USER(DST,SRC,LEN) memcpy_tofs(DST,SRC,LEN)
116 #endif
119 * DGRS include files
121 typedef unsigned char uchar;
122 typedef unsigned int bool;
123 #define vol volatile
125 #include "dgrs.h"
126 #include "dgrs_es4h.h"
127 #include "dgrs_plx9060.h"
128 #include "dgrs_i82596.h"
129 #include "dgrs_ether.h"
130 #include "dgrs_asstruct.h"
131 #include "dgrs_bcomm.h"
134 * Firmware. Compiled separately for local compilation,
135 * but #included for Linux distribution.
137 #ifndef NOFW
138 #include "dgrs_firmware.c"
139 #else
140 extern int dgrs_firmnum;
141 extern char dgrs_firmver[];
142 extern char dgrs_firmdate[];
143 extern uchar dgrs_code[];
144 extern int dgrs_ncode;
145 #endif
148 * Linux out*() is backwards from all other operating systems
150 #define OUTB(ADDR, VAL) outb(VAL, ADDR)
151 #define OUTW(ADDR, VAL) outw(VAL, ADDR)
152 #define OUTL(ADDR, VAL) outl(VAL, ADDR)
155 * Macros to convert switch to host and host to switch addresses
156 * (assumes a local variable priv points to board dependent struct)
158 #define S2H(A) ( ((unsigned long)(A)&0x00ffffff) + priv0->vmem )
159 #define S2HN(A) ( ((unsigned long)(A)&0x00ffffff) + privN->vmem )
160 #define H2S(A) ( ((char *) (A) - priv0->vmem) + 0xA3000000 )
163 * Convert a switch address to a "safe" address for use with the
164 * PLX 9060 DMA registers and the associated HW kludge that allows
165 * for host access of the DMA registers.
167 #define S2DMA(A) ( (unsigned long)(A) & 0x00ffffff)
170 * "Space.c" variables, now settable from module interface
171 * Use the name below, minus the "dgrs_" prefix. See init_module().
173 int dgrs_debug = 1;
174 int dgrs_dma = 1;
175 int dgrs_spantree = -1;
176 int dgrs_hashexpire = -1;
177 uchar dgrs_ipaddr[4] = { 0xff, 0xff, 0xff, 0xff};
178 uchar dgrs_iptrap[4] = { 0xff, 0xff, 0xff, 0xff};
179 __u32 dgrs_ipxnet = -1;
180 int dgrs_nicmode = 0;
183 * Chain of device structures
185 #ifdef MODULE
186 static struct device *dgrs_root_dev = NULL;
187 #endif
190 * Private per-board data structure (dev->priv)
192 typedef struct
195 * Stuff for generic ethercard I/F
197 char devname[8]; /* "ethN" string */
198 struct device *next_dev;
199 struct net_device_stats stats;
202 * DGRS specific data
204 char *vmem;
206 struct bios_comm *bcomm; /* Firmware BIOS comm structure */
207 PORT *port; /* Ptr to PORT[0] struct in VM */
208 I596_SCB *scbp; /* Ptr to SCB struct in VM */
209 I596_RFD *rfdp; /* Current RFD list */
210 I596_RBD *rbdp; /* Current RBD list */
212 int intrcnt; /* Count of interrupts */
215 * SE-4 (EISA) board variables
217 uchar is_reg; /* EISA: Value for ES4H_IS reg */
220 * SE-6 (PCI) board variables
222 * The PLX "expansion rom" space is used for DMA register
223 * access from the host on the SE-6. These are the physical
224 * and virtual addresses of that space.
226 ulong plxreg; /* Phys address of PLX chip */
227 char *vplxreg; /* Virtual address of PLX chip */
228 ulong plxdma; /* Phys addr of PLX "expansion rom" */
229 ulong volatile *vplxdma; /* Virtual addr of "expansion rom" */
230 int use_dma; /* Flag: use DMA */
231 DMACHAIN *dmadesc_s; /* area for DMA chains (SW addr.) */
232 DMACHAIN *dmadesc_h; /* area for DMA chains (Host Virtual) */
235 * Multi-NIC mode variables
237 * All entries of the devtbl[] array are valid for the 0th
238 * device (i.e. eth0, but not eth1...eth5). devtbl[0] is
239 * valid for all devices (i.e. eth0, eth1, ..., eth5).
241 int nports; /* Number of physical ports (4 or 6) */
242 int chan; /* Channel # (1-6) for this device */
243 struct device *devtbl[6]; /* Ptrs to N device structs */
245 } DGRS_PRIV;
249 * reset or un-reset the IDT processor
251 static void
252 proc_reset(struct device *dev0, int reset)
254 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
256 if (priv0->plxreg)
258 ulong val;
259 val = inl(dev0->base_addr + PLX_MISC_CSR);
260 if (reset)
261 val |= SE6_RESET;
262 else
263 val &= ~SE6_RESET;
264 OUTL(dev0->base_addr + PLX_MISC_CSR, val);
266 else
268 OUTB(dev0->base_addr + ES4H_PC, reset ? ES4H_PC_RESET : 0);
273 * See if the board supports bus master DMA
275 static int
276 check_board_dma(struct device *dev0)
278 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
279 ulong x;
282 * If Space.c says not to use DMA, or if its not a PLX based
283 * PCI board, or if the expansion ROM space is not PCI
284 * configured, then return false.
286 if (!dgrs_dma || !priv0->plxreg || !priv0->plxdma)
287 return (0);
290 * Set the local address remap register of the "expansion rom"
291 * area to 0x80000000 so that we can use it to access the DMA
292 * registers from the host side.
294 OUTL(dev0->base_addr + PLX_ROM_BASE_ADDR, 0x80000000);
297 * Set the PCI region descriptor to:
298 * Space 0:
299 * disable read-prefetch
300 * enable READY
301 * enable BURST
302 * 0 internal wait states
303 * Expansion ROM: (used for host DMA register access)
304 * disable read-prefetch
305 * enable READY
306 * disable BURST
307 * 0 internal wait states
309 OUTL(dev0->base_addr + PLX_BUS_REGION, 0x49430343);
312 * Now map the DMA registers into our virtual space
314 priv0->vplxdma = (ulong *) IOREMAP (priv0->plxdma, 256);
315 if (!priv0->vplxdma)
317 printk("%s: can't *remap() the DMA regs\n", dev0->name);
318 return (0);
322 * Now test to see if we can access the DMA registers
323 * If we write -1 and get back 1FFF, then we accessed the
324 * DMA register. Otherwise, we probably have an old board
325 * and wrote into regular RAM.
327 priv0->vplxdma[PLX_DMA0_MODE/4] = 0xFFFFFFFF;
328 x = priv0->vplxdma[PLX_DMA0_MODE/4];
329 if (x != 0x00001FFF)
330 return (0);
332 return (1);
336 * Initiate DMA using PLX part on PCI board. Spin the
337 * processor until completed. All addresses are physical!
339 * If pciaddr is NULL, then its a chaining DMA, and lcladdr is
340 * the address of the first DMA descriptor in the chain.
342 * If pciaddr is not NULL, then its a single DMA.
344 * In either case, "lcladdr" must have been fixed up to make
345 * sure the MSB isn't set using the S2DMA macro before passing
346 * the address to this routine.
348 static int
349 do_plx_dma(
350 struct device *dev,
351 ulong pciaddr,
352 ulong lcladdr,
353 int len,
354 int to_host
357 int i;
358 ulong csr;
359 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
361 if (pciaddr)
364 * Do a single, non-chain DMA
366 priv->vplxdma[PLX_DMA0_PCI_ADDR/4] = pciaddr;
367 priv->vplxdma[PLX_DMA0_LCL_ADDR/4] = lcladdr;
368 priv->vplxdma[PLX_DMA0_SIZE/4] = len;
369 priv->vplxdma[PLX_DMA0_DESCRIPTOR/4] = to_host
370 ? PLX_DMA_DESC_TO_HOST
371 : PLX_DMA_DESC_TO_BOARD;
372 priv->vplxdma[PLX_DMA0_MODE/4] =
373 PLX_DMA_MODE_WIDTH32
374 | PLX_DMA_MODE_WAITSTATES(0)
375 | PLX_DMA_MODE_READY
376 | PLX_DMA_MODE_NOBTERM
377 | PLX_DMA_MODE_BURST
378 | PLX_DMA_MODE_NOCHAIN;
380 else
383 * Do a chaining DMA
385 priv->vplxdma[PLX_DMA0_MODE/4] =
386 PLX_DMA_MODE_WIDTH32
387 | PLX_DMA_MODE_WAITSTATES(0)
388 | PLX_DMA_MODE_READY
389 | PLX_DMA_MODE_NOBTERM
390 | PLX_DMA_MODE_BURST
391 | PLX_DMA_MODE_CHAIN;
392 priv->vplxdma[PLX_DMA0_DESCRIPTOR/4] = lcladdr;
395 priv->vplxdma[PLX_DMA_CSR/4] =
396 PLX_DMA_CSR_0_ENABLE | PLX_DMA_CSR_0_START;
399 * Wait for DMA to complete
401 for (i = 0; i < 1000000; ++i)
404 * Spin the host CPU for 1 usec, so we don't thrash
405 * the PCI bus while the PLX 9060 is doing DMA.
407 udelay(1);
409 csr = (volatile unsigned long) priv->vplxdma[PLX_DMA_CSR/4];
411 if (csr & PLX_DMA_CSR_0_DONE)
412 break;
415 if ( ! (csr & PLX_DMA_CSR_0_DONE) )
417 printk("%s: DMA done never occurred. DMA disabled.\n",
418 dev->name);
419 priv->use_dma = 0;
420 return 1;
422 return 0;
426 * dgrs_rcv_frame()
428 * Process a received frame. This is called from the interrupt
429 * routine, and works for both switch mode and multi-NIC mode.
431 * Note that when in multi-NIC mode, we want to always access the
432 * hardware using the dev and priv structures of the first port,
433 * so that we are using only one set of variables to maintain
434 * the board interface status, but we want to use the Nth port
435 * dev and priv structures to maintain statistics and to pass
436 * the packet up.
438 * Only the first device structure is attached to the interrupt.
439 * We use the special "chan" variable at the end of the first RBD
440 * to select the Nth device in multi-NIC mode.
442 * We currently do chained DMA on a per-packet basis when the
443 * packet is "long", and we spin the CPU a short time polling
444 * for DMA completion. This avoids a second interrupt overhead,
445 * and gives the best performance for light traffic to the host.
447 * However, a better scheme that could be implemented would be
448 * to see how many packets are outstanding for the host, and if
449 * the number is "large", create a long chain to DMA several
450 * packets into the host in one go. In this case, we would set
451 * up some state variables to let the host CPU continue doing
452 * other things until a DMA completion interrupt comes along.
454 void
455 dgrs_rcv_frame(
456 struct device *dev0,
457 DGRS_PRIV *priv0,
458 I596_CB *cbp
461 int len;
462 I596_TBD *tbdp;
463 struct sk_buff *skb;
464 uchar *putp;
465 uchar *p;
466 struct device *devN;
467 DGRS_PRIV *privN;
470 * Determine Nth priv and dev structure pointers
472 if (dgrs_nicmode)
473 { /* Multi-NIC mode */
474 int chan = ((I596_RBD *) S2H(cbp->xmit.tbdp))->chan;
476 devN = priv0->devtbl[chan-1];
478 * If devN is null, we got an interrupt before the I/F
479 * has been initialized. Pitch the packet.
481 if (devN == NULL)
482 goto out;
483 privN = (DGRS_PRIV *) devN->priv;
485 else
486 { /* Switch mode */
487 devN = dev0;
488 privN = priv0;
491 if (0) printk("%s: rcv len=%ld\n", devN->name, cbp->xmit.count);
494 * Allocate a message block big enough to hold the whole frame
496 len = cbp->xmit.count;
497 if ((skb = dev_alloc_skb(len+5)) == NULL)
499 printk("%s: dev_alloc_skb failed for rcv buffer\n", devN->name);
500 ++privN->stats.rx_dropped;
501 /* discarding the frame */
502 goto out;
504 skb->dev = devN;
505 skb_reserve(skb, 2); /* Align IP header */
507 again:
508 putp = p = skb_put(skb, len);
511 * There are three modes here for doing the packet copy.
512 * If we have DMA, and the packet is "long", we use the
513 * chaining mode of DMA. If it's shorter, we use single
514 * DMA's. Otherwise, we use memcpy().
516 if (priv0->use_dma && priv0->dmadesc_h && len > 64)
519 * If we can use DMA and its a long frame, copy it using
520 * DMA chaining.
522 DMACHAIN *ddp_h; /* Host virtual DMA desc. pointer */
523 DMACHAIN *ddp_s; /* Switch physical DMA desc. pointer */
524 uchar *phys_p;
527 * Get the physical address of the STREAMS buffer.
528 * NOTE: allocb() guarantees that the whole buffer
529 * is in a single page if the length < 4096.
531 phys_p = (uchar *) virt_to_phys(putp);
533 ddp_h = priv0->dmadesc_h;
534 ddp_s = priv0->dmadesc_s;
535 tbdp = (I596_TBD *) S2H(cbp->xmit.tbdp);
536 for (;;)
538 int count;
539 int amt;
541 count = tbdp->count;
542 amt = count & 0x3fff;
543 if (amt == 0)
544 break; /* For safety */
545 if ( (p-putp) >= len)
547 printk("%s: cbp = %x\n", devN->name, H2S(cbp));
548 proc_reset(dev0, 1); /* Freeze IDT */
549 break; /* For Safety */
552 ddp_h->pciaddr = (ulong) phys_p;
553 ddp_h->lcladdr = S2DMA(tbdp->buf);
554 ddp_h->len = amt;
556 phys_p += amt;
557 p += amt;
559 if (count & I596_TBD_EOF)
561 ddp_h->next = PLX_DMA_DESC_TO_HOST
562 | PLX_DMA_DESC_EOC;
563 ++ddp_h;
564 break;
566 else
568 ++ddp_s;
569 ddp_h->next = PLX_DMA_DESC_TO_HOST
570 | (ulong) ddp_s;
571 tbdp = (I596_TBD *) S2H(tbdp->next);
572 ++ddp_h;
575 if (ddp_h - priv0->dmadesc_h)
577 int rc;
579 rc = do_plx_dma(dev0,
580 0, (ulong) priv0->dmadesc_s, len, 0);
581 if (rc)
583 printk("%s: Chained DMA failure\n", devN->name);
584 goto again;
588 else if (priv0->use_dma)
591 * If we can use DMA and its a shorter frame, copy it
592 * using single DMA transfers.
594 uchar *phys_p;
597 * Get the physical address of the STREAMS buffer.
598 * NOTE: allocb() guarantees that the whole buffer
599 * is in a single page if the length < 4096.
601 phys_p = (uchar *) virt_to_phys(putp);
603 tbdp = (I596_TBD *) S2H(cbp->xmit.tbdp);
604 for (;;)
606 int count;
607 int amt;
608 int rc;
610 count = tbdp->count;
611 amt = count & 0x3fff;
612 if (amt == 0)
613 break; /* For safety */
614 if ( (p-putp) >= len)
616 printk("%s: cbp = %x\n", devN->name, H2S(cbp));
617 proc_reset(dev0, 1); /* Freeze IDT */
618 break; /* For Safety */
620 rc = do_plx_dma(dev0, (ulong) phys_p,
621 S2DMA(tbdp->buf), amt, 1);
622 if (rc)
624 memcpy(p, S2H(tbdp->buf), amt);
625 printk("%s: Single DMA failed\n", devN->name);
627 phys_p += amt;
628 p += amt;
629 if (count & I596_TBD_EOF)
630 break;
631 tbdp = (I596_TBD *) S2H(tbdp->next);
634 else
637 * Otherwise, copy it piece by piece using memcpy()
639 tbdp = (I596_TBD *) S2H(cbp->xmit.tbdp);
640 for (;;)
642 int count;
643 int amt;
645 count = tbdp->count;
646 amt = count & 0x3fff;
647 if (amt == 0)
648 break; /* For safety */
649 if ( (p-putp) >= len)
651 printk("%s: cbp = %x\n", devN->name, H2S(cbp));
652 proc_reset(dev0, 1); /* Freeze IDT */
653 break; /* For Safety */
655 memcpy(p, S2H(tbdp->buf), amt);
656 p += amt;
657 if (count & I596_TBD_EOF)
658 break;
659 tbdp = (I596_TBD *) S2H(tbdp->next);
664 * Pass the frame to upper half
666 skb->protocol = eth_type_trans(skb, devN);
667 netif_rx(skb);
668 ++privN->stats.rx_packets;
670 out:
671 cbp->xmit.status = I596_CB_STATUS_C | I596_CB_STATUS_OK;
675 * Start transmission of a frame
677 * The interface to the board is simple: we pretend that we are
678 * a fifth 82596 ethernet controller 'receiving' data, and copy the
679 * data into the same structures that a real 82596 would. This way,
680 * the board firmware handles the host 'port' the same as any other.
682 * NOTE: we do not use Bus master DMA for this routine. Turns out
683 * that it is not needed. Slave writes over the PCI bus are about
684 * as fast as DMA, due to the fact that the PLX part can do burst
685 * writes. The same is not true for data being read from the board.
687 * For multi-NIC mode, we tell the firmware the desired 82596
688 * output port by setting the special "dstchan" member at the
689 * end of the traditional 82596 RFD structure.
692 static int dgrs_start_xmit(struct sk_buff *skb, struct device *devN)
694 DGRS_PRIV *privN = (DGRS_PRIV *) devN->priv;
695 struct device *dev0;
696 DGRS_PRIV *priv0;
697 I596_RBD *rbdp;
698 int count;
699 int i, len, amt;
700 # define mymin(A,B) ( (A) < (B) ? (A) : (B) )
703 * Determine 0th priv and dev structure pointers
705 if (dgrs_nicmode)
707 dev0 = privN->devtbl[0];
708 priv0 = (DGRS_PRIV *) dev0->priv;
710 else
712 dev0 = devN;
713 priv0 = privN;
716 if (dgrs_debug > 1)
717 printk("%s: xmit len=%d\n", devN->name, (int) skb->len);
719 devN->trans_start = jiffies;
720 devN->tbusy = 0;
722 if (priv0->rfdp->cmd & I596_RFD_EL)
723 { /* Out of RFD's */
724 if (0) printk("%s: NO RFD's\n", devN->name);
725 goto no_resources;
728 rbdp = priv0->rbdp;
729 count = 0;
730 priv0->rfdp->rbdp = (I596_RBD *) H2S(rbdp);
732 i = 0; len = skb->len;
733 for (;;)
735 if (rbdp->size & I596_RBD_EL)
736 { /* Out of RBD's */
737 if (0) printk("%s: NO RBD's\n", devN->name);
738 goto no_resources;
741 amt = mymin(len, rbdp->size - count);
742 memcpy( (char *) S2H(rbdp->buf) + count, skb->data + i, amt);
743 i += amt;
744 count += amt;
745 len -= amt;
746 if (len == 0)
748 if (skb->len < 60)
749 rbdp->count = 60 | I596_RBD_EOF;
750 else
751 rbdp->count = count | I596_RBD_EOF;
752 rbdp = (I596_RBD *) S2H(rbdp->next);
753 goto frame_done;
755 else if (count < 32)
757 /* More data to come, but we used less than 32
758 * bytes of this RBD. Keep filling this RBD.
760 {} /* Yes, we do nothing here */
762 else
764 rbdp->count = count;
765 rbdp = (I596_RBD *) S2H(rbdp->next);
766 count = 0;
770 frame_done:
771 priv0->rbdp = rbdp;
772 if (dgrs_nicmode)
773 priv0->rfdp->dstchan = privN->chan;
774 priv0->rfdp->status = I596_RFD_C | I596_RFD_OK;
775 priv0->rfdp = (I596_RFD *) S2H(priv0->rfdp->next);
777 ++privN->stats.tx_packets;
779 dev_kfree_skb (skb, FREE_WRITE);
780 return (0);
782 no_resources:
783 priv0->scbp->status |= I596_SCB_RNR; /* simulate I82596 */
784 return (-EAGAIN);
788 * Open the interface
790 static int
791 dgrs_open( struct device *dev )
793 dev->tbusy = 0;
794 dev->interrupt = 0;
795 dev->start = 1;
797 #ifdef MODULE
798 MOD_INC_USE_COUNT;
799 #endif
801 return (0);
805 * Close the interface
807 static int dgrs_close( struct device *dev )
809 dev->start = 0;
810 dev->tbusy = 1;
812 #ifdef MODULE
813 MOD_DEC_USE_COUNT;
814 #endif
816 return (0);
820 * Get statistics
822 static struct net_device_stats *dgrs_get_stats( struct device *dev )
824 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
826 return (&priv->stats);
830 * Set multicast list and/or promiscuous mode
833 static void dgrs_set_multicast_list( struct device *dev)
835 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
837 priv->port->is_promisc = (dev->flags & IFF_PROMISC) ? 1 : 0;
841 * Unique ioctl's
843 static int dgrs_ioctl(struct device *devN, struct ifreq *ifr, int cmd)
845 DGRS_PRIV *privN = (DGRS_PRIV *) devN->priv;
846 DGRS_IOCTL ioc;
847 int i;
849 if (cmd != DGRSIOCTL)
850 return -EINVAL;
852 if(COPY_FROM_USER(&ioc, ifr->ifr_data, sizeof(DGRS_IOCTL)))
853 return -EFAULT;
855 switch (ioc.cmd)
857 case DGRS_GETMEM:
858 if (ioc.len != sizeof(ulong))
859 return -EINVAL;
860 if(COPY_TO_USER(ioc.data, &devN->mem_start, ioc.len))
861 return -EFAULT;
862 return (0);
863 case DGRS_SETFILTER:
864 if (ioc.port > privN->bcomm->bc_nports)
865 return -EINVAL;
866 if (ioc.filter >= NFILTERS)
867 return -EINVAL;
868 if (ioc.len > privN->bcomm->bc_filter_area_len)
869 return -EINVAL;
871 /* Wait for old command to finish */
872 for (i = 0; i < 1000; ++i)
874 if ( (volatile long) privN->bcomm->bc_filter_cmd <= 0 )
875 break;
876 udelay(1);
878 if (i >= 1000)
879 return -EIO;
881 privN->bcomm->bc_filter_port = ioc.port;
882 privN->bcomm->bc_filter_num = ioc.filter;
883 privN->bcomm->bc_filter_len = ioc.len;
885 if (ioc.len)
887 if(COPY_FROM_USER(S2HN(privN->bcomm->bc_filter_area),
888 ioc.data, ioc.len))
889 return -EFAULT;
890 privN->bcomm->bc_filter_cmd = BC_FILTER_SET;
892 else
893 privN->bcomm->bc_filter_cmd = BC_FILTER_CLR;
894 return(0);
895 default:
896 return -EOPNOTSUPP;
901 * Process interrupts
903 * dev, priv will always refer to the 0th device in Multi-NIC mode.
906 static void dgrs_intr(int irq, void *dev_id, struct pt_regs *regs)
908 struct device *dev0 = (struct device *) dev_id;
909 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
910 I596_CB *cbp;
911 int cmd;
912 int i;
914 ++priv0->intrcnt;
915 if (1) ++priv0->bcomm->bc_cnt[4];
916 if (0)
918 static int cnt = 100;
919 if (--cnt > 0)
920 printk("%s: interrupt: irq %d\n", dev0->name, irq);
924 * Get 596 command
926 cmd = priv0->scbp->cmd;
929 * See if RU has been restarted
931 if ( (cmd & I596_SCB_RUC) == I596_SCB_RUC_START)
933 if (0) printk("%s: RUC start\n", dev0->name);
934 priv0->rfdp = (I596_RFD *) S2H(priv0->scbp->rfdp);
935 priv0->rbdp = (I596_RBD *) S2H(priv0->rfdp->rbdp);
936 priv0->scbp->status &= ~(I596_SCB_RNR|I596_SCB_RUS);
938 * Tell upper half (halves)
940 if (dgrs_nicmode)
942 for (i = 0; i < priv0->nports; ++i)
943 priv0->devtbl[i]->tbusy = 0;
945 else
946 dev0->tbusy = 0;
947 /* if (bd->flags & TX_QUEUED)
948 DL_sched(bd, bdd); */
952 * See if any CU commands to process
954 if ( (cmd & I596_SCB_CUC) != I596_SCB_CUC_START)
956 priv0->scbp->cmd = 0; /* Ignore all other commands */
957 goto ack_intr;
959 priv0->scbp->status &= ~(I596_SCB_CNA|I596_SCB_CUS);
962 * Process a command
964 cbp = (I596_CB *) S2H(priv0->scbp->cbp);
965 priv0->scbp->cmd = 0; /* Safe to clear the command */
966 for (;;)
968 switch (cbp->nop.cmd & I596_CB_CMD)
970 case I596_CB_CMD_XMIT:
971 dgrs_rcv_frame(dev0, priv0, cbp);
972 break;
973 default:
974 cbp->nop.status = I596_CB_STATUS_C | I596_CB_STATUS_OK;
975 break;
977 if (cbp->nop.cmd & I596_CB_CMD_EL)
978 break;
979 cbp = (I596_CB *) S2H(cbp->nop.next);
981 priv0->scbp->status |= I596_SCB_CNA;
984 * Ack the interrupt
986 ack_intr:
987 if (priv0->plxreg)
988 OUTL(dev0->base_addr + PLX_LCL2PCI_DOORBELL, 1);
992 * Download the board firmware
994 __initfunc(static int
995 dgrs_download(struct device *dev0))
997 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
998 int is;
999 int i;
1001 static int iv2is[16] = {
1002 0, 0, 0, ES4H_IS_INT3,
1003 0, ES4H_IS_INT5, 0, ES4H_IS_INT7,
1004 0, 0, ES4H_IS_INT10, ES4H_IS_INT11,
1005 ES4H_IS_INT12, 0, 0, ES4H_IS_INT15 };
1008 * Map in the dual port memory
1010 priv0->vmem = IOREMAP(dev0->mem_start, 2048*1024);
1011 if (!priv0->vmem)
1013 printk("%s: cannot map in board memory\n", dev0->name);
1014 return -ENXIO;
1018 * Hold the processor and configure the board addresses
1020 if (priv0->plxreg)
1021 { /* PCI bus */
1022 proc_reset(dev0, 1);
1024 else
1025 { /* EISA bus */
1026 is = iv2is[dev0->irq & 0x0f];
1027 if (!is)
1029 printk("%s: Illegal IRQ %d\n", dev0->name, dev0->irq);
1030 return -ENXIO;
1032 OUTB(dev0->base_addr + ES4H_AS_31_24,
1033 (uchar) (dev0->mem_start >> 24) );
1034 OUTB(dev0->base_addr + ES4H_AS_23_16,
1035 (uchar) (dev0->mem_start >> 16) );
1036 priv0->is_reg = ES4H_IS_LINEAR | is |
1037 ((uchar) (dev0->mem_start >> 8) & ES4H_IS_AS15);
1038 OUTB(dev0->base_addr + ES4H_IS, priv0->is_reg);
1039 OUTB(dev0->base_addr + ES4H_EC, ES4H_EC_ENABLE);
1040 OUTB(dev0->base_addr + ES4H_PC, ES4H_PC_RESET);
1041 OUTB(dev0->base_addr + ES4H_MW, ES4H_MW_ENABLE | 0x00);
1045 * See if we can do DMA on the SE-6
1047 priv0->use_dma = check_board_dma(dev0);
1048 if (priv0->use_dma)
1049 printk("%s: Bus Master DMA is enabled.\n", dev0->name);
1052 * Load and verify the code at the desired address
1054 memcpy(priv0->vmem, dgrs_code, dgrs_ncode); /* Load code */
1055 if (memcmp(priv0->vmem, dgrs_code, dgrs_ncode))
1057 IOUNMAP(priv0->vmem);
1058 priv0->vmem = NULL;
1059 printk("%s: download compare failed\n", dev0->name);
1060 return -ENXIO;
1064 * Configurables
1066 priv0->bcomm = (struct bios_comm *) (priv0->vmem + 0x0100);
1067 priv0->bcomm->bc_nowait = 1; /* Tell board to make printf not wait */
1068 priv0->bcomm->bc_squelch = 0; /* Flag from Space.c */
1069 priv0->bcomm->bc_150ohm = 0; /* Flag from Space.c */
1071 priv0->bcomm->bc_spew = 0; /* Debug flag from Space.c */
1072 priv0->bcomm->bc_maxrfd = 0; /* Debug flag from Space.c */
1073 priv0->bcomm->bc_maxrbd = 0; /* Debug flag from Space.c */
1076 * Tell board we are operating in switch mode (1) or in
1077 * multi-NIC mode (2).
1079 priv0->bcomm->bc_host = dgrs_nicmode ? BC_MULTINIC : BC_SWITCH;
1082 * Request memory space on board for DMA chains
1084 if (priv0->use_dma)
1085 priv0->bcomm->bc_hostarea_len = (2048/64) * 16;
1088 * NVRAM configurables from Space.c
1090 priv0->bcomm->bc_spantree = dgrs_spantree;
1091 priv0->bcomm->bc_hashexpire = dgrs_hashexpire;
1092 memcpy(priv0->bcomm->bc_ipaddr, dgrs_ipaddr, 4);
1093 memcpy(priv0->bcomm->bc_iptrap, dgrs_iptrap, 4);
1094 memcpy(priv0->bcomm->bc_ipxnet, &dgrs_ipxnet, 4);
1097 * Release processor, wait 8 seconds for board to initialize
1099 proc_reset(dev0, 0);
1101 for (i = jiffies + 8 * HZ; i > jiffies; )
1103 if (priv0->bcomm->bc_status >= BC_RUN)
1104 break;
1107 if (priv0->bcomm->bc_status < BC_RUN)
1109 printk("%s: board not operating\n", dev0->name);
1110 return -ENXIO;
1113 priv0->port = (PORT *) S2H(priv0->bcomm->bc_port);
1114 priv0->scbp = (I596_SCB *) S2H(priv0->port->scbp);
1115 priv0->rfdp = (I596_RFD *) S2H(priv0->scbp->rfdp);
1116 priv0->rbdp = (I596_RBD *) S2H(priv0->rfdp->rbdp);
1118 priv0->scbp->status = I596_SCB_CNA; /* CU is idle */
1121 * Get switch physical and host virtual pointers to DMA
1122 * chaining area. NOTE: the MSB of the switch physical
1123 * address *must* be turned off. Otherwise, the HW kludge
1124 * that allows host access of the PLX DMA registers will
1125 * erroneously select the PLX registers.
1127 priv0->dmadesc_s = (DMACHAIN *) S2DMA(priv0->bcomm->bc_hostarea);
1128 if (priv0->dmadesc_s)
1129 priv0->dmadesc_h = (DMACHAIN *) S2H(priv0->dmadesc_s);
1130 else
1131 priv0->dmadesc_h = NULL;
1134 * Enable board interrupts
1136 if (priv0->plxreg)
1137 { /* PCI bus */
1138 OUTL(dev0->base_addr + PLX_INT_CSR,
1139 inl(dev0->base_addr + PLX_INT_CSR)
1140 | PLX_PCI_DOORBELL_IE); /* Enable intr to host */
1141 OUTL(dev0->base_addr + PLX_LCL2PCI_DOORBELL, 1);
1143 else
1144 { /* EISA bus */
1147 return (0);
1151 * Probe (init) a board
1153 __initfunc(int
1154 dgrs_probe1(struct device *dev))
1156 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
1157 int i;
1158 int rc;
1160 printk("%s: Digi RightSwitch io=%lx mem=%lx irq=%d plx=%lx dma=%lx\n",
1161 dev->name, dev->base_addr, dev->mem_start, dev->irq,
1162 priv->plxreg, priv->plxdma);
1165 * Download the firmware and light the processor
1167 rc = dgrs_download(dev);
1168 if (rc)
1170 return rc;
1174 * Get ether address of board
1176 printk("%s: Ethernet address", dev->name);
1177 memcpy(dev->dev_addr, priv->port->ethaddr, 6);
1178 for (i = 0; i < 6; ++i)
1179 printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
1180 printk("\n");
1182 if (dev->dev_addr[0] & 1)
1184 printk("%s: Illegal Ethernet Address\n", dev->name);
1185 return (-ENXIO);
1189 * ACK outstanding interrupts, hook the interrupt,
1190 * and verify that we are getting interrupts from the board.
1192 if (priv->plxreg)
1193 OUTL(dev->base_addr + PLX_LCL2PCI_DOORBELL, 1);
1194 rc = request_irq(dev->irq, &dgrs_intr, 0, "RightSwitch", dev);
1195 if (rc)
1196 return (rc);
1198 priv->intrcnt = 0;
1199 for (i = jiffies + 2*HZ + HZ/2; i > jiffies; )
1200 if (priv->intrcnt >= 2)
1201 break;
1202 if (priv->intrcnt < 2)
1204 printk("%s: Not interrupting on IRQ %d (%d)\n",
1205 dev->name, dev->irq, priv->intrcnt);
1206 return (-ENXIO);
1210 * Register the /proc/ioports information...
1212 request_region(dev->base_addr, 256, "RightSwitch");
1215 * Entry points...
1217 dev->open = &dgrs_open;
1218 dev->stop = &dgrs_close;
1219 dev->get_stats = &dgrs_get_stats;
1220 dev->hard_start_xmit = &dgrs_start_xmit;
1221 dev->set_multicast_list = &dgrs_set_multicast_list;
1222 dev->do_ioctl = &dgrs_ioctl;
1224 return (0);
1227 __initfunc(int
1228 dgrs_initclone(struct device *dev))
1230 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
1231 int i;
1233 printk("%s: Digi RightSwitch port %d ",
1234 dev->name, priv->chan);
1235 for (i = 0; i < 6; ++i)
1236 printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
1237 printk("\n");
1239 return (0);
1242 __initfunc(static int
1243 dgrs_found_device(
1244 struct device *dev,
1245 int io,
1246 ulong mem,
1247 int irq,
1248 ulong plxreg,
1249 ulong plxdma
1252 DGRS_PRIV *priv;
1254 #ifdef MODULE
1256 /* Allocate and fill new device structure. */
1257 int dev_size = sizeof(struct device) + sizeof(DGRS_PRIV);
1258 int i;
1260 dev = (struct device *) kmalloc(dev_size, GFP_KERNEL);
1261 memset(dev, 0, dev_size);
1262 dev->priv = ((void *)dev) + sizeof(struct device);
1263 priv = (DGRS_PRIV *)dev->priv;
1265 dev->name = priv->devname; /* An empty string. */
1266 dev->base_addr = io;
1267 dev->mem_start = mem;
1268 dev->mem_end = mem + 2048 * 1024 - 1;
1269 dev->irq = irq;
1270 priv->plxreg = plxreg;
1271 priv->plxdma = plxdma;
1272 priv->vplxdma = NULL;
1274 priv->chan = 1;
1275 priv->devtbl[0] = dev;
1277 dev->init = dgrs_probe1;
1279 ether_setup(dev);
1280 priv->next_dev = dgrs_root_dev;
1281 dgrs_root_dev = dev;
1282 if (register_netdev(dev) != 0)
1283 return -EIO;
1285 if ( !dgrs_nicmode )
1286 return (0); /* Switch mode, we are done */
1289 * Operating card as N separate NICs
1291 priv->nports = priv->bcomm->bc_nports;
1292 for (i = 1; i < priv->nports; ++i)
1294 struct device *devN;
1295 DGRS_PRIV *privN;
1297 /* Allocate new dev and priv structures */
1298 devN = (struct device *) kmalloc(dev_size, GFP_KERNEL);
1300 /* Make it an exact copy of dev[0]... */
1301 memcpy(devN, dev, dev_size);
1302 devN->priv = ((void *)devN) + sizeof(struct device);
1303 privN = (DGRS_PRIV *)devN->priv;
1305 /* ... but seset devname to a NULL string */
1306 privN->devname[0] = 0;
1307 devN->name = privN->devname;
1309 /* ... and zero out VM areas */
1310 privN->vmem = 0;
1311 privN->vplxdma = 0;
1313 /* ... and zero out IRQ */
1314 devN->irq = 0;
1316 /* ... and base MAC address off address of 1st port */
1317 devN->dev_addr[5] += i;
1318 privN->chan = i+1;
1320 priv->devtbl[i] = devN;
1322 devN->init = dgrs_initclone;
1323 ether_setup(devN);
1324 privN->next_dev = dgrs_root_dev;
1325 dgrs_root_dev = devN;
1326 if (register_netdev(devN) != 0)
1327 return -EIO;
1330 #else
1332 if (dev)
1334 dev->priv = kmalloc(sizeof (DGRS_PRIV), GFP_KERNEL);
1335 memset(dev->priv, 0, sizeof (DGRS_PRIV));
1337 dev = init_etherdev(dev, sizeof(DGRS_PRIV));
1338 priv = (DGRS_PRIV *)dev->priv;
1340 dev->base_addr = io;
1341 dev->mem_start = mem;
1342 dev->mem_end = mem + 2048 * 1024;
1343 dev->irq = irq;
1344 priv->plxreg = plxreg;
1345 priv->plxdma = plxdma;
1346 priv->vplxdma = NULL;
1348 priv->chan = 1;
1349 priv->devtbl[0] = dev;
1351 dgrs_probe1(dev);
1353 #endif
1355 return (0);
1359 * Scan for all boards
1361 __initfunc(static int
1362 dgrs_scan(struct device *dev))
1364 int cards_found = 0;
1365 uint io;
1366 uint mem;
1367 uint irq;
1368 uint plxreg;
1369 uint plxdma;
1372 * First, check for PCI boards
1374 if (pcibios_present())
1376 int pci_index = 0;
1378 for (; pci_index < 8; pci_index++)
1380 uchar pci_bus, pci_device_fn;
1381 uchar pci_irq;
1382 uchar pci_latency;
1383 ushort pci_command;
1385 if (pcibios_find_device(SE6_PCI_VENDOR_ID,
1386 SE6_PCI_DEVICE_ID,
1387 pci_index, &pci_bus,
1388 &pci_device_fn))
1389 break;
1391 pcibios_read_config_byte(pci_bus, pci_device_fn,
1392 PCI_INTERRUPT_LINE, &pci_irq);
1393 pcibios_read_config_dword(pci_bus, pci_device_fn,
1394 PCI_BASE_ADDRESS_0, &plxreg);
1395 pcibios_read_config_dword(pci_bus, pci_device_fn,
1396 PCI_BASE_ADDRESS_1, &io);
1397 pcibios_read_config_dword(pci_bus, pci_device_fn,
1398 PCI_BASE_ADDRESS_2, &mem);
1399 pcibios_read_config_dword(pci_bus, pci_device_fn,
1400 0x30, &plxdma);
1401 irq = pci_irq;
1402 plxreg &= ~15;
1403 io &= ~3;
1404 mem &= ~15;
1405 plxdma &= ~15;
1408 * On some BIOSES, the PLX "expansion rom" (used for DMA)
1409 * address comes up as "0". This is probably because
1410 * the BIOS doesn't see a valid 55 AA ROM signature at
1411 * the "ROM" start and zeroes the address. To get
1412 * around this problem the SE-6 is configured to ask
1413 * for 4 MB of space for the dual port memory. We then
1414 * must set its range back to 2 MB, and use the upper
1415 * half for DMA register access
1417 OUTL(io + PLX_SPACE0_RANGE, 0xFFE00000L);
1418 if (plxdma == 0)
1419 plxdma = mem + (2048L * 1024L);
1420 pcibios_write_config_dword(pci_bus, pci_device_fn,
1421 0x30, plxdma + 1);
1422 pcibios_read_config_dword(pci_bus, pci_device_fn,
1423 0x30, &plxdma);
1424 plxdma &= ~15;
1427 * Get and check the bus-master and latency values.
1428 * Some PCI BIOSes fail to set the master-enable bit,
1429 * and the latency timer must be set to the maximum
1430 * value to avoid data corruption that occurs when the
1431 * timer expires during a transfer. Yes, it's a bug.
1433 pcibios_read_config_word(pci_bus, pci_device_fn,
1434 PCI_COMMAND, &pci_command);
1435 if ( ! (pci_command & PCI_COMMAND_MASTER))
1437 printk(" Setting the PCI Master Bit!\n");
1438 pci_command |= PCI_COMMAND_MASTER;
1439 pcibios_write_config_word(pci_bus,
1440 pci_device_fn,
1441 PCI_COMMAND, pci_command);
1443 pcibios_read_config_byte(pci_bus, pci_device_fn,
1444 PCI_LATENCY_TIMER, &pci_latency);
1445 if (pci_latency != 255)
1447 printk(" Overriding PCI latency timer: "
1448 "was %d, now is 255.\n", pci_latency);
1449 pcibios_write_config_byte(pci_bus,
1450 pci_device_fn,
1451 PCI_LATENCY_TIMER, 255);
1454 dgrs_found_device(dev, io, mem, irq, plxreg, plxdma);
1456 dev = 0;
1457 cards_found++;
1462 * Second, check for EISA boards
1464 if (EISA_bus)
1466 static int is2iv[8] __initdata = { 0, 3, 5, 7, 10, 11, 12, 15 };
1468 for (io = 0x1000; io < 0x9000; io += 0x1000)
1470 if (inb(io+ES4H_MANUFmsb) != 0x10
1471 || inb(io+ES4H_MANUFlsb) != 0x49
1472 || inb(io+ES4H_PRODUCT) != ES4H_PRODUCT_CODE)
1473 continue;
1475 if ( ! (inb(io+ES4H_EC) & ES4H_EC_ENABLE) )
1476 continue; /* Not EISA configured */
1478 mem = (inb(io+ES4H_AS_31_24) << 24)
1479 + (inb(io+ES4H_AS_23_16) << 16);
1481 irq = is2iv[ inb(io+ES4H_IS) & ES4H_IS_INTMASK ];
1483 dgrs_found_device(dev, io, mem, irq, 0L, 0L);
1485 dev = 0;
1486 ++cards_found;
1490 return cards_found;
1494 * Module/driver initialization points. Two ways, depending on
1495 * whether we are a module or statically linked, ala Don Becker's
1496 * 3c59x driver.
1499 #ifdef MODULE
1502 * Variables that can be overriden from command line
1504 static int debug = -1;
1505 static int dma = -1;
1506 static int hashexpire = -1;
1507 static int spantree = -1;
1508 static int ipaddr[4] = { -1 };
1509 static int iptrap[4] = { -1 };
1510 static __u32 ipxnet = -1;
1511 static int nicmode = -1;
1513 MODULE_PARM(debug, "i");
1514 MODULE_PARM(dma, "i");
1515 MODULE_PARM(hashexpire, "i");
1516 MODULE_PARM(spantree, "i");
1517 MODULE_PARM(ipaddr, "1-4i");
1518 MODULE_PARM(iptrap, "1-4i");
1519 MODULE_PARM(ipxnet, "i");
1520 MODULE_PARM(nicmode, "i");
1523 init_module(void)
1525 int cards_found;
1526 int i;
1529 * Command line variable overrides
1530 * debug=NNN
1531 * dma=0/1
1532 * spantree=0/1
1533 * hashexpire=NNN
1534 * ipaddr=A,B,C,D
1535 * iptrap=A,B,C,D
1536 * ipxnet=NNN
1537 * nicmode=NNN
1539 if (debug >= 0)
1540 dgrs_debug = debug;
1541 if (dma >= 0)
1542 dgrs_dma = dma;
1543 if (nicmode >= 0)
1544 dgrs_nicmode = nicmode;
1545 if (hashexpire >= 0)
1546 dgrs_hashexpire = hashexpire;
1547 if (spantree >= 0)
1548 dgrs_spantree = spantree;
1549 if (ipaddr[0] != -1)
1550 for (i = 0; i < 4; ++i)
1551 dgrs_ipaddr[i] = ipaddr[i];
1552 if (iptrap[0] != -1)
1553 for (i = 0; i < 4; ++i)
1554 dgrs_iptrap[i] = iptrap[i];
1555 if (ipxnet != -1)
1556 dgrs_ipxnet = htonl( ipxnet );
1558 if (dgrs_debug)
1560 printk("dgrs: SW=%s FW=Build %d %s\n",
1561 version, dgrs_firmnum, dgrs_firmdate);
1565 * Find and configure all the cards
1567 dgrs_root_dev = NULL;
1568 cards_found = dgrs_scan(0);
1570 return cards_found ? 0 : -ENODEV;
1573 void
1574 cleanup_module(void)
1576 while (dgrs_root_dev)
1578 struct device *next_dev;
1579 DGRS_PRIV *priv;
1581 priv = (DGRS_PRIV *) dgrs_root_dev->priv;
1582 next_dev = priv->next_dev;
1583 unregister_netdev(dgrs_root_dev);
1585 proc_reset(priv->devtbl[0], 1);
1587 if (priv->vmem)
1588 IOUNMAP(priv->vmem);
1589 if (priv->vplxdma)
1590 IOUNMAP((uchar *) priv->vplxdma);
1592 release_region(dgrs_root_dev->base_addr, 256);
1594 if (dgrs_root_dev->irq)
1595 free_irq(dgrs_root_dev->irq, dgrs_root_dev);
1597 kfree(dgrs_root_dev);
1598 dgrs_root_dev = next_dev;
1602 #else
1604 __initfunc(int
1605 dgrs_probe(struct device *dev))
1607 int cards_found;
1609 cards_found = dgrs_scan(dev);
1610 if (dgrs_debug && cards_found)
1611 printk("dgrs: SW=%s FW=Build %d %s\n",
1612 version, dgrs_firmnum, dgrs_firmdate);
1613 return cards_found ? 0 : -ENODEV;
1615 #endif