2 * rrunner.c: Linux driver for the Essential RoadRunner HIPPI board.
4 * Copyright (C) 1998-2002 by Jes Sorensen, <jes@wildopensource.com>.
6 * Thanks to Essential Communication for providing us with hardware
7 * and very comprehensive documentation without which I would not have
8 * been able to write this driver. A special thank you to John Gibbon
9 * for sorting out the legal issues, with the NDA, allowing the code to
10 * be released under the GPL.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * Thanks to Jayaram Bhat from ODS/Essential for fixing some of the
18 * stupid bugs in my code.
20 * Softnet support and various other patches from Val Henson of
23 * PCI DMA mapping code partly based on work by Francois Romieu.
28 #define RX_DMA_SKBUFF 1
29 #define PKT_COPY_THRESHOLD 512
31 #include <linux/module.h>
32 #include <linux/types.h>
33 #include <linux/errno.h>
34 #include <linux/ioport.h>
35 #include <linux/pci.h>
36 #include <linux/kernel.h>
37 #include <linux/netdevice.h>
38 #include <linux/hippidevice.h>
39 #include <linux/skbuff.h>
40 #include <linux/init.h>
41 #include <linux/delay.h>
43 #include <linux/slab.h>
46 #include <asm/cache.h>
47 #include <asm/byteorder.h>
50 #include <asm/uaccess.h>
52 #define rr_if_busy(dev) netif_queue_stopped(dev)
53 #define rr_if_running(dev) netif_running(dev)
57 #define RUN_AT(x) (jiffies + (x))
60 MODULE_AUTHOR("Jes Sorensen <jes@wildopensource.com>");
61 MODULE_DESCRIPTION("Essential RoadRunner HIPPI driver");
62 MODULE_LICENSE("GPL");
64 static char version[] = "rrunner.c: v0.50 11/11/2002 Jes Sorensen (jes@wildopensource.com)\n";
67 static const struct net_device_ops rr_netdev_ops = {
70 .ndo_do_ioctl = rr_ioctl,
71 .ndo_start_xmit = rr_start_xmit,
72 .ndo_change_mtu = hippi_change_mtu,
73 .ndo_set_mac_address = hippi_mac_addr,
77 * Implementation notes:
79 * The DMA engine only allows for DMA within physical 64KB chunks of
80 * memory. The current approach of the driver (and stack) is to use
81 * linear blocks of memory for the skbuffs. However, as the data block
82 * is always the first part of the skb and skbs are 2^n aligned so we
83 * are guarantted to get the whole block within one 64KB align 64KB
86 * On the long term, relying on being able to allocate 64KB linear
87 * chunks of memory is not feasible and the skb handling code and the
88 * stack will need to know about I/O vectors or something similar.
91 static int rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
93 struct net_device *dev;
94 static int version_disp;
96 struct rr_private *rrpriv;
101 dev = alloc_hippi_dev(sizeof(struct rr_private));
105 ret = pci_enable_device(pdev);
111 rrpriv = netdev_priv(dev);
113 SET_NETDEV_DEV(dev, &pdev->dev);
115 ret = pci_request_regions(pdev, "rrunner");
119 pci_set_drvdata(pdev, dev);
121 rrpriv->pci_dev = pdev;
123 spin_lock_init(&rrpriv->lock);
125 dev->netdev_ops = &rr_netdev_ops;
127 /* display version info if adapter is found */
129 /* set display flag to TRUE so that */
130 /* we only display this string ONCE */
135 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency);
136 if (pci_latency <= 0x58){
138 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, pci_latency);
141 pci_set_master(pdev);
143 printk(KERN_INFO "%s: Essential RoadRunner serial HIPPI "
144 "at 0x%llx, irq %i, PCI latency %i\n", dev->name,
145 (unsigned long long)pci_resource_start(pdev, 0),
146 pdev->irq, pci_latency);
149 * Remap the MMIO regs into kernel space.
151 rrpriv->regs = pci_iomap(pdev, 0, 0x1000);
153 printk(KERN_ERR "%s: Unable to map I/O register, "
154 "RoadRunner will be disabled.\n", dev->name);
159 tmpptr = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
160 rrpriv->tx_ring = tmpptr;
161 rrpriv->tx_ring_dma = ring_dma;
168 tmpptr = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
169 rrpriv->rx_ring = tmpptr;
170 rrpriv->rx_ring_dma = ring_dma;
177 tmpptr = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma);
178 rrpriv->evt_ring = tmpptr;
179 rrpriv->evt_ring_dma = ring_dma;
187 * Don't access any register before this point!
190 writel(readl(&rrpriv->regs->HostCtrl) | NO_SWAP,
191 &rrpriv->regs->HostCtrl);
194 * Need to add a case for little-endian 64-bit hosts here.
199 ret = register_netdev(dev);
206 pci_free_consistent(pdev, RX_TOTAL_SIZE, rrpriv->rx_ring,
207 rrpriv->rx_ring_dma);
209 pci_free_consistent(pdev, TX_TOTAL_SIZE, rrpriv->tx_ring,
210 rrpriv->tx_ring_dma);
212 pci_iounmap(pdev, rrpriv->regs);
214 pci_release_regions(pdev);
215 pci_set_drvdata(pdev, NULL);
223 static void rr_remove_one(struct pci_dev *pdev)
225 struct net_device *dev = pci_get_drvdata(pdev);
226 struct rr_private *rr = netdev_priv(dev);
228 if (!(readl(&rr->regs->HostCtrl) & NIC_HALTED)) {
229 printk(KERN_ERR "%s: trying to unload running NIC\n",
231 writel(HALT_NIC, &rr->regs->HostCtrl);
234 unregister_netdev(dev);
235 pci_free_consistent(pdev, EVT_RING_SIZE, rr->evt_ring,
237 pci_free_consistent(pdev, RX_TOTAL_SIZE, rr->rx_ring,
239 pci_free_consistent(pdev, TX_TOTAL_SIZE, rr->tx_ring,
241 pci_iounmap(pdev, rr->regs);
242 pci_release_regions(pdev);
243 pci_disable_device(pdev);
244 pci_set_drvdata(pdev, NULL);
250 * Commands are considered to be slow, thus there is no reason to
253 static void rr_issue_cmd(struct rr_private *rrpriv, struct cmd *cmd)
255 struct rr_regs __iomem *regs;
260 * This is temporary - it will go away in the final version.
261 * We probably also want to make this function inline.
263 if (readl(®s->HostCtrl) & NIC_HALTED){
264 printk("issuing command for halted NIC, code 0x%x, "
265 "HostCtrl %08x\n", cmd->code, readl(®s->HostCtrl));
266 if (readl(®s->Mode) & FATAL_ERR)
267 printk("error codes Fail1 %02x, Fail2 %02x\n",
268 readl(®s->Fail1), readl(®s->Fail2));
271 idx = rrpriv->info->cmd_ctrl.pi;
273 writel(*(u32*)(cmd), ®s->CmdRing[idx]);
276 idx = (idx - 1) % CMD_RING_ENTRIES;
277 rrpriv->info->cmd_ctrl.pi = idx;
280 if (readl(®s->Mode) & FATAL_ERR)
281 printk("error code %02x\n", readl(®s->Fail1));
286 * Reset the board in a sensible manner. The NIC is already halted
287 * when we get here and a spin-lock is held.
289 static int rr_reset(struct net_device *dev)
291 struct rr_private *rrpriv;
292 struct rr_regs __iomem *regs;
296 rrpriv = netdev_priv(dev);
299 rr_load_firmware(dev);
301 writel(0x01000000, ®s->TX_state);
302 writel(0xff800000, ®s->RX_state);
303 writel(0, ®s->AssistState);
304 writel(CLEAR_INTA, ®s->LocalCtrl);
305 writel(0x01, ®s->BrkPt);
306 writel(0, ®s->Timer);
307 writel(0, ®s->TimerRef);
308 writel(RESET_DMA, ®s->DmaReadState);
309 writel(RESET_DMA, ®s->DmaWriteState);
310 writel(0, ®s->DmaWriteHostHi);
311 writel(0, ®s->DmaWriteHostLo);
312 writel(0, ®s->DmaReadHostHi);
313 writel(0, ®s->DmaReadHostLo);
314 writel(0, ®s->DmaReadLen);
315 writel(0, ®s->DmaWriteLen);
316 writel(0, ®s->DmaWriteLcl);
317 writel(0, ®s->DmaWriteIPchecksum);
318 writel(0, ®s->DmaReadLcl);
319 writel(0, ®s->DmaReadIPchecksum);
320 writel(0, ®s->PciState);
321 #if (BITS_PER_LONG == 64) && defined __LITTLE_ENDIAN
322 writel(SWAP_DATA | PTR64BIT | PTR_WD_SWAP, ®s->Mode);
323 #elif (BITS_PER_LONG == 64)
324 writel(SWAP_DATA | PTR64BIT | PTR_WD_NOSWAP, ®s->Mode);
326 writel(SWAP_DATA | PTR32BIT | PTR_WD_NOSWAP, ®s->Mode);
331 * Don't worry, this is just black magic.
333 writel(0xdf000, ®s->RxBase);
334 writel(0xdf000, ®s->RxPrd);
335 writel(0xdf000, ®s->RxCon);
336 writel(0xce000, ®s->TxBase);
337 writel(0xce000, ®s->TxPrd);
338 writel(0xce000, ®s->TxCon);
339 writel(0, ®s->RxIndPro);
340 writel(0, ®s->RxIndCon);
341 writel(0, ®s->RxIndRef);
342 writel(0, ®s->TxIndPro);
343 writel(0, ®s->TxIndCon);
344 writel(0, ®s->TxIndRef);
345 writel(0xcc000, ®s->pad10[0]);
346 writel(0, ®s->DrCmndPro);
347 writel(0, ®s->DrCmndCon);
348 writel(0, ®s->DwCmndPro);
349 writel(0, ®s->DwCmndCon);
350 writel(0, ®s->DwCmndRef);
351 writel(0, ®s->DrDataPro);
352 writel(0, ®s->DrDataCon);
353 writel(0, ®s->DrDataRef);
354 writel(0, ®s->DwDataPro);
355 writel(0, ®s->DwDataCon);
356 writel(0, ®s->DwDataRef);
359 writel(0xffffffff, ®s->MbEvent);
360 writel(0, ®s->Event);
362 writel(0, ®s->TxPi);
363 writel(0, ®s->IpRxPi);
365 writel(0, ®s->EvtCon);
366 writel(0, ®s->EvtPrd);
368 rrpriv->info->evt_ctrl.pi = 0;
370 for (i = 0; i < CMD_RING_ENTRIES; i++)
371 writel(0, ®s->CmdRing[i]);
374 * Why 32 ? is this not cache line size dependent?
376 writel(RBURST_64|WBURST_64, ®s->PciState);
379 start_pc = rr_read_eeprom_word(rrpriv,
380 offsetof(struct eeprom, rncd_info.FwStart));
383 printk("%s: Executing firmware at address 0x%06x\n",
384 dev->name, start_pc);
387 writel(start_pc + 0x800, ®s->Pc);
391 writel(start_pc, ®s->Pc);
399 * Read a string from the EEPROM.
401 static unsigned int rr_read_eeprom(struct rr_private *rrpriv,
402 unsigned long offset,
404 unsigned long length)
406 struct rr_regs __iomem *regs = rrpriv->regs;
407 u32 misc, io, host, i;
409 io = readl(®s->ExtIo);
410 writel(0, ®s->ExtIo);
411 misc = readl(®s->LocalCtrl);
412 writel(0, ®s->LocalCtrl);
413 host = readl(®s->HostCtrl);
414 writel(host | HALT_NIC, ®s->HostCtrl);
417 for (i = 0; i < length; i++){
418 writel((EEPROM_BASE + ((offset+i) << 3)), ®s->WinBase);
420 buf[i] = (readl(®s->WinData) >> 24) & 0xff;
424 writel(host, ®s->HostCtrl);
425 writel(misc, ®s->LocalCtrl);
426 writel(io, ®s->ExtIo);
433 * Shortcut to read one word (4 bytes) out of the EEPROM and convert
434 * it to our CPU byte-order.
436 static u32 rr_read_eeprom_word(struct rr_private *rrpriv,
441 if ((rr_read_eeprom(rrpriv, offset,
442 (unsigned char *)&word, 4) == 4))
443 return be32_to_cpu(word);
449 * Write a string to the EEPROM.
451 * This is only called when the firmware is not running.
453 static unsigned int write_eeprom(struct rr_private *rrpriv,
454 unsigned long offset,
456 unsigned long length)
458 struct rr_regs __iomem *regs = rrpriv->regs;
459 u32 misc, io, data, i, j, ready, error = 0;
461 io = readl(®s->ExtIo);
462 writel(0, ®s->ExtIo);
463 misc = readl(®s->LocalCtrl);
464 writel(ENABLE_EEPROM_WRITE, ®s->LocalCtrl);
467 for (i = 0; i < length; i++){
468 writel((EEPROM_BASE + ((offset+i) << 3)), ®s->WinBase);
472 * Only try to write the data if it is not the same
475 if ((readl(®s->WinData) & 0xff000000) != data){
476 writel(data, ®s->WinData);
482 if ((readl(®s->WinData) & 0xff000000) ==
487 printk("data mismatch: %08x, "
488 "WinData %08x\n", data,
489 readl(®s->WinData));
497 writel(misc, ®s->LocalCtrl);
498 writel(io, ®s->ExtIo);
505 static int rr_init(struct net_device *dev)
507 struct rr_private *rrpriv;
508 struct rr_regs __iomem *regs;
511 rrpriv = netdev_priv(dev);
514 rev = readl(®s->FwRev);
515 rrpriv->fw_rev = rev;
516 if (rev > 0x00020024)
517 printk(" Firmware revision: %i.%i.%i\n", (rev >> 16),
518 ((rev >> 8) & 0xff), (rev & 0xff));
519 else if (rev >= 0x00020000) {
520 printk(" Firmware revision: %i.%i.%i (2.0.37 or "
521 "later is recommended)\n", (rev >> 16),
522 ((rev >> 8) & 0xff), (rev & 0xff));
524 printk(" Firmware revision too old: %i.%i.%i, please "
525 "upgrade to 2.0.37 or later.\n",
526 (rev >> 16), ((rev >> 8) & 0xff), (rev & 0xff));
530 printk(" Maximum receive rings %i\n", readl(®s->MaxRxRng));
534 * Read the hardware address from the eeprom. The HW address
535 * is not really necessary for HIPPI but awfully convenient.
536 * The pointer arithmetic to put it in dev_addr is ugly, but
537 * Donald Becker does it this way for the GigE version of this
538 * card and it's shorter and more portable than any
539 * other method I've seen. -VAL
542 *(__be16 *)(dev->dev_addr) =
543 htons(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA)));
544 *(__be32 *)(dev->dev_addr+2) =
545 htonl(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA[4])));
547 printk(" MAC: %pM\n", dev->dev_addr);
549 sram_size = rr_read_eeprom_word(rrpriv, 8);
550 printk(" SRAM size 0x%06x\n", sram_size);
556 static int rr_init1(struct net_device *dev)
558 struct rr_private *rrpriv;
559 struct rr_regs __iomem *regs;
560 unsigned long myjif, flags;
566 rrpriv = netdev_priv(dev);
569 spin_lock_irqsave(&rrpriv->lock, flags);
571 hostctrl = readl(®s->HostCtrl);
572 writel(hostctrl | HALT_NIC | RR_CLEAR_INT, ®s->HostCtrl);
575 if (hostctrl & PARITY_ERR){
576 printk("%s: Parity error halting NIC - this is serious!\n",
578 spin_unlock_irqrestore(&rrpriv->lock, flags);
583 set_rxaddr(regs, rrpriv->rx_ctrl_dma);
584 set_infoaddr(regs, rrpriv->info_dma);
586 rrpriv->info->evt_ctrl.entry_size = sizeof(struct event);
587 rrpriv->info->evt_ctrl.entries = EVT_RING_ENTRIES;
588 rrpriv->info->evt_ctrl.mode = 0;
589 rrpriv->info->evt_ctrl.pi = 0;
590 set_rraddr(&rrpriv->info->evt_ctrl.rngptr, rrpriv->evt_ring_dma);
592 rrpriv->info->cmd_ctrl.entry_size = sizeof(struct cmd);
593 rrpriv->info->cmd_ctrl.entries = CMD_RING_ENTRIES;
594 rrpriv->info->cmd_ctrl.mode = 0;
595 rrpriv->info->cmd_ctrl.pi = 15;
597 for (i = 0; i < CMD_RING_ENTRIES; i++) {
598 writel(0, ®s->CmdRing[i]);
601 for (i = 0; i < TX_RING_ENTRIES; i++) {
602 rrpriv->tx_ring[i].size = 0;
603 set_rraddr(&rrpriv->tx_ring[i].addr, 0);
604 rrpriv->tx_skbuff[i] = NULL;
606 rrpriv->info->tx_ctrl.entry_size = sizeof(struct tx_desc);
607 rrpriv->info->tx_ctrl.entries = TX_RING_ENTRIES;
608 rrpriv->info->tx_ctrl.mode = 0;
609 rrpriv->info->tx_ctrl.pi = 0;
610 set_rraddr(&rrpriv->info->tx_ctrl.rngptr, rrpriv->tx_ring_dma);
613 * Set dirty_tx before we start receiving interrupts, otherwise
614 * the interrupt handler might think it is supposed to process
615 * tx ints before we are up and running, which may cause a null
616 * pointer access in the int handler.
620 rrpriv->dirty_rx = rrpriv->dirty_tx = 0;
625 writel(0x5000, ®s->ConRetry);
626 writel(0x100, ®s->ConRetryTmr);
627 writel(0x500000, ®s->ConTmout);
628 writel(0x60, ®s->IntrTmr);
629 writel(0x500000, ®s->TxDataMvTimeout);
630 writel(0x200000, ®s->RxDataMvTimeout);
631 writel(0x80, ®s->WriteDmaThresh);
632 writel(0x80, ®s->ReadDmaThresh);
634 rrpriv->fw_running = 0;
637 hostctrl &= ~(HALT_NIC | INVALID_INST_B | PARITY_ERR);
638 writel(hostctrl, ®s->HostCtrl);
641 spin_unlock_irqrestore(&rrpriv->lock, flags);
643 for (i = 0; i < RX_RING_ENTRIES; i++) {
647 rrpriv->rx_ring[i].mode = 0;
648 skb = alloc_skb(dev->mtu + HIPPI_HLEN, GFP_ATOMIC);
650 printk(KERN_WARNING "%s: Unable to allocate memory "
651 "for receive ring - halting NIC\n", dev->name);
655 rrpriv->rx_skbuff[i] = skb;
656 addr = pci_map_single(rrpriv->pci_dev, skb->data,
657 dev->mtu + HIPPI_HLEN, PCI_DMA_FROMDEVICE);
659 * Sanity test to see if we conflict with the DMA
660 * limitations of the Roadrunner.
662 if ((((unsigned long)skb->data) & 0xfff) > ~65320)
663 printk("skb alloc error\n");
665 set_rraddr(&rrpriv->rx_ring[i].addr, addr);
666 rrpriv->rx_ring[i].size = dev->mtu + HIPPI_HLEN;
669 rrpriv->rx_ctrl[4].entry_size = sizeof(struct rx_desc);
670 rrpriv->rx_ctrl[4].entries = RX_RING_ENTRIES;
671 rrpriv->rx_ctrl[4].mode = 8;
672 rrpriv->rx_ctrl[4].pi = 0;
674 set_rraddr(&rrpriv->rx_ctrl[4].rngptr, rrpriv->rx_ring_dma);
679 * Now start the FirmWare.
681 cmd.code = C_START_FW;
685 rr_issue_cmd(rrpriv, &cmd);
688 * Give the FirmWare time to chew on the `get running' command.
690 myjif = jiffies + 5 * HZ;
691 while (time_before(jiffies, myjif) && !rrpriv->fw_running)
694 netif_start_queue(dev);
700 * We might have gotten here because we are out of memory,
701 * make sure we release everything we allocated before failing
703 for (i = 0; i < RX_RING_ENTRIES; i++) {
704 struct sk_buff *skb = rrpriv->rx_skbuff[i];
707 pci_unmap_single(rrpriv->pci_dev,
708 rrpriv->rx_ring[i].addr.addrlo,
709 dev->mtu + HIPPI_HLEN,
711 rrpriv->rx_ring[i].size = 0;
712 set_rraddr(&rrpriv->rx_ring[i].addr, 0);
714 rrpriv->rx_skbuff[i] = NULL;
722 * All events are considered to be slow (RX/TX ints do not generate
723 * events) and are handled here, outside the main interrupt handler,
724 * to reduce the size of the handler.
726 static u32 rr_handle_event(struct net_device *dev, u32 prodidx, u32 eidx)
728 struct rr_private *rrpriv;
729 struct rr_regs __iomem *regs;
732 rrpriv = netdev_priv(dev);
735 while (prodidx != eidx){
736 switch (rrpriv->evt_ring[eidx].code){
738 tmp = readl(®s->FwRev);
739 printk(KERN_INFO "%s: Firmware revision %i.%i.%i "
740 "up and running\n", dev->name,
741 (tmp >> 16), ((tmp >> 8) & 0xff), (tmp & 0xff));
742 rrpriv->fw_running = 1;
743 writel(RX_RING_ENTRIES - 1, ®s->IpRxPi);
747 printk(KERN_INFO "%s: Optical link ON\n", dev->name);
750 printk(KERN_INFO "%s: Optical link OFF\n", dev->name);
753 printk(KERN_WARNING "%s: RX data not moving\n",
757 printk(KERN_INFO "%s: The watchdog is here to see "
761 printk(KERN_ERR "%s: HIPPI Internal NIC error\n",
763 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
768 printk(KERN_ERR "%s: Host software error\n",
770 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
778 printk(KERN_WARNING "%s: Connection rejected\n",
780 dev->stats.tx_aborted_errors++;
783 printk(KERN_WARNING "%s: Connection timeout\n",
787 printk(KERN_WARNING "%s: HIPPI disconnect error\n",
789 dev->stats.tx_aborted_errors++;
792 printk(KERN_ERR "%s: HIPPI Internal Parity error\n",
794 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
799 printk(KERN_WARNING "%s: Transmitter idle\n",
803 printk(KERN_WARNING "%s: Link lost during transmit\n",
805 dev->stats.tx_aborted_errors++;
806 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
811 printk(KERN_ERR "%s: Invalid send ring block\n",
813 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
818 printk(KERN_ERR "%s: Invalid send buffer address\n",
820 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
825 printk(KERN_ERR "%s: Invalid descriptor address\n",
827 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
835 printk(KERN_INFO "%s: Receive ring full\n", dev->name);
839 printk(KERN_WARNING "%s: Receive parity error\n",
843 printk(KERN_WARNING "%s: Receive LLRC error\n",
847 printk(KERN_WARNING "%s: Receive packet length "
848 "error\n", dev->name);
851 printk(KERN_WARNING "%s: Data checksum error\n",
855 printk(KERN_WARNING "%s: Unexpected short burst "
856 "error\n", dev->name);
859 printk(KERN_WARNING "%s: Recv. state transition"
860 " error\n", dev->name);
863 printk(KERN_WARNING "%s: Unexpected data error\n",
867 printk(KERN_WARNING "%s: Link lost error\n",
871 printk(KERN_WARNING "%s: Framming Error\n",
875 printk(KERN_WARNING "%s: Flag sync. lost during "
876 "packet\n", dev->name);
879 printk(KERN_ERR "%s: Invalid receive buffer "
880 "address\n", dev->name);
881 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
886 printk(KERN_ERR "%s: Invalid receive descriptor "
887 "address\n", dev->name);
888 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
893 printk(KERN_ERR "%s: Invalid ring block\n",
895 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
900 /* Label packet to be dropped.
901 * Actual dropping occurs in rx
904 * The index of packet we get to drop is
905 * the index of the packet following
906 * the bad packet. -kbf
909 u16 index = rrpriv->evt_ring[eidx].index;
910 index = (index + (RX_RING_ENTRIES - 1)) %
912 rrpriv->rx_ring[index].mode |=
913 (PACKET_BAD | PACKET_END);
917 printk(KERN_WARNING "%s: Unhandled event 0x%02x\n",
918 dev->name, rrpriv->evt_ring[eidx].code);
920 eidx = (eidx + 1) % EVT_RING_ENTRIES;
923 rrpriv->info->evt_ctrl.pi = eidx;
929 static void rx_int(struct net_device *dev, u32 rxlimit, u32 index)
931 struct rr_private *rrpriv = netdev_priv(dev);
932 struct rr_regs __iomem *regs = rrpriv->regs;
935 struct rx_desc *desc;
938 desc = &(rrpriv->rx_ring[index]);
939 pkt_len = desc->size;
941 printk("index %i, rxlimit %i\n", index, rxlimit);
942 printk("len %x, mode %x\n", pkt_len, desc->mode);
944 if ( (rrpriv->rx_ring[index].mode & PACKET_BAD) == PACKET_BAD){
945 dev->stats.rx_dropped++;
950 struct sk_buff *skb, *rx_skb;
952 rx_skb = rrpriv->rx_skbuff[index];
954 if (pkt_len < PKT_COPY_THRESHOLD) {
955 skb = alloc_skb(pkt_len, GFP_ATOMIC);
957 printk(KERN_WARNING "%s: Unable to allocate skb (%i bytes), deferring packet\n", dev->name, pkt_len);
958 dev->stats.rx_dropped++;
961 pci_dma_sync_single_for_cpu(rrpriv->pci_dev,
966 memcpy(skb_put(skb, pkt_len),
967 rx_skb->data, pkt_len);
969 pci_dma_sync_single_for_device(rrpriv->pci_dev,
975 struct sk_buff *newskb;
977 newskb = alloc_skb(dev->mtu + HIPPI_HLEN,
982 pci_unmap_single(rrpriv->pci_dev,
983 desc->addr.addrlo, dev->mtu +
984 HIPPI_HLEN, PCI_DMA_FROMDEVICE);
986 skb_put(skb, pkt_len);
987 rrpriv->rx_skbuff[index] = newskb;
988 addr = pci_map_single(rrpriv->pci_dev,
990 dev->mtu + HIPPI_HLEN,
992 set_rraddr(&desc->addr, addr);
994 printk("%s: Out of memory, deferring "
995 "packet\n", dev->name);
996 dev->stats.rx_dropped++;
1000 skb->protocol = hippi_type_trans(skb, dev);
1002 netif_rx(skb); /* send it up */
1004 dev->stats.rx_packets++;
1005 dev->stats.rx_bytes += pkt_len;
1009 desc->size = dev->mtu + HIPPI_HLEN;
1011 if ((index & 7) == 7)
1012 writel(index, ®s->IpRxPi);
1014 index = (index + 1) % RX_RING_ENTRIES;
1015 } while(index != rxlimit);
1017 rrpriv->cur_rx = index;
1022 static irqreturn_t rr_interrupt(int irq, void *dev_id)
1024 struct rr_private *rrpriv;
1025 struct rr_regs __iomem *regs;
1026 struct net_device *dev = (struct net_device *)dev_id;
1027 u32 prodidx, rxindex, eidx, txcsmr, rxlimit, txcon;
1029 rrpriv = netdev_priv(dev);
1030 regs = rrpriv->regs;
1032 if (!(readl(®s->HostCtrl) & RR_INT))
1035 spin_lock(&rrpriv->lock);
1037 prodidx = readl(®s->EvtPrd);
1038 txcsmr = (prodidx >> 8) & 0xff;
1039 rxlimit = (prodidx >> 16) & 0xff;
1043 printk("%s: interrupt, prodidx = %i, eidx = %i\n", dev->name,
1044 prodidx, rrpriv->info->evt_ctrl.pi);
1047 * Order here is important. We must handle events
1048 * before doing anything else in order to catch
1049 * such things as LLRC errors, etc -kbf
1052 eidx = rrpriv->info->evt_ctrl.pi;
1053 if (prodidx != eidx)
1054 eidx = rr_handle_event(dev, prodidx, eidx);
1056 rxindex = rrpriv->cur_rx;
1057 if (rxindex != rxlimit)
1058 rx_int(dev, rxlimit, rxindex);
1060 txcon = rrpriv->dirty_tx;
1061 if (txcsmr != txcon) {
1063 /* Due to occational firmware TX producer/consumer out
1064 * of sync. error need to check entry in ring -kbf
1066 if(rrpriv->tx_skbuff[txcon]){
1067 struct tx_desc *desc;
1068 struct sk_buff *skb;
1070 desc = &(rrpriv->tx_ring[txcon]);
1071 skb = rrpriv->tx_skbuff[txcon];
1073 dev->stats.tx_packets++;
1074 dev->stats.tx_bytes += skb->len;
1076 pci_unmap_single(rrpriv->pci_dev,
1077 desc->addr.addrlo, skb->len,
1079 dev_kfree_skb_irq(skb);
1081 rrpriv->tx_skbuff[txcon] = NULL;
1083 set_rraddr(&rrpriv->tx_ring[txcon].addr, 0);
1086 txcon = (txcon + 1) % TX_RING_ENTRIES;
1087 } while (txcsmr != txcon);
1090 rrpriv->dirty_tx = txcon;
1091 if (rrpriv->tx_full && rr_if_busy(dev) &&
1092 (((rrpriv->info->tx_ctrl.pi + 1) % TX_RING_ENTRIES)
1093 != rrpriv->dirty_tx)){
1094 rrpriv->tx_full = 0;
1095 netif_wake_queue(dev);
1099 eidx |= ((txcsmr << 8) | (rxlimit << 16));
1100 writel(eidx, ®s->EvtCon);
1103 spin_unlock(&rrpriv->lock);
1107 static inline void rr_raz_tx(struct rr_private *rrpriv,
1108 struct net_device *dev)
1112 for (i = 0; i < TX_RING_ENTRIES; i++) {
1113 struct sk_buff *skb = rrpriv->tx_skbuff[i];
1116 struct tx_desc *desc = &(rrpriv->tx_ring[i]);
1118 pci_unmap_single(rrpriv->pci_dev, desc->addr.addrlo,
1119 skb->len, PCI_DMA_TODEVICE);
1121 set_rraddr(&desc->addr, 0);
1123 rrpriv->tx_skbuff[i] = NULL;
1129 static inline void rr_raz_rx(struct rr_private *rrpriv,
1130 struct net_device *dev)
1134 for (i = 0; i < RX_RING_ENTRIES; i++) {
1135 struct sk_buff *skb = rrpriv->rx_skbuff[i];
1138 struct rx_desc *desc = &(rrpriv->rx_ring[i]);
1140 pci_unmap_single(rrpriv->pci_dev, desc->addr.addrlo,
1141 dev->mtu + HIPPI_HLEN, PCI_DMA_FROMDEVICE);
1143 set_rraddr(&desc->addr, 0);
1145 rrpriv->rx_skbuff[i] = NULL;
1150 static void rr_timer(unsigned long data)
1152 struct net_device *dev = (struct net_device *)data;
1153 struct rr_private *rrpriv = netdev_priv(dev);
1154 struct rr_regs __iomem *regs = rrpriv->regs;
1155 unsigned long flags;
1157 if (readl(®s->HostCtrl) & NIC_HALTED){
1158 printk("%s: Restarting nic\n", dev->name);
1159 memset(rrpriv->rx_ctrl, 0, 256 * sizeof(struct ring_ctrl));
1160 memset(rrpriv->info, 0, sizeof(struct rr_info));
1163 rr_raz_tx(rrpriv, dev);
1164 rr_raz_rx(rrpriv, dev);
1166 if (rr_init1(dev)) {
1167 spin_lock_irqsave(&rrpriv->lock, flags);
1168 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
1170 spin_unlock_irqrestore(&rrpriv->lock, flags);
1173 rrpriv->timer.expires = RUN_AT(5*HZ);
1174 add_timer(&rrpriv->timer);
1178 static int rr_open(struct net_device *dev)
1180 struct rr_private *rrpriv = netdev_priv(dev);
1181 struct pci_dev *pdev = rrpriv->pci_dev;
1182 struct rr_regs __iomem *regs;
1184 unsigned long flags;
1185 dma_addr_t dma_addr;
1187 regs = rrpriv->regs;
1189 if (rrpriv->fw_rev < 0x00020000) {
1190 printk(KERN_WARNING "%s: trying to configure device with "
1191 "obsolete firmware\n", dev->name);
1196 rrpriv->rx_ctrl = pci_alloc_consistent(pdev,
1197 256 * sizeof(struct ring_ctrl),
1199 if (!rrpriv->rx_ctrl) {
1203 rrpriv->rx_ctrl_dma = dma_addr;
1204 memset(rrpriv->rx_ctrl, 0, 256*sizeof(struct ring_ctrl));
1206 rrpriv->info = pci_alloc_consistent(pdev, sizeof(struct rr_info),
1208 if (!rrpriv->info) {
1212 rrpriv->info_dma = dma_addr;
1213 memset(rrpriv->info, 0, sizeof(struct rr_info));
1216 spin_lock_irqsave(&rrpriv->lock, flags);
1217 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, ®s->HostCtrl);
1218 readl(®s->HostCtrl);
1219 spin_unlock_irqrestore(&rrpriv->lock, flags);
1221 if (request_irq(pdev->irq, rr_interrupt, IRQF_SHARED, dev->name, dev)) {
1222 printk(KERN_WARNING "%s: Requested IRQ %d is busy\n",
1223 dev->name, pdev->irq);
1228 if ((ecode = rr_init1(dev)))
1231 /* Set the timer to switch to check for link beat and perhaps switch
1232 to an alternate media type. */
1233 init_timer(&rrpriv->timer);
1234 rrpriv->timer.expires = RUN_AT(5*HZ); /* 5 sec. watchdog */
1235 rrpriv->timer.data = (unsigned long)dev;
1236 rrpriv->timer.function = rr_timer; /* timer handler */
1237 add_timer(&rrpriv->timer);
1239 netif_start_queue(dev);
1244 spin_lock_irqsave(&rrpriv->lock, flags);
1245 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, ®s->HostCtrl);
1246 spin_unlock_irqrestore(&rrpriv->lock, flags);
1249 pci_free_consistent(pdev, sizeof(struct rr_info), rrpriv->info,
1251 rrpriv->info = NULL;
1253 if (rrpriv->rx_ctrl) {
1254 pci_free_consistent(pdev, sizeof(struct ring_ctrl),
1255 rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma);
1256 rrpriv->rx_ctrl = NULL;
1259 netif_stop_queue(dev);
1265 static void rr_dump(struct net_device *dev)
1267 struct rr_private *rrpriv;
1268 struct rr_regs __iomem *regs;
1273 rrpriv = netdev_priv(dev);
1274 regs = rrpriv->regs;
1276 printk("%s: dumping NIC TX rings\n", dev->name);
1278 printk("RxPrd %08x, TxPrd %02x, EvtPrd %08x, TxPi %02x, TxCtrlPi %02x\n",
1279 readl(®s->RxPrd), readl(®s->TxPrd),
1280 readl(®s->EvtPrd), readl(®s->TxPi),
1281 rrpriv->info->tx_ctrl.pi);
1283 printk("Error code 0x%x\n", readl(®s->Fail1));
1285 index = (((readl(®s->EvtPrd) >> 8) & 0xff) - 1) % TX_RING_ENTRIES;
1286 cons = rrpriv->dirty_tx;
1287 printk("TX ring index %i, TX consumer %i\n",
1290 if (rrpriv->tx_skbuff[index]){
1291 len = min_t(int, 0x80, rrpriv->tx_skbuff[index]->len);
1292 printk("skbuff for index %i is valid - dumping data (0x%x bytes - DMA len 0x%x)\n", index, len, rrpriv->tx_ring[index].size);
1293 for (i = 0; i < len; i++){
1296 printk("%02x ", (unsigned char) rrpriv->tx_skbuff[index]->data[i]);
1301 if (rrpriv->tx_skbuff[cons]){
1302 len = min_t(int, 0x80, rrpriv->tx_skbuff[cons]->len);
1303 printk("skbuff for cons %i is valid - dumping data (0x%x bytes - skbuff len 0x%x)\n", cons, len, rrpriv->tx_skbuff[cons]->len);
1304 printk("mode 0x%x, size 0x%x,\n phys %08Lx, skbuff-addr %08lx, truesize 0x%x\n",
1305 rrpriv->tx_ring[cons].mode,
1306 rrpriv->tx_ring[cons].size,
1307 (unsigned long long) rrpriv->tx_ring[cons].addr.addrlo,
1308 (unsigned long)rrpriv->tx_skbuff[cons]->data,
1309 (unsigned int)rrpriv->tx_skbuff[cons]->truesize);
1310 for (i = 0; i < len; i++){
1313 printk("%02x ", (unsigned char)rrpriv->tx_ring[cons].size);
1318 printk("dumping TX ring info:\n");
1319 for (i = 0; i < TX_RING_ENTRIES; i++)
1320 printk("mode 0x%x, size 0x%x, phys-addr %08Lx\n",
1321 rrpriv->tx_ring[i].mode,
1322 rrpriv->tx_ring[i].size,
1323 (unsigned long long) rrpriv->tx_ring[i].addr.addrlo);
1328 static int rr_close(struct net_device *dev)
1330 struct rr_private *rrpriv = netdev_priv(dev);
1331 struct rr_regs __iomem *regs = rrpriv->regs;
1332 struct pci_dev *pdev = rrpriv->pci_dev;
1333 unsigned long flags;
1337 netif_stop_queue(dev);
1341 * Lock to make sure we are not cleaning up while another CPU
1342 * is handling interrupts.
1344 spin_lock_irqsave(&rrpriv->lock, flags);
1346 tmp = readl(®s->HostCtrl);
1347 if (tmp & NIC_HALTED){
1348 printk("%s: NIC already halted\n", dev->name);
1351 tmp |= HALT_NIC | RR_CLEAR_INT;
1352 writel(tmp, ®s->HostCtrl);
1353 readl(®s->HostCtrl);
1356 rrpriv->fw_running = 0;
1358 del_timer_sync(&rrpriv->timer);
1360 writel(0, ®s->TxPi);
1361 writel(0, ®s->IpRxPi);
1363 writel(0, ®s->EvtCon);
1364 writel(0, ®s->EvtPrd);
1366 for (i = 0; i < CMD_RING_ENTRIES; i++)
1367 writel(0, ®s->CmdRing[i]);
1369 rrpriv->info->tx_ctrl.entries = 0;
1370 rrpriv->info->cmd_ctrl.pi = 0;
1371 rrpriv->info->evt_ctrl.pi = 0;
1372 rrpriv->rx_ctrl[4].entries = 0;
1374 rr_raz_tx(rrpriv, dev);
1375 rr_raz_rx(rrpriv, dev);
1377 pci_free_consistent(pdev, 256 * sizeof(struct ring_ctrl),
1378 rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma);
1379 rrpriv->rx_ctrl = NULL;
1381 pci_free_consistent(pdev, sizeof(struct rr_info), rrpriv->info,
1383 rrpriv->info = NULL;
1385 free_irq(pdev->irq, dev);
1386 spin_unlock_irqrestore(&rrpriv->lock, flags);
1392 static netdev_tx_t rr_start_xmit(struct sk_buff *skb,
1393 struct net_device *dev)
1395 struct rr_private *rrpriv = netdev_priv(dev);
1396 struct rr_regs __iomem *regs = rrpriv->regs;
1397 struct hippi_cb *hcb = (struct hippi_cb *) skb->cb;
1398 struct ring_ctrl *txctrl;
1399 unsigned long flags;
1400 u32 index, len = skb->len;
1402 struct sk_buff *new_skb;
1404 if (readl(®s->Mode) & FATAL_ERR)
1405 printk("error codes Fail1 %02x, Fail2 %02x\n",
1406 readl(®s->Fail1), readl(®s->Fail2));
1409 * We probably need to deal with tbusy here to prevent overruns.
1412 if (skb_headroom(skb) < 8){
1413 printk("incoming skb too small - reallocating\n");
1414 if (!(new_skb = dev_alloc_skb(len + 8))) {
1416 netif_wake_queue(dev);
1417 return NETDEV_TX_OK;
1419 skb_reserve(new_skb, 8);
1420 skb_put(new_skb, len);
1421 skb_copy_from_linear_data(skb, new_skb->data, len);
1426 ifield = (u32 *)skb_push(skb, 8);
1429 ifield[1] = hcb->ifield;
1432 * We don't need the lock before we are actually going to start
1433 * fiddling with the control blocks.
1435 spin_lock_irqsave(&rrpriv->lock, flags);
1437 txctrl = &rrpriv->info->tx_ctrl;
1441 rrpriv->tx_skbuff[index] = skb;
1442 set_rraddr(&rrpriv->tx_ring[index].addr, pci_map_single(
1443 rrpriv->pci_dev, skb->data, len + 8, PCI_DMA_TODEVICE));
1444 rrpriv->tx_ring[index].size = len + 8; /* include IFIELD */
1445 rrpriv->tx_ring[index].mode = PACKET_START | PACKET_END;
1446 txctrl->pi = (index + 1) % TX_RING_ENTRIES;
1448 writel(txctrl->pi, ®s->TxPi);
1450 if (txctrl->pi == rrpriv->dirty_tx){
1451 rrpriv->tx_full = 1;
1452 netif_stop_queue(dev);
1455 spin_unlock_irqrestore(&rrpriv->lock, flags);
1457 return NETDEV_TX_OK;
1462 * Read the firmware out of the EEPROM and put it into the SRAM
1463 * (or from user space - later)
1465 * This operation requires the NIC to be halted and is performed with
1466 * interrupts disabled and with the spinlock hold.
1468 static int rr_load_firmware(struct net_device *dev)
1470 struct rr_private *rrpriv;
1471 struct rr_regs __iomem *regs;
1472 size_t eptr, segptr;
1474 u32 localctrl, sptr, len, tmp;
1475 u32 p2len, p2size, nr_seg, revision, io, sram_size;
1477 rrpriv = netdev_priv(dev);
1478 regs = rrpriv->regs;
1480 if (dev->flags & IFF_UP)
1483 if (!(readl(®s->HostCtrl) & NIC_HALTED)){
1484 printk("%s: Trying to load firmware to a running NIC.\n",
1489 localctrl = readl(®s->LocalCtrl);
1490 writel(0, ®s->LocalCtrl);
1492 writel(0, ®s->EvtPrd);
1493 writel(0, ®s->RxPrd);
1494 writel(0, ®s->TxPrd);
1497 * First wipe the entire SRAM, otherwise we might run into all
1498 * kinds of trouble ... sigh, this took almost all afternoon
1501 io = readl(®s->ExtIo);
1502 writel(0, ®s->ExtIo);
1503 sram_size = rr_read_eeprom_word(rrpriv, 8);
1505 for (i = 200; i < sram_size / 4; i++){
1506 writel(i * 4, ®s->WinBase);
1508 writel(0, ®s->WinData);
1511 writel(io, ®s->ExtIo);
1514 eptr = rr_read_eeprom_word(rrpriv,
1515 offsetof(struct eeprom, rncd_info.AddrRunCodeSegs));
1516 eptr = ((eptr & 0x1fffff) >> 3);
1518 p2len = rr_read_eeprom_word(rrpriv, 0x83*4);
1519 p2len = (p2len << 2);
1520 p2size = rr_read_eeprom_word(rrpriv, 0x84*4);
1521 p2size = ((p2size & 0x1fffff) >> 3);
1523 if ((eptr < p2size) || (eptr > (p2size + p2len))){
1524 printk("%s: eptr is invalid\n", dev->name);
1528 revision = rr_read_eeprom_word(rrpriv,
1529 offsetof(struct eeprom, manf.HeaderFmt));
1532 printk("%s: invalid firmware format (%i)\n",
1533 dev->name, revision);
1537 nr_seg = rr_read_eeprom_word(rrpriv, eptr);
1540 printk("%s: nr_seg %i\n", dev->name, nr_seg);
1543 for (i = 0; i < nr_seg; i++){
1544 sptr = rr_read_eeprom_word(rrpriv, eptr);
1546 len = rr_read_eeprom_word(rrpriv, eptr);
1548 segptr = rr_read_eeprom_word(rrpriv, eptr);
1549 segptr = ((segptr & 0x1fffff) >> 3);
1552 printk("%s: segment %i, sram address %06x, length %04x, segptr %06x\n",
1553 dev->name, i, sptr, len, segptr);
1555 for (j = 0; j < len; j++){
1556 tmp = rr_read_eeprom_word(rrpriv, segptr);
1557 writel(sptr, ®s->WinBase);
1559 writel(tmp, ®s->WinData);
1567 writel(localctrl, ®s->LocalCtrl);
1573 static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1575 struct rr_private *rrpriv;
1576 unsigned char *image, *oldimage;
1577 unsigned long flags;
1579 int error = -EOPNOTSUPP;
1581 rrpriv = netdev_priv(dev);
1585 if (!capable(CAP_SYS_RAWIO)){
1589 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1593 if (rrpriv->fw_running){
1594 printk("%s: Firmware already running\n", dev->name);
1599 spin_lock_irqsave(&rrpriv->lock, flags);
1600 i = rr_read_eeprom(rrpriv, 0, image, EEPROM_BYTES);
1601 spin_unlock_irqrestore(&rrpriv->lock, flags);
1602 if (i != EEPROM_BYTES){
1603 printk(KERN_ERR "%s: Error reading EEPROM\n",
1608 error = copy_to_user(rq->ifr_data, image, EEPROM_BYTES);
1616 if (!capable(CAP_SYS_RAWIO)){
1620 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1621 oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1622 if (!image || !oldimage) {
1627 error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES);
1633 if (rrpriv->fw_running){
1634 printk("%s: Firmware already running\n", dev->name);
1639 printk("%s: Updating EEPROM firmware\n", dev->name);
1641 spin_lock_irqsave(&rrpriv->lock, flags);
1642 error = write_eeprom(rrpriv, 0, image, EEPROM_BYTES);
1644 printk(KERN_ERR "%s: Error writing EEPROM\n",
1647 i = rr_read_eeprom(rrpriv, 0, oldimage, EEPROM_BYTES);
1648 spin_unlock_irqrestore(&rrpriv->lock, flags);
1650 if (i != EEPROM_BYTES)
1651 printk(KERN_ERR "%s: Error reading back EEPROM "
1652 "image\n", dev->name);
1654 error = memcmp(image, oldimage, EEPROM_BYTES);
1656 printk(KERN_ERR "%s: Error verifying EEPROM image\n",
1666 return put_user(0x52523032, (int __user *)rq->ifr_data);
1672 static DEFINE_PCI_DEVICE_TABLE(rr_pci_tbl) = {
1673 { PCI_VENDOR_ID_ESSENTIAL, PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER,
1674 PCI_ANY_ID, PCI_ANY_ID, },
1677 MODULE_DEVICE_TABLE(pci, rr_pci_tbl);
1679 static struct pci_driver rr_driver = {
1681 .id_table = rr_pci_tbl,
1682 .probe = rr_init_one,
1683 .remove = rr_remove_one,
1686 static int __init rr_init_module(void)
1688 return pci_register_driver(&rr_driver);
1691 static void __exit rr_cleanup_module(void)
1693 pci_unregister_driver(&rr_driver);
1696 module_init(rr_init_module);
1697 module_exit(rr_cleanup_module);