Import 2.3.52pre1
[davej-history.git] / drivers / net / dgrs.c
blob5a5f3cc62cf1707e1240696551cc79afb0666319
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 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.
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/init.h>
91 #include <asm/bitops.h>
92 #include <asm/io.h>
93 #include <asm/byteorder.h>
95 #include <linux/netdevice.h>
96 #include <linux/etherdevice.h>
97 #include <linux/skbuff.h>
99 #include <linux/types.h>
102 * API changed at linux version 2.1.0
104 #if LINUX_VERSION_CODE >= 0x20100
105 #include <asm/uaccess.h>
106 #define IOREMAP(ADDR, LEN) ioremap(ADDR, LEN)
107 #define IOUNMAP(ADDR) iounmap(ADDR)
108 #define COPY_FROM_USER(DST,SRC,LEN) copy_from_user(DST,SRC,LEN)
109 #define COPY_TO_USER(DST,SRC,LEN) copy_to_user(DST,SRC,LEN)
110 #else
111 #include <linux/bios32.h>
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 static struct net_device *dgrs_root_dev = NULL;
188 * Private per-board data structure (dev->priv)
190 typedef struct
193 * Stuff for generic ethercard I/F
195 char devname[8]; /* "ethN" string */
196 struct net_device *next_dev;
197 struct net_device_stats stats;
200 * DGRS specific data
202 char *vmem;
204 struct bios_comm *bcomm; /* Firmware BIOS comm structure */
205 PORT *port; /* Ptr to PORT[0] struct in VM */
206 I596_SCB *scbp; /* Ptr to SCB struct in VM */
207 I596_RFD *rfdp; /* Current RFD list */
208 I596_RBD *rbdp; /* Current RBD list */
210 int intrcnt; /* Count of interrupts */
213 * SE-4 (EISA) board variables
215 uchar is_reg; /* EISA: Value for ES4H_IS reg */
218 * SE-6 (PCI) board variables
220 * The PLX "expansion rom" space is used for DMA register
221 * access from the host on the SE-6. These are the physical
222 * and virtual addresses of that space.
224 ulong plxreg; /* Phys address of PLX chip */
225 char *vplxreg; /* Virtual address of PLX chip */
226 ulong plxdma; /* Phys addr of PLX "expansion rom" */
227 ulong volatile *vplxdma; /* Virtual addr of "expansion rom" */
228 int use_dma; /* Flag: use DMA */
229 DMACHAIN *dmadesc_s; /* area for DMA chains (SW addr.) */
230 DMACHAIN *dmadesc_h; /* area for DMA chains (Host Virtual) */
233 * Multi-NIC mode variables
235 * All entries of the devtbl[] array are valid for the 0th
236 * device (i.e. eth0, but not eth1...eth5). devtbl[0] is
237 * valid for all devices (i.e. eth0, eth1, ..., eth5).
239 int nports; /* Number of physical ports (4 or 6) */
240 int chan; /* Channel # (1-6) for this device */
241 struct net_device *devtbl[6]; /* Ptrs to N device structs */
243 } DGRS_PRIV;
247 * reset or un-reset the IDT processor
249 static void
250 proc_reset(struct net_device *dev0, int reset)
252 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
254 if (priv0->plxreg)
256 ulong val;
257 val = inl(dev0->base_addr + PLX_MISC_CSR);
258 if (reset)
259 val |= SE6_RESET;
260 else
261 val &= ~SE6_RESET;
262 OUTL(dev0->base_addr + PLX_MISC_CSR, val);
264 else
266 OUTB(dev0->base_addr + ES4H_PC, reset ? ES4H_PC_RESET : 0);
271 * See if the board supports bus master DMA
273 static int
274 check_board_dma(struct net_device *dev0)
276 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
277 ulong x;
280 * If Space.c says not to use DMA, or if its not a PLX based
281 * PCI board, or if the expansion ROM space is not PCI
282 * configured, then return false.
284 if (!dgrs_dma || !priv0->plxreg || !priv0->plxdma)
285 return (0);
288 * Set the local address remap register of the "expansion rom"
289 * area to 0x80000000 so that we can use it to access the DMA
290 * registers from the host side.
292 OUTL(dev0->base_addr + PLX_ROM_BASE_ADDR, 0x80000000);
295 * Set the PCI region descriptor to:
296 * Space 0:
297 * disable read-prefetch
298 * enable READY
299 * enable BURST
300 * 0 internal wait states
301 * Expansion ROM: (used for host DMA register access)
302 * disable read-prefetch
303 * enable READY
304 * disable BURST
305 * 0 internal wait states
307 OUTL(dev0->base_addr + PLX_BUS_REGION, 0x49430343);
310 * Now map the DMA registers into our virtual space
312 priv0->vplxdma = (ulong *) IOREMAP (priv0->plxdma, 256);
313 if (!priv0->vplxdma)
315 printk("%s: can't *remap() the DMA regs\n", dev0->name);
316 return (0);
320 * Now test to see if we can access the DMA registers
321 * If we write -1 and get back 1FFF, then we accessed the
322 * DMA register. Otherwise, we probably have an old board
323 * and wrote into regular RAM.
325 priv0->vplxdma[PLX_DMA0_MODE/4] = 0xFFFFFFFF;
326 x = priv0->vplxdma[PLX_DMA0_MODE/4];
327 if (x != 0x00001FFF)
328 return (0);
330 return (1);
334 * Initiate DMA using PLX part on PCI board. Spin the
335 * processor until completed. All addresses are physical!
337 * If pciaddr is NULL, then its a chaining DMA, and lcladdr is
338 * the address of the first DMA descriptor in the chain.
340 * If pciaddr is not NULL, then its a single DMA.
342 * In either case, "lcladdr" must have been fixed up to make
343 * sure the MSB isn't set using the S2DMA macro before passing
344 * the address to this routine.
346 static int
347 do_plx_dma(
348 struct net_device *dev,
349 ulong pciaddr,
350 ulong lcladdr,
351 int len,
352 int to_host
355 int i;
356 ulong csr = 0;
357 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
359 if (pciaddr)
362 * Do a single, non-chain DMA
364 priv->vplxdma[PLX_DMA0_PCI_ADDR/4] = pciaddr;
365 priv->vplxdma[PLX_DMA0_LCL_ADDR/4] = lcladdr;
366 priv->vplxdma[PLX_DMA0_SIZE/4] = len;
367 priv->vplxdma[PLX_DMA0_DESCRIPTOR/4] = to_host
368 ? PLX_DMA_DESC_TO_HOST
369 : PLX_DMA_DESC_TO_BOARD;
370 priv->vplxdma[PLX_DMA0_MODE/4] =
371 PLX_DMA_MODE_WIDTH32
372 | PLX_DMA_MODE_WAITSTATES(0)
373 | PLX_DMA_MODE_READY
374 | PLX_DMA_MODE_NOBTERM
375 | PLX_DMA_MODE_BURST
376 | PLX_DMA_MODE_NOCHAIN;
378 else
381 * Do a chaining DMA
383 priv->vplxdma[PLX_DMA0_MODE/4] =
384 PLX_DMA_MODE_WIDTH32
385 | PLX_DMA_MODE_WAITSTATES(0)
386 | PLX_DMA_MODE_READY
387 | PLX_DMA_MODE_NOBTERM
388 | PLX_DMA_MODE_BURST
389 | PLX_DMA_MODE_CHAIN;
390 priv->vplxdma[PLX_DMA0_DESCRIPTOR/4] = lcladdr;
393 priv->vplxdma[PLX_DMA_CSR/4] =
394 PLX_DMA_CSR_0_ENABLE | PLX_DMA_CSR_0_START;
397 * Wait for DMA to complete
399 for (i = 0; i < 1000000; ++i)
402 * Spin the host CPU for 1 usec, so we don't thrash
403 * the PCI bus while the PLX 9060 is doing DMA.
405 udelay(1);
407 csr = (volatile unsigned long) priv->vplxdma[PLX_DMA_CSR/4];
409 if (csr & PLX_DMA_CSR_0_DONE)
410 break;
413 if ( ! (csr & PLX_DMA_CSR_0_DONE) )
415 printk("%s: DMA done never occurred. DMA disabled.\n",
416 dev->name);
417 priv->use_dma = 0;
418 return 1;
420 return 0;
424 * dgrs_rcv_frame()
426 * Process a received frame. This is called from the interrupt
427 * routine, and works for both switch mode and multi-NIC mode.
429 * Note that when in multi-NIC mode, we want to always access the
430 * hardware using the dev and priv structures of the first port,
431 * so that we are using only one set of variables to maintain
432 * the board interface status, but we want to use the Nth port
433 * dev and priv structures to maintain statistics and to pass
434 * the packet up.
436 * Only the first device structure is attached to the interrupt.
437 * We use the special "chan" variable at the end of the first RBD
438 * to select the Nth device in multi-NIC mode.
440 * We currently do chained DMA on a per-packet basis when the
441 * packet is "long", and we spin the CPU a short time polling
442 * for DMA completion. This avoids a second interrupt overhead,
443 * and gives the best performance for light traffic to the host.
445 * However, a better scheme that could be implemented would be
446 * to see how many packets are outstanding for the host, and if
447 * the number is "large", create a long chain to DMA several
448 * packets into the host in one go. In this case, we would set
449 * up some state variables to let the host CPU continue doing
450 * other things until a DMA completion interrupt comes along.
452 void
453 dgrs_rcv_frame(
454 struct net_device *dev0,
455 DGRS_PRIV *priv0,
456 I596_CB *cbp
459 int len;
460 I596_TBD *tbdp;
461 struct sk_buff *skb;
462 uchar *putp;
463 uchar *p;
464 struct net_device *devN;
465 DGRS_PRIV *privN;
468 * Determine Nth priv and dev structure pointers
470 if (dgrs_nicmode)
471 { /* Multi-NIC mode */
472 int chan = ((I596_RBD *) S2H(cbp->xmit.tbdp))->chan;
474 devN = priv0->devtbl[chan-1];
476 * If devN is null, we got an interrupt before the I/F
477 * has been initialized. Pitch the packet.
479 if (devN == NULL)
480 goto out;
481 privN = (DGRS_PRIV *) devN->priv;
483 else
484 { /* Switch mode */
485 devN = dev0;
486 privN = priv0;
489 if (0) printk("%s: rcv len=%ld\n", devN->name, cbp->xmit.count);
492 * Allocate a message block big enough to hold the whole frame
494 len = cbp->xmit.count;
495 if ((skb = dev_alloc_skb(len+5)) == NULL)
497 printk("%s: dev_alloc_skb failed for rcv buffer\n", devN->name);
498 ++privN->stats.rx_dropped;
499 /* discarding the frame */
500 goto out;
502 skb->dev = devN;
503 skb_reserve(skb, 2); /* Align IP header */
505 again:
506 putp = p = skb_put(skb, len);
509 * There are three modes here for doing the packet copy.
510 * If we have DMA, and the packet is "long", we use the
511 * chaining mode of DMA. If it's shorter, we use single
512 * DMA's. Otherwise, we use memcpy().
514 if (priv0->use_dma && priv0->dmadesc_h && len > 64)
517 * If we can use DMA and its a long frame, copy it using
518 * DMA chaining.
520 DMACHAIN *ddp_h; /* Host virtual DMA desc. pointer */
521 DMACHAIN *ddp_s; /* Switch physical DMA desc. pointer */
522 uchar *phys_p;
525 * Get the physical address of the STREAMS buffer.
526 * NOTE: allocb() guarantees that the whole buffer
527 * is in a single page if the length < 4096.
529 phys_p = (uchar *) virt_to_phys(putp);
531 ddp_h = priv0->dmadesc_h;
532 ddp_s = priv0->dmadesc_s;
533 tbdp = (I596_TBD *) S2H(cbp->xmit.tbdp);
534 for (;;)
536 int count;
537 int amt;
539 count = tbdp->count;
540 amt = count & 0x3fff;
541 if (amt == 0)
542 break; /* For safety */
543 if ( (p-putp) >= len)
545 printk("%s: cbp = %x\n", devN->name, H2S(cbp));
546 proc_reset(dev0, 1); /* Freeze IDT */
547 break; /* For Safety */
550 ddp_h->pciaddr = (ulong) phys_p;
551 ddp_h->lcladdr = S2DMA(tbdp->buf);
552 ddp_h->len = amt;
554 phys_p += amt;
555 p += amt;
557 if (count & I596_TBD_EOF)
559 ddp_h->next = PLX_DMA_DESC_TO_HOST
560 | PLX_DMA_DESC_EOC;
561 ++ddp_h;
562 break;
564 else
566 ++ddp_s;
567 ddp_h->next = PLX_DMA_DESC_TO_HOST
568 | (ulong) ddp_s;
569 tbdp = (I596_TBD *) S2H(tbdp->next);
570 ++ddp_h;
573 if (ddp_h - priv0->dmadesc_h)
575 int rc;
577 rc = do_plx_dma(dev0,
578 0, (ulong) priv0->dmadesc_s, len, 0);
579 if (rc)
581 printk("%s: Chained DMA failure\n", devN->name);
582 goto again;
586 else if (priv0->use_dma)
589 * If we can use DMA and its a shorter frame, copy it
590 * using single DMA transfers.
592 uchar *phys_p;
595 * Get the physical address of the STREAMS buffer.
596 * NOTE: allocb() guarantees that the whole buffer
597 * is in a single page if the length < 4096.
599 phys_p = (uchar *) virt_to_phys(putp);
601 tbdp = (I596_TBD *) S2H(cbp->xmit.tbdp);
602 for (;;)
604 int count;
605 int amt;
606 int rc;
608 count = tbdp->count;
609 amt = count & 0x3fff;
610 if (amt == 0)
611 break; /* For safety */
612 if ( (p-putp) >= len)
614 printk("%s: cbp = %x\n", devN->name, H2S(cbp));
615 proc_reset(dev0, 1); /* Freeze IDT */
616 break; /* For Safety */
618 rc = do_plx_dma(dev0, (ulong) phys_p,
619 S2DMA(tbdp->buf), amt, 1);
620 if (rc)
622 memcpy(p, S2H(tbdp->buf), amt);
623 printk("%s: Single DMA failed\n", devN->name);
625 phys_p += amt;
626 p += amt;
627 if (count & I596_TBD_EOF)
628 break;
629 tbdp = (I596_TBD *) S2H(tbdp->next);
632 else
635 * Otherwise, copy it piece by piece using memcpy()
637 tbdp = (I596_TBD *) S2H(cbp->xmit.tbdp);
638 for (;;)
640 int count;
641 int amt;
643 count = tbdp->count;
644 amt = count & 0x3fff;
645 if (amt == 0)
646 break; /* For safety */
647 if ( (p-putp) >= len)
649 printk("%s: cbp = %x\n", devN->name, H2S(cbp));
650 proc_reset(dev0, 1); /* Freeze IDT */
651 break; /* For Safety */
653 memcpy(p, S2H(tbdp->buf), amt);
654 p += amt;
655 if (count & I596_TBD_EOF)
656 break;
657 tbdp = (I596_TBD *) S2H(tbdp->next);
662 * Pass the frame to upper half
664 skb->protocol = eth_type_trans(skb, devN);
665 netif_rx(skb);
666 ++privN->stats.rx_packets;
668 out:
669 cbp->xmit.status = I596_CB_STATUS_C | I596_CB_STATUS_OK;
673 * Start transmission of a frame
675 * The interface to the board is simple: we pretend that we are
676 * a fifth 82596 ethernet controller 'receiving' data, and copy the
677 * data into the same structures that a real 82596 would. This way,
678 * the board firmware handles the host 'port' the same as any other.
680 * NOTE: we do not use Bus master DMA for this routine. Turns out
681 * that it is not needed. Slave writes over the PCI bus are about
682 * as fast as DMA, due to the fact that the PLX part can do burst
683 * writes. The same is not true for data being read from the board.
685 * For multi-NIC mode, we tell the firmware the desired 82596
686 * output port by setting the special "dstchan" member at the
687 * end of the traditional 82596 RFD structure.
690 static int dgrs_start_xmit(struct sk_buff *skb, struct net_device *devN)
692 DGRS_PRIV *privN = (DGRS_PRIV *) devN->priv;
693 struct net_device *dev0;
694 DGRS_PRIV *priv0;
695 I596_RBD *rbdp;
696 int count;
697 int i, len, amt;
698 # define mymin(A,B) ( (A) < (B) ? (A) : (B) )
701 * Determine 0th priv and dev structure pointers
703 if (dgrs_nicmode)
705 dev0 = privN->devtbl[0];
706 priv0 = (DGRS_PRIV *) dev0->priv;
708 else
710 dev0 = devN;
711 priv0 = privN;
714 if (dgrs_debug > 1)
715 printk("%s: xmit len=%d\n", devN->name, (int) skb->len);
717 devN->trans_start = jiffies;
718 netif_start_queue(devN);
720 if (priv0->rfdp->cmd & I596_RFD_EL)
721 { /* Out of RFD's */
722 if (0) printk("%s: NO RFD's\n", devN->name);
723 goto no_resources;
726 rbdp = priv0->rbdp;
727 count = 0;
728 priv0->rfdp->rbdp = (I596_RBD *) H2S(rbdp);
730 i = 0; len = skb->len;
731 for (;;)
733 if (rbdp->size & I596_RBD_EL)
734 { /* Out of RBD's */
735 if (0) printk("%s: NO RBD's\n", devN->name);
736 goto no_resources;
739 amt = mymin(len, rbdp->size - count);
740 memcpy( (char *) S2H(rbdp->buf) + count, skb->data + i, amt);
741 i += amt;
742 count += amt;
743 len -= amt;
744 if (len == 0)
746 if (skb->len < 60)
747 rbdp->count = 60 | I596_RBD_EOF;
748 else
749 rbdp->count = count | I596_RBD_EOF;
750 rbdp = (I596_RBD *) S2H(rbdp->next);
751 goto frame_done;
753 else if (count < 32)
755 /* More data to come, but we used less than 32
756 * bytes of this RBD. Keep filling this RBD.
758 {} /* Yes, we do nothing here */
760 else
762 rbdp->count = count;
763 rbdp = (I596_RBD *) S2H(rbdp->next);
764 count = 0;
768 frame_done:
769 priv0->rbdp = rbdp;
770 if (dgrs_nicmode)
771 priv0->rfdp->dstchan = privN->chan;
772 priv0->rfdp->status = I596_RFD_C | I596_RFD_OK;
773 priv0->rfdp = (I596_RFD *) S2H(priv0->rfdp->next);
775 ++privN->stats.tx_packets;
777 dev_kfree_skb (skb);
778 return (0);
780 no_resources:
781 priv0->scbp->status |= I596_SCB_RNR; /* simulate I82596 */
782 return (-EAGAIN);
786 * Open the interface
788 static int
789 dgrs_open( struct net_device *dev )
791 netif_start_queue(dev);
793 MOD_INC_USE_COUNT;
795 return (0);
799 * Close the interface
801 static int dgrs_close( struct net_device *dev )
803 netif_stop_queue(dev);
805 MOD_DEC_USE_COUNT;
807 return (0);
811 * Get statistics
813 static struct net_device_stats *dgrs_get_stats( struct net_device *dev )
815 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
817 return (&priv->stats);
821 * Set multicast list and/or promiscuous mode
824 static void dgrs_set_multicast_list( struct net_device *dev)
826 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
828 priv->port->is_promisc = (dev->flags & IFF_PROMISC) ? 1 : 0;
832 * Unique ioctl's
834 static int dgrs_ioctl(struct net_device *devN, struct ifreq *ifr, int cmd)
836 DGRS_PRIV *privN = (DGRS_PRIV *) devN->priv;
837 DGRS_IOCTL ioc;
838 int i;
840 if (cmd != DGRSIOCTL)
841 return -EINVAL;
843 if(COPY_FROM_USER(&ioc, ifr->ifr_data, sizeof(DGRS_IOCTL)))
844 return -EFAULT;
846 switch (ioc.cmd)
848 case DGRS_GETMEM:
849 if (ioc.len != sizeof(ulong))
850 return -EINVAL;
851 if(COPY_TO_USER(ioc.data, &devN->mem_start, ioc.len))
852 return -EFAULT;
853 return (0);
854 case DGRS_SETFILTER:
855 if (!capable(CAP_NET_ADMIN))
856 return -EPERM;
857 if (ioc.port > privN->bcomm->bc_nports)
858 return -EINVAL;
859 if (ioc.filter >= NFILTERS)
860 return -EINVAL;
861 if (ioc.len > privN->bcomm->bc_filter_area_len)
862 return -EINVAL;
864 /* Wait for old command to finish */
865 for (i = 0; i < 1000; ++i)
867 if ( (volatile long) privN->bcomm->bc_filter_cmd <= 0 )
868 break;
869 udelay(1);
871 if (i >= 1000)
872 return -EIO;
874 privN->bcomm->bc_filter_port = ioc.port;
875 privN->bcomm->bc_filter_num = ioc.filter;
876 privN->bcomm->bc_filter_len = ioc.len;
878 if (ioc.len)
880 if(COPY_FROM_USER(S2HN(privN->bcomm->bc_filter_area),
881 ioc.data, ioc.len))
882 return -EFAULT;
883 privN->bcomm->bc_filter_cmd = BC_FILTER_SET;
885 else
886 privN->bcomm->bc_filter_cmd = BC_FILTER_CLR;
887 return(0);
888 default:
889 return -EOPNOTSUPP;
894 * Process interrupts
896 * dev, priv will always refer to the 0th device in Multi-NIC mode.
899 static void dgrs_intr(int irq, void *dev_id, struct pt_regs *regs)
901 struct net_device *dev0 = (struct net_device *) dev_id;
902 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
903 I596_CB *cbp;
904 int cmd;
905 int i;
907 ++priv0->intrcnt;
908 if (1) ++priv0->bcomm->bc_cnt[4];
909 if (0)
911 static int cnt = 100;
912 if (--cnt > 0)
913 printk("%s: interrupt: irq %d\n", dev0->name, irq);
917 * Get 596 command
919 cmd = priv0->scbp->cmd;
922 * See if RU has been restarted
924 if ( (cmd & I596_SCB_RUC) == I596_SCB_RUC_START)
926 if (0) printk("%s: RUC start\n", dev0->name);
927 priv0->rfdp = (I596_RFD *) S2H(priv0->scbp->rfdp);
928 priv0->rbdp = (I596_RBD *) S2H(priv0->rfdp->rbdp);
929 priv0->scbp->status &= ~(I596_SCB_RNR|I596_SCB_RUS);
931 * Tell upper half (halves)
933 if (dgrs_nicmode)
935 for (i = 0; i < priv0->nports; ++i)
936 netif_wake_queue (priv0->devtbl[i]);
938 else
939 netif_wake_queue (dev0);
940 /* if (bd->flags & TX_QUEUED)
941 DL_sched(bd, bdd); */
945 * See if any CU commands to process
947 if ( (cmd & I596_SCB_CUC) != I596_SCB_CUC_START)
949 priv0->scbp->cmd = 0; /* Ignore all other commands */
950 goto ack_intr;
952 priv0->scbp->status &= ~(I596_SCB_CNA|I596_SCB_CUS);
955 * Process a command
957 cbp = (I596_CB *) S2H(priv0->scbp->cbp);
958 priv0->scbp->cmd = 0; /* Safe to clear the command */
959 for (;;)
961 switch (cbp->nop.cmd & I596_CB_CMD)
963 case I596_CB_CMD_XMIT:
964 dgrs_rcv_frame(dev0, priv0, cbp);
965 break;
966 default:
967 cbp->nop.status = I596_CB_STATUS_C | I596_CB_STATUS_OK;
968 break;
970 if (cbp->nop.cmd & I596_CB_CMD_EL)
971 break;
972 cbp = (I596_CB *) S2H(cbp->nop.next);
974 priv0->scbp->status |= I596_SCB_CNA;
977 * Ack the interrupt
979 ack_intr:
980 if (priv0->plxreg)
981 OUTL(dev0->base_addr + PLX_LCL2PCI_DOORBELL, 1);
985 * Download the board firmware
987 static int __init
988 dgrs_download(struct net_device *dev0)
990 DGRS_PRIV *priv0 = (DGRS_PRIV *) dev0->priv;
991 int is;
992 int i;
994 static int iv2is[16] = {
995 0, 0, 0, ES4H_IS_INT3,
996 0, ES4H_IS_INT5, 0, ES4H_IS_INT7,
997 0, 0, ES4H_IS_INT10, ES4H_IS_INT11,
998 ES4H_IS_INT12, 0, 0, ES4H_IS_INT15 };
1001 * Map in the dual port memory
1003 priv0->vmem = IOREMAP(dev0->mem_start, 2048*1024);
1004 if (!priv0->vmem)
1006 printk("%s: cannot map in board memory\n", dev0->name);
1007 return -ENXIO;
1011 * Hold the processor and configure the board addresses
1013 if (priv0->plxreg)
1014 { /* PCI bus */
1015 proc_reset(dev0, 1);
1017 else
1018 { /* EISA bus */
1019 is = iv2is[dev0->irq & 0x0f];
1020 if (!is)
1022 printk("%s: Illegal IRQ %d\n", dev0->name, dev0->irq);
1023 return -ENXIO;
1025 OUTB(dev0->base_addr + ES4H_AS_31_24,
1026 (uchar) (dev0->mem_start >> 24) );
1027 OUTB(dev0->base_addr + ES4H_AS_23_16,
1028 (uchar) (dev0->mem_start >> 16) );
1029 priv0->is_reg = ES4H_IS_LINEAR | is |
1030 ((uchar) (dev0->mem_start >> 8) & ES4H_IS_AS15);
1031 OUTB(dev0->base_addr + ES4H_IS, priv0->is_reg);
1032 OUTB(dev0->base_addr + ES4H_EC, ES4H_EC_ENABLE);
1033 OUTB(dev0->base_addr + ES4H_PC, ES4H_PC_RESET);
1034 OUTB(dev0->base_addr + ES4H_MW, ES4H_MW_ENABLE | 0x00);
1038 * See if we can do DMA on the SE-6
1040 priv0->use_dma = check_board_dma(dev0);
1041 if (priv0->use_dma)
1042 printk("%s: Bus Master DMA is enabled.\n", dev0->name);
1045 * Load and verify the code at the desired address
1047 memcpy(priv0->vmem, dgrs_code, dgrs_ncode); /* Load code */
1048 if (memcmp(priv0->vmem, dgrs_code, dgrs_ncode))
1050 IOUNMAP(priv0->vmem);
1051 priv0->vmem = NULL;
1052 printk("%s: download compare failed\n", dev0->name);
1053 return -ENXIO;
1057 * Configurables
1059 priv0->bcomm = (struct bios_comm *) (priv0->vmem + 0x0100);
1060 priv0->bcomm->bc_nowait = 1; /* Tell board to make printf not wait */
1061 priv0->bcomm->bc_squelch = 0; /* Flag from Space.c */
1062 priv0->bcomm->bc_150ohm = 0; /* Flag from Space.c */
1064 priv0->bcomm->bc_spew = 0; /* Debug flag from Space.c */
1065 priv0->bcomm->bc_maxrfd = 0; /* Debug flag from Space.c */
1066 priv0->bcomm->bc_maxrbd = 0; /* Debug flag from Space.c */
1069 * Tell board we are operating in switch mode (1) or in
1070 * multi-NIC mode (2).
1072 priv0->bcomm->bc_host = dgrs_nicmode ? BC_MULTINIC : BC_SWITCH;
1075 * Request memory space on board for DMA chains
1077 if (priv0->use_dma)
1078 priv0->bcomm->bc_hostarea_len = (2048/64) * 16;
1081 * NVRAM configurables from Space.c
1083 priv0->bcomm->bc_spantree = dgrs_spantree;
1084 priv0->bcomm->bc_hashexpire = dgrs_hashexpire;
1085 memcpy(priv0->bcomm->bc_ipaddr, dgrs_ipaddr, 4);
1086 memcpy(priv0->bcomm->bc_iptrap, dgrs_iptrap, 4);
1087 memcpy(priv0->bcomm->bc_ipxnet, &dgrs_ipxnet, 4);
1090 * Release processor, wait 8 seconds for board to initialize
1092 proc_reset(dev0, 0);
1094 for (i = jiffies + 8 * HZ; time_after(i, jiffies); )
1096 if (priv0->bcomm->bc_status >= BC_RUN)
1097 break;
1100 if (priv0->bcomm->bc_status < BC_RUN)
1102 printk("%s: board not operating\n", dev0->name);
1103 return -ENXIO;
1106 priv0->port = (PORT *) S2H(priv0->bcomm->bc_port);
1107 priv0->scbp = (I596_SCB *) S2H(priv0->port->scbp);
1108 priv0->rfdp = (I596_RFD *) S2H(priv0->scbp->rfdp);
1109 priv0->rbdp = (I596_RBD *) S2H(priv0->rfdp->rbdp);
1111 priv0->scbp->status = I596_SCB_CNA; /* CU is idle */
1114 * Get switch physical and host virtual pointers to DMA
1115 * chaining area. NOTE: the MSB of the switch physical
1116 * address *must* be turned off. Otherwise, the HW kludge
1117 * that allows host access of the PLX DMA registers will
1118 * erroneously select the PLX registers.
1120 priv0->dmadesc_s = (DMACHAIN *) S2DMA(priv0->bcomm->bc_hostarea);
1121 if (priv0->dmadesc_s)
1122 priv0->dmadesc_h = (DMACHAIN *) S2H(priv0->dmadesc_s);
1123 else
1124 priv0->dmadesc_h = NULL;
1127 * Enable board interrupts
1129 if (priv0->plxreg)
1130 { /* PCI bus */
1131 OUTL(dev0->base_addr + PLX_INT_CSR,
1132 inl(dev0->base_addr + PLX_INT_CSR)
1133 | PLX_PCI_DOORBELL_IE); /* Enable intr to host */
1134 OUTL(dev0->base_addr + PLX_LCL2PCI_DOORBELL, 1);
1136 else
1137 { /* EISA bus */
1140 return (0);
1144 * Probe (init) a board
1146 int __init
1147 dgrs_probe1(struct net_device *dev)
1149 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
1150 int i;
1151 int rc;
1153 printk("%s: Digi RightSwitch io=%lx mem=%lx irq=%d plx=%lx dma=%lx\n",
1154 dev->name, dev->base_addr, dev->mem_start, dev->irq,
1155 priv->plxreg, priv->plxdma);
1158 * Download the firmware and light the processor
1160 rc = dgrs_download(dev);
1161 if (rc)
1163 return rc;
1167 * Get ether address of board
1169 printk("%s: Ethernet address", dev->name);
1170 memcpy(dev->dev_addr, priv->port->ethaddr, 6);
1171 for (i = 0; i < 6; ++i)
1172 printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
1173 printk("\n");
1175 if (dev->dev_addr[0] & 1)
1177 printk("%s: Illegal Ethernet Address\n", dev->name);
1178 return (-ENXIO);
1182 * ACK outstanding interrupts, hook the interrupt,
1183 * and verify that we are getting interrupts from the board.
1185 if (priv->plxreg)
1186 OUTL(dev->base_addr + PLX_LCL2PCI_DOORBELL, 1);
1187 rc = request_irq(dev->irq, &dgrs_intr, 0, "RightSwitch", dev);
1188 if (rc)
1189 return (rc);
1191 priv->intrcnt = 0;
1192 for (i = jiffies + 2*HZ + HZ/2; time_after(i, jiffies); )
1194 barrier(); /* gcc 2.95 needs this */
1195 if (priv->intrcnt >= 2)
1196 break;
1198 if (priv->intrcnt < 2)
1200 printk("%s: Not interrupting on IRQ %d (%d)\n",
1201 dev->name, dev->irq, priv->intrcnt);
1202 return (-ENXIO);
1206 * Register the /proc/ioports information...
1208 request_region(dev->base_addr, 256, "RightSwitch");
1211 * Entry points...
1213 dev->open = &dgrs_open;
1214 dev->stop = &dgrs_close;
1215 dev->get_stats = &dgrs_get_stats;
1216 dev->hard_start_xmit = &dgrs_start_xmit;
1217 dev->set_multicast_list = &dgrs_set_multicast_list;
1218 dev->do_ioctl = &dgrs_ioctl;
1220 return (0);
1223 int __init
1224 dgrs_initclone(struct net_device *dev)
1226 DGRS_PRIV *priv = (DGRS_PRIV *) dev->priv;
1227 int i;
1229 printk("%s: Digi RightSwitch port %d ",
1230 dev->name, priv->chan);
1231 for (i = 0; i < 6; ++i)
1232 printk("%c%2.2x", i ? ':' : ' ', dev->dev_addr[i]);
1233 printk("\n");
1235 return (0);
1238 static int __init
1239 dgrs_found_device(
1240 int io,
1241 ulong mem,
1242 int irq,
1243 ulong plxreg,
1244 ulong plxdma
1247 DGRS_PRIV *priv;
1248 struct net_device *dev;
1250 /* Allocate and fill new device structure. */
1251 int dev_size = sizeof(struct net_device) + sizeof(DGRS_PRIV);
1252 int i;
1254 dev = (struct net_device *) kmalloc(dev_size, GFP_KERNEL);
1255 memset(dev, 0, dev_size);
1256 dev->priv = ((void *)dev) + sizeof(struct net_device);
1257 priv = (DGRS_PRIV *)dev->priv;
1259 dev->name = priv->devname; /* An empty string. */
1260 dev->base_addr = io;
1261 dev->mem_start = mem;
1262 dev->mem_end = mem + 2048 * 1024 - 1;
1263 dev->irq = irq;
1264 priv->plxreg = plxreg;
1265 priv->plxdma = plxdma;
1266 priv->vplxdma = NULL;
1268 priv->chan = 1;
1269 priv->devtbl[0] = dev;
1271 dev->init = dgrs_probe1;
1272 ether_setup(dev);
1273 priv->next_dev = dgrs_root_dev;
1274 dgrs_root_dev = dev;
1275 if (register_netdev(dev) != 0)
1276 return -EIO;
1278 if ( !dgrs_nicmode )
1279 return (0); /* Switch mode, we are done */
1282 * Operating card as N separate NICs
1285 priv->nports = priv->bcomm->bc_nports;
1287 for (i = 1; i < priv->nports; ++i)
1289 struct net_device *devN;
1290 DGRS_PRIV *privN;
1291 /* Allocate new dev and priv structures */
1292 devN = (struct net_device *) kmalloc(dev_size, GFP_KERNEL);
1293 /* Make it an exact copy of dev[0]... */
1294 memcpy(devN, dev, dev_size);
1295 devN->priv = ((void *)devN) + sizeof(struct net_device);
1296 privN = (DGRS_PRIV *)devN->priv;
1297 /* ... but seset devname to a NULL string */
1298 privN->devname[0] = 0;
1299 devN->name = privN->devname;
1300 /* ... and zero out VM areas */
1301 privN->vmem = 0;
1302 privN->vplxdma = 0;
1303 /* ... and zero out IRQ */
1304 devN->irq = 0;
1305 /* ... and base MAC address off address of 1st port */
1306 devN->dev_addr[5] += i;
1307 privN->chan = i+1;
1308 priv->devtbl[i] = devN;
1309 devN->init = dgrs_initclone;
1310 ether_setup(devN);
1311 privN->next_dev = dgrs_root_dev;
1312 dgrs_root_dev = devN;
1313 if (register_netdev(devN) != 0)
1314 return -EIO;
1316 return (0);
1320 * Scan for all boards
1322 static int is2iv[8] __initdata = { 0, 3, 5, 7, 10, 11, 12, 15 };
1324 static int __init dgrs_scan(void)
1326 int cards_found = 0;
1327 uint io;
1328 uint mem;
1329 uint irq;
1330 uint plxreg;
1331 uint plxdma;
1334 * First, check for PCI boards
1336 if (pci_present())
1338 int pci_index = 0;
1340 for (; pci_index < 8; pci_index++)
1342 uchar pci_bus, pci_device_fn;
1343 #if LINUX_VERSION_CODE < 0x20100
1344 uchar pci_irq;
1345 #else
1346 uint pci_irq;
1347 struct pci_dev *pdev;
1348 #endif
1349 uchar pci_latency;
1350 ushort pci_command;
1352 if (pcibios_find_device(SE6_PCI_VENDOR_ID,
1353 SE6_PCI_DEVICE_ID,
1354 pci_index, &pci_bus,
1355 &pci_device_fn))
1356 break;
1358 pdev = pci_find_slot(pci_bus, pci_device_fn);
1359 pci_irq = pdev->irq;
1360 plxreg = pdev->resource[0].start;
1361 io = pdev->resource[1].start;
1362 mem = pdev->resource[2].start;
1363 pcibios_read_config_dword(pci_bus, pci_device_fn,
1364 0x30, &plxdma);
1365 irq = pci_irq;
1366 plxdma &= ~15;
1369 * On some BIOSES, the PLX "expansion rom" (used for DMA)
1370 * address comes up as "0". This is probably because
1371 * the BIOS doesn't see a valid 55 AA ROM signature at
1372 * the "ROM" start and zeroes the address. To get
1373 * around this problem the SE-6 is configured to ask
1374 * for 4 MB of space for the dual port memory. We then
1375 * must set its range back to 2 MB, and use the upper
1376 * half for DMA register access
1378 OUTL(io + PLX_SPACE0_RANGE, 0xFFE00000L);
1379 if (plxdma == 0)
1380 plxdma = mem + (2048L * 1024L);
1381 pcibios_write_config_dword(pci_bus, pci_device_fn,
1382 0x30, plxdma + 1);
1383 pcibios_read_config_dword(pci_bus, pci_device_fn,
1384 0x30, &plxdma);
1385 plxdma &= ~15;
1388 * Get and check the bus-master and latency values.
1389 * Some PCI BIOSes fail to set the master-enable bit,
1390 * and the latency timer must be set to the maximum
1391 * value to avoid data corruption that occurs when the
1392 * timer expires during a transfer. Yes, it's a bug.
1394 pcibios_read_config_word(pci_bus, pci_device_fn,
1395 PCI_COMMAND, &pci_command);
1396 if ( ! (pci_command & PCI_COMMAND_MASTER))
1398 printk(" Setting the PCI Master Bit!\n");
1399 pci_command |= PCI_COMMAND_MASTER;
1400 pcibios_write_config_word(pci_bus,
1401 pci_device_fn,
1402 PCI_COMMAND, pci_command);
1404 pcibios_read_config_byte(pci_bus, pci_device_fn,
1405 PCI_LATENCY_TIMER, &pci_latency);
1406 if (pci_latency != 255)
1408 printk(" Overriding PCI latency timer: "
1409 "was %d, now is 255.\n", pci_latency);
1410 pcibios_write_config_byte(pci_bus,
1411 pci_device_fn,
1412 PCI_LATENCY_TIMER, 255);
1415 dgrs_found_device(io, mem, irq, plxreg, plxdma);
1417 cards_found++;
1422 * Second, check for EISA boards
1424 if (EISA_bus)
1426 for (io = 0x1000; io < 0x9000; io += 0x1000)
1428 if (inb(io+ES4H_MANUFmsb) != 0x10
1429 || inb(io+ES4H_MANUFlsb) != 0x49
1430 || inb(io+ES4H_PRODUCT) != ES4H_PRODUCT_CODE)
1431 continue;
1433 if ( ! (inb(io+ES4H_EC) & ES4H_EC_ENABLE) )
1434 continue; /* Not EISA configured */
1436 mem = (inb(io+ES4H_AS_31_24) << 24)
1437 + (inb(io+ES4H_AS_23_16) << 16);
1439 irq = is2iv[ inb(io+ES4H_IS) & ES4H_IS_INTMASK ];
1441 dgrs_found_device(io, mem, irq, 0L, 0L);
1443 ++cards_found;
1447 return cards_found;
1452 * Variables that can be overriden from module command line
1454 static int debug = -1;
1455 static int dma = -1;
1456 static int hashexpire = -1;
1457 static int spantree = -1;
1458 static int ipaddr[4] = { -1 };
1459 static int iptrap[4] = { -1 };
1460 static __u32 ipxnet = -1;
1461 static int nicmode = -1;
1463 MODULE_PARM(debug, "i");
1464 MODULE_PARM(dma, "i");
1465 MODULE_PARM(hashexpire, "i");
1466 MODULE_PARM(spantree, "i");
1467 MODULE_PARM(ipaddr, "1-4i");
1468 MODULE_PARM(iptrap, "1-4i");
1469 MODULE_PARM(ipxnet, "i");
1470 MODULE_PARM(nicmode, "i");
1472 static int __init dgrs_init_module (void)
1474 int cards_found;
1475 int i;
1478 * Command line variable overrides
1479 * debug=NNN
1480 * dma=0/1
1481 * spantree=0/1
1482 * hashexpire=NNN
1483 * ipaddr=A,B,C,D
1484 * iptrap=A,B,C,D
1485 * ipxnet=NNN
1486 * nicmode=NNN
1488 if (debug >= 0)
1489 dgrs_debug = debug;
1490 if (dma >= 0)
1491 dgrs_dma = dma;
1492 if (nicmode >= 0)
1493 dgrs_nicmode = nicmode;
1494 if (hashexpire >= 0)
1495 dgrs_hashexpire = hashexpire;
1496 if (spantree >= 0)
1497 dgrs_spantree = spantree;
1498 if (ipaddr[0] != -1)
1499 for (i = 0; i < 4; ++i)
1500 dgrs_ipaddr[i] = ipaddr[i];
1501 if (iptrap[0] != -1)
1502 for (i = 0; i < 4; ++i)
1503 dgrs_iptrap[i] = iptrap[i];
1504 if (ipxnet != -1)
1505 dgrs_ipxnet = htonl( ipxnet );
1507 if (dgrs_debug)
1509 printk("dgrs: SW=%s FW=Build %d %s\n",
1510 version, dgrs_firmnum, dgrs_firmdate);
1514 * Find and configure all the cards
1516 dgrs_root_dev = NULL;
1517 cards_found = dgrs_scan();
1519 return cards_found ? 0 : -ENODEV;
1522 static void __exit dgrs_cleanup_module (void)
1524 while (dgrs_root_dev)
1526 struct net_device *next_dev;
1527 DGRS_PRIV *priv;
1529 priv = (DGRS_PRIV *) dgrs_root_dev->priv;
1530 next_dev = priv->next_dev;
1531 unregister_netdev(dgrs_root_dev);
1533 proc_reset(priv->devtbl[0], 1);
1535 if (priv->vmem)
1536 IOUNMAP(priv->vmem);
1537 if (priv->vplxdma)
1538 IOUNMAP((uchar *) priv->vplxdma);
1540 release_region(dgrs_root_dev->base_addr, 256);
1542 if (dgrs_root_dev->irq)
1543 free_irq(dgrs_root_dev->irq, dgrs_root_dev);
1545 kfree(dgrs_root_dev);
1546 dgrs_root_dev = next_dev;
1550 module_init(dgrs_init_module);
1551 module_exit(dgrs_cleanup_module);