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>
45 #include <asm/system.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[] __devinitdata = "rrunner.c: v0.50 11/11/2002 Jes Sorensen (jes@wildopensource.com)\n";
67 * Implementation notes:
69 * The DMA engine only allows for DMA within physical 64KB chunks of
70 * memory. The current approach of the driver (and stack) is to use
71 * linear blocks of memory for the skbuffs. However, as the data block
72 * is always the first part of the skb and skbs are 2^n aligned so we
73 * are guarantted to get the whole block within one 64KB align 64KB
76 * On the long term, relying on being able to allocate 64KB linear
77 * chunks of memory is not feasible and the skb handling code and the
78 * stack will need to know about I/O vectors or something similar.
81 static int __devinit rr_init_one(struct pci_dev *pdev,
82 const struct pci_device_id *ent)
84 struct net_device *dev;
85 static int version_disp;
87 struct rr_private *rrpriv;
92 dev = alloc_hippi_dev(sizeof(struct rr_private));
96 ret = pci_enable_device(pdev);
102 rrpriv = netdev_priv(dev);
104 SET_NETDEV_DEV(dev, &pdev->dev);
106 if (pci_request_regions(pdev, "rrunner")) {
111 pci_set_drvdata(pdev, dev);
113 rrpriv->pci_dev = pdev;
115 spin_lock_init(&rrpriv->lock);
117 dev->irq = pdev->irq;
118 dev->open = &rr_open;
119 dev->hard_start_xmit = &rr_start_xmit;
120 dev->stop = &rr_close;
121 dev->do_ioctl = &rr_ioctl;
123 dev->base_addr = pci_resource_start(pdev, 0);
125 /* display version info if adapter is found */
127 /* set display flag to TRUE so that */
128 /* we only display this string ONCE */
133 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency);
134 if (pci_latency <= 0x58){
136 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, pci_latency);
139 pci_set_master(pdev);
141 printk(KERN_INFO "%s: Essential RoadRunner serial HIPPI "
142 "at 0x%08lx, irq %i, PCI latency %i\n", dev->name,
143 dev->base_addr, dev->irq, pci_latency);
146 * Remap the regs into kernel space.
149 rrpriv->regs = ioremap(dev->base_addr, 0x1000);
152 printk(KERN_ERR "%s: Unable to map I/O register, "
153 "RoadRunner will be disabled.\n", dev->name);
158 tmpptr = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
159 rrpriv->tx_ring = tmpptr;
160 rrpriv->tx_ring_dma = ring_dma;
167 tmpptr = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
168 rrpriv->rx_ring = tmpptr;
169 rrpriv->rx_ring_dma = ring_dma;
176 tmpptr = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma);
177 rrpriv->evt_ring = tmpptr;
178 rrpriv->evt_ring_dma = ring_dma;
186 * Don't access any register before this point!
189 writel(readl(&rrpriv->regs->HostCtrl) | NO_SWAP,
190 &rrpriv->regs->HostCtrl);
193 * 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 iounmap(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);
229 struct rr_private *rr = netdev_priv(dev);
231 if (!(readl(&rr->regs->HostCtrl) & NIC_HALTED)){
232 printk(KERN_ERR "%s: trying to unload running NIC\n",
234 writel(HALT_NIC, &rr->regs->HostCtrl);
237 pci_free_consistent(pdev, EVT_RING_SIZE, rr->evt_ring,
239 pci_free_consistent(pdev, RX_TOTAL_SIZE, rr->rx_ring,
241 pci_free_consistent(pdev, TX_TOTAL_SIZE, rr->tx_ring,
243 unregister_netdev(dev);
246 pci_release_regions(pdev);
247 pci_disable_device(pdev);
248 pci_set_drvdata(pdev, NULL);
254 * Commands are considered to be slow, thus there is no reason to
257 static void rr_issue_cmd(struct rr_private *rrpriv, struct cmd *cmd)
259 struct rr_regs __iomem *regs;
264 * This is temporary - it will go away in the final version.
265 * We probably also want to make this function inline.
267 if (readl(®s->HostCtrl) & NIC_HALTED){
268 printk("issuing command for halted NIC, code 0x%x, "
269 "HostCtrl %08x\n", cmd->code, readl(®s->HostCtrl));
270 if (readl(®s->Mode) & FATAL_ERR)
271 printk("error codes Fail1 %02x, Fail2 %02x\n",
272 readl(®s->Fail1), readl(®s->Fail2));
275 idx = rrpriv->info->cmd_ctrl.pi;
277 writel(*(u32*)(cmd), ®s->CmdRing[idx]);
280 idx = (idx - 1) % CMD_RING_ENTRIES;
281 rrpriv->info->cmd_ctrl.pi = idx;
284 if (readl(®s->Mode) & FATAL_ERR)
285 printk("error code %02x\n", readl(®s->Fail1));
290 * Reset the board in a sensible manner. The NIC is already halted
291 * when we get here and a spin-lock is held.
293 static int rr_reset(struct net_device *dev)
295 struct rr_private *rrpriv;
296 struct rr_regs __iomem *regs;
300 rrpriv = netdev_priv(dev);
303 rr_load_firmware(dev);
305 writel(0x01000000, ®s->TX_state);
306 writel(0xff800000, ®s->RX_state);
307 writel(0, ®s->AssistState);
308 writel(CLEAR_INTA, ®s->LocalCtrl);
309 writel(0x01, ®s->BrkPt);
310 writel(0, ®s->Timer);
311 writel(0, ®s->TimerRef);
312 writel(RESET_DMA, ®s->DmaReadState);
313 writel(RESET_DMA, ®s->DmaWriteState);
314 writel(0, ®s->DmaWriteHostHi);
315 writel(0, ®s->DmaWriteHostLo);
316 writel(0, ®s->DmaReadHostHi);
317 writel(0, ®s->DmaReadHostLo);
318 writel(0, ®s->DmaReadLen);
319 writel(0, ®s->DmaWriteLen);
320 writel(0, ®s->DmaWriteLcl);
321 writel(0, ®s->DmaWriteIPchecksum);
322 writel(0, ®s->DmaReadLcl);
323 writel(0, ®s->DmaReadIPchecksum);
324 writel(0, ®s->PciState);
325 #if (BITS_PER_LONG == 64) && defined __LITTLE_ENDIAN
326 writel(SWAP_DATA | PTR64BIT | PTR_WD_SWAP, ®s->Mode);
327 #elif (BITS_PER_LONG == 64)
328 writel(SWAP_DATA | PTR64BIT | PTR_WD_NOSWAP, ®s->Mode);
330 writel(SWAP_DATA | PTR32BIT | PTR_WD_NOSWAP, ®s->Mode);
335 * Don't worry, this is just black magic.
337 writel(0xdf000, ®s->RxBase);
338 writel(0xdf000, ®s->RxPrd);
339 writel(0xdf000, ®s->RxCon);
340 writel(0xce000, ®s->TxBase);
341 writel(0xce000, ®s->TxPrd);
342 writel(0xce000, ®s->TxCon);
343 writel(0, ®s->RxIndPro);
344 writel(0, ®s->RxIndCon);
345 writel(0, ®s->RxIndRef);
346 writel(0, ®s->TxIndPro);
347 writel(0, ®s->TxIndCon);
348 writel(0, ®s->TxIndRef);
349 writel(0xcc000, ®s->pad10[0]);
350 writel(0, ®s->DrCmndPro);
351 writel(0, ®s->DrCmndCon);
352 writel(0, ®s->DwCmndPro);
353 writel(0, ®s->DwCmndCon);
354 writel(0, ®s->DwCmndRef);
355 writel(0, ®s->DrDataPro);
356 writel(0, ®s->DrDataCon);
357 writel(0, ®s->DrDataRef);
358 writel(0, ®s->DwDataPro);
359 writel(0, ®s->DwDataCon);
360 writel(0, ®s->DwDataRef);
363 writel(0xffffffff, ®s->MbEvent);
364 writel(0, ®s->Event);
366 writel(0, ®s->TxPi);
367 writel(0, ®s->IpRxPi);
369 writel(0, ®s->EvtCon);
370 writel(0, ®s->EvtPrd);
372 rrpriv->info->evt_ctrl.pi = 0;
374 for (i = 0; i < CMD_RING_ENTRIES; i++)
375 writel(0, ®s->CmdRing[i]);
378 * Why 32 ? is this not cache line size dependent?
380 writel(RBURST_64|WBURST_64, ®s->PciState);
383 start_pc = rr_read_eeprom_word(rrpriv,
384 offsetof(struct eeprom, rncd_info.FwStart));
387 printk("%s: Executing firmware at address 0x%06x\n",
388 dev->name, start_pc);
391 writel(start_pc + 0x800, ®s->Pc);
395 writel(start_pc, ®s->Pc);
403 * Read a string from the EEPROM.
405 static unsigned int rr_read_eeprom(struct rr_private *rrpriv,
406 unsigned long offset,
408 unsigned long length)
410 struct rr_regs __iomem *regs = rrpriv->regs;
411 u32 misc, io, host, i;
413 io = readl(®s->ExtIo);
414 writel(0, ®s->ExtIo);
415 misc = readl(®s->LocalCtrl);
416 writel(0, ®s->LocalCtrl);
417 host = readl(®s->HostCtrl);
418 writel(host | HALT_NIC, ®s->HostCtrl);
421 for (i = 0; i < length; i++){
422 writel((EEPROM_BASE + ((offset+i) << 3)), ®s->WinBase);
424 buf[i] = (readl(®s->WinData) >> 24) & 0xff;
428 writel(host, ®s->HostCtrl);
429 writel(misc, ®s->LocalCtrl);
430 writel(io, ®s->ExtIo);
437 * Shortcut to read one word (4 bytes) out of the EEPROM and convert
438 * it to our CPU byte-order.
440 static u32 rr_read_eeprom_word(struct rr_private *rrpriv,
445 if ((rr_read_eeprom(rrpriv, offset,
446 (unsigned char *)&word, 4) == 4))
447 return be32_to_cpu(word);
453 * Write a string to the EEPROM.
455 * This is only called when the firmware is not running.
457 static unsigned int write_eeprom(struct rr_private *rrpriv,
458 unsigned long offset,
460 unsigned long length)
462 struct rr_regs __iomem *regs = rrpriv->regs;
463 u32 misc, io, data, i, j, ready, error = 0;
465 io = readl(®s->ExtIo);
466 writel(0, ®s->ExtIo);
467 misc = readl(®s->LocalCtrl);
468 writel(ENABLE_EEPROM_WRITE, ®s->LocalCtrl);
471 for (i = 0; i < length; i++){
472 writel((EEPROM_BASE + ((offset+i) << 3)), ®s->WinBase);
476 * Only try to write the data if it is not the same
479 if ((readl(®s->WinData) & 0xff000000) != data){
480 writel(data, ®s->WinData);
486 if ((readl(®s->WinData) & 0xff000000) ==
491 printk("data mismatch: %08x, "
492 "WinData %08x\n", data,
493 readl(®s->WinData));
501 writel(misc, ®s->LocalCtrl);
502 writel(io, ®s->ExtIo);
509 static int __devinit rr_init(struct net_device *dev)
511 struct rr_private *rrpriv;
512 struct rr_regs __iomem *regs;
515 rrpriv = netdev_priv(dev);
518 rev = readl(®s->FwRev);
519 rrpriv->fw_rev = rev;
520 if (rev > 0x00020024)
521 printk(" Firmware revision: %i.%i.%i\n", (rev >> 16),
522 ((rev >> 8) & 0xff), (rev & 0xff));
523 else if (rev >= 0x00020000) {
524 printk(" Firmware revision: %i.%i.%i (2.0.37 or "
525 "later is recommended)\n", (rev >> 16),
526 ((rev >> 8) & 0xff), (rev & 0xff));
528 printk(" Firmware revision too old: %i.%i.%i, please "
529 "upgrade to 2.0.37 or later.\n",
530 (rev >> 16), ((rev >> 8) & 0xff), (rev & 0xff));
534 printk(" Maximum receive rings %i\n", readl(®s->MaxRxRng));
538 * Read the hardware address from the eeprom. The HW address
539 * is not really necessary for HIPPI but awfully convenient.
540 * The pointer arithmetic to put it in dev_addr is ugly, but
541 * Donald Becker does it this way for the GigE version of this
542 * card and it's shorter and more portable than any
543 * other method I've seen. -VAL
546 *(__be16 *)(dev->dev_addr) =
547 htons(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA)));
548 *(__be32 *)(dev->dev_addr+2) =
549 htonl(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA[4])));
551 printk(" MAC: %pM\n", dev->dev_addr);
553 sram_size = rr_read_eeprom_word(rrpriv, 8);
554 printk(" SRAM size 0x%06x\n", sram_size);
560 static int rr_init1(struct net_device *dev)
562 struct rr_private *rrpriv;
563 struct rr_regs __iomem *regs;
564 unsigned long myjif, flags;
570 rrpriv = netdev_priv(dev);
573 spin_lock_irqsave(&rrpriv->lock, flags);
575 hostctrl = readl(®s->HostCtrl);
576 writel(hostctrl | HALT_NIC | RR_CLEAR_INT, ®s->HostCtrl);
579 if (hostctrl & PARITY_ERR){
580 printk("%s: Parity error halting NIC - this is serious!\n",
582 spin_unlock_irqrestore(&rrpriv->lock, flags);
587 set_rxaddr(regs, rrpriv->rx_ctrl_dma);
588 set_infoaddr(regs, rrpriv->info_dma);
590 rrpriv->info->evt_ctrl.entry_size = sizeof(struct event);
591 rrpriv->info->evt_ctrl.entries = EVT_RING_ENTRIES;
592 rrpriv->info->evt_ctrl.mode = 0;
593 rrpriv->info->evt_ctrl.pi = 0;
594 set_rraddr(&rrpriv->info->evt_ctrl.rngptr, rrpriv->evt_ring_dma);
596 rrpriv->info->cmd_ctrl.entry_size = sizeof(struct cmd);
597 rrpriv->info->cmd_ctrl.entries = CMD_RING_ENTRIES;
598 rrpriv->info->cmd_ctrl.mode = 0;
599 rrpriv->info->cmd_ctrl.pi = 15;
601 for (i = 0; i < CMD_RING_ENTRIES; i++) {
602 writel(0, ®s->CmdRing[i]);
605 for (i = 0; i < TX_RING_ENTRIES; i++) {
606 rrpriv->tx_ring[i].size = 0;
607 set_rraddr(&rrpriv->tx_ring[i].addr, 0);
608 rrpriv->tx_skbuff[i] = NULL;
610 rrpriv->info->tx_ctrl.entry_size = sizeof(struct tx_desc);
611 rrpriv->info->tx_ctrl.entries = TX_RING_ENTRIES;
612 rrpriv->info->tx_ctrl.mode = 0;
613 rrpriv->info->tx_ctrl.pi = 0;
614 set_rraddr(&rrpriv->info->tx_ctrl.rngptr, rrpriv->tx_ring_dma);
617 * Set dirty_tx before we start receiving interrupts, otherwise
618 * the interrupt handler might think it is supposed to process
619 * tx ints before we are up and running, which may cause a null
620 * pointer access in the int handler.
624 rrpriv->dirty_rx = rrpriv->dirty_tx = 0;
629 writel(0x5000, ®s->ConRetry);
630 writel(0x100, ®s->ConRetryTmr);
631 writel(0x500000, ®s->ConTmout);
632 writel(0x60, ®s->IntrTmr);
633 writel(0x500000, ®s->TxDataMvTimeout);
634 writel(0x200000, ®s->RxDataMvTimeout);
635 writel(0x80, ®s->WriteDmaThresh);
636 writel(0x80, ®s->ReadDmaThresh);
638 rrpriv->fw_running = 0;
641 hostctrl &= ~(HALT_NIC | INVALID_INST_B | PARITY_ERR);
642 writel(hostctrl, ®s->HostCtrl);
645 spin_unlock_irqrestore(&rrpriv->lock, flags);
647 for (i = 0; i < RX_RING_ENTRIES; i++) {
651 rrpriv->rx_ring[i].mode = 0;
652 skb = alloc_skb(dev->mtu + HIPPI_HLEN, GFP_ATOMIC);
654 printk(KERN_WARNING "%s: Unable to allocate memory "
655 "for receive ring - halting NIC\n", dev->name);
659 rrpriv->rx_skbuff[i] = skb;
660 addr = pci_map_single(rrpriv->pci_dev, skb->data,
661 dev->mtu + HIPPI_HLEN, PCI_DMA_FROMDEVICE);
663 * Sanity test to see if we conflict with the DMA
664 * limitations of the Roadrunner.
666 if ((((unsigned long)skb->data) & 0xfff) > ~65320)
667 printk("skb alloc error\n");
669 set_rraddr(&rrpriv->rx_ring[i].addr, addr);
670 rrpriv->rx_ring[i].size = dev->mtu + HIPPI_HLEN;
673 rrpriv->rx_ctrl[4].entry_size = sizeof(struct rx_desc);
674 rrpriv->rx_ctrl[4].entries = RX_RING_ENTRIES;
675 rrpriv->rx_ctrl[4].mode = 8;
676 rrpriv->rx_ctrl[4].pi = 0;
678 set_rraddr(&rrpriv->rx_ctrl[4].rngptr, rrpriv->rx_ring_dma);
683 * Now start the FirmWare.
685 cmd.code = C_START_FW;
689 rr_issue_cmd(rrpriv, &cmd);
692 * Give the FirmWare time to chew on the `get running' command.
694 myjif = jiffies + 5 * HZ;
695 while (time_before(jiffies, myjif) && !rrpriv->fw_running)
698 netif_start_queue(dev);
704 * We might have gotten here because we are out of memory,
705 * make sure we release everything we allocated before failing
707 for (i = 0; i < RX_RING_ENTRIES; i++) {
708 struct sk_buff *skb = rrpriv->rx_skbuff[i];
711 pci_unmap_single(rrpriv->pci_dev,
712 rrpriv->rx_ring[i].addr.addrlo,
713 dev->mtu + HIPPI_HLEN,
715 rrpriv->rx_ring[i].size = 0;
716 set_rraddr(&rrpriv->rx_ring[i].addr, 0);
718 rrpriv->rx_skbuff[i] = NULL;
726 * All events are considered to be slow (RX/TX ints do not generate
727 * events) and are handled here, outside the main interrupt handler,
728 * to reduce the size of the handler.
730 static u32 rr_handle_event(struct net_device *dev, u32 prodidx, u32 eidx)
732 struct rr_private *rrpriv;
733 struct rr_regs __iomem *regs;
736 rrpriv = netdev_priv(dev);
739 while (prodidx != eidx){
740 switch (rrpriv->evt_ring[eidx].code){
742 tmp = readl(®s->FwRev);
743 printk(KERN_INFO "%s: Firmware revision %i.%i.%i "
744 "up and running\n", dev->name,
745 (tmp >> 16), ((tmp >> 8) & 0xff), (tmp & 0xff));
746 rrpriv->fw_running = 1;
747 writel(RX_RING_ENTRIES - 1, ®s->IpRxPi);
751 printk(KERN_INFO "%s: Optical link ON\n", dev->name);
754 printk(KERN_INFO "%s: Optical link OFF\n", dev->name);
757 printk(KERN_WARNING "%s: RX data not moving\n",
761 printk(KERN_INFO "%s: The watchdog is here to see "
765 printk(KERN_ERR "%s: HIPPI Internal NIC error\n",
767 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
772 printk(KERN_ERR "%s: Host software error\n",
774 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
782 printk(KERN_WARNING "%s: Connection rejected\n",
784 dev->stats.tx_aborted_errors++;
787 printk(KERN_WARNING "%s: Connection timeout\n",
791 printk(KERN_WARNING "%s: HIPPI disconnect error\n",
793 dev->stats.tx_aborted_errors++;
796 printk(KERN_ERR "%s: HIPPI Internal Parity error\n",
798 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
803 printk(KERN_WARNING "%s: Transmitter idle\n",
807 printk(KERN_WARNING "%s: Link lost during transmit\n",
809 dev->stats.tx_aborted_errors++;
810 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
815 printk(KERN_ERR "%s: Invalid send ring block\n",
817 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
822 printk(KERN_ERR "%s: Invalid send buffer address\n",
824 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
829 printk(KERN_ERR "%s: Invalid descriptor address\n",
831 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
839 printk(KERN_INFO "%s: Receive ring full\n", dev->name);
843 printk(KERN_WARNING "%s: Receive parity error\n",
847 printk(KERN_WARNING "%s: Receive LLRC error\n",
851 printk(KERN_WARNING "%s: Receive packet length "
852 "error\n", dev->name);
855 printk(KERN_WARNING "%s: Data checksum error\n",
859 printk(KERN_WARNING "%s: Unexpected short burst "
860 "error\n", dev->name);
863 printk(KERN_WARNING "%s: Recv. state transition"
864 " error\n", dev->name);
867 printk(KERN_WARNING "%s: Unexpected data error\n",
871 printk(KERN_WARNING "%s: Link lost error\n",
875 printk(KERN_WARNING "%s: Framming Error\n",
879 printk(KERN_WARNING "%s: Flag sync. lost during "
880 "packet\n", dev->name);
883 printk(KERN_ERR "%s: Invalid receive buffer "
884 "address\n", dev->name);
885 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
890 printk(KERN_ERR "%s: Invalid receive descriptor "
891 "address\n", dev->name);
892 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
897 printk(KERN_ERR "%s: Invalid ring block\n",
899 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
904 /* Label packet to be dropped.
905 * Actual dropping occurs in rx
908 * The index of packet we get to drop is
909 * the index of the packet following
910 * the bad packet. -kbf
913 u16 index = rrpriv->evt_ring[eidx].index;
914 index = (index + (RX_RING_ENTRIES - 1)) %
916 rrpriv->rx_ring[index].mode |=
917 (PACKET_BAD | PACKET_END);
921 printk(KERN_WARNING "%s: Unhandled event 0x%02x\n",
922 dev->name, rrpriv->evt_ring[eidx].code);
924 eidx = (eidx + 1) % EVT_RING_ENTRIES;
927 rrpriv->info->evt_ctrl.pi = eidx;
933 static void rx_int(struct net_device *dev, u32 rxlimit, u32 index)
935 struct rr_private *rrpriv = netdev_priv(dev);
936 struct rr_regs __iomem *regs = rrpriv->regs;
939 struct rx_desc *desc;
942 desc = &(rrpriv->rx_ring[index]);
943 pkt_len = desc->size;
945 printk("index %i, rxlimit %i\n", index, rxlimit);
946 printk("len %x, mode %x\n", pkt_len, desc->mode);
948 if ( (rrpriv->rx_ring[index].mode & PACKET_BAD) == PACKET_BAD){
949 dev->stats.rx_dropped++;
954 struct sk_buff *skb, *rx_skb;
956 rx_skb = rrpriv->rx_skbuff[index];
958 if (pkt_len < PKT_COPY_THRESHOLD) {
959 skb = alloc_skb(pkt_len, GFP_ATOMIC);
961 printk(KERN_WARNING "%s: Unable to allocate skb (%i bytes), deferring packet\n", dev->name, pkt_len);
962 dev->stats.rx_dropped++;
965 pci_dma_sync_single_for_cpu(rrpriv->pci_dev,
970 memcpy(skb_put(skb, pkt_len),
971 rx_skb->data, pkt_len);
973 pci_dma_sync_single_for_device(rrpriv->pci_dev,
979 struct sk_buff *newskb;
981 newskb = alloc_skb(dev->mtu + HIPPI_HLEN,
986 pci_unmap_single(rrpriv->pci_dev,
987 desc->addr.addrlo, dev->mtu +
988 HIPPI_HLEN, PCI_DMA_FROMDEVICE);
990 skb_put(skb, pkt_len);
991 rrpriv->rx_skbuff[index] = newskb;
992 addr = pci_map_single(rrpriv->pci_dev,
994 dev->mtu + HIPPI_HLEN,
996 set_rraddr(&desc->addr, addr);
998 printk("%s: Out of memory, deferring "
999 "packet\n", dev->name);
1000 dev->stats.rx_dropped++;
1004 skb->protocol = hippi_type_trans(skb, dev);
1006 netif_rx(skb); /* send it up */
1008 dev->stats.rx_packets++;
1009 dev->stats.rx_bytes += pkt_len;
1013 desc->size = dev->mtu + HIPPI_HLEN;
1015 if ((index & 7) == 7)
1016 writel(index, ®s->IpRxPi);
1018 index = (index + 1) % RX_RING_ENTRIES;
1019 } while(index != rxlimit);
1021 rrpriv->cur_rx = index;
1026 static irqreturn_t rr_interrupt(int irq, void *dev_id)
1028 struct rr_private *rrpriv;
1029 struct rr_regs __iomem *regs;
1030 struct net_device *dev = (struct net_device *)dev_id;
1031 u32 prodidx, rxindex, eidx, txcsmr, rxlimit, txcon;
1033 rrpriv = netdev_priv(dev);
1034 regs = rrpriv->regs;
1036 if (!(readl(®s->HostCtrl) & RR_INT))
1039 spin_lock(&rrpriv->lock);
1041 prodidx = readl(®s->EvtPrd);
1042 txcsmr = (prodidx >> 8) & 0xff;
1043 rxlimit = (prodidx >> 16) & 0xff;
1047 printk("%s: interrupt, prodidx = %i, eidx = %i\n", dev->name,
1048 prodidx, rrpriv->info->evt_ctrl.pi);
1051 * Order here is important. We must handle events
1052 * before doing anything else in order to catch
1053 * such things as LLRC errors, etc -kbf
1056 eidx = rrpriv->info->evt_ctrl.pi;
1057 if (prodidx != eidx)
1058 eidx = rr_handle_event(dev, prodidx, eidx);
1060 rxindex = rrpriv->cur_rx;
1061 if (rxindex != rxlimit)
1062 rx_int(dev, rxlimit, rxindex);
1064 txcon = rrpriv->dirty_tx;
1065 if (txcsmr != txcon) {
1067 /* Due to occational firmware TX producer/consumer out
1068 * of sync. error need to check entry in ring -kbf
1070 if(rrpriv->tx_skbuff[txcon]){
1071 struct tx_desc *desc;
1072 struct sk_buff *skb;
1074 desc = &(rrpriv->tx_ring[txcon]);
1075 skb = rrpriv->tx_skbuff[txcon];
1077 dev->stats.tx_packets++;
1078 dev->stats.tx_bytes += skb->len;
1080 pci_unmap_single(rrpriv->pci_dev,
1081 desc->addr.addrlo, skb->len,
1083 dev_kfree_skb_irq(skb);
1085 rrpriv->tx_skbuff[txcon] = NULL;
1087 set_rraddr(&rrpriv->tx_ring[txcon].addr, 0);
1090 txcon = (txcon + 1) % TX_RING_ENTRIES;
1091 } while (txcsmr != txcon);
1094 rrpriv->dirty_tx = txcon;
1095 if (rrpriv->tx_full && rr_if_busy(dev) &&
1096 (((rrpriv->info->tx_ctrl.pi + 1) % TX_RING_ENTRIES)
1097 != rrpriv->dirty_tx)){
1098 rrpriv->tx_full = 0;
1099 netif_wake_queue(dev);
1103 eidx |= ((txcsmr << 8) | (rxlimit << 16));
1104 writel(eidx, ®s->EvtCon);
1107 spin_unlock(&rrpriv->lock);
1111 static inline void rr_raz_tx(struct rr_private *rrpriv,
1112 struct net_device *dev)
1116 for (i = 0; i < TX_RING_ENTRIES; i++) {
1117 struct sk_buff *skb = rrpriv->tx_skbuff[i];
1120 struct tx_desc *desc = &(rrpriv->tx_ring[i]);
1122 pci_unmap_single(rrpriv->pci_dev, desc->addr.addrlo,
1123 skb->len, PCI_DMA_TODEVICE);
1125 set_rraddr(&desc->addr, 0);
1127 rrpriv->tx_skbuff[i] = NULL;
1133 static inline void rr_raz_rx(struct rr_private *rrpriv,
1134 struct net_device *dev)
1138 for (i = 0; i < RX_RING_ENTRIES; i++) {
1139 struct sk_buff *skb = rrpriv->rx_skbuff[i];
1142 struct rx_desc *desc = &(rrpriv->rx_ring[i]);
1144 pci_unmap_single(rrpriv->pci_dev, desc->addr.addrlo,
1145 dev->mtu + HIPPI_HLEN, PCI_DMA_FROMDEVICE);
1147 set_rraddr(&desc->addr, 0);
1149 rrpriv->rx_skbuff[i] = NULL;
1154 static void rr_timer(unsigned long data)
1156 struct net_device *dev = (struct net_device *)data;
1157 struct rr_private *rrpriv = netdev_priv(dev);
1158 struct rr_regs __iomem *regs = rrpriv->regs;
1159 unsigned long flags;
1161 if (readl(®s->HostCtrl) & NIC_HALTED){
1162 printk("%s: Restarting nic\n", dev->name);
1163 memset(rrpriv->rx_ctrl, 0, 256 * sizeof(struct ring_ctrl));
1164 memset(rrpriv->info, 0, sizeof(struct rr_info));
1167 rr_raz_tx(rrpriv, dev);
1168 rr_raz_rx(rrpriv, dev);
1170 if (rr_init1(dev)) {
1171 spin_lock_irqsave(&rrpriv->lock, flags);
1172 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT,
1174 spin_unlock_irqrestore(&rrpriv->lock, flags);
1177 rrpriv->timer.expires = RUN_AT(5*HZ);
1178 add_timer(&rrpriv->timer);
1182 static int rr_open(struct net_device *dev)
1184 struct rr_private *rrpriv = netdev_priv(dev);
1185 struct pci_dev *pdev = rrpriv->pci_dev;
1186 struct rr_regs __iomem *regs;
1188 unsigned long flags;
1189 dma_addr_t dma_addr;
1191 regs = rrpriv->regs;
1193 if (rrpriv->fw_rev < 0x00020000) {
1194 printk(KERN_WARNING "%s: trying to configure device with "
1195 "obsolete firmware\n", dev->name);
1200 rrpriv->rx_ctrl = pci_alloc_consistent(pdev,
1201 256 * sizeof(struct ring_ctrl),
1203 if (!rrpriv->rx_ctrl) {
1207 rrpriv->rx_ctrl_dma = dma_addr;
1208 memset(rrpriv->rx_ctrl, 0, 256*sizeof(struct ring_ctrl));
1210 rrpriv->info = pci_alloc_consistent(pdev, sizeof(struct rr_info),
1212 if (!rrpriv->info) {
1216 rrpriv->info_dma = dma_addr;
1217 memset(rrpriv->info, 0, sizeof(struct rr_info));
1220 spin_lock_irqsave(&rrpriv->lock, flags);
1221 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, ®s->HostCtrl);
1222 readl(®s->HostCtrl);
1223 spin_unlock_irqrestore(&rrpriv->lock, flags);
1225 if (request_irq(dev->irq, rr_interrupt, IRQF_SHARED, dev->name, dev)) {
1226 printk(KERN_WARNING "%s: Requested IRQ %d is busy\n",
1227 dev->name, dev->irq);
1232 if ((ecode = rr_init1(dev)))
1235 /* Set the timer to switch to check for link beat and perhaps switch
1236 to an alternate media type. */
1237 init_timer(&rrpriv->timer);
1238 rrpriv->timer.expires = RUN_AT(5*HZ); /* 5 sec. watchdog */
1239 rrpriv->timer.data = (unsigned long)dev;
1240 rrpriv->timer.function = &rr_timer; /* timer handler */
1241 add_timer(&rrpriv->timer);
1243 netif_start_queue(dev);
1248 spin_lock_irqsave(&rrpriv->lock, flags);
1249 writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, ®s->HostCtrl);
1250 spin_unlock_irqrestore(&rrpriv->lock, flags);
1253 pci_free_consistent(pdev, sizeof(struct rr_info), rrpriv->info,
1255 rrpriv->info = NULL;
1257 if (rrpriv->rx_ctrl) {
1258 pci_free_consistent(pdev, sizeof(struct ring_ctrl),
1259 rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma);
1260 rrpriv->rx_ctrl = NULL;
1263 netif_stop_queue(dev);
1269 static void rr_dump(struct net_device *dev)
1271 struct rr_private *rrpriv;
1272 struct rr_regs __iomem *regs;
1277 rrpriv = netdev_priv(dev);
1278 regs = rrpriv->regs;
1280 printk("%s: dumping NIC TX rings\n", dev->name);
1282 printk("RxPrd %08x, TxPrd %02x, EvtPrd %08x, TxPi %02x, TxCtrlPi %02x\n",
1283 readl(®s->RxPrd), readl(®s->TxPrd),
1284 readl(®s->EvtPrd), readl(®s->TxPi),
1285 rrpriv->info->tx_ctrl.pi);
1287 printk("Error code 0x%x\n", readl(®s->Fail1));
1289 index = (((readl(®s->EvtPrd) >> 8) & 0xff ) - 1) % EVT_RING_ENTRIES;
1290 cons = rrpriv->dirty_tx;
1291 printk("TX ring index %i, TX consumer %i\n",
1294 if (rrpriv->tx_skbuff[index]){
1295 len = min_t(int, 0x80, rrpriv->tx_skbuff[index]->len);
1296 printk("skbuff for index %i is valid - dumping data (0x%x bytes - DMA len 0x%x)\n", index, len, rrpriv->tx_ring[index].size);
1297 for (i = 0; i < len; i++){
1300 printk("%02x ", (unsigned char) rrpriv->tx_skbuff[index]->data[i]);
1305 if (rrpriv->tx_skbuff[cons]){
1306 len = min_t(int, 0x80, rrpriv->tx_skbuff[cons]->len);
1307 printk("skbuff for cons %i is valid - dumping data (0x%x bytes - skbuff len 0x%x)\n", cons, len, rrpriv->tx_skbuff[cons]->len);
1308 printk("mode 0x%x, size 0x%x,\n phys %08Lx, skbuff-addr %08lx, truesize 0x%x\n",
1309 rrpriv->tx_ring[cons].mode,
1310 rrpriv->tx_ring[cons].size,
1311 (unsigned long long) rrpriv->tx_ring[cons].addr.addrlo,
1312 (unsigned long)rrpriv->tx_skbuff[cons]->data,
1313 (unsigned int)rrpriv->tx_skbuff[cons]->truesize);
1314 for (i = 0; i < len; i++){
1317 printk("%02x ", (unsigned char)rrpriv->tx_ring[cons].size);
1322 printk("dumping TX ring info:\n");
1323 for (i = 0; i < TX_RING_ENTRIES; i++)
1324 printk("mode 0x%x, size 0x%x, phys-addr %08Lx\n",
1325 rrpriv->tx_ring[i].mode,
1326 rrpriv->tx_ring[i].size,
1327 (unsigned long long) rrpriv->tx_ring[i].addr.addrlo);
1332 static int rr_close(struct net_device *dev)
1334 struct rr_private *rrpriv;
1335 struct rr_regs __iomem *regs;
1336 unsigned long flags;
1340 netif_stop_queue(dev);
1342 rrpriv = netdev_priv(dev);
1343 regs = rrpriv->regs;
1346 * Lock to make sure we are not cleaning up while another CPU
1347 * is handling interrupts.
1349 spin_lock_irqsave(&rrpriv->lock, flags);
1351 tmp = readl(®s->HostCtrl);
1352 if (tmp & NIC_HALTED){
1353 printk("%s: NIC already halted\n", dev->name);
1356 tmp |= HALT_NIC | RR_CLEAR_INT;
1357 writel(tmp, ®s->HostCtrl);
1358 readl(®s->HostCtrl);
1361 rrpriv->fw_running = 0;
1363 del_timer_sync(&rrpriv->timer);
1365 writel(0, ®s->TxPi);
1366 writel(0, ®s->IpRxPi);
1368 writel(0, ®s->EvtCon);
1369 writel(0, ®s->EvtPrd);
1371 for (i = 0; i < CMD_RING_ENTRIES; i++)
1372 writel(0, ®s->CmdRing[i]);
1374 rrpriv->info->tx_ctrl.entries = 0;
1375 rrpriv->info->cmd_ctrl.pi = 0;
1376 rrpriv->info->evt_ctrl.pi = 0;
1377 rrpriv->rx_ctrl[4].entries = 0;
1379 rr_raz_tx(rrpriv, dev);
1380 rr_raz_rx(rrpriv, dev);
1382 pci_free_consistent(rrpriv->pci_dev, 256 * sizeof(struct ring_ctrl),
1383 rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma);
1384 rrpriv->rx_ctrl = NULL;
1386 pci_free_consistent(rrpriv->pci_dev, sizeof(struct rr_info),
1387 rrpriv->info, rrpriv->info_dma);
1388 rrpriv->info = NULL;
1390 free_irq(dev->irq, dev);
1391 spin_unlock_irqrestore(&rrpriv->lock, flags);
1397 static int rr_start_xmit(struct sk_buff *skb, struct net_device *dev)
1399 struct rr_private *rrpriv = netdev_priv(dev);
1400 struct rr_regs __iomem *regs = rrpriv->regs;
1401 struct hippi_cb *hcb = (struct hippi_cb *) skb->cb;
1402 struct ring_ctrl *txctrl;
1403 unsigned long flags;
1404 u32 index, len = skb->len;
1406 struct sk_buff *new_skb;
1408 if (readl(®s->Mode) & FATAL_ERR)
1409 printk("error codes Fail1 %02x, Fail2 %02x\n",
1410 readl(®s->Fail1), readl(®s->Fail2));
1413 * We probably need to deal with tbusy here to prevent overruns.
1416 if (skb_headroom(skb) < 8){
1417 printk("incoming skb too small - reallocating\n");
1418 if (!(new_skb = dev_alloc_skb(len + 8))) {
1420 netif_wake_queue(dev);
1423 skb_reserve(new_skb, 8);
1424 skb_put(new_skb, len);
1425 skb_copy_from_linear_data(skb, new_skb->data, len);
1430 ifield = (u32 *)skb_push(skb, 8);
1433 ifield[1] = hcb->ifield;
1436 * We don't need the lock before we are actually going to start
1437 * fiddling with the control blocks.
1439 spin_lock_irqsave(&rrpriv->lock, flags);
1441 txctrl = &rrpriv->info->tx_ctrl;
1445 rrpriv->tx_skbuff[index] = skb;
1446 set_rraddr(&rrpriv->tx_ring[index].addr, pci_map_single(
1447 rrpriv->pci_dev, skb->data, len + 8, PCI_DMA_TODEVICE));
1448 rrpriv->tx_ring[index].size = len + 8; /* include IFIELD */
1449 rrpriv->tx_ring[index].mode = PACKET_START | PACKET_END;
1450 txctrl->pi = (index + 1) % TX_RING_ENTRIES;
1452 writel(txctrl->pi, ®s->TxPi);
1454 if (txctrl->pi == rrpriv->dirty_tx){
1455 rrpriv->tx_full = 1;
1456 netif_stop_queue(dev);
1459 spin_unlock_irqrestore(&rrpriv->lock, flags);
1461 dev->trans_start = jiffies;
1467 * Read the firmware out of the EEPROM and put it into the SRAM
1468 * (or from user space - later)
1470 * This operation requires the NIC to be halted and is performed with
1471 * interrupts disabled and with the spinlock hold.
1473 static int rr_load_firmware(struct net_device *dev)
1475 struct rr_private *rrpriv;
1476 struct rr_regs __iomem *regs;
1477 size_t eptr, segptr;
1479 u32 localctrl, sptr, len, tmp;
1480 u32 p2len, p2size, nr_seg, revision, io, sram_size;
1482 rrpriv = netdev_priv(dev);
1483 regs = rrpriv->regs;
1485 if (dev->flags & IFF_UP)
1488 if (!(readl(®s->HostCtrl) & NIC_HALTED)){
1489 printk("%s: Trying to load firmware to a running NIC.\n",
1494 localctrl = readl(®s->LocalCtrl);
1495 writel(0, ®s->LocalCtrl);
1497 writel(0, ®s->EvtPrd);
1498 writel(0, ®s->RxPrd);
1499 writel(0, ®s->TxPrd);
1502 * First wipe the entire SRAM, otherwise we might run into all
1503 * kinds of trouble ... sigh, this took almost all afternoon
1506 io = readl(®s->ExtIo);
1507 writel(0, ®s->ExtIo);
1508 sram_size = rr_read_eeprom_word(rrpriv, 8);
1510 for (i = 200; i < sram_size / 4; i++){
1511 writel(i * 4, ®s->WinBase);
1513 writel(0, ®s->WinData);
1516 writel(io, ®s->ExtIo);
1519 eptr = rr_read_eeprom_word(rrpriv,
1520 offsetof(struct eeprom, rncd_info.AddrRunCodeSegs));
1521 eptr = ((eptr & 0x1fffff) >> 3);
1523 p2len = rr_read_eeprom_word(rrpriv, 0x83*4);
1524 p2len = (p2len << 2);
1525 p2size = rr_read_eeprom_word(rrpriv, 0x84*4);
1526 p2size = ((p2size & 0x1fffff) >> 3);
1528 if ((eptr < p2size) || (eptr > (p2size + p2len))){
1529 printk("%s: eptr is invalid\n", dev->name);
1533 revision = rr_read_eeprom_word(rrpriv,
1534 offsetof(struct eeprom, manf.HeaderFmt));
1537 printk("%s: invalid firmware format (%i)\n",
1538 dev->name, revision);
1542 nr_seg = rr_read_eeprom_word(rrpriv, eptr);
1545 printk("%s: nr_seg %i\n", dev->name, nr_seg);
1548 for (i = 0; i < nr_seg; i++){
1549 sptr = rr_read_eeprom_word(rrpriv, eptr);
1551 len = rr_read_eeprom_word(rrpriv, eptr);
1553 segptr = rr_read_eeprom_word(rrpriv, eptr);
1554 segptr = ((segptr & 0x1fffff) >> 3);
1557 printk("%s: segment %i, sram address %06x, length %04x, segptr %06x\n",
1558 dev->name, i, sptr, len, segptr);
1560 for (j = 0; j < len; j++){
1561 tmp = rr_read_eeprom_word(rrpriv, segptr);
1562 writel(sptr, ®s->WinBase);
1564 writel(tmp, ®s->WinData);
1572 writel(localctrl, ®s->LocalCtrl);
1578 static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1580 struct rr_private *rrpriv;
1581 unsigned char *image, *oldimage;
1582 unsigned long flags;
1584 int error = -EOPNOTSUPP;
1586 rrpriv = netdev_priv(dev);
1590 if (!capable(CAP_SYS_RAWIO)){
1594 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1596 printk(KERN_ERR "%s: Unable to allocate memory "
1597 "for EEPROM image\n", dev->name);
1602 if (rrpriv->fw_running){
1603 printk("%s: Firmware already running\n", dev->name);
1608 spin_lock_irqsave(&rrpriv->lock, flags);
1609 i = rr_read_eeprom(rrpriv, 0, image, EEPROM_BYTES);
1610 spin_unlock_irqrestore(&rrpriv->lock, flags);
1611 if (i != EEPROM_BYTES){
1612 printk(KERN_ERR "%s: Error reading EEPROM\n",
1617 error = copy_to_user(rq->ifr_data, image, EEPROM_BYTES);
1625 if (!capable(CAP_SYS_RAWIO)){
1629 image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1630 oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1631 if (!image || !oldimage) {
1632 printk(KERN_ERR "%s: Unable to allocate memory "
1633 "for EEPROM image\n", dev->name);
1638 error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES);
1644 if (rrpriv->fw_running){
1645 printk("%s: Firmware already running\n", dev->name);
1650 printk("%s: Updating EEPROM firmware\n", dev->name);
1652 spin_lock_irqsave(&rrpriv->lock, flags);
1653 error = write_eeprom(rrpriv, 0, image, EEPROM_BYTES);
1655 printk(KERN_ERR "%s: Error writing EEPROM\n",
1658 i = rr_read_eeprom(rrpriv, 0, oldimage, EEPROM_BYTES);
1659 spin_unlock_irqrestore(&rrpriv->lock, flags);
1661 if (i != EEPROM_BYTES)
1662 printk(KERN_ERR "%s: Error reading back EEPROM "
1663 "image\n", dev->name);
1665 error = memcmp(image, oldimage, EEPROM_BYTES);
1667 printk(KERN_ERR "%s: Error verifying EEPROM image\n",
1677 return put_user(0x52523032, (int __user *)rq->ifr_data);
1683 static struct pci_device_id rr_pci_tbl[] = {
1684 { PCI_VENDOR_ID_ESSENTIAL, PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER,
1685 PCI_ANY_ID, PCI_ANY_ID, },
1688 MODULE_DEVICE_TABLE(pci, rr_pci_tbl);
1690 static struct pci_driver rr_driver = {
1692 .id_table = rr_pci_tbl,
1693 .probe = rr_init_one,
1694 .remove = __devexit_p(rr_remove_one),
1697 static int __init rr_init_module(void)
1699 return pci_register_driver(&rr_driver);
1702 static void __exit rr_cleanup_module(void)
1704 pci_unregister_driver(&rr_driver);
1707 module_init(rr_init_module);
1708 module_exit(rr_cleanup_module);
1712 * compile-command: "gcc -D__KERNEL__ -I../../include -Wall -Wstrict-prototypes -O2 -pipe -fomit-frame-pointer -fno-strength-reduce -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DMODULE -DMODVERSIONS -include ../../include/linux/modversions.h -c rrunner.c"