r8169: PCI ID for Corega Gigabit network card
[linux-2.6/linux-loongson.git] / drivers / net / dgrs.c
blobd0842527b3694782ebdcbde85e21e5ad95f55193
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@remotepoint.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 independent 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.
74 * Fixes:
75 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 11/01/2001
76 * - fix dgrs_found_device wrt checking kmalloc return and
77 * rollbacking the partial steps of the whole process when
78 * one of the devices can't be allocated. Fix SET_MODULE_OWNER
79 * on the loop to use devN instead of repeated calls to dev.
81 * davej <davej@suse.de> - 9/2/2001
82 * - Enable PCI device before reading ioaddr/irq
86 #include <linux/module.h>
87 #include <linux/eisa.h>
88 #include <linux/kernel.h>
89 #include <linux/string.h>
90 #include <linux/delay.h>
91 #include <linux/errno.h>
92 #include <linux/ioport.h>
93 #include <linux/slab.h>
94 #include <linux/interrupt.h>
95 #include <linux/pci.h>
96 #include <linux/init.h>
97 #include <linux/netdevice.h>
98 #include <linux/etherdevice.h>
99 #include <linux/skbuff.h>
100 #include <linux/bitops.h>
102 #include <asm/io.h>
103 #include <asm/byteorder.h>
104 #include <asm/uaccess.h>
106 static char version[] __initdata =
107 "$Id: dgrs.c,v 1.13 2000/06/06 04:07:00 rick Exp $";
110 * DGRS include files
112 typedef unsigned char uchar;
113 #define vol volatile
115 #include "dgrs.h"
116 #include "dgrs_es4h.h"
117 #include "dgrs_plx9060.h"
118 #include "dgrs_i82596.h"
119 #include "dgrs_ether.h"
120 #include "dgrs_asstruct.h"
121 #include "dgrs_bcomm.h"
123 #ifdef CONFIG_PCI
124 static struct pci_device_id dgrs_pci_tbl[] = {
125 { SE6_PCI_VENDOR_ID, SE6_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, },
126 { } /* Terminating entry */
128 MODULE_DEVICE_TABLE(pci, dgrs_pci_tbl);
129 #endif
131 #ifdef CONFIG_EISA
132 static struct eisa_device_id dgrs_eisa_tbl[] = {
133 { "DBI0A01" },
136 MODULE_DEVICE_TABLE(eisa, dgrs_eisa_tbl);
137 #endif
139 MODULE_LICENSE("GPL");
143 * Firmware. Compiled separately for local compilation,
144 * but #included for Linux distribution.
146 #ifndef NOFW
147 #include "dgrs_firmware.c"
148 #else
149 extern int dgrs_firmnum;
150 extern char dgrs_firmver[];
151 extern char dgrs_firmdate[];
152 extern uchar dgrs_code[];
153 extern int dgrs_ncode;
154 #endif
157 * Linux out*() is backwards from all other operating systems
159 #define OUTB(ADDR, VAL) outb(VAL, ADDR)
160 #define OUTW(ADDR, VAL) outw(VAL, ADDR)
161 #define OUTL(ADDR, VAL) outl(VAL, ADDR)
164 * Macros to convert switch to host and host to switch addresses
165 * (assumes a local variable priv points to board dependent struct)
167 #define S2H(A) ( ((unsigned long)(A)&0x00ffffff) + priv0->vmem )
168 #define S2HN(A) ( ((unsigned long)(A)&0x00ffffff) + privN->vmem )
169 #define H2S(A) ( ((char *) (A) - priv0->vmem) + 0xA3000000 )
172 * Convert a switch address to a "safe" address for use with the
173 * PLX 9060 DMA registers and the associated HW kludge that allows
174 * for host access of the DMA registers.
176 #define S2DMA(A) ( (unsigned long)(A) & 0x00ffffff)
179 * "Space.c" variables, now settable from module interface
180 * Use the name below, minus the "dgrs_" prefix. See init_module().
182 static int dgrs_debug = 1;
183 static int dgrs_dma = 1;
184 static int dgrs_spantree = -1;
185 static int dgrs_hashexpire = -1;
186 static uchar dgrs_ipaddr[4] = { 0xff, 0xff, 0xff, 0xff};
187 static uchar dgrs_iptrap[4] = { 0xff, 0xff, 0xff, 0xff};
188 static __u32 dgrs_ipxnet = -1;
189 static int dgrs_nicmode;
192 * Private per-board data structure (dev->priv)
194 typedef struct
197 * Stuff for generic ethercard I/F
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 volatile 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 net_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 net_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 net_device *dev0)
278 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
279 ulong x;
282 * If Space.c says not to use DMA, or if it's 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 iounmap((void *)priv0->vplxdma);
331 return (0);
334 return (1);
338 * Initiate DMA using PLX part on PCI board. Spin the
339 * processor until completed. All addresses are physical!
341 * If pciaddr is NULL, then it's a chaining DMA, and lcladdr is
342 * the address of the first DMA descriptor in the chain.
344 * If pciaddr is not NULL, then it's a single DMA.
346 * In either case, "lcladdr" must have been fixed up to make
347 * sure the MSB isn't set using the S2DMA macro before passing
348 * the address to this routine.
350 static int
351 do_plx_dma(
352 struct net_device *dev,
353 ulong pciaddr,
354 ulong lcladdr,
355 int len,
356 int to_host
359 int i;
360 ulong csr = 0;
361 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
363 if (pciaddr)
366 * Do a single, non-chain DMA
368 priv->vplxdma[PLX_DMA0_PCI_ADDR/4] = pciaddr;
369 priv->vplxdma[PLX_DMA0_LCL_ADDR/4] = lcladdr;
370 priv->vplxdma[PLX_DMA0_SIZE/4] = len;
371 priv->vplxdma[PLX_DMA0_DESCRIPTOR/4] = to_host
372 ? PLX_DMA_DESC_TO_HOST
373 : PLX_DMA_DESC_TO_BOARD;
374 priv->vplxdma[PLX_DMA0_MODE/4] =
375 PLX_DMA_MODE_WIDTH32
376 | PLX_DMA_MODE_WAITSTATES(0)
377 | PLX_DMA_MODE_READY
378 | PLX_DMA_MODE_NOBTERM
379 | PLX_DMA_MODE_BURST
380 | PLX_DMA_MODE_NOCHAIN;
382 else
385 * Do a chaining DMA
387 priv->vplxdma[PLX_DMA0_MODE/4] =
388 PLX_DMA_MODE_WIDTH32
389 | PLX_DMA_MODE_WAITSTATES(0)
390 | PLX_DMA_MODE_READY
391 | PLX_DMA_MODE_NOBTERM
392 | PLX_DMA_MODE_BURST
393 | PLX_DMA_MODE_CHAIN;
394 priv->vplxdma[PLX_DMA0_DESCRIPTOR/4] = lcladdr;
397 priv->vplxdma[PLX_DMA_CSR/4] =
398 PLX_DMA_CSR_0_ENABLE | PLX_DMA_CSR_0_START;
401 * Wait for DMA to complete
403 for (i = 0; i < 1000000; ++i)
406 * Spin the host CPU for 1 usec, so we don't thrash
407 * the PCI bus while the PLX 9060 is doing DMA.
409 udelay(1);
411 csr = (volatile unsigned long) priv->vplxdma[PLX_DMA_CSR/4];
413 if (csr & PLX_DMA_CSR_0_DONE)
414 break;
417 if ( ! (csr & PLX_DMA_CSR_0_DONE) )
419 printk("%s: DMA done never occurred. DMA disabled.\n",
420 dev->name);
421 priv->use_dma = 0;
422 return 1;
424 return 0;
428 * dgrs_rcv_frame()
430 * Process a received frame. This is called from the interrupt
431 * routine, and works for both switch mode and multi-NIC mode.
433 * Note that when in multi-NIC mode, we want to always access the
434 * hardware using the dev and priv structures of the first port,
435 * so that we are using only one set of variables to maintain
436 * the board interface status, but we want to use the Nth port
437 * dev and priv structures to maintain statistics and to pass
438 * the packet up.
440 * Only the first device structure is attached to the interrupt.
441 * We use the special "chan" variable at the end of the first RBD
442 * to select the Nth device in multi-NIC mode.
444 * We currently do chained DMA on a per-packet basis when the
445 * packet is "long", and we spin the CPU a short time polling
446 * for DMA completion. This avoids a second interrupt overhead,
447 * and gives the best performance for light traffic to the host.
449 * However, a better scheme that could be implemented would be
450 * to see how many packets are outstanding for the host, and if
451 * the number is "large", create a long chain to DMA several
452 * packets into the host in one go. In this case, we would set
453 * up some state variables to let the host CPU continue doing
454 * other things until a DMA completion interrupt comes along.
456 static void
457 dgrs_rcv_frame(
458 struct net_device *dev0,
459 DGRS_PRIV *priv0,
460 I596_CB *cbp
463 int len;
464 I596_TBD *tbdp;
465 struct sk_buff *skb;
466 uchar *putp;
467 uchar *p;
468 struct net_device *devN;
469 DGRS_PRIV *privN;
472 * Determine Nth priv and dev structure pointers
474 if (dgrs_nicmode)
475 { /* Multi-NIC mode */
476 int chan = ((I596_RBD *) S2H(cbp->xmit.tbdp))->chan;
478 devN = priv0->devtbl[chan-1];
480 * If devN is null, we got an interrupt before the I/F
481 * has been initialized. Pitch the packet.
483 if (devN == NULL)
484 goto out;
485 privN = (DGRS_PRIV *) devN->priv;
487 else
488 { /* Switch mode */
489 devN = dev0;
490 privN = priv0;
493 if (0) printk("%s: rcv len=%ld\n", devN->name, cbp->xmit.count);
496 * Allocate a message block big enough to hold the whole frame
498 len = cbp->xmit.count;
499 if ((skb = dev_alloc_skb(len+5)) == NULL)
501 printk("%s: dev_alloc_skb failed for rcv buffer\n", devN->name);
502 ++privN->stats.rx_dropped;
503 /* discarding the frame */
504 goto out;
506 skb->dev = devN;
507 skb_reserve(skb, 2); /* Align IP header */
509 again:
510 putp = p = skb_put(skb, len);
513 * There are three modes here for doing the packet copy.
514 * If we have DMA, and the packet is "long", we use the
515 * chaining mode of DMA. If it's shorter, we use single
516 * DMA's. Otherwise, we use memcpy().
518 if (priv0->use_dma && priv0->dmadesc_h && len > 64)
521 * If we can use DMA and it's a long frame, copy it using
522 * DMA chaining.
524 DMACHAIN *ddp_h; /* Host virtual DMA desc. pointer */
525 DMACHAIN *ddp_s; /* Switch physical DMA desc. pointer */
526 uchar *phys_p;
529 * Get the physical address of the STREAMS buffer.
530 * NOTE: allocb() guarantees that the whole buffer
531 * is in a single page if the length < 4096.
533 phys_p = (uchar *) virt_to_phys(putp);
535 ddp_h = priv0->dmadesc_h;
536 ddp_s = priv0->dmadesc_s;
537 tbdp = (I596_TBD *) S2H(cbp->xmit.tbdp);
538 for (;;)
540 int count;
541 int amt;
543 count = tbdp->count;
544 amt = count & 0x3fff;
545 if (amt == 0)
546 break; /* For safety */
547 if ( (p-putp) >= len)
549 printk("%s: cbp = %lx\n", devN->name, (long) H2S(cbp));
550 proc_reset(dev0, 1); /* Freeze IDT */
551 break; /* For Safety */
554 ddp_h->pciaddr = (ulong) phys_p;
555 ddp_h->lcladdr = S2DMA(tbdp->buf);
556 ddp_h->len = amt;
558 phys_p += amt;
559 p += amt;
561 if (count & I596_TBD_EOF)
563 ddp_h->next = PLX_DMA_DESC_TO_HOST
564 | PLX_DMA_DESC_EOC;
565 ++ddp_h;
566 break;
568 else
570 ++ddp_s;
571 ddp_h->next = PLX_DMA_DESC_TO_HOST
572 | (ulong) ddp_s;
573 tbdp = (I596_TBD *) S2H(tbdp->next);
574 ++ddp_h;
577 if (ddp_h - priv0->dmadesc_h)
579 int rc;
581 rc = do_plx_dma(dev0,
582 0, (ulong) priv0->dmadesc_s, len, 0);
583 if (rc)
585 printk("%s: Chained DMA failure\n", devN->name);
586 goto again;
590 else if (priv0->use_dma)
593 * If we can use DMA and it's a shorter frame, copy it
594 * using single DMA transfers.
596 uchar *phys_p;
599 * Get the physical address of the STREAMS buffer.
600 * NOTE: allocb() guarantees that the whole buffer
601 * is in a single page if the length < 4096.
603 phys_p = (uchar *) virt_to_phys(putp);
605 tbdp = (I596_TBD *) S2H(cbp->xmit.tbdp);
606 for (;;)
608 int count;
609 int amt;
610 int rc;
612 count = tbdp->count;
613 amt = count & 0x3fff;
614 if (amt == 0)
615 break; /* For safety */
616 if ( (p-putp) >= len)
618 printk("%s: cbp = %lx\n", devN->name, (long) H2S(cbp));
619 proc_reset(dev0, 1); /* Freeze IDT */
620 break; /* For Safety */
622 rc = do_plx_dma(dev0, (ulong) phys_p,
623 S2DMA(tbdp->buf), amt, 1);
624 if (rc)
626 memcpy(p, S2H(tbdp->buf), amt);
627 printk("%s: Single DMA failed\n", devN->name);
629 phys_p += amt;
630 p += amt;
631 if (count & I596_TBD_EOF)
632 break;
633 tbdp = (I596_TBD *) S2H(tbdp->next);
636 else
639 * Otherwise, copy it piece by piece using memcpy()
641 tbdp = (I596_TBD *) S2H(cbp->xmit.tbdp);
642 for (;;)
644 int count;
645 int amt;
647 count = tbdp->count;
648 amt = count & 0x3fff;
649 if (amt == 0)
650 break; /* For safety */
651 if ( (p-putp) >= len)
653 printk("%s: cbp = %lx\n", devN->name, (long) H2S(cbp));
654 proc_reset(dev0, 1); /* Freeze IDT */
655 break; /* For Safety */
657 memcpy(p, S2H(tbdp->buf), amt);
658 p += amt;
659 if (count & I596_TBD_EOF)
660 break;
661 tbdp = (I596_TBD *) S2H(tbdp->next);
666 * Pass the frame to upper half
668 skb->protocol = eth_type_trans(skb, devN);
669 netif_rx(skb);
670 devN->last_rx = jiffies;
671 ++privN->stats.rx_packets;
672 privN->stats.rx_bytes += len;
674 out:
675 cbp->xmit.status = I596_CB_STATUS_C | I596_CB_STATUS_OK;
679 * Start transmission of a frame
681 * The interface to the board is simple: we pretend that we are
682 * a fifth 82596 ethernet controller 'receiving' data, and copy the
683 * data into the same structures that a real 82596 would. This way,
684 * the board firmware handles the host 'port' the same as any other.
686 * NOTE: we do not use Bus master DMA for this routine. Turns out
687 * that it is not needed. Slave writes over the PCI bus are about
688 * as fast as DMA, due to the fact that the PLX part can do burst
689 * writes. The same is not true for data being read from the board.
691 * For multi-NIC mode, we tell the firmware the desired 82596
692 * output port by setting the special "dstchan" member at the
693 * end of the traditional 82596 RFD structure.
696 static int dgrs_start_xmit(struct sk_buff *skb, struct net_device *devN)
698 DGRS_PRIV *privN = (DGRS_PRIV *) devN->priv;
699 struct net_device *dev0;
700 DGRS_PRIV *priv0;
701 I596_RBD *rbdp;
702 int count;
703 int i, len, amt;
706 * Determine 0th priv and dev structure pointers
708 if (dgrs_nicmode)
710 dev0 = privN->devtbl[0];
711 priv0 = (DGRS_PRIV *) dev0->priv;
713 else
715 dev0 = devN;
716 priv0 = privN;
719 if (dgrs_debug > 1)
720 printk("%s: xmit len=%d\n", devN->name, (int) skb->len);
722 devN->trans_start = jiffies;
723 netif_start_queue(devN);
725 if (priv0->rfdp->cmd & I596_RFD_EL)
726 { /* Out of RFD's */
727 if (0) printk("%s: NO RFD's\n", devN->name);
728 goto no_resources;
731 rbdp = priv0->rbdp;
732 count = 0;
733 priv0->rfdp->rbdp = (I596_RBD *) H2S(rbdp);
735 i = 0; len = skb->len;
736 for (;;)
738 if (rbdp->size & I596_RBD_EL)
739 { /* Out of RBD's */
740 if (0) printk("%s: NO RBD's\n", devN->name);
741 goto no_resources;
744 amt = min_t(unsigned int, len, rbdp->size - count);
745 memcpy( (char *) S2H(rbdp->buf) + count, skb->data + i, amt);
746 i += amt;
747 count += amt;
748 len -= amt;
749 if (len == 0)
751 if (skb->len < 60)
752 rbdp->count = 60 | I596_RBD_EOF;
753 else
754 rbdp->count = count | I596_RBD_EOF;
755 rbdp = (I596_RBD *) S2H(rbdp->next);
756 goto frame_done;
758 else if (count < 32)
760 /* More data to come, but we used less than 32
761 * bytes of this RBD. Keep filling this RBD.
763 {} /* Yes, we do nothing here */
765 else
767 rbdp->count = count;
768 rbdp = (I596_RBD *) S2H(rbdp->next);
769 count = 0;
773 frame_done:
774 priv0->rbdp = rbdp;
775 if (dgrs_nicmode)
776 priv0->rfdp->dstchan = privN->chan;
777 priv0->rfdp->status = I596_RFD_C | I596_RFD_OK;
778 priv0->rfdp = (I596_RFD *) S2H(priv0->rfdp->next);
780 ++privN->stats.tx_packets;
782 dev_kfree_skb (skb);
783 return (0);
785 no_resources:
786 priv0->scbp->status |= I596_SCB_RNR; /* simulate I82596 */
787 return (-EAGAIN);
791 * Open the interface
793 static int
794 dgrs_open( struct net_device *dev )
796 netif_start_queue(dev);
797 return (0);
801 * Close the interface
803 static int dgrs_close( struct net_device *dev )
805 netif_stop_queue(dev);
806 return (0);
810 * Get statistics
812 static struct net_device_stats *dgrs_get_stats( struct net_device *dev )
814 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
816 return (&priv->stats);
820 * Set multicast list and/or promiscuous mode
823 static void dgrs_set_multicast_list( struct net_device *dev)
825 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
827 priv->port->is_promisc = (dev->flags & IFF_PROMISC) ? 1 : 0;
831 * Unique ioctl's
833 static int dgrs_ioctl(struct net_device *devN, struct ifreq *ifr, int cmd)
835 DGRS_PRIV *privN = (DGRS_PRIV *) devN->priv;
836 DGRS_IOCTL ioc;
837 int i;
839 if (cmd != DGRSIOCTL)
840 return -EINVAL;
842 if(copy_from_user(&ioc, ifr->ifr_data, sizeof(DGRS_IOCTL)))
843 return -EFAULT;
845 switch (ioc.cmd)
847 case DGRS_GETMEM:
848 if (ioc.len != sizeof(ulong))
849 return -EINVAL;
850 if(copy_to_user(ioc.data, &devN->mem_start, ioc.len))
851 return -EFAULT;
852 return (0);
853 case DGRS_SETFILTER:
854 if (!capable(CAP_NET_ADMIN))
855 return -EPERM;
856 if (ioc.port > privN->bcomm->bc_nports)
857 return -EINVAL;
858 if (ioc.filter >= NFILTERS)
859 return -EINVAL;
860 if (ioc.len > privN->bcomm->bc_filter_area_len)
861 return -EINVAL;
863 /* Wait for old command to finish */
864 for (i = 0; i < 1000; ++i)
866 if ( (volatile long) privN->bcomm->bc_filter_cmd <= 0 )
867 break;
868 udelay(1);
870 if (i >= 1000)
871 return -EIO;
873 privN->bcomm->bc_filter_port = ioc.port;
874 privN->bcomm->bc_filter_num = ioc.filter;
875 privN->bcomm->bc_filter_len = ioc.len;
877 if (ioc.len)
879 if(copy_from_user(S2HN(privN->bcomm->bc_filter_area),
880 ioc.data, ioc.len))
881 return -EFAULT;
882 privN->bcomm->bc_filter_cmd = BC_FILTER_SET;
884 else
885 privN->bcomm->bc_filter_cmd = BC_FILTER_CLR;
886 return(0);
887 default:
888 return -EOPNOTSUPP;
893 * Process interrupts
895 * dev, priv will always refer to the 0th device in Multi-NIC mode.
898 static irqreturn_t dgrs_intr(int irq, void *dev_id, struct pt_regs *regs)
900 struct net_device *dev0 = (struct net_device *) dev_id;
901 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
902 I596_CB *cbp;
903 int cmd;
904 int i;
906 ++priv0->intrcnt;
907 if (1) ++priv0->bcomm->bc_cnt[4];
908 if (0)
910 static int cnt = 100;
911 if (--cnt > 0)
912 printk("%s: interrupt: irq %d\n", dev0->name, irq);
916 * Get 596 command
918 cmd = priv0->scbp->cmd;
921 * See if RU has been restarted
923 if ( (cmd & I596_SCB_RUC) == I596_SCB_RUC_START)
925 if (0) printk("%s: RUC start\n", dev0->name);
926 priv0->rfdp = (I596_RFD *) S2H(priv0->scbp->rfdp);
927 priv0->rbdp = (I596_RBD *) S2H(priv0->rfdp->rbdp);
928 priv0->scbp->status &= ~(I596_SCB_RNR|I596_SCB_RUS);
930 * Tell upper half (halves)
932 if (dgrs_nicmode)
934 for (i = 0; i < priv0->nports; ++i)
935 netif_wake_queue (priv0->devtbl[i]);
937 else
938 netif_wake_queue (dev0);
939 /* if (bd->flags & TX_QUEUED)
940 DL_sched(bd, bdd); */
944 * See if any CU commands to process
946 if ( (cmd & I596_SCB_CUC) != I596_SCB_CUC_START)
948 priv0->scbp->cmd = 0; /* Ignore all other commands */
949 goto ack_intr;
951 priv0->scbp->status &= ~(I596_SCB_CNA|I596_SCB_CUS);
954 * Process a command
956 cbp = (I596_CB *) S2H(priv0->scbp->cbp);
957 priv0->scbp->cmd = 0; /* Safe to clear the command */
958 for (;;)
960 switch (cbp->nop.cmd & I596_CB_CMD)
962 case I596_CB_CMD_XMIT:
963 dgrs_rcv_frame(dev0, priv0, cbp);
964 break;
965 default:
966 cbp->nop.status = I596_CB_STATUS_C | I596_CB_STATUS_OK;
967 break;
969 if (cbp->nop.cmd & I596_CB_CMD_EL)
970 break;
971 cbp = (I596_CB *) S2H(cbp->nop.next);
973 priv0->scbp->status |= I596_SCB_CNA;
976 * Ack the interrupt
978 ack_intr:
979 if (priv0->plxreg)
980 OUTL(dev0->base_addr + PLX_LCL2PCI_DOORBELL, 1);
982 return IRQ_HANDLED;
986 * Download the board firmware
988 static int __init
989 dgrs_download(struct net_device *dev0)
991 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
992 int is;
993 unsigned long i;
995 static const int iv2is[16] = {
996 0, 0, 0, ES4H_IS_INT3,
997 0, ES4H_IS_INT5, 0, ES4H_IS_INT7,
998 0, 0, ES4H_IS_INT10, ES4H_IS_INT11,
999 ES4H_IS_INT12, 0, 0, ES4H_IS_INT15 };
1002 * Map in the dual port memory
1004 priv0->vmem = ioremap(dev0->mem_start, 2048*1024);
1005 if (!priv0->vmem)
1007 printk("%s: cannot map in board memory\n", dev0->name);
1008 return -ENXIO;
1012 * Hold the processor and configure the board addresses
1014 if (priv0->plxreg)
1015 { /* PCI bus */
1016 proc_reset(dev0, 1);
1018 else
1019 { /* EISA bus */
1020 is = iv2is[dev0->irq & 0x0f];
1021 if (!is)
1023 printk("%s: Illegal IRQ %d\n", dev0->name, dev0->irq);
1024 iounmap(priv0->vmem);
1025 priv0->vmem = NULL;
1026 return -ENXIO;
1028 OUTB(dev0->base_addr + ES4H_AS_31_24,
1029 (uchar) (dev0->mem_start >> 24) );
1030 OUTB(dev0->base_addr + ES4H_AS_23_16,
1031 (uchar) (dev0->mem_start >> 16) );
1032 priv0->is_reg = ES4H_IS_LINEAR | is |
1033 ((uchar) (dev0->mem_start >> 8) & ES4H_IS_AS15);
1034 OUTB(dev0->base_addr + ES4H_IS, priv0->is_reg);
1035 OUTB(dev0->base_addr + ES4H_EC, ES4H_EC_ENABLE);
1036 OUTB(dev0->base_addr + ES4H_PC, ES4H_PC_RESET);
1037 OUTB(dev0->base_addr + ES4H_MW, ES4H_MW_ENABLE | 0x00);
1041 * See if we can do DMA on the SE-6
1043 priv0->use_dma = check_board_dma(dev0);
1044 if (priv0->use_dma)
1045 printk("%s: Bus Master DMA is enabled.\n", dev0->name);
1048 * Load and verify the code at the desired address
1050 memcpy(priv0->vmem, dgrs_code, dgrs_ncode); /* Load code */
1051 if (memcmp(priv0->vmem, dgrs_code, dgrs_ncode))
1053 iounmap(priv0->vmem);
1054 priv0->vmem = NULL;
1055 printk("%s: download compare failed\n", dev0->name);
1056 return -ENXIO;
1060 * Configurables
1062 priv0->bcomm = (struct bios_comm *) (priv0->vmem + 0x0100);
1063 priv0->bcomm->bc_nowait = 1; /* Tell board to make printf not wait */
1064 priv0->bcomm->bc_squelch = 0; /* Flag from Space.c */
1065 priv0->bcomm->bc_150ohm = 0; /* Flag from Space.c */
1067 priv0->bcomm->bc_spew = 0; /* Debug flag from Space.c */
1068 priv0->bcomm->bc_maxrfd = 0; /* Debug flag from Space.c */
1069 priv0->bcomm->bc_maxrbd = 0; /* Debug flag from Space.c */
1072 * Tell board we are operating in switch mode (1) or in
1073 * multi-NIC mode (2).
1075 priv0->bcomm->bc_host = dgrs_nicmode ? BC_MULTINIC : BC_SWITCH;
1078 * Request memory space on board for DMA chains
1080 if (priv0->use_dma)
1081 priv0->bcomm->bc_hostarea_len = (2048/64) * 16;
1084 * NVRAM configurables from Space.c
1086 priv0->bcomm->bc_spantree = dgrs_spantree;
1087 priv0->bcomm->bc_hashexpire = dgrs_hashexpire;
1088 memcpy(priv0->bcomm->bc_ipaddr, dgrs_ipaddr, 4);
1089 memcpy(priv0->bcomm->bc_iptrap, dgrs_iptrap, 4);
1090 memcpy(priv0->bcomm->bc_ipxnet, &dgrs_ipxnet, 4);
1093 * Release processor, wait 8 seconds for board to initialize
1095 proc_reset(dev0, 0);
1097 for (i = jiffies + 8 * HZ; time_after(i, jiffies); )
1099 barrier(); /* Gcc 2.95 needs this */
1100 if (priv0->bcomm->bc_status >= BC_RUN)
1101 break;
1104 if (priv0->bcomm->bc_status < BC_RUN)
1106 printk("%s: board not operating\n", dev0->name);
1107 iounmap(priv0->vmem);
1108 priv0->vmem = NULL;
1109 return -ENXIO;
1112 priv0->port = (PORT *) S2H(priv0->bcomm->bc_port);
1113 priv0->scbp = (I596_SCB *) S2H(priv0->port->scbp);
1114 priv0->rfdp = (I596_RFD *) S2H(priv0->scbp->rfdp);
1115 priv0->rbdp = (I596_RBD *) S2H(priv0->rfdp->rbdp);
1117 priv0->scbp->status = I596_SCB_CNA; /* CU is idle */
1120 * Get switch physical and host virtual pointers to DMA
1121 * chaining area. NOTE: the MSB of the switch physical
1122 * address *must* be turned off. Otherwise, the HW kludge
1123 * that allows host access of the PLX DMA registers will
1124 * erroneously select the PLX registers.
1126 priv0->dmadesc_s = (DMACHAIN *) S2DMA(priv0->bcomm->bc_hostarea);
1127 if (priv0->dmadesc_s)
1128 priv0->dmadesc_h = (DMACHAIN *) S2H(priv0->dmadesc_s);
1129 else
1130 priv0->dmadesc_h = NULL;
1133 * Enable board interrupts
1135 if (priv0->plxreg)
1136 { /* PCI bus */
1137 OUTL(dev0->base_addr + PLX_INT_CSR,
1138 inl(dev0->base_addr + PLX_INT_CSR)
1139 | PLX_PCI_DOORBELL_IE); /* Enable intr to host */
1140 OUTL(dev0->base_addr + PLX_LCL2PCI_DOORBELL, 1);
1142 else
1143 { /* EISA bus */
1146 return (0);
1150 * Probe (init) a board
1152 static int __init
1153 dgrs_probe1(struct net_device *dev)
1155 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
1156 unsigned long i;
1157 int rc;
1159 printk("%s: Digi RightSwitch io=%lx mem=%lx irq=%d plx=%lx dma=%lx\n",
1160 dev->name, dev->base_addr, dev->mem_start, dev->irq,
1161 priv->plxreg, priv->plxdma);
1164 * Download the firmware and light the processor
1166 rc = dgrs_download(dev);
1167 if (rc)
1168 goto err_out;
1171 * Get ether address of board
1173 printk("%s: Ethernet address", dev->name);
1174 memcpy(dev->dev_addr, priv->port->ethaddr, 6);
1175 for (i = 0; i < 6; ++i)
1176 printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
1177 printk("\n");
1179 if (dev->dev_addr[0] & 1)
1181 printk("%s: Illegal Ethernet Address\n", dev->name);
1182 rc = -ENXIO;
1183 goto err_out;
1187 * ACK outstanding interrupts, hook the interrupt,
1188 * and verify that we are getting interrupts from the board.
1190 if (priv->plxreg)
1191 OUTL(dev->base_addr + PLX_LCL2PCI_DOORBELL, 1);
1193 rc = request_irq(dev->irq, &dgrs_intr, IRQF_SHARED, "RightSwitch", dev);
1194 if (rc)
1195 goto err_out;
1197 priv->intrcnt = 0;
1198 for (i = jiffies + 2*HZ + HZ/2; time_after(i, jiffies); )
1200 cpu_relax();
1201 if (priv->intrcnt >= 2)
1202 break;
1204 if (priv->intrcnt < 2)
1206 printk(KERN_ERR "%s: Not interrupting on IRQ %d (%d)\n",
1207 dev->name, dev->irq, priv->intrcnt);
1208 rc = -ENXIO;
1209 goto err_free_irq;
1213 * Entry points...
1215 dev->open = &dgrs_open;
1216 dev->stop = &dgrs_close;
1217 dev->get_stats = &dgrs_get_stats;
1218 dev->hard_start_xmit = &dgrs_start_xmit;
1219 dev->set_multicast_list = &dgrs_set_multicast_list;
1220 dev->do_ioctl = &dgrs_ioctl;
1222 return rc;
1224 err_free_irq:
1225 free_irq(dev->irq, dev);
1226 err_out:
1227 return rc;
1230 static int __init
1231 dgrs_initclone(struct net_device *dev)
1233 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
1234 int i;
1236 printk("%s: Digi RightSwitch port %d ",
1237 dev->name, priv->chan);
1238 for (i = 0; i < 6; ++i)
1239 printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
1240 printk("\n");
1242 return (0);
1245 static struct net_device * __init
1246 dgrs_found_device(
1247 int io,
1248 ulong mem,
1249 int irq,
1250 ulong plxreg,
1251 ulong plxdma,
1252 struct device *pdev
1255 DGRS_PRIV *priv;
1256 struct net_device *dev;
1257 int i, ret = -ENOMEM;
1259 dev = alloc_etherdev(sizeof(DGRS_PRIV));
1260 if (!dev)
1261 goto err0;
1263 priv = (DGRS_PRIV *)dev->priv;
1265 dev->base_addr = io;
1266 dev->mem_start = mem;
1267 dev->mem_end = mem + 2048 * 1024 - 1;
1268 dev->irq = irq;
1269 priv->plxreg = plxreg;
1270 priv->plxdma = plxdma;
1271 priv->vplxdma = NULL;
1273 priv->chan = 1;
1274 priv->devtbl[0] = dev;
1276 SET_MODULE_OWNER(dev);
1277 SET_NETDEV_DEV(dev, pdev);
1279 ret = dgrs_probe1(dev);
1280 if (ret)
1281 goto err1;
1283 ret = register_netdev(dev);
1284 if (ret)
1285 goto err2;
1287 if ( !dgrs_nicmode )
1288 return dev; /* Switch mode, we are done */
1291 * Operating card as N separate NICs
1294 priv->nports = priv->bcomm->bc_nports;
1296 for (i = 1; i < priv->nports; ++i)
1298 struct net_device *devN;
1299 DGRS_PRIV *privN;
1300 /* Allocate new dev and priv structures */
1301 devN = alloc_etherdev(sizeof(DGRS_PRIV));
1302 ret = -ENOMEM;
1303 if (!devN)
1304 goto fail;
1306 /* Don't copy the network device structure! */
1308 /* copy the priv structure of dev[0] */
1309 privN = (DGRS_PRIV *)devN->priv;
1310 *privN = *priv;
1312 /* ... and zero out VM areas */
1313 privN->vmem = NULL;
1314 privN->vplxdma = NULL;
1315 /* ... and zero out IRQ */
1316 devN->irq = 0;
1317 /* ... and base MAC address off address of 1st port */
1318 devN->dev_addr[5] += i;
1320 ret = dgrs_initclone(devN);
1321 if (ret)
1322 goto fail;
1324 SET_MODULE_OWNER(devN);
1325 SET_NETDEV_DEV(dev, pdev);
1327 ret = register_netdev(devN);
1328 if (ret) {
1329 free_netdev(devN);
1330 goto fail;
1332 privN->chan = i+1;
1333 priv->devtbl[i] = devN;
1335 return dev;
1337 fail:
1338 while (i >= 0) {
1339 struct net_device *d = priv->devtbl[i--];
1340 unregister_netdev(d);
1341 free_netdev(d);
1344 err2:
1345 free_irq(dev->irq, dev);
1346 err1:
1347 free_netdev(dev);
1348 err0:
1349 return ERR_PTR(ret);
1352 static void __devexit dgrs_remove(struct net_device *dev)
1354 DGRS_PRIV *priv = dev->priv;
1355 int i;
1357 unregister_netdev(dev);
1359 for (i = 1; i < priv->nports; ++i) {
1360 struct net_device *d = priv->devtbl[i];
1361 if (d) {
1362 unregister_netdev(d);
1363 free_netdev(d);
1367 proc_reset(priv->devtbl[0], 1);
1369 if (priv->vmem)
1370 iounmap(priv->vmem);
1371 if (priv->vplxdma)
1372 iounmap((uchar *) priv->vplxdma);
1374 if (dev->irq)
1375 free_irq(dev->irq, dev);
1377 for (i = 1; i < priv->nports; ++i) {
1378 if (priv->devtbl[i])
1379 unregister_netdev(priv->devtbl[i]);
1383 #ifdef CONFIG_PCI
1384 static int __init dgrs_pci_probe(struct pci_dev *pdev,
1385 const struct pci_device_id *ent)
1387 struct net_device *dev;
1388 int err;
1389 uint io;
1390 uint mem;
1391 uint irq;
1392 uint plxreg;
1393 uint plxdma;
1396 * Get and check the bus-master and latency values.
1397 * Some PCI BIOSes fail to set the master-enable bit,
1398 * and the latency timer must be set to the maximum
1399 * value to avoid data corruption that occurs when the
1400 * timer expires during a transfer. Yes, it's a bug.
1402 err = pci_enable_device(pdev);
1403 if (err)
1404 return err;
1405 err = pci_request_regions(pdev, "RightSwitch");
1406 if (err)
1407 return err;
1409 pci_set_master(pdev);
1411 plxreg = pci_resource_start (pdev, 0);
1412 io = pci_resource_start (pdev, 1);
1413 mem = pci_resource_start (pdev, 2);
1414 pci_read_config_dword(pdev, 0x30, &plxdma);
1415 irq = pdev->irq;
1416 plxdma &= ~15;
1419 * On some BIOSES, the PLX "expansion rom" (used for DMA)
1420 * address comes up as "0". This is probably because
1421 * the BIOS doesn't see a valid 55 AA ROM signature at
1422 * the "ROM" start and zeroes the address. To get
1423 * around this problem the SE-6 is configured to ask
1424 * for 4 MB of space for the dual port memory. We then
1425 * must set its range back to 2 MB, and use the upper
1426 * half for DMA register access
1428 OUTL(io + PLX_SPACE0_RANGE, 0xFFE00000L);
1429 if (plxdma == 0)
1430 plxdma = mem + (2048L * 1024L);
1431 pci_write_config_dword(pdev, 0x30, plxdma + 1);
1432 pci_read_config_dword(pdev, 0x30, &plxdma);
1433 plxdma &= ~15;
1435 dev = dgrs_found_device(io, mem, irq, plxreg, plxdma, &pdev->dev);
1436 if (IS_ERR(dev)) {
1437 pci_release_regions(pdev);
1438 return PTR_ERR(dev);
1441 pci_set_drvdata(pdev, dev);
1442 return 0;
1445 static void __devexit dgrs_pci_remove(struct pci_dev *pdev)
1447 struct net_device *dev = pci_get_drvdata(pdev);
1449 dgrs_remove(dev);
1450 pci_release_regions(pdev);
1451 free_netdev(dev);
1454 static struct pci_driver dgrs_pci_driver = {
1455 .name = "dgrs",
1456 .id_table = dgrs_pci_tbl,
1457 .probe = dgrs_pci_probe,
1458 .remove = __devexit_p(dgrs_pci_remove),
1460 #else
1461 static struct pci_driver dgrs_pci_driver = {};
1462 #endif
1465 #ifdef CONFIG_EISA
1466 static int is2iv[8] __initdata = { 0, 3, 5, 7, 10, 11, 12, 15 };
1468 static int __init dgrs_eisa_probe (struct device *gendev)
1470 struct net_device *dev;
1471 struct eisa_device *edev = to_eisa_device(gendev);
1472 uint io = edev->base_addr;
1473 uint mem;
1474 uint irq;
1475 int rc = -ENODEV; /* Not EISA configured */
1477 if (!request_region(io, 256, "RightSwitch")) {
1478 printk(KERN_ERR "dgrs: eisa io 0x%x, which is busy.\n", io);
1479 return -EBUSY;
1482 if ( ! (inb(io+ES4H_EC) & ES4H_EC_ENABLE) )
1483 goto err_out;
1485 mem = (inb(io+ES4H_AS_31_24) << 24)
1486 + (inb(io+ES4H_AS_23_16) << 16);
1488 irq = is2iv[ inb(io+ES4H_IS) & ES4H_IS_INTMASK ];
1490 dev = dgrs_found_device(io, mem, irq, 0L, 0L, gendev);
1491 if (IS_ERR(dev)) {
1492 rc = PTR_ERR(dev);
1493 goto err_out;
1496 gendev->driver_data = dev;
1497 return 0;
1498 err_out:
1499 release_region(io, 256);
1500 return rc;
1503 static int __devexit dgrs_eisa_remove(struct device *gendev)
1505 struct net_device *dev = gendev->driver_data;
1507 dgrs_remove(dev);
1509 release_region(dev->base_addr, 256);
1511 free_netdev(dev);
1512 return 0;
1516 static struct eisa_driver dgrs_eisa_driver = {
1517 .id_table = dgrs_eisa_tbl,
1518 .driver = {
1519 .name = "dgrs",
1520 .probe = dgrs_eisa_probe,
1521 .remove = __devexit_p(dgrs_eisa_remove),
1524 #endif
1527 * Variables that can be overriden from module command line
1529 static int debug = -1;
1530 static int dma = -1;
1531 static int hashexpire = -1;
1532 static int spantree = -1;
1533 static int ipaddr[4] = { -1 };
1534 static int iptrap[4] = { -1 };
1535 static __u32 ipxnet = -1;
1536 static int nicmode = -1;
1538 module_param(debug, int, 0);
1539 module_param(dma, int, 0);
1540 module_param(hashexpire, int, 0);
1541 module_param(spantree, int, 0);
1542 module_param_array(ipaddr, int, NULL, 0);
1543 module_param_array(iptrap, int, NULL, 0);
1544 module_param(ipxnet, int, 0);
1545 module_param(nicmode, int, 0);
1546 MODULE_PARM_DESC(debug, "Digi RightSwitch enable debugging (0-1)");
1547 MODULE_PARM_DESC(dma, "Digi RightSwitch enable BM DMA (0-1)");
1548 MODULE_PARM_DESC(nicmode, "Digi RightSwitch operating mode (1: switch, 2: multi-NIC)");
1550 static int __init dgrs_init_module (void)
1552 int i;
1553 int err;
1556 * Command line variable overrides
1557 * debug=NNN
1558 * dma=0/1
1559 * spantree=0/1
1560 * hashexpire=NNN
1561 * ipaddr=A,B,C,D
1562 * iptrap=A,B,C,D
1563 * ipxnet=NNN
1564 * nicmode=NNN
1566 if (debug >= 0)
1567 dgrs_debug = debug;
1568 if (dma >= 0)
1569 dgrs_dma = dma;
1570 if (nicmode >= 0)
1571 dgrs_nicmode = nicmode;
1572 if (hashexpire >= 0)
1573 dgrs_hashexpire = hashexpire;
1574 if (spantree >= 0)
1575 dgrs_spantree = spantree;
1576 if (ipaddr[0] != -1)
1577 for (i = 0; i < 4; ++i)
1578 dgrs_ipaddr[i] = ipaddr[i];
1579 if (iptrap[0] != -1)
1580 for (i = 0; i < 4; ++i)
1581 dgrs_iptrap[i] = iptrap[i];
1582 if (ipxnet != -1)
1583 dgrs_ipxnet = htonl( ipxnet );
1585 if (dgrs_debug)
1587 printk(KERN_INFO "dgrs: SW=%s FW=Build %d %s\nFW Version=%s\n",
1588 version, dgrs_firmnum, dgrs_firmdate, dgrs_firmver);
1592 * Find and configure all the cards
1594 #ifdef CONFIG_EISA
1595 err = eisa_driver_register(&dgrs_eisa_driver);
1596 if (err)
1597 return err;
1598 #endif
1599 err = pci_register_driver(&dgrs_pci_driver);
1600 if (err)
1601 return err;
1602 return 0;
1605 static void __exit dgrs_cleanup_module (void)
1607 #ifdef CONFIG_EISA
1608 eisa_driver_unregister (&dgrs_eisa_driver);
1609 #endif
1610 #ifdef CONFIG_PCI
1611 pci_unregister_driver (&dgrs_pci_driver);
1612 #endif
1615 module_init(dgrs_init_module);
1616 module_exit(dgrs_cleanup_module);