2 * rrunner.c: Linux driver for the Essential RoadRunner HIPPI board.
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))
61 MODULE_DESCRIPTION("Essential RoadRunner HIPPI driver");
62 MODULE_LICENSE("GPL");
64 static char version[] __devinitdata = "rrunner.c: v0.50 11/11/2002 Jes Sorensen (
[email protected])\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 __devinit rr_init_one(struct pci_dev *pdev,
92 const struct pci_device_id *ent)
94 struct net_device *dev;
95 static int version_disp;
97 struct rr_private *rrpriv;
102 dev = alloc_hippi_dev(sizeof(struct rr_private));
106 ret = pci_enable_device(pdev);
112 rrpriv = netdev_priv(dev);
114 SET_NETDEV_DEV(dev, &pdev->dev);
116 ret = pci_request_regions(pdev, "rrunner");
120 pci_set_drvdata(pdev, dev);
122 rrpriv->pci_dev = pdev;
124 spin_lock_init(&rrpriv->lock);
126 dev->netdev_ops = &rr_netdev_ops;
128 /* display version info if adapter is found */
130 /* set display flag to TRUE so that */
131 /* we only display this string ONCE */
136 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency);
137 if (pci_latency <= 0x58){
139 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, pci_latency);
142 pci_set_master(pdev);
144 printk(KERN_INFO "%s: Essential RoadRunner serial HIPPI "
145 "at 0x%llx, irq %i, PCI latency %i\n", dev->name,
146 (unsigned long long)pci_resource_start(pdev, 0),
147 pdev->irq, pci_latency);
150 * Remap the MMIO regs into kernel space.
152 rrpriv->regs = pci_iomap(pdev, 0, 0x1000);
154 printk(KERN_ERR "%s: Unable to map I/O register, "
155 "RoadRunner will be disabled.\n", dev->name);
160 tmpptr = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
161 rrpriv->tx_ring = tmpptr;
162 rrpriv->tx_ring_dma = ring_dma;
169 tmpptr = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
170 rrpriv->rx_ring = tmpptr;
171 rrpriv->rx_ring_dma = ring_dma;
178 tmpptr = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma);
179 rrpriv->evt_ring = tmpptr;
180 rrpriv->evt_ring_dma = ring_dma;
188 * Don't access any register before this point!
191 writel(readl(&rrpriv->regs->HostCtrl) | NO_SWAP,
192 &rrpriv->regs->HostCtrl);
195 * Need to add a case for little-endian 64-bit hosts here.
200 ret = register_netdev(dev);
207 pci_free_consistent(pdev, RX_TOTAL_SIZE, rrpriv->rx_ring,
208 rrpriv->rx_ring_dma);
210 pci_free_consistent(pdev, TX_TOTAL_SIZE, rrpriv->tx_ring,
211 rrpriv->tx_ring_dma);
213 pci_iounmap(pdev, rrpriv->regs);
215 pci_release_regions(pdev);
216 pci_set_drvdata(pdev, NULL);
224 static void __devexit rr_remove_one (struct pci_dev *pdev)
226 struct net_device *dev = pci_get_drvdata(pdev);
227 struct rr_private *rr = netdev_priv(dev);
229 if (!(readl(&rr->regs->HostCtrl) & NIC_HALTED)) {
230 printk(KERN_ERR "%s: trying to unload running NIC\n",
232 writel(HALT_NIC, &rr->regs->HostCtrl);
235 unregister_netdev(dev);
236 pci_free_consistent(pdev, EVT_RING_SIZE, rr->evt_ring,
238 pci_free_consistent(pdev, RX_TOTAL_SIZE, rr->rx_ring,
240 pci_free_consistent(pdev, TX_TOTAL_SIZE, rr->tx_ring,
242 pci_iounmap(pdev, rr->regs);
243 pci_release_regions(pdev);
244 pci_disable_device(pdev);
245 pci_set_drvdata(pdev, NULL);
251 * Commands are considered to be slow, thus there is no reason to
254 static void rr_issue_cmd(struct rr_private *rrpriv, struct cmd *cmd)
256 struct rr_regs __iomem *regs;
261 * This is temporary - it will go away in the final version.
262 * We probably also want to make this function inline.
264 if (readl(®s->HostCtrl) & NIC_HALTED){
265 printk("issuing command for halted NIC, code 0x%x, "
266 "HostCtrl %08x\n", cmd->code, readl(®s->HostCtrl));
267 if (readl(®s->Mode) & FATAL_ERR)
268 printk("error codes Fail1 %02x, Fail2 %02x\n",
269 readl(®s->Fail1), readl(®s->Fail2));
272 idx = rrpriv->info->cmd_ctrl.pi;
274 writel(*(u32*)(cmd), ®s->CmdRing[idx]);
277 idx = (idx - 1) % CMD_RING_ENTRIES;
278 rrpriv->info->cmd_ctrl.pi = idx;
281 if (readl(®s->Mode) & FATAL_ERR)
282 printk("error code %02x\n", readl(®s->Fail1));
287 * Reset the board in a sensible manner. The NIC is already halted
288 * when we get here and a spin-lock is held.
290 static int rr_reset(struct net_device *dev)
292 struct rr_private *rrpriv;
293 struct rr_regs __iomem *regs;
297 rrpriv = netdev_priv(dev);
300 rr_load_firmware(dev);
302 writel(0x01000000, ®s->TX_state);
303 writel(0xff800000, ®s->RX_state);
304 writel(0, ®s->AssistState);
305 writel(CLEAR_INTA, ®s->LocalCtrl);
306 writel(0x01, ®s->BrkPt);
307 writel(0, ®s->Timer);
308 writel(0, ®s->TimerRef);
309 writel(RESET_DMA, ®s->DmaReadState);
310 writel(RESET_DMA, ®s->DmaWriteState);
311 writel(0, ®s->DmaWriteHostHi);
312 writel(0, ®s->DmaWriteHostLo);
313 writel(0, ®s->DmaReadHostHi);
314 writel(0, ®s->DmaReadHostLo);
315 writel(0, ®s->DmaReadLen);
316 writel(0, ®s->DmaWriteLen);
317 writel(0, ®s->DmaWriteLcl);
318 writel(0, ®s->DmaWriteIPchecksum);
319 writel(0, ®s->DmaReadLcl);
320 writel(0, ®s->DmaReadIPchecksum);
321 writel(0, ®s->PciState);
322 #if (BITS_PER_LONG == 64) && defined __LITTLE_ENDIAN
323 writel(SWAP_DATA | PTR64BIT | PTR_WD_SWAP, ®s->Mode);
324 #elif (BITS_PER_LONG == 64)
325 writel(SWAP_DATA | PTR64BIT | PTR_WD_NOSWAP, ®s->Mode);
327 writel(SWAP_DATA | PTR32BIT | PTR_WD_NOSWAP, ®s->Mode);
332 * Don't worry, this is just black magic.
334 writel(0xdf000, ®s->RxBase);
335 writel(0xdf000, ®s->RxPrd);
336 writel(0xdf000, ®s->RxCon);
337 writel(0xce000, ®s->TxBase);
338 writel(0xce000, ®s->TxPrd);
339 writel(0xce000, ®s->TxCon);
340 writel(0, ®s->RxIndPro);
341 writel(0, ®s->RxIndCon);
342 writel(0, ®s->RxIndRef);
343 writel(0, ®s->TxIndPro);
344 writel(0, ®s->TxIndCon);
345 writel(0, ®s->TxIndRef);
346 writel(0xcc000, ®s->pad10[0]);
347 writel(0, ®s->DrCmndPro);
348 writel(0, ®s->DrCmndCon);
349 writel(0, ®s->DwCmndPro);
350 writel(0, ®s->DwCmndCon);
351 writel(0, ®s->DwCmndRef);
352 writel(0, ®s->DrDataPro);
353 writel(0, ®s->DrDataCon);
354 writel(0, ®s->DrDataRef);
355 writel(0, ®s->DwDataPro);
356 writel(0, ®s->DwDataCon);
357 writel(0, ®s->DwDataRef);
360 writel(0xffffffff, ®s->MbEvent);
361 writel(0, ®s->Event);
363 writel(0, ®s->TxPi);
364 writel(0, ®s->IpRxPi);
366 writel(0, ®s->EvtCon);
367 writel(0, ®s->EvtPrd);
369 rrpriv->info->evt_ctrl.pi = 0;
371 for (i = 0; i < CMD_RING_ENTRIES; i++)
372 writel(0, ®s->CmdRing[i]);
375 * Why 32 ? is this not cache line size dependent?
377 writel(RBURST_64|WBURST_64, ®s->PciState);
380 start_pc = rr_read_eeprom_word(rrpriv,
381 offsetof(struct eeprom, rncd_info.FwStart));
384 printk("%s: Executing firmware at address 0x%06x\n",
385 dev->name, start_pc);
388 writel(start_pc + 0x800, ®s->Pc);
392 writel(start_pc, ®s->Pc);
400 * Read a string from the EEPROM.
402 static unsigned int rr_read_eeprom(struct rr_private *rrpriv,
403 unsigned long offset,
405 unsigned long length)
407 struct rr_regs __iomem *regs = rrpriv->regs;
408 u32 misc, io, host, i;
410 io = readl(®s->ExtIo);
411 writel(0, ®s->ExtIo);
412 misc = readl(®s->LocalCtrl);
413 writel(0, ®s->LocalCtrl);
414 host = readl(®s->HostCtrl);
415 writel(host | HALT_NIC, ®s->HostCtrl);
418 for (i = 0; i < length; i++){
419 writel((EEPROM_BASE + ((offset+i) << 3)), ®s->WinBase);
421 buf[i] = (readl(®s->WinData) >> 24) & 0xff;
425 writel(host, ®s->HostCtrl);
426 writel(misc, ®s->LocalCtrl);
427 writel(io, ®s->ExtIo);
434 * Shortcut to read one word (4 bytes) out of the EEPROM and convert
435 * it to our CPU byte-order.
437 static u32 rr_read_eeprom_word(struct rr_private *rrpriv,
442 if ((rr_read_eeprom(rrpriv, offset,
443 (unsigned char *)&word, 4) == 4))
444 return be32_to_cpu(word);
450 * Write a string to the EEPROM.
452 * This is only called when the firmware is not running.
454 static unsigned int write_eeprom(struct rr_private *rrpriv,
455 unsigned long offset,
457 unsigned long length)
459 struct rr_regs __iomem *regs = rrpriv->regs;
460 u32 misc, io, data, i, j, ready, error = 0;
462 io = readl(®s->ExtIo);
463 writel(0, ®s->ExtIo);
464 misc = readl(®s->LocalCtrl);
465 writel(ENABLE_EEPROM_WRITE, ®s->LocalCtrl);
468 for (i = 0; i < length; i++){
469 writel((EEPROM_BASE + ((offset+i) << 3)), ®s->WinBase);
473 * Only try to write the data if it is not the same
476 if ((readl(®s->WinData) & 0xff000000) != data){
477 writel(data, ®s->WinData);
483 if ((readl(®s->WinData) & 0xff000000) ==
488 printk("data mismatch: %08x, "
489 "WinData %08x\n", data,
490 readl(®s->WinData));
498 writel(misc, ®s->LocalCtrl);
499 writel(io, ®s->ExtIo);
506 static int __devinit rr_init(struct net_device *dev)
508 struct rr_private *rrpriv;
509 struct rr_regs __iomem *regs;
512 rrpriv = netdev_priv(dev);
515 rev = readl(®s->FwRev);
516 rrpriv->fw_rev = rev;
517 if (rev > 0x00020024)
518 printk(" Firmware revision: %i.%i.%i\n", (rev >> 16),
519 ((rev >> 8) & 0xff), (rev & 0xff));
520 else if (rev >= 0x00020000) {
521 printk(" Firmware revision: %i.%i.%i (2.0.37 or "
522 "later is recommended)\n", (rev >> 16),
523 ((rev >> 8) & 0xff), (rev & 0xff));
525 printk(" Firmware revision too old: %i.%i.%i, please "
526 "upgrade to 2.0.37 or later.\n",
527 (rev >> 16), ((rev >> 8) & 0xff), (rev & 0xff));
531 printk(" Maximum receive rings %i\n", readl(®s->MaxRxRng));
535 * Read the hardware address from the eeprom. The HW address
536 * is not really necessary for HIPPI but awfully convenient.
537 * The pointer arithmetic to put it in dev_addr is ugly, but
538 * Donald Becker does it this way for the GigE version of this
539 * card and it's shorter and more portable than any
540 * other method I've seen. -VAL
543 *(__be16 *)(dev->dev_addr) =
544 htons(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA)));
545 *(__be32 *)(dev->dev_addr+2) =
546 htonl(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA[4])));
548 printk(" MAC: %pM\n", dev->dev_addr);
550 sram_size = rr_read_eeprom_word(rrpriv, 8);
551 printk(" SRAM size 0x%06x\n", sram_size);
557 static int rr_init1(struct net_device *dev)
559 struct rr_private *rrpriv;
560 struct rr_regs __iomem *regs;
561 unsigned long myjif, flags;
567 rrpriv = netdev_priv(dev);
570 spin_lock_irqsave(&rrpriv->lock, flags);
572 hostctrl = readl(®s->HostCtrl);
573 writel(hostctrl | HALT_NIC | RR_CLEAR_INT, ®s->HostCtrl);
576 if (hostctrl & PARITY_ERR){
577 printk("%s: Parity error halting NIC - this is serious!\n",
579 spin_unlock_irqrestore(&rrpriv->lock, flags);
584 set_rxaddr(regs, rrpriv->rx_ctrl_dma);
585 set_infoaddr(regs, rrpriv->info_dma);
587 rrpriv->info->evt_ctrl.entry_size = sizeof(struct event);
588 rrpriv->info->evt_ctrl.entries = EVT_RING_ENTRIES;
589 rrpriv->info->evt_ctrl.mode = 0;
590 rrpriv->info->evt_ctrl.pi = 0;
591 set_rraddr(&rrpriv->info->evt_ctrl.rngptr, rrpriv->evt_ring_dma);
593 rrpriv->info->cmd_ctrl.entry_size = sizeof(struct cmd);
594 rrpriv->info->cmd_ctrl.entries = CMD_RING_ENTRIES;
595 rrpriv->info->cmd_ctrl.mode = 0;
596 rrpriv->info->cmd_ctrl.pi = 15;
598 for (i = 0; i < CMD_RING_ENTRIES; i++) {
599 writel(0, ®s->CmdRing[i]);
602 for (i = 0; i < TX_RING_ENTRIES; i++) {
603 rrpriv->tx_ring[i].size = 0;
604 set_rraddr(&rrpriv->tx_ring[i].addr, 0);
605 rrpriv->tx_skbuff[i] = NULL;
607 rrpriv->info->tx_ctrl.entry_size = sizeof(struct tx_desc);
608 rrpriv->info->tx_ctrl.entries = TX_RING_ENTRIES;
609 rrpriv->info->tx_ctrl.mode = 0;
610 rrpriv->info->tx_ctrl.pi = 0;
611 set_rraddr(&rrpriv->info->tx_ctrl.rngptr, rrpriv->tx_ring_dma);
614 * Set dirty_tx before we start receiving interrupts, otherwise
615 * the interrupt handler might think it is supposed to process
616 * tx ints before we are up and running, which may cause a null
617 * pointer access in the int handler.
621 rrpriv->dirty_rx = rrpriv->dirty_tx = 0;
626 writel(0x5000, ®s->ConRetry);
627 writel(0x100, ®s->ConRetryTmr);
628 writel(0x500000, ®s->ConTmout);
629 writel(0x60, ®s->IntrTmr);
630 writel(0x500000, ®s->TxDataMvTimeout);
631 writel(0x200000, ®s->RxDataMvTimeout);
632 writel(0x80, ®s->WriteDmaThresh);
633 writel(0x80, ®s->ReadDmaThresh);
635 rrpriv->fw_running = 0;
638 hostctrl &= ~(HALT_NIC | INVALID_INST_B | PARITY_ERR);
639 writel(hostctrl, ®s->HostCtrl);
642 spin_unlock_irqrestore(&rrpriv->lock, flags);
644 for (i = 0; i < RX_RING_ENTRIES; i++) {
648 rrpriv->rx_ring[i].mode = 0;
649 skb = alloc_skb(dev->mtu + HIPPI_HLEN, GFP_ATOMIC);
651 printk(KERN_WARNING "%s: Unable to allocate memory "
652 "for receive ring - halting NIC\n", dev->name);
656 rrpriv->rx_skbuff[i] = skb;
657 addr = pci_map_single(rrpriv->pci_dev, skb->data,
658 dev->mtu + HIPPI_HLEN, PCI_DMA_FROMDEVICE);
660 * Sanity test to see if we conflict with the DMA
661 * limitations of the Roadrunner.
663 if ((((unsigned long)skb->data) & 0xfff) > ~65320)
664 printk("skb alloc error\n");
666 set_rraddr(&rrpriv->rx_ring[i].addr, addr);
667 rrpriv->rx_ring[i].size = dev->mtu + HIPPI_HLEN;
670 rrpriv->rx_ctrl[4].entry_size = sizeof(struct rx_desc);
671 rrpriv->rx_ctrl[4].entries = RX_RING_ENTRIES;
672 rrpriv->rx_ctrl[4].mode = 8;
673 rrpriv->rx_ctrl[4].pi = 0;
675 set_rraddr(&rrpriv->rx_ctrl[4].rngptr, rrpriv->rx_ring_dma);
680 * Now start the FirmWare.
682 cmd.code = C_START_FW;
686 rr_issue_cmd(rrpriv, &cmd);
689 * Give the FirmWare time to chew on the `get running' command.
691 myjif = jiffies + 5 * HZ;
692 while (time_before(jiffies, myjif) && !rrpriv->fw_running)
695 netif_start_queue(dev);
701 * We might have gotten here because we are out of memory,
702 * make sure we release everything we allocated before failing
704 for (i = 0; i < RX_RING_ENTRIES; i++) {
705 struct sk_buff *skb = rrpriv->rx_skbuff[i];
708 pci_unmap_single(rrpriv->pci_dev,
709 rrpriv->rx_ring[i].addr.addrlo,
710 dev->mtu + HIPPI_HLEN,
712 rrpriv->rx_ring[i].size = 0;
713 set_rraddr(&rrpriv->rx_ring[i].addr, 0);
715 rrpriv->rx_skbuff[i] = NULL;
723 * All events are considered to be slow (RX/TX ints do not generate
724 * events) and are handled here, outside the main interrupt handler,
725 * to reduce the size of the handler.
727 static u32 rr_handle_event(struct net_device *dev, u32 prodidx, u32 eidx)
729 struct rr_private *rrpriv;
730 struct rr_regs __iomem *regs;
733 rrpriv = netdev_priv(dev);
736 while (prodidx != eidx){
737 switch (rrpriv->evt_ring[eidx].code){
739 tmp = readl(®s->FwRev);
740 printk(KERN_INFO "%s: Firmware revision %i.%i.%i "
741 "up and running\n", dev->name,
742 (tmp >> 16), ((tmp >> 8) & 0xff), (tmp & 0xff));
743 rrpriv->fw_running = 1;
744 writel(RX_RING_ENTRIES - 1, ®s->IpRxPi);
748 printk(KERN_INFO "%s: Optical link ON\n", dev->name);
751 printk(KERN_INFO "%s: Optical link OFF\n", dev->name);
754 printk(KERN_WARNING "%s: RX data not moving\n",
758 printk(KERN_INFO "%s: The watchdog is here to see "
762 printk(KERN_ERR "%s: HIPPI Internal NIC error\n",
764 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
769 printk(KERN_ERR "%s: Host software error\n",
771 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
779 printk(KERN_WARNING "%s: Connection rejected\n",
781 dev->stats.tx_aborted_errors++;
784 printk(KERN_WARNING "%s: Connection timeout\n",
788 printk(KERN_WARNING "%s: HIPPI disconnect error\n",
790 dev->stats.tx_aborted_errors++;
793 printk(KERN_ERR "%s: HIPPI Internal Parity error\n",
795 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
800 printk(KERN_WARNING "%s: Transmitter idle\n",
804 printk(KERN_WARNING "%s: Link lost during transmit\n",
806 dev->stats.tx_aborted_errors++;
807 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
812 printk(KERN_ERR "%s: Invalid send ring block\n",
814 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
819 printk(KERN_ERR "%s: Invalid send buffer address\n",
821 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
826 printk(KERN_ERR "%s: Invalid descriptor address\n",
828 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
836 printk(KERN_INFO "%s: Receive ring full\n", dev->name);
840 printk(KERN_WARNING "%s: Receive parity error\n",
844 printk(KERN_WARNING "%s: Receive LLRC error\n",
848 printk(KERN_WARNING "%s: Receive packet length "
849 "error\n", dev->name);
852 printk(KERN_WARNING "%s: Data checksum error\n",
856 printk(KERN_WARNING "%s: Unexpected short burst "
857 "error\n", dev->name);
860 printk(KERN_WARNING "%s: Recv. state transition"
861 " error\n", dev->name);
864 printk(KERN_WARNING "%s: Unexpected data error\n",
868 printk(KERN_WARNING "%s: Link lost error\n",
872 printk(KERN_WARNING "%s: Framming Error\n",
876 printk(KERN_WARNING "%s: Flag sync. lost during "
877 "packet\n", dev->name);
880 printk(KERN_ERR "%s: Invalid receive buffer "
881 "address\n", dev->name);
882 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
887 printk(KERN_ERR "%s: Invalid receive descriptor "
888 "address\n", dev->name);
889 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
894 printk(KERN_ERR "%s: Invalid ring block\n",
896 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
901 /* Label packet to be dropped.
902 * Actual dropping occurs in rx
905 * The index of packet we get to drop is
906 * the index of the packet following
907 * the bad packet. -kbf
910 u16 index = rrpriv->evt_ring[eidx].index;
911 index = (index + (RX_RING_ENTRIES - 1)) %
913 rrpriv->rx_ring[index].mode |=
914 (PACKET_BAD | PACKET_END);
918 printk(KERN_WARNING "%s: Unhandled event 0x%02x\n",
919 dev->name, rrpriv->evt_ring[eidx].code);
921 eidx = (eidx + 1) % EVT_RING_ENTRIES;
924 rrpriv->info->evt_ctrl.pi = eidx;
930 static void rx_int(struct net_device *dev, u32 rxlimit, u32 index)
932 struct rr_private *rrpriv = netdev_priv(dev);
933 struct rr_regs __iomem *regs = rrpriv->regs;
936 struct rx_desc *desc;
939 desc = &(rrpriv->rx_ring[index]);
940 pkt_len = desc->size;
942 printk("index %i, rxlimit %i\n", index, rxlimit);
943 printk("len %x, mode %x\n", pkt_len, desc->mode);
945 if ( (rrpriv->rx_ring[index].mode & PACKET_BAD) == PACKET_BAD){
946 dev->stats.rx_dropped++;
951 struct sk_buff *skb, *rx_skb;
953 rx_skb = rrpriv->rx_skbuff[index];
955 if (pkt_len < PKT_COPY_THRESHOLD) {
956 skb = alloc_skb(pkt_len, GFP_ATOMIC);
958 printk(KERN_WARNING "%s: Unable to allocate skb (%i bytes), deferring packet\n", dev->name, pkt_len);
959 dev->stats.rx_dropped++;
962 pci_dma_sync_single_for_cpu(rrpriv->pci_dev,
967 memcpy(skb_put(skb, pkt_len),
968 rx_skb->data, pkt_len);
970 pci_dma_sync_single_for_device(rrpriv->pci_dev,
976 struct sk_buff *newskb;
978 newskb = alloc_skb(dev->mtu + HIPPI_HLEN,
983 pci_unmap_single(rrpriv->pci_dev,
984 desc->addr.addrlo, dev->mtu +
985 HIPPI_HLEN, PCI_DMA_FROMDEVICE);
987 skb_put(skb, pkt_len);
988 rrpriv->rx_skbuff[index] = newskb;
989 addr = pci_map_single(rrpriv->pci_dev,
991 dev->mtu + HIPPI_HLEN,
993 set_rraddr(&desc->addr, addr);
995 printk("%s: Out of memory, deferring "
996 "packet\n", dev->name);
997 dev->stats.rx_dropped++;
1001 skb->protocol = hippi_type_trans(skb, dev);
1003 netif_rx(skb); /* send it up */
1005 dev->stats.rx_packets++;
1006 dev->stats.rx_bytes += pkt_len;
1010 desc->size = dev->mtu + HIPPI_HLEN;
1012 if ((index & 7) == 7)
1013 writel(index, ®s->IpRxPi);
1015 index = (index + 1) % RX_RING_ENTRIES;
1016 } while(index != rxlimit);
1018 rrpriv->cur_rx = index;
1023 static irqreturn_t rr_interrupt(int irq, void *dev_id)
1025 struct rr_private *rrpriv;
1026 struct rr_regs __iomem *regs;
1027 struct net_device *dev = (struct net_device *)dev_id;
1028 u32 prodidx, rxindex, eidx, txcsmr, rxlimit, txcon;
1030 rrpriv = netdev_priv(dev);
1031 regs = rrpriv->regs;
1033 if (!(readl(®s->HostCtrl) & RR_INT))
1036 spin_lock(&rrpriv->lock);
1038 prodidx = readl(®s->EvtPrd);
1039 txcsmr = (prodidx >> 8) & 0xff;
1040 rxlimit = (prodidx >> 16) & 0xff;
1044 printk("%s: interrupt, prodidx = %i, eidx = %i\n", dev->name,
1045 prodidx, rrpriv->info->evt_ctrl.pi);
1048 * Order here is important. We must handle events
1049 * before doing anything else in order to catch
1050 * such things as LLRC errors, etc -kbf
1053 eidx = rrpriv->info->evt_ctrl.pi;
1054 if (prodidx != eidx)
1055 eidx = rr_handle_event(dev, prodidx, eidx);
1057 rxindex = rrpriv->cur_rx;
1058 if (rxindex != rxlimit)
1059 rx_int(dev, rxlimit, rxindex);
1061 txcon = rrpriv->dirty_tx;
1062 if (txcsmr != txcon) {
1064 /* Due to occational firmware TX producer/consumer out
1065 * of sync. error need to check entry in ring -kbf
1067 if(rrpriv->tx_skbuff[txcon]){
1068 struct tx_desc *desc;
1069 struct sk_buff *skb;
1071 desc = &(rrpriv->tx_ring[txcon]);
1072 skb = rrpriv->tx_skbuff[txcon];
1074 dev->stats.tx_packets++;
1075 dev->stats.tx_bytes += skb->len;
1077 pci_unmap_single(rrpriv->pci_dev,
1078 desc->addr.addrlo, skb->len,
1080 dev_kfree_skb_irq(skb);
1082 rrpriv->tx_skbuff[txcon] = NULL;
1084 set_rraddr(&rrpriv->tx_ring[txcon].addr, 0);
1087 txcon = (txcon + 1) % TX_RING_ENTRIES;
1088 } while (txcsmr != txcon);
1091 rrpriv->dirty_tx = txcon;
1092 if (rrpriv->tx_full && rr_if_busy(dev) &&
1093 (((rrpriv->info->tx_ctrl.pi + 1) % TX_RING_ENTRIES)
1094 != rrpriv->dirty_tx)){
1095 rrpriv->tx_full = 0;
1096 netif_wake_queue(dev);
1100 eidx |= ((txcsmr << 8) | (rxlimit << 16));
1101 writel(eidx, ®s->EvtCon);
1104 spin_unlock(&rrpriv->lock);
1108 static inline void rr_raz_tx(struct rr_private *rrpriv,
1109 struct net_device *dev)
1113 for (i = 0; i < TX_RING_ENTRIES; i++) {
1114 struct sk_buff *skb = rrpriv->tx_skbuff[i];
1117 struct tx_desc *desc = &(rrpriv->tx_ring[i]);
1119 pci_unmap_single(rrpriv->pci_dev, desc->addr.addrlo,
1120 skb->len, PCI_DMA_TODEVICE);
1122 set_rraddr(&desc->addr, 0);
1124 rrpriv->tx_skbuff[i] = NULL;
1130 static inline void rr_raz_rx(struct rr_private *rrpriv,
1131 struct net_device *dev)
1135 for (i = 0; i < RX_RING_ENTRIES; i++) {
1136 struct sk_buff *skb = rrpriv->rx_skbuff[i];
1139 struct rx_desc *desc = &(rrpriv->rx_ring[i]);
1141 pci_unmap_single(rrpriv->pci_dev, desc->addr.addrlo,
1142 dev->mtu + HIPPI_HLEN, PCI_DMA_FROMDEVICE);
1144 set_rraddr(&desc->addr, 0);
1146 rrpriv->rx_skbuff[i] = NULL;
1151 static void rr_timer(unsigned long data)
1153 struct net_device *dev = (struct net_device *)data;
1154 struct rr_private *rrpriv = netdev_priv(dev);
1155 struct rr_regs __iomem *regs = rrpriv->regs;
1156 unsigned long flags;
1158 if (readl(®s->HostCtrl) & NIC_HALTED){
1159 printk("%s: Restarting nic\n", dev->name);
1160 memset(rrpriv->rx_ctrl, 0, 256 * sizeof(struct ring_ctrl));
1161 memset(rrpriv->info, 0, sizeof(struct rr_info));
1164 rr_raz_tx(rrpriv, dev);
1165 rr_raz_rx(rrpriv, dev);
1167 if (rr_init1(dev)) {
1168 spin_lock_irqsave(&rrpriv->lock, flags);
1169 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
1171 spin_unlock_irqrestore(&rrpriv->lock, flags);
1174 rrpriv->timer.expires = RUN_AT(5*HZ);
1175 add_timer(&rrpriv->timer);
1179 static int rr_open(struct net_device *dev)
1181 struct rr_private *rrpriv = netdev_priv(dev);
1182 struct pci_dev *pdev = rrpriv->pci_dev;
1183 struct rr_regs __iomem *regs;
1185 unsigned long flags;
1186 dma_addr_t dma_addr;
1188 regs = rrpriv->regs;
1190 if (rrpriv->fw_rev < 0x00020000) {
1191 printk(KERN_WARNING "%s: trying to configure device with "
1192 "obsolete firmware\n", dev->name);
1197 rrpriv->rx_ctrl = pci_alloc_consistent(pdev,
1198 256 * sizeof(struct ring_ctrl),
1200 if (!rrpriv->rx_ctrl) {
1204 rrpriv->rx_ctrl_dma = dma_addr;
1205 memset(rrpriv->rx_ctrl, 0, 256*sizeof(struct ring_ctrl));
1207 rrpriv->info = pci_alloc_consistent(pdev, sizeof(struct rr_info),
1209 if (!rrpriv->info) {
1213 rrpriv->info_dma = dma_addr;
1214 memset(rrpriv->info, 0, sizeof(struct rr_info));
1217 spin_lock_irqsave(&rrpriv->lock, flags);
1218 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, ®s->HostCtrl);
1219 readl(®s->HostCtrl);
1220 spin_unlock_irqrestore(&rrpriv->lock, flags);
1222 if (request_irq(pdev->irq, rr_interrupt, IRQF_SHARED, dev->name, dev)) {
1223 printk(KERN_WARNING "%s: Requested IRQ %d is busy\n",
1224 dev->name, pdev->irq);
1229 if ((ecode = rr_init1(dev)))
1232 /* Set the timer to switch to check for link beat and perhaps switch
1233 to an alternate media type. */
1234 init_timer(&rrpriv->timer);
1235 rrpriv->timer.expires = RUN_AT(5*HZ); /* 5 sec. watchdog */
1236 rrpriv->timer.data = (unsigned long)dev;
1237 rrpriv->timer.function = rr_timer; /* timer handler */
1238 add_timer(&rrpriv->timer);
1240 netif_start_queue(dev);
1245 spin_lock_irqsave(&rrpriv->lock, flags);
1246 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, ®s->HostCtrl);
1247 spin_unlock_irqrestore(&rrpriv->lock, flags);
1250 pci_free_consistent(pdev, sizeof(struct rr_info), rrpriv->info,
1252 rrpriv->info = NULL;
1254 if (rrpriv->rx_ctrl) {
1255 pci_free_consistent(pdev, sizeof(struct ring_ctrl),
1256 rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma);
1257 rrpriv->rx_ctrl = NULL;
1260 netif_stop_queue(dev);
1266 static void rr_dump(struct net_device *dev)
1268 struct rr_private *rrpriv;
1269 struct rr_regs __iomem *regs;
1274 rrpriv = netdev_priv(dev);
1275 regs = rrpriv->regs;
1277 printk("%s: dumping NIC TX rings\n", dev->name);
1279 printk("RxPrd %08x, TxPrd %02x, EvtPrd %08x, TxPi %02x, TxCtrlPi %02x\n",
1280 readl(®s->RxPrd), readl(®s->TxPrd),
1281 readl(®s->EvtPrd), readl(®s->TxPi),
1282 rrpriv->info->tx_ctrl.pi);
1284 printk("Error code 0x%x\n", readl(®s->Fail1));
1286 index = (((readl(®s->EvtPrd) >> 8) & 0xff) - 1) % TX_RING_ENTRIES;
1287 cons = rrpriv->dirty_tx;
1288 printk("TX ring index %i, TX consumer %i\n",
1291 if (rrpriv->tx_skbuff[index]){
1292 len = min_t(int, 0x80, rrpriv->tx_skbuff[index]->len);
1293 printk("skbuff for index %i is valid - dumping data (0x%x bytes - DMA len 0x%x)\n", index, len, rrpriv->tx_ring[index].size);
1294 for (i = 0; i < len; i++){
1297 printk("%02x ", (unsigned char) rrpriv->tx_skbuff[index]->data[i]);
1302 if (rrpriv->tx_skbuff[cons]){
1303 len = min_t(int, 0x80, rrpriv->tx_skbuff[cons]->len);
1304 printk("skbuff for cons %i is valid - dumping data (0x%x bytes - skbuff len 0x%x)\n", cons, len, rrpriv->tx_skbuff[cons]->len);
1305 printk("mode 0x%x, size 0x%x,\n phys %08Lx, skbuff-addr %08lx, truesize 0x%x\n",
1306 rrpriv->tx_ring[cons].mode,
1307 rrpriv->tx_ring[cons].size,
1308 (unsigned long long) rrpriv->tx_ring[cons].addr.addrlo,
1309 (unsigned long)rrpriv->tx_skbuff[cons]->data,
1310 (unsigned int)rrpriv->tx_skbuff[cons]->truesize);
1311 for (i = 0; i < len; i++){
1314 printk("%02x ", (unsigned char)rrpriv->tx_ring[cons].size);
1319 printk("dumping TX ring info:\n");
1320 for (i = 0; i < TX_RING_ENTRIES; i++)
1321 printk("mode 0x%x, size 0x%x, phys-addr %08Lx\n",
1322 rrpriv->tx_ring[i].mode,
1323 rrpriv->tx_ring[i].size,
1324 (unsigned long long) rrpriv->tx_ring[i].addr.addrlo);
1329 static int rr_close(struct net_device *dev)
1331 struct rr_private *rrpriv = netdev_priv(dev);
1332 struct rr_regs __iomem *regs = rrpriv->regs;
1333 struct pci_dev *pdev = rrpriv->pci_dev;
1334 unsigned long flags;
1338 netif_stop_queue(dev);
1342 * Lock to make sure we are not cleaning up while another CPU
1343 * is handling interrupts.
1345 spin_lock_irqsave(&rrpriv->lock, flags);
1347 tmp = readl(®s->HostCtrl);
1348 if (tmp & NIC_HALTED){
1349 printk("%s: NIC already halted\n", dev->name);
1352 tmp |= HALT_NIC | RR_CLEAR_INT;
1353 writel(tmp, ®s->HostCtrl);
1354 readl(®s->HostCtrl);
1357 rrpriv->fw_running = 0;
1359 del_timer_sync(&rrpriv->timer);
1361 writel(0, ®s->TxPi);
1362 writel(0, ®s->IpRxPi);
1364 writel(0, ®s->EvtCon);
1365 writel(0, ®s->EvtPrd);
1367 for (i = 0; i < CMD_RING_ENTRIES; i++)
1368 writel(0, ®s->CmdRing[i]);
1370 rrpriv->info->tx_ctrl.entries = 0;
1371 rrpriv->info->cmd_ctrl.pi = 0;
1372 rrpriv->info->evt_ctrl.pi = 0;
1373 rrpriv->rx_ctrl[4].entries = 0;
1375 rr_raz_tx(rrpriv, dev);
1376 rr_raz_rx(rrpriv, dev);
1378 pci_free_consistent(pdev, 256 * sizeof(struct ring_ctrl),
1379 rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma);
1380 rrpriv->rx_ctrl = NULL;
1382 pci_free_consistent(pdev, sizeof(struct rr_info), rrpriv->info,
1384 rrpriv->info = NULL;
1386 free_irq(pdev->irq, dev);
1387 spin_unlock_irqrestore(&rrpriv->lock, flags);
1393 static netdev_tx_t rr_start_xmit(struct sk_buff *skb,
1394 struct net_device *dev)
1396 struct rr_private *rrpriv = netdev_priv(dev);
1397 struct rr_regs __iomem *regs = rrpriv->regs;
1398 struct hippi_cb *hcb = (struct hippi_cb *) skb->cb;
1399 struct ring_ctrl *txctrl;
1400 unsigned long flags;
1401 u32 index, len = skb->len;
1403 struct sk_buff *new_skb;
1405 if (readl(®s->Mode) & FATAL_ERR)
1406 printk("error codes Fail1 %02x, Fail2 %02x\n",
1407 readl(®s->Fail1), readl(®s->Fail2));
1410 * We probably need to deal with tbusy here to prevent overruns.
1413 if (skb_headroom(skb) < 8){
1414 printk("incoming skb too small - reallocating\n");
1415 if (!(new_skb = dev_alloc_skb(len + 8))) {
1417 netif_wake_queue(dev);
1418 return NETDEV_TX_OK;
1420 skb_reserve(new_skb, 8);
1421 skb_put(new_skb, len);
1422 skb_copy_from_linear_data(skb, new_skb->data, len);
1427 ifield = (u32 *)skb_push(skb, 8);
1430 ifield[1] = hcb->ifield;
1433 * We don't need the lock before we are actually going to start
1434 * fiddling with the control blocks.
1436 spin_lock_irqsave(&rrpriv->lock, flags);
1438 txctrl = &rrpriv->info->tx_ctrl;
1442 rrpriv->tx_skbuff[index] = skb;
1443 set_rraddr(&rrpriv->tx_ring[index].addr, pci_map_single(
1444 rrpriv->pci_dev, skb->data, len + 8, PCI_DMA_TODEVICE));
1445 rrpriv->tx_ring[index].size = len + 8; /* include IFIELD */
1446 rrpriv->tx_ring[index].mode = PACKET_START | PACKET_END;
1447 txctrl->pi = (index + 1) % TX_RING_ENTRIES;
1449 writel(txctrl->pi, ®s->TxPi);
1451 if (txctrl->pi == rrpriv->dirty_tx){
1452 rrpriv->tx_full = 1;
1453 netif_stop_queue(dev);
1456 spin_unlock_irqrestore(&rrpriv->lock, flags);
1458 return NETDEV_TX_OK;
1463 * Read the firmware out of the EEPROM and put it into the SRAM
1464 * (or from user space - later)
1466 * This operation requires the NIC to be halted and is performed with
1467 * interrupts disabled and with the spinlock hold.
1469 static int rr_load_firmware(struct net_device *dev)
1471 struct rr_private *rrpriv;
1472 struct rr_regs __iomem *regs;
1473 size_t eptr, segptr;
1475 u32 localctrl, sptr, len, tmp;
1476 u32 p2len, p2size, nr_seg, revision, io, sram_size;
1478 rrpriv = netdev_priv(dev);
1479 regs = rrpriv->regs;
1481 if (dev->flags & IFF_UP)
1484 if (!(readl(®s->HostCtrl) & NIC_HALTED)){
1485 printk("%s: Trying to load firmware to a running NIC.\n",
1490 localctrl = readl(®s->LocalCtrl);
1491 writel(0, ®s->LocalCtrl);
1493 writel(0, ®s->EvtPrd);
1494 writel(0, ®s->RxPrd);
1495 writel(0, ®s->TxPrd);
1498 * First wipe the entire SRAM, otherwise we might run into all
1499 * kinds of trouble ... sigh, this took almost all afternoon
1502 io = readl(®s->ExtIo);
1503 writel(0, ®s->ExtIo);
1504 sram_size = rr_read_eeprom_word(rrpriv, 8);
1506 for (i = 200; i < sram_size / 4; i++){
1507 writel(i * 4, ®s->WinBase);
1509 writel(0, ®s->WinData);
1512 writel(io, ®s->ExtIo);
1515 eptr = rr_read_eeprom_word(rrpriv,
1516 offsetof(struct eeprom, rncd_info.AddrRunCodeSegs));
1517 eptr = ((eptr & 0x1fffff) >> 3);
1519 p2len = rr_read_eeprom_word(rrpriv, 0x83*4);
1520 p2len = (p2len << 2);
1521 p2size = rr_read_eeprom_word(rrpriv, 0x84*4);
1522 p2size = ((p2size & 0x1fffff) >> 3);
1524 if ((eptr < p2size) || (eptr > (p2size + p2len))){
1525 printk("%s: eptr is invalid\n", dev->name);
1529 revision = rr_read_eeprom_word(rrpriv,
1530 offsetof(struct eeprom, manf.HeaderFmt));
1533 printk("%s: invalid firmware format (%i)\n",
1534 dev->name, revision);
1538 nr_seg = rr_read_eeprom_word(rrpriv, eptr);
1541 printk("%s: nr_seg %i\n", dev->name, nr_seg);
1544 for (i = 0; i < nr_seg; i++){
1545 sptr = rr_read_eeprom_word(rrpriv, eptr);
1547 len = rr_read_eeprom_word(rrpriv, eptr);
1549 segptr = rr_read_eeprom_word(rrpriv, eptr);
1550 segptr = ((segptr & 0x1fffff) >> 3);
1553 printk("%s: segment %i, sram address %06x, length %04x, segptr %06x\n",
1554 dev->name, i, sptr, len, segptr);
1556 for (j = 0; j < len; j++){
1557 tmp = rr_read_eeprom_word(rrpriv, segptr);
1558 writel(sptr, ®s->WinBase);
1560 writel(tmp, ®s->WinData);
1568 writel(localctrl, ®s->LocalCtrl);
1574 static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1576 struct rr_private *rrpriv;
1577 unsigned char *image, *oldimage;
1578 unsigned long flags;
1580 int error = -EOPNOTSUPP;
1582 rrpriv = netdev_priv(dev);
1586 if (!capable(CAP_SYS_RAWIO)){
1590 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1594 if (rrpriv->fw_running){
1595 printk("%s: Firmware already running\n", dev->name);
1600 spin_lock_irqsave(&rrpriv->lock, flags);
1601 i = rr_read_eeprom(rrpriv, 0, image, EEPROM_BYTES);
1602 spin_unlock_irqrestore(&rrpriv->lock, flags);
1603 if (i != EEPROM_BYTES){
1604 printk(KERN_ERR "%s: Error reading EEPROM\n",
1609 error = copy_to_user(rq->ifr_data, image, EEPROM_BYTES);
1617 if (!capable(CAP_SYS_RAWIO)){
1621 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1622 oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1623 if (!image || !oldimage) {
1628 error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES);
1634 if (rrpriv->fw_running){
1635 printk("%s: Firmware already running\n", dev->name);
1640 printk("%s: Updating EEPROM firmware\n", dev->name);
1642 spin_lock_irqsave(&rrpriv->lock, flags);
1643 error = write_eeprom(rrpriv, 0, image, EEPROM_BYTES);
1645 printk(KERN_ERR "%s: Error writing EEPROM\n",
1648 i = rr_read_eeprom(rrpriv, 0, oldimage, EEPROM_BYTES);
1649 spin_unlock_irqrestore(&rrpriv->lock, flags);
1651 if (i != EEPROM_BYTES)
1652 printk(KERN_ERR "%s: Error reading back EEPROM "
1653 "image\n", dev->name);
1655 error = memcmp(image, oldimage, EEPROM_BYTES);
1657 printk(KERN_ERR "%s: Error verifying EEPROM image\n",
1667 return put_user(0x52523032, (int __user *)rq->ifr_data);
1673 static DEFINE_PCI_DEVICE_TABLE(rr_pci_tbl) = {
1674 { PCI_VENDOR_ID_ESSENTIAL, PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER,
1675 PCI_ANY_ID, PCI_ANY_ID, },
1678 MODULE_DEVICE_TABLE(pci, rr_pci_tbl);
1680 static struct pci_driver rr_driver = {
1682 .id_table = rr_pci_tbl,
1683 .probe = rr_init_one,
1684 .remove = __devexit_p(rr_remove_one),
1687 static int __init rr_init_module(void)
1689 return pci_register_driver(&rr_driver);
1692 static void __exit rr_cleanup_module(void)
1694 pci_unregister_driver(&rr_driver);
1697 module_init(rr_init_module);
1698 module_exit(rr_cleanup_module);