Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * rrunner.c: Linux driver for the Essential RoadRunner HIPPI board. |
| 3 | * |
| 4 | * Copyright (C) 1998-2002 by Jes Sorensen, <jes@wildopensource.com>. |
| 5 | * |
| 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. |
| 11 | * |
| 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. |
| 16 | * |
| 17 | * Thanks to Jayaram Bhat from ODS/Essential for fixing some of the |
| 18 | * stupid bugs in my code. |
| 19 | * |
| 20 | * Softnet support and various other patches from Val Henson of |
| 21 | * ODS/Essential. |
| 22 | * |
| 23 | * PCI DMA mapping code partly based on work by Francois Romieu. |
| 24 | */ |
| 25 | |
| 26 | |
| 27 | #define DEBUG 1 |
| 28 | #define RX_DMA_SKBUFF 1 |
| 29 | #define PKT_COPY_THRESHOLD 512 |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/delay.h> |
| 41 | #include <linux/mm.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 42 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <net/sock.h> |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <asm/cache.h> |
| 46 | #include <asm/byteorder.h> |
| 47 | #include <asm/io.h> |
| 48 | #include <asm/irq.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 49 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | #define rr_if_busy(dev) netif_queue_stopped(dev) |
| 52 | #define rr_if_running(dev) netif_running(dev) |
| 53 | |
| 54 | #include "rrunner.h" |
| 55 | |
| 56 | #define RUN_AT(x) (jiffies + (x)) |
| 57 | |
| 58 | |
| 59 | MODULE_AUTHOR("Jes Sorensen <jes@wildopensource.com>"); |
| 60 | MODULE_DESCRIPTION("Essential RoadRunner HIPPI driver"); |
| 61 | MODULE_LICENSE("GPL"); |
| 62 | |
Bill Pemberton | 6e94549 | 2012-12-03 09:24:11 -0500 | [diff] [blame] | 63 | static char version[] = "rrunner.c: v0.50 11/11/2002 Jes Sorensen (jes@wildopensource.com)\n"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
Stephen Hemminger | 748ff68 | 2008-11-20 20:32:15 -0800 | [diff] [blame] | 65 | |
| 66 | static const struct net_device_ops rr_netdev_ops = { |
| 67 | .ndo_open = rr_open, |
| 68 | .ndo_stop = rr_close, |
| 69 | .ndo_do_ioctl = rr_ioctl, |
| 70 | .ndo_start_xmit = rr_start_xmit, |
Stephen Hemminger | 748ff68 | 2008-11-20 20:32:15 -0800 | [diff] [blame] | 71 | .ndo_set_mac_address = hippi_mac_addr, |
| 72 | }; |
| 73 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | /* |
| 75 | * Implementation notes: |
| 76 | * |
| 77 | * The DMA engine only allows for DMA within physical 64KB chunks of |
| 78 | * memory. The current approach of the driver (and stack) is to use |
| 79 | * linear blocks of memory for the skbuffs. However, as the data block |
| 80 | * is always the first part of the skb and skbs are 2^n aligned so we |
| 81 | * are guarantted to get the whole block within one 64KB align 64KB |
| 82 | * chunk. |
| 83 | * |
| 84 | * On the long term, relying on being able to allocate 64KB linear |
| 85 | * chunks of memory is not feasible and the skb handling code and the |
| 86 | * stack will need to know about I/O vectors or something similar. |
| 87 | */ |
| 88 | |
Greg Kroah-Hartman | 1dd06ae | 2012-12-06 14:30:56 +0000 | [diff] [blame] | 89 | static int rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | { |
| 91 | struct net_device *dev; |
| 92 | static int version_disp; |
| 93 | u8 pci_latency; |
| 94 | struct rr_private *rrpriv; |
| 95 | void *tmpptr; |
| 96 | dma_addr_t ring_dma; |
| 97 | int ret = -ENOMEM; |
| 98 | |
| 99 | dev = alloc_hippi_dev(sizeof(struct rr_private)); |
| 100 | if (!dev) |
| 101 | goto out3; |
| 102 | |
| 103 | ret = pci_enable_device(pdev); |
| 104 | if (ret) { |
| 105 | ret = -ENODEV; |
| 106 | goto out2; |
| 107 | } |
| 108 | |
| 109 | rrpriv = netdev_priv(dev); |
| 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | SET_NETDEV_DEV(dev, &pdev->dev); |
| 112 | |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 113 | ret = pci_request_regions(pdev, "rrunner"); |
| 114 | if (ret < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | pci_set_drvdata(pdev, dev); |
| 118 | |
| 119 | rrpriv->pci_dev = pdev; |
| 120 | |
| 121 | spin_lock_init(&rrpriv->lock); |
| 122 | |
Stephen Hemminger | 748ff68 | 2008-11-20 20:32:15 -0800 | [diff] [blame] | 123 | dev->netdev_ops = &rr_netdev_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | /* display version info if adapter is found */ |
| 126 | if (!version_disp) { |
| 127 | /* set display flag to TRUE so that */ |
| 128 | /* we only display this string ONCE */ |
| 129 | version_disp = 1; |
| 130 | printk(version); |
| 131 | } |
| 132 | |
| 133 | pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &pci_latency); |
| 134 | if (pci_latency <= 0x58){ |
| 135 | pci_latency = 0x58; |
| 136 | pci_write_config_byte(pdev, PCI_LATENCY_TIMER, pci_latency); |
| 137 | } |
| 138 | |
| 139 | pci_set_master(pdev); |
| 140 | |
| 141 | printk(KERN_INFO "%s: Essential RoadRunner serial HIPPI " |
Randy Dunlap | ecffe75 | 2012-04-16 15:01:33 +0000 | [diff] [blame] | 142 | "at 0x%llx, irq %i, PCI latency %i\n", dev->name, |
| 143 | (unsigned long long)pci_resource_start(pdev, 0), |
| 144 | pdev->irq, pci_latency); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | /* |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 147 | * Remap the MMIO regs into kernel space. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | */ |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 149 | rrpriv->regs = pci_iomap(pdev, 0, 0x1000); |
| 150 | if (!rrpriv->regs) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | printk(KERN_ERR "%s: Unable to map I/O register, " |
| 152 | "RoadRunner will be disabled.\n", dev->name); |
| 153 | ret = -EIO; |
| 154 | goto out; |
| 155 | } |
| 156 | |
| 157 | tmpptr = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma); |
| 158 | rrpriv->tx_ring = tmpptr; |
| 159 | rrpriv->tx_ring_dma = ring_dma; |
| 160 | |
| 161 | if (!tmpptr) { |
| 162 | ret = -ENOMEM; |
| 163 | goto out; |
| 164 | } |
| 165 | |
| 166 | tmpptr = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma); |
| 167 | rrpriv->rx_ring = tmpptr; |
| 168 | rrpriv->rx_ring_dma = ring_dma; |
| 169 | |
| 170 | if (!tmpptr) { |
| 171 | ret = -ENOMEM; |
| 172 | goto out; |
| 173 | } |
| 174 | |
| 175 | tmpptr = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma); |
| 176 | rrpriv->evt_ring = tmpptr; |
| 177 | rrpriv->evt_ring_dma = ring_dma; |
| 178 | |
| 179 | if (!tmpptr) { |
| 180 | ret = -ENOMEM; |
| 181 | goto out; |
| 182 | } |
| 183 | |
| 184 | /* |
| 185 | * Don't access any register before this point! |
| 186 | */ |
| 187 | #ifdef __BIG_ENDIAN |
| 188 | writel(readl(&rrpriv->regs->HostCtrl) | NO_SWAP, |
| 189 | &rrpriv->regs->HostCtrl); |
| 190 | #endif |
| 191 | /* |
| 192 | * Need to add a case for little-endian 64-bit hosts here. |
| 193 | */ |
| 194 | |
| 195 | rr_init(dev); |
| 196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | ret = register_netdev(dev); |
| 198 | if (ret) |
| 199 | goto out; |
| 200 | return 0; |
| 201 | |
| 202 | out: |
David Oostdyk | fef4c86 | 2013-03-08 08:28:15 +0000 | [diff] [blame] | 203 | if (rrpriv->evt_ring) |
| 204 | pci_free_consistent(pdev, EVT_RING_SIZE, rrpriv->evt_ring, |
| 205 | rrpriv->evt_ring_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | if (rrpriv->rx_ring) |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 207 | pci_free_consistent(pdev, RX_TOTAL_SIZE, rrpriv->rx_ring, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | rrpriv->rx_ring_dma); |
| 209 | if (rrpriv->tx_ring) |
| 210 | pci_free_consistent(pdev, TX_TOTAL_SIZE, rrpriv->tx_ring, |
| 211 | rrpriv->tx_ring_dma); |
| 212 | if (rrpriv->regs) |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 213 | pci_iounmap(pdev, rrpriv->regs); |
Jingoo Han | 79ac7c9 | 2013-12-10 12:48:38 +0900 | [diff] [blame] | 214 | if (pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | pci_release_regions(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | out2: |
| 217 | free_netdev(dev); |
| 218 | out3: |
| 219 | return ret; |
| 220 | } |
| 221 | |
Bill Pemberton | 6e94549 | 2012-12-03 09:24:11 -0500 | [diff] [blame] | 222 | static void rr_remove_one(struct pci_dev *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | { |
| 224 | struct net_device *dev = pci_get_drvdata(pdev); |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 225 | struct rr_private *rr = netdev_priv(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 227 | if (!(readl(&rr->regs->HostCtrl) & NIC_HALTED)) { |
| 228 | printk(KERN_ERR "%s: trying to unload running NIC\n", |
| 229 | dev->name); |
| 230 | writel(HALT_NIC, &rr->regs->HostCtrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | } |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 232 | |
| 233 | unregister_netdev(dev); |
| 234 | pci_free_consistent(pdev, EVT_RING_SIZE, rr->evt_ring, |
| 235 | rr->evt_ring_dma); |
| 236 | pci_free_consistent(pdev, RX_TOTAL_SIZE, rr->rx_ring, |
| 237 | rr->rx_ring_dma); |
| 238 | pci_free_consistent(pdev, TX_TOTAL_SIZE, rr->tx_ring, |
| 239 | rr->tx_ring_dma); |
| 240 | pci_iounmap(pdev, rr->regs); |
| 241 | pci_release_regions(pdev); |
| 242 | pci_disable_device(pdev); |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 243 | free_netdev(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | |
| 247 | /* |
| 248 | * Commands are considered to be slow, thus there is no reason to |
| 249 | * inline this. |
| 250 | */ |
| 251 | static void rr_issue_cmd(struct rr_private *rrpriv, struct cmd *cmd) |
| 252 | { |
| 253 | struct rr_regs __iomem *regs; |
| 254 | u32 idx; |
| 255 | |
| 256 | regs = rrpriv->regs; |
| 257 | /* |
| 258 | * This is temporary - it will go away in the final version. |
| 259 | * We probably also want to make this function inline. |
| 260 | */ |
| 261 | if (readl(®s->HostCtrl) & NIC_HALTED){ |
| 262 | printk("issuing command for halted NIC, code 0x%x, " |
| 263 | "HostCtrl %08x\n", cmd->code, readl(®s->HostCtrl)); |
| 264 | if (readl(®s->Mode) & FATAL_ERR) |
| 265 | printk("error codes Fail1 %02x, Fail2 %02x\n", |
| 266 | readl(®s->Fail1), readl(®s->Fail2)); |
| 267 | } |
| 268 | |
| 269 | idx = rrpriv->info->cmd_ctrl.pi; |
| 270 | |
| 271 | writel(*(u32*)(cmd), ®s->CmdRing[idx]); |
| 272 | wmb(); |
| 273 | |
| 274 | idx = (idx - 1) % CMD_RING_ENTRIES; |
| 275 | rrpriv->info->cmd_ctrl.pi = idx; |
| 276 | wmb(); |
| 277 | |
| 278 | if (readl(®s->Mode) & FATAL_ERR) |
| 279 | printk("error code %02x\n", readl(®s->Fail1)); |
| 280 | } |
| 281 | |
| 282 | |
| 283 | /* |
| 284 | * Reset the board in a sensible manner. The NIC is already halted |
| 285 | * when we get here and a spin-lock is held. |
| 286 | */ |
| 287 | static int rr_reset(struct net_device *dev) |
| 288 | { |
| 289 | struct rr_private *rrpriv; |
| 290 | struct rr_regs __iomem *regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | u32 start_pc; |
| 292 | int i; |
| 293 | |
| 294 | rrpriv = netdev_priv(dev); |
| 295 | regs = rrpriv->regs; |
| 296 | |
| 297 | rr_load_firmware(dev); |
| 298 | |
| 299 | writel(0x01000000, ®s->TX_state); |
| 300 | writel(0xff800000, ®s->RX_state); |
| 301 | writel(0, ®s->AssistState); |
| 302 | writel(CLEAR_INTA, ®s->LocalCtrl); |
| 303 | writel(0x01, ®s->BrkPt); |
| 304 | writel(0, ®s->Timer); |
| 305 | writel(0, ®s->TimerRef); |
| 306 | writel(RESET_DMA, ®s->DmaReadState); |
| 307 | writel(RESET_DMA, ®s->DmaWriteState); |
| 308 | writel(0, ®s->DmaWriteHostHi); |
| 309 | writel(0, ®s->DmaWriteHostLo); |
| 310 | writel(0, ®s->DmaReadHostHi); |
| 311 | writel(0, ®s->DmaReadHostLo); |
| 312 | writel(0, ®s->DmaReadLen); |
| 313 | writel(0, ®s->DmaWriteLen); |
| 314 | writel(0, ®s->DmaWriteLcl); |
| 315 | writel(0, ®s->DmaWriteIPchecksum); |
| 316 | writel(0, ®s->DmaReadLcl); |
| 317 | writel(0, ®s->DmaReadIPchecksum); |
| 318 | writel(0, ®s->PciState); |
| 319 | #if (BITS_PER_LONG == 64) && defined __LITTLE_ENDIAN |
| 320 | writel(SWAP_DATA | PTR64BIT | PTR_WD_SWAP, ®s->Mode); |
| 321 | #elif (BITS_PER_LONG == 64) |
| 322 | writel(SWAP_DATA | PTR64BIT | PTR_WD_NOSWAP, ®s->Mode); |
| 323 | #else |
| 324 | writel(SWAP_DATA | PTR32BIT | PTR_WD_NOSWAP, ®s->Mode); |
| 325 | #endif |
| 326 | |
| 327 | #if 0 |
| 328 | /* |
| 329 | * Don't worry, this is just black magic. |
| 330 | */ |
| 331 | writel(0xdf000, ®s->RxBase); |
| 332 | writel(0xdf000, ®s->RxPrd); |
| 333 | writel(0xdf000, ®s->RxCon); |
| 334 | writel(0xce000, ®s->TxBase); |
| 335 | writel(0xce000, ®s->TxPrd); |
| 336 | writel(0xce000, ®s->TxCon); |
| 337 | writel(0, ®s->RxIndPro); |
| 338 | writel(0, ®s->RxIndCon); |
| 339 | writel(0, ®s->RxIndRef); |
| 340 | writel(0, ®s->TxIndPro); |
| 341 | writel(0, ®s->TxIndCon); |
| 342 | writel(0, ®s->TxIndRef); |
| 343 | writel(0xcc000, ®s->pad10[0]); |
| 344 | writel(0, ®s->DrCmndPro); |
| 345 | writel(0, ®s->DrCmndCon); |
| 346 | writel(0, ®s->DwCmndPro); |
| 347 | writel(0, ®s->DwCmndCon); |
| 348 | writel(0, ®s->DwCmndRef); |
| 349 | writel(0, ®s->DrDataPro); |
| 350 | writel(0, ®s->DrDataCon); |
| 351 | writel(0, ®s->DrDataRef); |
| 352 | writel(0, ®s->DwDataPro); |
| 353 | writel(0, ®s->DwDataCon); |
| 354 | writel(0, ®s->DwDataRef); |
| 355 | #endif |
| 356 | |
| 357 | writel(0xffffffff, ®s->MbEvent); |
| 358 | writel(0, ®s->Event); |
| 359 | |
| 360 | writel(0, ®s->TxPi); |
| 361 | writel(0, ®s->IpRxPi); |
| 362 | |
| 363 | writel(0, ®s->EvtCon); |
| 364 | writel(0, ®s->EvtPrd); |
| 365 | |
| 366 | rrpriv->info->evt_ctrl.pi = 0; |
| 367 | |
| 368 | for (i = 0; i < CMD_RING_ENTRIES; i++) |
| 369 | writel(0, ®s->CmdRing[i]); |
| 370 | |
| 371 | /* |
| 372 | * Why 32 ? is this not cache line size dependent? |
| 373 | */ |
| 374 | writel(RBURST_64|WBURST_64, ®s->PciState); |
| 375 | wmb(); |
| 376 | |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 377 | start_pc = rr_read_eeprom_word(rrpriv, |
| 378 | offsetof(struct eeprom, rncd_info.FwStart)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | |
| 380 | #if (DEBUG > 1) |
| 381 | printk("%s: Executing firmware at address 0x%06x\n", |
| 382 | dev->name, start_pc); |
| 383 | #endif |
| 384 | |
| 385 | writel(start_pc + 0x800, ®s->Pc); |
| 386 | wmb(); |
| 387 | udelay(5); |
| 388 | |
| 389 | writel(start_pc, ®s->Pc); |
| 390 | wmb(); |
| 391 | |
| 392 | return 0; |
| 393 | } |
| 394 | |
| 395 | |
| 396 | /* |
| 397 | * Read a string from the EEPROM. |
| 398 | */ |
| 399 | static unsigned int rr_read_eeprom(struct rr_private *rrpriv, |
| 400 | unsigned long offset, |
| 401 | unsigned char *buf, |
| 402 | unsigned long length) |
| 403 | { |
| 404 | struct rr_regs __iomem *regs = rrpriv->regs; |
| 405 | u32 misc, io, host, i; |
| 406 | |
| 407 | io = readl(®s->ExtIo); |
| 408 | writel(0, ®s->ExtIo); |
| 409 | misc = readl(®s->LocalCtrl); |
| 410 | writel(0, ®s->LocalCtrl); |
| 411 | host = readl(®s->HostCtrl); |
| 412 | writel(host | HALT_NIC, ®s->HostCtrl); |
| 413 | mb(); |
| 414 | |
| 415 | for (i = 0; i < length; i++){ |
| 416 | writel((EEPROM_BASE + ((offset+i) << 3)), ®s->WinBase); |
| 417 | mb(); |
| 418 | buf[i] = (readl(®s->WinData) >> 24) & 0xff; |
| 419 | mb(); |
| 420 | } |
| 421 | |
| 422 | writel(host, ®s->HostCtrl); |
| 423 | writel(misc, ®s->LocalCtrl); |
| 424 | writel(io, ®s->ExtIo); |
| 425 | mb(); |
| 426 | return i; |
| 427 | } |
| 428 | |
| 429 | |
| 430 | /* |
| 431 | * Shortcut to read one word (4 bytes) out of the EEPROM and convert |
| 432 | * it to our CPU byte-order. |
| 433 | */ |
| 434 | static u32 rr_read_eeprom_word(struct rr_private *rrpriv, |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 435 | size_t offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | { |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 437 | __be32 word; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 439 | if ((rr_read_eeprom(rrpriv, offset, |
| 440 | (unsigned char *)&word, 4) == 4)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | return be32_to_cpu(word); |
| 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | |
| 446 | /* |
| 447 | * Write a string to the EEPROM. |
| 448 | * |
| 449 | * This is only called when the firmware is not running. |
| 450 | */ |
| 451 | static unsigned int write_eeprom(struct rr_private *rrpriv, |
| 452 | unsigned long offset, |
| 453 | unsigned char *buf, |
| 454 | unsigned long length) |
| 455 | { |
| 456 | struct rr_regs __iomem *regs = rrpriv->regs; |
| 457 | u32 misc, io, data, i, j, ready, error = 0; |
| 458 | |
| 459 | io = readl(®s->ExtIo); |
| 460 | writel(0, ®s->ExtIo); |
| 461 | misc = readl(®s->LocalCtrl); |
| 462 | writel(ENABLE_EEPROM_WRITE, ®s->LocalCtrl); |
| 463 | mb(); |
| 464 | |
| 465 | for (i = 0; i < length; i++){ |
| 466 | writel((EEPROM_BASE + ((offset+i) << 3)), ®s->WinBase); |
| 467 | mb(); |
| 468 | data = buf[i] << 24; |
| 469 | /* |
| 470 | * Only try to write the data if it is not the same |
| 471 | * value already. |
| 472 | */ |
| 473 | if ((readl(®s->WinData) & 0xff000000) != data){ |
| 474 | writel(data, ®s->WinData); |
| 475 | ready = 0; |
| 476 | j = 0; |
| 477 | mb(); |
| 478 | while(!ready){ |
| 479 | udelay(20); |
| 480 | if ((readl(®s->WinData) & 0xff000000) == |
| 481 | data) |
| 482 | ready = 1; |
| 483 | mb(); |
| 484 | if (j++ > 5000){ |
| 485 | printk("data mismatch: %08x, " |
| 486 | "WinData %08x\n", data, |
| 487 | readl(®s->WinData)); |
| 488 | ready = 1; |
| 489 | error = 1; |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | writel(misc, ®s->LocalCtrl); |
| 496 | writel(io, ®s->ExtIo); |
| 497 | mb(); |
| 498 | |
| 499 | return error; |
| 500 | } |
| 501 | |
| 502 | |
Bill Pemberton | 6e94549 | 2012-12-03 09:24:11 -0500 | [diff] [blame] | 503 | static int rr_init(struct net_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | { |
| 505 | struct rr_private *rrpriv; |
| 506 | struct rr_regs __iomem *regs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | u32 sram_size, rev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | |
| 509 | rrpriv = netdev_priv(dev); |
| 510 | regs = rrpriv->regs; |
| 511 | |
| 512 | rev = readl(®s->FwRev); |
| 513 | rrpriv->fw_rev = rev; |
| 514 | if (rev > 0x00020024) |
| 515 | printk(" Firmware revision: %i.%i.%i\n", (rev >> 16), |
| 516 | ((rev >> 8) & 0xff), (rev & 0xff)); |
| 517 | else if (rev >= 0x00020000) { |
| 518 | printk(" Firmware revision: %i.%i.%i (2.0.37 or " |
| 519 | "later is recommended)\n", (rev >> 16), |
| 520 | ((rev >> 8) & 0xff), (rev & 0xff)); |
| 521 | }else{ |
| 522 | printk(" Firmware revision too old: %i.%i.%i, please " |
| 523 | "upgrade to 2.0.37 or later.\n", |
| 524 | (rev >> 16), ((rev >> 8) & 0xff), (rev & 0xff)); |
| 525 | } |
| 526 | |
| 527 | #if (DEBUG > 2) |
| 528 | printk(" Maximum receive rings %i\n", readl(®s->MaxRxRng)); |
| 529 | #endif |
| 530 | |
| 531 | /* |
| 532 | * Read the hardware address from the eeprom. The HW address |
| 533 | * is not really necessary for HIPPI but awfully convenient. |
| 534 | * The pointer arithmetic to put it in dev_addr is ugly, but |
| 535 | * Donald Becker does it this way for the GigE version of this |
| 536 | * card and it's shorter and more portable than any |
| 537 | * other method I've seen. -VAL |
| 538 | */ |
| 539 | |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 540 | *(__be16 *)(dev->dev_addr) = |
| 541 | htons(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA))); |
| 542 | *(__be32 *)(dev->dev_addr+2) = |
| 543 | htonl(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA[4]))); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 544 | |
Johannes Berg | e174961 | 2008-10-27 15:59:26 -0700 | [diff] [blame] | 545 | printk(" MAC: %pM\n", dev->dev_addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 547 | sram_size = rr_read_eeprom_word(rrpriv, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | printk(" SRAM size 0x%06x\n", sram_size); |
| 549 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | return 0; |
| 551 | } |
| 552 | |
| 553 | |
| 554 | static int rr_init1(struct net_device *dev) |
| 555 | { |
| 556 | struct rr_private *rrpriv; |
| 557 | struct rr_regs __iomem *regs; |
| 558 | unsigned long myjif, flags; |
| 559 | struct cmd cmd; |
| 560 | u32 hostctrl; |
| 561 | int ecode = 0; |
| 562 | short i; |
| 563 | |
| 564 | rrpriv = netdev_priv(dev); |
| 565 | regs = rrpriv->regs; |
| 566 | |
| 567 | spin_lock_irqsave(&rrpriv->lock, flags); |
| 568 | |
| 569 | hostctrl = readl(®s->HostCtrl); |
| 570 | writel(hostctrl | HALT_NIC | RR_CLEAR_INT, ®s->HostCtrl); |
| 571 | wmb(); |
| 572 | |
| 573 | if (hostctrl & PARITY_ERR){ |
| 574 | printk("%s: Parity error halting NIC - this is serious!\n", |
| 575 | dev->name); |
| 576 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
| 577 | ecode = -EFAULT; |
| 578 | goto error; |
| 579 | } |
| 580 | |
| 581 | set_rxaddr(regs, rrpriv->rx_ctrl_dma); |
| 582 | set_infoaddr(regs, rrpriv->info_dma); |
| 583 | |
| 584 | rrpriv->info->evt_ctrl.entry_size = sizeof(struct event); |
| 585 | rrpriv->info->evt_ctrl.entries = EVT_RING_ENTRIES; |
| 586 | rrpriv->info->evt_ctrl.mode = 0; |
| 587 | rrpriv->info->evt_ctrl.pi = 0; |
| 588 | set_rraddr(&rrpriv->info->evt_ctrl.rngptr, rrpriv->evt_ring_dma); |
| 589 | |
| 590 | rrpriv->info->cmd_ctrl.entry_size = sizeof(struct cmd); |
| 591 | rrpriv->info->cmd_ctrl.entries = CMD_RING_ENTRIES; |
| 592 | rrpriv->info->cmd_ctrl.mode = 0; |
| 593 | rrpriv->info->cmd_ctrl.pi = 15; |
| 594 | |
| 595 | for (i = 0; i < CMD_RING_ENTRIES; i++) { |
| 596 | writel(0, ®s->CmdRing[i]); |
| 597 | } |
| 598 | |
| 599 | for (i = 0; i < TX_RING_ENTRIES; i++) { |
| 600 | rrpriv->tx_ring[i].size = 0; |
| 601 | set_rraddr(&rrpriv->tx_ring[i].addr, 0); |
| 602 | rrpriv->tx_skbuff[i] = NULL; |
| 603 | } |
| 604 | rrpriv->info->tx_ctrl.entry_size = sizeof(struct tx_desc); |
| 605 | rrpriv->info->tx_ctrl.entries = TX_RING_ENTRIES; |
| 606 | rrpriv->info->tx_ctrl.mode = 0; |
| 607 | rrpriv->info->tx_ctrl.pi = 0; |
| 608 | set_rraddr(&rrpriv->info->tx_ctrl.rngptr, rrpriv->tx_ring_dma); |
| 609 | |
| 610 | /* |
| 611 | * Set dirty_tx before we start receiving interrupts, otherwise |
| 612 | * the interrupt handler might think it is supposed to process |
| 613 | * tx ints before we are up and running, which may cause a null |
| 614 | * pointer access in the int handler. |
| 615 | */ |
| 616 | rrpriv->tx_full = 0; |
| 617 | rrpriv->cur_rx = 0; |
| 618 | rrpriv->dirty_rx = rrpriv->dirty_tx = 0; |
| 619 | |
| 620 | rr_reset(dev); |
| 621 | |
| 622 | /* Tuning values */ |
| 623 | writel(0x5000, ®s->ConRetry); |
| 624 | writel(0x100, ®s->ConRetryTmr); |
| 625 | writel(0x500000, ®s->ConTmout); |
| 626 | writel(0x60, ®s->IntrTmr); |
| 627 | writel(0x500000, ®s->TxDataMvTimeout); |
| 628 | writel(0x200000, ®s->RxDataMvTimeout); |
| 629 | writel(0x80, ®s->WriteDmaThresh); |
| 630 | writel(0x80, ®s->ReadDmaThresh); |
| 631 | |
| 632 | rrpriv->fw_running = 0; |
| 633 | wmb(); |
| 634 | |
| 635 | hostctrl &= ~(HALT_NIC | INVALID_INST_B | PARITY_ERR); |
| 636 | writel(hostctrl, ®s->HostCtrl); |
| 637 | wmb(); |
| 638 | |
| 639 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
| 640 | |
| 641 | for (i = 0; i < RX_RING_ENTRIES; i++) { |
| 642 | struct sk_buff *skb; |
| 643 | dma_addr_t addr; |
| 644 | |
| 645 | rrpriv->rx_ring[i].mode = 0; |
| 646 | skb = alloc_skb(dev->mtu + HIPPI_HLEN, GFP_ATOMIC); |
| 647 | if (!skb) { |
| 648 | printk(KERN_WARNING "%s: Unable to allocate memory " |
| 649 | "for receive ring - halting NIC\n", dev->name); |
| 650 | ecode = -ENOMEM; |
| 651 | goto error; |
| 652 | } |
| 653 | rrpriv->rx_skbuff[i] = skb; |
| 654 | addr = pci_map_single(rrpriv->pci_dev, skb->data, |
| 655 | dev->mtu + HIPPI_HLEN, PCI_DMA_FROMDEVICE); |
| 656 | /* |
| 657 | * Sanity test to see if we conflict with the DMA |
| 658 | * limitations of the Roadrunner. |
| 659 | */ |
| 660 | if ((((unsigned long)skb->data) & 0xfff) > ~65320) |
| 661 | printk("skb alloc error\n"); |
| 662 | |
| 663 | set_rraddr(&rrpriv->rx_ring[i].addr, addr); |
| 664 | rrpriv->rx_ring[i].size = dev->mtu + HIPPI_HLEN; |
| 665 | } |
| 666 | |
| 667 | rrpriv->rx_ctrl[4].entry_size = sizeof(struct rx_desc); |
| 668 | rrpriv->rx_ctrl[4].entries = RX_RING_ENTRIES; |
| 669 | rrpriv->rx_ctrl[4].mode = 8; |
| 670 | rrpriv->rx_ctrl[4].pi = 0; |
| 671 | wmb(); |
| 672 | set_rraddr(&rrpriv->rx_ctrl[4].rngptr, rrpriv->rx_ring_dma); |
| 673 | |
| 674 | udelay(1000); |
| 675 | |
| 676 | /* |
| 677 | * Now start the FirmWare. |
| 678 | */ |
| 679 | cmd.code = C_START_FW; |
| 680 | cmd.ring = 0; |
| 681 | cmd.index = 0; |
| 682 | |
| 683 | rr_issue_cmd(rrpriv, &cmd); |
| 684 | |
| 685 | /* |
| 686 | * Give the FirmWare time to chew on the `get running' command. |
| 687 | */ |
| 688 | myjif = jiffies + 5 * HZ; |
| 689 | while (time_before(jiffies, myjif) && !rrpriv->fw_running) |
| 690 | cpu_relax(); |
| 691 | |
| 692 | netif_start_queue(dev); |
| 693 | |
| 694 | return ecode; |
| 695 | |
| 696 | error: |
| 697 | /* |
| 698 | * We might have gotten here because we are out of memory, |
| 699 | * make sure we release everything we allocated before failing |
| 700 | */ |
| 701 | for (i = 0; i < RX_RING_ENTRIES; i++) { |
| 702 | struct sk_buff *skb = rrpriv->rx_skbuff[i]; |
| 703 | |
| 704 | if (skb) { |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 705 | pci_unmap_single(rrpriv->pci_dev, |
| 706 | rrpriv->rx_ring[i].addr.addrlo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | dev->mtu + HIPPI_HLEN, |
| 708 | PCI_DMA_FROMDEVICE); |
| 709 | rrpriv->rx_ring[i].size = 0; |
| 710 | set_rraddr(&rrpriv->rx_ring[i].addr, 0); |
| 711 | dev_kfree_skb(skb); |
| 712 | rrpriv->rx_skbuff[i] = NULL; |
| 713 | } |
| 714 | } |
| 715 | return ecode; |
| 716 | } |
| 717 | |
| 718 | |
| 719 | /* |
| 720 | * All events are considered to be slow (RX/TX ints do not generate |
| 721 | * events) and are handled here, outside the main interrupt handler, |
| 722 | * to reduce the size of the handler. |
| 723 | */ |
| 724 | static u32 rr_handle_event(struct net_device *dev, u32 prodidx, u32 eidx) |
| 725 | { |
| 726 | struct rr_private *rrpriv; |
| 727 | struct rr_regs __iomem *regs; |
| 728 | u32 tmp; |
| 729 | |
| 730 | rrpriv = netdev_priv(dev); |
| 731 | regs = rrpriv->regs; |
| 732 | |
| 733 | while (prodidx != eidx){ |
| 734 | switch (rrpriv->evt_ring[eidx].code){ |
| 735 | case E_NIC_UP: |
| 736 | tmp = readl(®s->FwRev); |
| 737 | printk(KERN_INFO "%s: Firmware revision %i.%i.%i " |
| 738 | "up and running\n", dev->name, |
| 739 | (tmp >> 16), ((tmp >> 8) & 0xff), (tmp & 0xff)); |
| 740 | rrpriv->fw_running = 1; |
| 741 | writel(RX_RING_ENTRIES - 1, ®s->IpRxPi); |
| 742 | wmb(); |
| 743 | break; |
| 744 | case E_LINK_ON: |
| 745 | printk(KERN_INFO "%s: Optical link ON\n", dev->name); |
| 746 | break; |
| 747 | case E_LINK_OFF: |
| 748 | printk(KERN_INFO "%s: Optical link OFF\n", dev->name); |
| 749 | break; |
| 750 | case E_RX_IDLE: |
| 751 | printk(KERN_WARNING "%s: RX data not moving\n", |
| 752 | dev->name); |
| 753 | goto drop; |
| 754 | case E_WATCHDOG: |
| 755 | printk(KERN_INFO "%s: The watchdog is here to see " |
| 756 | "us\n", dev->name); |
| 757 | break; |
| 758 | case E_INTERN_ERR: |
| 759 | printk(KERN_ERR "%s: HIPPI Internal NIC error\n", |
| 760 | dev->name); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 761 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | ®s->HostCtrl); |
| 763 | wmb(); |
| 764 | break; |
| 765 | case E_HOST_ERR: |
| 766 | printk(KERN_ERR "%s: Host software error\n", |
| 767 | dev->name); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 768 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | ®s->HostCtrl); |
| 770 | wmb(); |
| 771 | break; |
| 772 | /* |
| 773 | * TX events. |
| 774 | */ |
| 775 | case E_CON_REJ: |
| 776 | printk(KERN_WARNING "%s: Connection rejected\n", |
| 777 | dev->name); |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 778 | dev->stats.tx_aborted_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | break; |
| 780 | case E_CON_TMOUT: |
| 781 | printk(KERN_WARNING "%s: Connection timeout\n", |
| 782 | dev->name); |
| 783 | break; |
| 784 | case E_DISC_ERR: |
| 785 | printk(KERN_WARNING "%s: HIPPI disconnect error\n", |
| 786 | dev->name); |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 787 | dev->stats.tx_aborted_errors++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | break; |
| 789 | case E_INT_PRTY: |
| 790 | printk(KERN_ERR "%s: HIPPI Internal Parity error\n", |
| 791 | dev->name); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 792 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | ®s->HostCtrl); |
| 794 | wmb(); |
| 795 | break; |
| 796 | case E_TX_IDLE: |
| 797 | printk(KERN_WARNING "%s: Transmitter idle\n", |
| 798 | dev->name); |
| 799 | break; |
| 800 | case E_TX_LINK_DROP: |
| 801 | printk(KERN_WARNING "%s: Link lost during transmit\n", |
| 802 | dev->name); |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 803 | dev->stats.tx_aborted_errors++; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 804 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | ®s->HostCtrl); |
| 806 | wmb(); |
| 807 | break; |
| 808 | case E_TX_INV_RNG: |
| 809 | printk(KERN_ERR "%s: Invalid send ring block\n", |
| 810 | dev->name); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 811 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 812 | ®s->HostCtrl); |
| 813 | wmb(); |
| 814 | break; |
| 815 | case E_TX_INV_BUF: |
| 816 | printk(KERN_ERR "%s: Invalid send buffer address\n", |
| 817 | dev->name); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 818 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | ®s->HostCtrl); |
| 820 | wmb(); |
| 821 | break; |
| 822 | case E_TX_INV_DSC: |
| 823 | printk(KERN_ERR "%s: Invalid descriptor address\n", |
| 824 | dev->name); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 825 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | ®s->HostCtrl); |
| 827 | wmb(); |
| 828 | break; |
| 829 | /* |
| 830 | * RX events. |
| 831 | */ |
| 832 | case E_RX_RNG_OUT: |
| 833 | printk(KERN_INFO "%s: Receive ring full\n", dev->name); |
| 834 | break; |
| 835 | |
| 836 | case E_RX_PAR_ERR: |
| 837 | printk(KERN_WARNING "%s: Receive parity error\n", |
| 838 | dev->name); |
| 839 | goto drop; |
| 840 | case E_RX_LLRC_ERR: |
| 841 | printk(KERN_WARNING "%s: Receive LLRC error\n", |
| 842 | dev->name); |
| 843 | goto drop; |
| 844 | case E_PKT_LN_ERR: |
| 845 | printk(KERN_WARNING "%s: Receive packet length " |
| 846 | "error\n", dev->name); |
| 847 | goto drop; |
| 848 | case E_DTA_CKSM_ERR: |
| 849 | printk(KERN_WARNING "%s: Data checksum error\n", |
| 850 | dev->name); |
| 851 | goto drop; |
| 852 | case E_SHT_BST: |
| 853 | printk(KERN_WARNING "%s: Unexpected short burst " |
| 854 | "error\n", dev->name); |
| 855 | goto drop; |
| 856 | case E_STATE_ERR: |
| 857 | printk(KERN_WARNING "%s: Recv. state transition" |
| 858 | " error\n", dev->name); |
| 859 | goto drop; |
| 860 | case E_UNEXP_DATA: |
| 861 | printk(KERN_WARNING "%s: Unexpected data error\n", |
| 862 | dev->name); |
| 863 | goto drop; |
| 864 | case E_LST_LNK_ERR: |
| 865 | printk(KERN_WARNING "%s: Link lost error\n", |
| 866 | dev->name); |
| 867 | goto drop; |
| 868 | case E_FRM_ERR: |
| 869 | printk(KERN_WARNING "%s: Framming Error\n", |
| 870 | dev->name); |
| 871 | goto drop; |
| 872 | case E_FLG_SYN_ERR: |
Joe Perches | 2450022 | 2007-11-19 17:48:28 -0800 | [diff] [blame] | 873 | printk(KERN_WARNING "%s: Flag sync. lost during " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | "packet\n", dev->name); |
| 875 | goto drop; |
| 876 | case E_RX_INV_BUF: |
| 877 | printk(KERN_ERR "%s: Invalid receive buffer " |
| 878 | "address\n", dev->name); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 879 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 880 | ®s->HostCtrl); |
| 881 | wmb(); |
| 882 | break; |
| 883 | case E_RX_INV_DSC: |
| 884 | printk(KERN_ERR "%s: Invalid receive descriptor " |
| 885 | "address\n", dev->name); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 886 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | ®s->HostCtrl); |
| 888 | wmb(); |
| 889 | break; |
| 890 | case E_RNG_BLK: |
| 891 | printk(KERN_ERR "%s: Invalid ring block\n", |
| 892 | dev->name); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 893 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 894 | ®s->HostCtrl); |
| 895 | wmb(); |
| 896 | break; |
| 897 | drop: |
| 898 | /* Label packet to be dropped. |
| 899 | * Actual dropping occurs in rx |
| 900 | * handling. |
| 901 | * |
| 902 | * The index of packet we get to drop is |
| 903 | * the index of the packet following |
| 904 | * the bad packet. -kbf |
| 905 | */ |
| 906 | { |
| 907 | u16 index = rrpriv->evt_ring[eidx].index; |
| 908 | index = (index + (RX_RING_ENTRIES - 1)) % |
| 909 | RX_RING_ENTRIES; |
| 910 | rrpriv->rx_ring[index].mode |= |
| 911 | (PACKET_BAD | PACKET_END); |
| 912 | } |
| 913 | break; |
| 914 | default: |
| 915 | printk(KERN_WARNING "%s: Unhandled event 0x%02x\n", |
| 916 | dev->name, rrpriv->evt_ring[eidx].code); |
| 917 | } |
| 918 | eidx = (eidx + 1) % EVT_RING_ENTRIES; |
| 919 | } |
| 920 | |
| 921 | rrpriv->info->evt_ctrl.pi = eidx; |
| 922 | wmb(); |
| 923 | return eidx; |
| 924 | } |
| 925 | |
| 926 | |
| 927 | static void rx_int(struct net_device *dev, u32 rxlimit, u32 index) |
| 928 | { |
| 929 | struct rr_private *rrpriv = netdev_priv(dev); |
| 930 | struct rr_regs __iomem *regs = rrpriv->regs; |
| 931 | |
| 932 | do { |
| 933 | struct rx_desc *desc; |
| 934 | u32 pkt_len; |
| 935 | |
| 936 | desc = &(rrpriv->rx_ring[index]); |
| 937 | pkt_len = desc->size; |
| 938 | #if (DEBUG > 2) |
| 939 | printk("index %i, rxlimit %i\n", index, rxlimit); |
| 940 | printk("len %x, mode %x\n", pkt_len, desc->mode); |
| 941 | #endif |
| 942 | if ( (rrpriv->rx_ring[index].mode & PACKET_BAD) == PACKET_BAD){ |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 943 | dev->stats.rx_dropped++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | goto defer; |
| 945 | } |
| 946 | |
| 947 | if (pkt_len > 0){ |
| 948 | struct sk_buff *skb, *rx_skb; |
| 949 | |
| 950 | rx_skb = rrpriv->rx_skbuff[index]; |
| 951 | |
| 952 | if (pkt_len < PKT_COPY_THRESHOLD) { |
| 953 | skb = alloc_skb(pkt_len, GFP_ATOMIC); |
| 954 | if (skb == NULL){ |
| 955 | printk(KERN_WARNING "%s: Unable to allocate skb (%i bytes), deferring packet\n", dev->name, pkt_len); |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 956 | dev->stats.rx_dropped++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | goto defer; |
| 958 | } else { |
| 959 | pci_dma_sync_single_for_cpu(rrpriv->pci_dev, |
| 960 | desc->addr.addrlo, |
| 961 | pkt_len, |
| 962 | PCI_DMA_FROMDEVICE); |
| 963 | |
| 964 | memcpy(skb_put(skb, pkt_len), |
| 965 | rx_skb->data, pkt_len); |
| 966 | |
| 967 | pci_dma_sync_single_for_device(rrpriv->pci_dev, |
| 968 | desc->addr.addrlo, |
| 969 | pkt_len, |
| 970 | PCI_DMA_FROMDEVICE); |
| 971 | } |
| 972 | }else{ |
| 973 | struct sk_buff *newskb; |
| 974 | |
| 975 | newskb = alloc_skb(dev->mtu + HIPPI_HLEN, |
| 976 | GFP_ATOMIC); |
| 977 | if (newskb){ |
| 978 | dma_addr_t addr; |
| 979 | |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 980 | pci_unmap_single(rrpriv->pci_dev, |
| 981 | desc->addr.addrlo, dev->mtu + |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 982 | HIPPI_HLEN, PCI_DMA_FROMDEVICE); |
| 983 | skb = rx_skb; |
| 984 | skb_put(skb, pkt_len); |
| 985 | rrpriv->rx_skbuff[index] = newskb; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 986 | addr = pci_map_single(rrpriv->pci_dev, |
| 987 | newskb->data, |
| 988 | dev->mtu + HIPPI_HLEN, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | PCI_DMA_FROMDEVICE); |
| 990 | set_rraddr(&desc->addr, addr); |
| 991 | } else { |
| 992 | printk("%s: Out of memory, deferring " |
| 993 | "packet\n", dev->name); |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 994 | dev->stats.rx_dropped++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | goto defer; |
| 996 | } |
| 997 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | skb->protocol = hippi_type_trans(skb, dev); |
| 999 | |
| 1000 | netif_rx(skb); /* send it up */ |
| 1001 | |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1002 | dev->stats.rx_packets++; |
| 1003 | dev->stats.rx_bytes += pkt_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | } |
| 1005 | defer: |
| 1006 | desc->mode = 0; |
| 1007 | desc->size = dev->mtu + HIPPI_HLEN; |
| 1008 | |
| 1009 | if ((index & 7) == 7) |
| 1010 | writel(index, ®s->IpRxPi); |
| 1011 | |
| 1012 | index = (index + 1) % RX_RING_ENTRIES; |
| 1013 | } while(index != rxlimit); |
| 1014 | |
| 1015 | rrpriv->cur_rx = index; |
| 1016 | wmb(); |
| 1017 | } |
| 1018 | |
| 1019 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 1020 | static irqreturn_t rr_interrupt(int irq, void *dev_id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 | { |
| 1022 | struct rr_private *rrpriv; |
| 1023 | struct rr_regs __iomem *regs; |
| 1024 | struct net_device *dev = (struct net_device *)dev_id; |
| 1025 | u32 prodidx, rxindex, eidx, txcsmr, rxlimit, txcon; |
| 1026 | |
| 1027 | rrpriv = netdev_priv(dev); |
| 1028 | regs = rrpriv->regs; |
| 1029 | |
| 1030 | if (!(readl(®s->HostCtrl) & RR_INT)) |
| 1031 | return IRQ_NONE; |
| 1032 | |
| 1033 | spin_lock(&rrpriv->lock); |
| 1034 | |
| 1035 | prodidx = readl(®s->EvtPrd); |
| 1036 | txcsmr = (prodidx >> 8) & 0xff; |
| 1037 | rxlimit = (prodidx >> 16) & 0xff; |
| 1038 | prodidx &= 0xff; |
| 1039 | |
| 1040 | #if (DEBUG > 2) |
| 1041 | printk("%s: interrupt, prodidx = %i, eidx = %i\n", dev->name, |
| 1042 | prodidx, rrpriv->info->evt_ctrl.pi); |
| 1043 | #endif |
| 1044 | /* |
| 1045 | * Order here is important. We must handle events |
| 1046 | * before doing anything else in order to catch |
| 1047 | * such things as LLRC errors, etc -kbf |
| 1048 | */ |
| 1049 | |
| 1050 | eidx = rrpriv->info->evt_ctrl.pi; |
| 1051 | if (prodidx != eidx) |
| 1052 | eidx = rr_handle_event(dev, prodidx, eidx); |
| 1053 | |
| 1054 | rxindex = rrpriv->cur_rx; |
| 1055 | if (rxindex != rxlimit) |
| 1056 | rx_int(dev, rxlimit, rxindex); |
| 1057 | |
| 1058 | txcon = rrpriv->dirty_tx; |
| 1059 | if (txcsmr != txcon) { |
| 1060 | do { |
| 1061 | /* Due to occational firmware TX producer/consumer out |
| 1062 | * of sync. error need to check entry in ring -kbf |
| 1063 | */ |
| 1064 | if(rrpriv->tx_skbuff[txcon]){ |
| 1065 | struct tx_desc *desc; |
| 1066 | struct sk_buff *skb; |
| 1067 | |
| 1068 | desc = &(rrpriv->tx_ring[txcon]); |
| 1069 | skb = rrpriv->tx_skbuff[txcon]; |
| 1070 | |
Jeff Garzik | 09f75cd | 2007-10-03 17:41:50 -0700 | [diff] [blame] | 1071 | dev->stats.tx_packets++; |
| 1072 | dev->stats.tx_bytes += skb->len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | |
| 1074 | pci_unmap_single(rrpriv->pci_dev, |
| 1075 | desc->addr.addrlo, skb->len, |
| 1076 | PCI_DMA_TODEVICE); |
| 1077 | dev_kfree_skb_irq(skb); |
| 1078 | |
| 1079 | rrpriv->tx_skbuff[txcon] = NULL; |
| 1080 | desc->size = 0; |
| 1081 | set_rraddr(&rrpriv->tx_ring[txcon].addr, 0); |
| 1082 | desc->mode = 0; |
| 1083 | } |
| 1084 | txcon = (txcon + 1) % TX_RING_ENTRIES; |
| 1085 | } while (txcsmr != txcon); |
| 1086 | wmb(); |
| 1087 | |
| 1088 | rrpriv->dirty_tx = txcon; |
| 1089 | if (rrpriv->tx_full && rr_if_busy(dev) && |
| 1090 | (((rrpriv->info->tx_ctrl.pi + 1) % TX_RING_ENTRIES) |
| 1091 | != rrpriv->dirty_tx)){ |
| 1092 | rrpriv->tx_full = 0; |
| 1093 | netif_wake_queue(dev); |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | eidx |= ((txcsmr << 8) | (rxlimit << 16)); |
| 1098 | writel(eidx, ®s->EvtCon); |
| 1099 | wmb(); |
| 1100 | |
| 1101 | spin_unlock(&rrpriv->lock); |
| 1102 | return IRQ_HANDLED; |
| 1103 | } |
| 1104 | |
| 1105 | static inline void rr_raz_tx(struct rr_private *rrpriv, |
| 1106 | struct net_device *dev) |
| 1107 | { |
| 1108 | int i; |
| 1109 | |
| 1110 | for (i = 0; i < TX_RING_ENTRIES; i++) { |
| 1111 | struct sk_buff *skb = rrpriv->tx_skbuff[i]; |
| 1112 | |
| 1113 | if (skb) { |
| 1114 | struct tx_desc *desc = &(rrpriv->tx_ring[i]); |
| 1115 | |
| 1116 | pci_unmap_single(rrpriv->pci_dev, desc->addr.addrlo, |
| 1117 | skb->len, PCI_DMA_TODEVICE); |
| 1118 | desc->size = 0; |
| 1119 | set_rraddr(&desc->addr, 0); |
| 1120 | dev_kfree_skb(skb); |
| 1121 | rrpriv->tx_skbuff[i] = NULL; |
| 1122 | } |
| 1123 | } |
| 1124 | } |
| 1125 | |
| 1126 | |
| 1127 | static inline void rr_raz_rx(struct rr_private *rrpriv, |
| 1128 | struct net_device *dev) |
| 1129 | { |
| 1130 | int i; |
| 1131 | |
| 1132 | for (i = 0; i < RX_RING_ENTRIES; i++) { |
| 1133 | struct sk_buff *skb = rrpriv->rx_skbuff[i]; |
| 1134 | |
| 1135 | if (skb) { |
| 1136 | struct rx_desc *desc = &(rrpriv->rx_ring[i]); |
| 1137 | |
| 1138 | pci_unmap_single(rrpriv->pci_dev, desc->addr.addrlo, |
| 1139 | dev->mtu + HIPPI_HLEN, PCI_DMA_FROMDEVICE); |
| 1140 | desc->size = 0; |
| 1141 | set_rraddr(&desc->addr, 0); |
| 1142 | dev_kfree_skb(skb); |
| 1143 | rrpriv->rx_skbuff[i] = NULL; |
| 1144 | } |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | static void rr_timer(unsigned long data) |
| 1149 | { |
| 1150 | struct net_device *dev = (struct net_device *)data; |
| 1151 | struct rr_private *rrpriv = netdev_priv(dev); |
| 1152 | struct rr_regs __iomem *regs = rrpriv->regs; |
| 1153 | unsigned long flags; |
| 1154 | |
| 1155 | if (readl(®s->HostCtrl) & NIC_HALTED){ |
| 1156 | printk("%s: Restarting nic\n", dev->name); |
| 1157 | memset(rrpriv->rx_ctrl, 0, 256 * sizeof(struct ring_ctrl)); |
| 1158 | memset(rrpriv->info, 0, sizeof(struct rr_info)); |
| 1159 | wmb(); |
| 1160 | |
| 1161 | rr_raz_tx(rrpriv, dev); |
| 1162 | rr_raz_rx(rrpriv, dev); |
| 1163 | |
| 1164 | if (rr_init1(dev)) { |
| 1165 | spin_lock_irqsave(&rrpriv->lock, flags); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1166 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | ®s->HostCtrl); |
| 1168 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
| 1169 | } |
| 1170 | } |
| 1171 | rrpriv->timer.expires = RUN_AT(5*HZ); |
| 1172 | add_timer(&rrpriv->timer); |
| 1173 | } |
| 1174 | |
| 1175 | |
| 1176 | static int rr_open(struct net_device *dev) |
| 1177 | { |
| 1178 | struct rr_private *rrpriv = netdev_priv(dev); |
| 1179 | struct pci_dev *pdev = rrpriv->pci_dev; |
| 1180 | struct rr_regs __iomem *regs; |
| 1181 | int ecode = 0; |
| 1182 | unsigned long flags; |
| 1183 | dma_addr_t dma_addr; |
| 1184 | |
| 1185 | regs = rrpriv->regs; |
| 1186 | |
| 1187 | if (rrpriv->fw_rev < 0x00020000) { |
| 1188 | printk(KERN_WARNING "%s: trying to configure device with " |
| 1189 | "obsolete firmware\n", dev->name); |
| 1190 | ecode = -EBUSY; |
| 1191 | goto error; |
| 1192 | } |
| 1193 | |
| 1194 | rrpriv->rx_ctrl = pci_alloc_consistent(pdev, |
| 1195 | 256 * sizeof(struct ring_ctrl), |
| 1196 | &dma_addr); |
| 1197 | if (!rrpriv->rx_ctrl) { |
| 1198 | ecode = -ENOMEM; |
| 1199 | goto error; |
| 1200 | } |
| 1201 | rrpriv->rx_ctrl_dma = dma_addr; |
| 1202 | memset(rrpriv->rx_ctrl, 0, 256*sizeof(struct ring_ctrl)); |
| 1203 | |
| 1204 | rrpriv->info = pci_alloc_consistent(pdev, sizeof(struct rr_info), |
| 1205 | &dma_addr); |
| 1206 | if (!rrpriv->info) { |
| 1207 | ecode = -ENOMEM; |
| 1208 | goto error; |
| 1209 | } |
| 1210 | rrpriv->info_dma = dma_addr; |
| 1211 | memset(rrpriv->info, 0, sizeof(struct rr_info)); |
| 1212 | wmb(); |
| 1213 | |
| 1214 | spin_lock_irqsave(&rrpriv->lock, flags); |
| 1215 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, ®s->HostCtrl); |
| 1216 | readl(®s->HostCtrl); |
| 1217 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
| 1218 | |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 1219 | if (request_irq(pdev->irq, rr_interrupt, IRQF_SHARED, dev->name, dev)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1220 | printk(KERN_WARNING "%s: Requested IRQ %d is busy\n", |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 1221 | dev->name, pdev->irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | ecode = -EAGAIN; |
| 1223 | goto error; |
| 1224 | } |
| 1225 | |
| 1226 | if ((ecode = rr_init1(dev))) |
| 1227 | goto error; |
| 1228 | |
| 1229 | /* Set the timer to switch to check for link beat and perhaps switch |
| 1230 | to an alternate media type. */ |
| 1231 | init_timer(&rrpriv->timer); |
| 1232 | rrpriv->timer.expires = RUN_AT(5*HZ); /* 5 sec. watchdog */ |
| 1233 | rrpriv->timer.data = (unsigned long)dev; |
Joe Perches | c061b18 | 2010-08-23 18:20:03 +0000 | [diff] [blame] | 1234 | rrpriv->timer.function = rr_timer; /* timer handler */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | add_timer(&rrpriv->timer); |
| 1236 | |
| 1237 | netif_start_queue(dev); |
| 1238 | |
| 1239 | return ecode; |
| 1240 | |
| 1241 | error: |
| 1242 | spin_lock_irqsave(&rrpriv->lock, flags); |
| 1243 | writel(readl(®s->HostCtrl)|HALT_NIC|RR_CLEAR_INT, ®s->HostCtrl); |
| 1244 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
| 1245 | |
| 1246 | if (rrpriv->info) { |
| 1247 | pci_free_consistent(pdev, sizeof(struct rr_info), rrpriv->info, |
| 1248 | rrpriv->info_dma); |
| 1249 | rrpriv->info = NULL; |
| 1250 | } |
| 1251 | if (rrpriv->rx_ctrl) { |
| 1252 | pci_free_consistent(pdev, sizeof(struct ring_ctrl), |
| 1253 | rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma); |
| 1254 | rrpriv->rx_ctrl = NULL; |
| 1255 | } |
| 1256 | |
| 1257 | netif_stop_queue(dev); |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1258 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | return ecode; |
| 1260 | } |
| 1261 | |
| 1262 | |
| 1263 | static void rr_dump(struct net_device *dev) |
| 1264 | { |
| 1265 | struct rr_private *rrpriv; |
| 1266 | struct rr_regs __iomem *regs; |
| 1267 | u32 index, cons; |
| 1268 | short i; |
| 1269 | int len; |
| 1270 | |
| 1271 | rrpriv = netdev_priv(dev); |
| 1272 | regs = rrpriv->regs; |
| 1273 | |
| 1274 | printk("%s: dumping NIC TX rings\n", dev->name); |
| 1275 | |
| 1276 | printk("RxPrd %08x, TxPrd %02x, EvtPrd %08x, TxPi %02x, TxCtrlPi %02x\n", |
| 1277 | readl(®s->RxPrd), readl(®s->TxPrd), |
| 1278 | readl(®s->EvtPrd), readl(®s->TxPi), |
| 1279 | rrpriv->info->tx_ctrl.pi); |
| 1280 | |
| 1281 | printk("Error code 0x%x\n", readl(®s->Fail1)); |
| 1282 | |
Dan Carpenter | 2585e7e | 2010-01-02 04:08:46 +0000 | [diff] [blame] | 1283 | index = (((readl(®s->EvtPrd) >> 8) & 0xff) - 1) % TX_RING_ENTRIES; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1284 | cons = rrpriv->dirty_tx; |
| 1285 | printk("TX ring index %i, TX consumer %i\n", |
| 1286 | index, cons); |
| 1287 | |
| 1288 | if (rrpriv->tx_skbuff[index]){ |
| 1289 | len = min_t(int, 0x80, rrpriv->tx_skbuff[index]->len); |
| 1290 | printk("skbuff for index %i is valid - dumping data (0x%x bytes - DMA len 0x%x)\n", index, len, rrpriv->tx_ring[index].size); |
| 1291 | for (i = 0; i < len; i++){ |
| 1292 | if (!(i & 7)) |
| 1293 | printk("\n"); |
| 1294 | printk("%02x ", (unsigned char) rrpriv->tx_skbuff[index]->data[i]); |
| 1295 | } |
| 1296 | printk("\n"); |
| 1297 | } |
| 1298 | |
| 1299 | if (rrpriv->tx_skbuff[cons]){ |
| 1300 | len = min_t(int, 0x80, rrpriv->tx_skbuff[cons]->len); |
| 1301 | printk("skbuff for cons %i is valid - dumping data (0x%x bytes - skbuff len 0x%x)\n", cons, len, rrpriv->tx_skbuff[cons]->len); |
| 1302 | printk("mode 0x%x, size 0x%x,\n phys %08Lx, skbuff-addr %08lx, truesize 0x%x\n", |
| 1303 | rrpriv->tx_ring[cons].mode, |
| 1304 | rrpriv->tx_ring[cons].size, |
| 1305 | (unsigned long long) rrpriv->tx_ring[cons].addr.addrlo, |
| 1306 | (unsigned long)rrpriv->tx_skbuff[cons]->data, |
| 1307 | (unsigned int)rrpriv->tx_skbuff[cons]->truesize); |
| 1308 | for (i = 0; i < len; i++){ |
| 1309 | if (!(i & 7)) |
| 1310 | printk("\n"); |
| 1311 | printk("%02x ", (unsigned char)rrpriv->tx_ring[cons].size); |
| 1312 | } |
| 1313 | printk("\n"); |
| 1314 | } |
| 1315 | |
| 1316 | printk("dumping TX ring info:\n"); |
| 1317 | for (i = 0; i < TX_RING_ENTRIES; i++) |
| 1318 | printk("mode 0x%x, size 0x%x, phys-addr %08Lx\n", |
| 1319 | rrpriv->tx_ring[i].mode, |
| 1320 | rrpriv->tx_ring[i].size, |
| 1321 | (unsigned long long) rrpriv->tx_ring[i].addr.addrlo); |
| 1322 | |
| 1323 | } |
| 1324 | |
| 1325 | |
| 1326 | static int rr_close(struct net_device *dev) |
| 1327 | { |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 1328 | struct rr_private *rrpriv = netdev_priv(dev); |
| 1329 | struct rr_regs __iomem *regs = rrpriv->regs; |
| 1330 | struct pci_dev *pdev = rrpriv->pci_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | unsigned long flags; |
| 1332 | u32 tmp; |
| 1333 | short i; |
| 1334 | |
| 1335 | netif_stop_queue(dev); |
| 1336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1337 | |
| 1338 | /* |
| 1339 | * Lock to make sure we are not cleaning up while another CPU |
| 1340 | * is handling interrupts. |
| 1341 | */ |
| 1342 | spin_lock_irqsave(&rrpriv->lock, flags); |
| 1343 | |
| 1344 | tmp = readl(®s->HostCtrl); |
| 1345 | if (tmp & NIC_HALTED){ |
| 1346 | printk("%s: NIC already halted\n", dev->name); |
| 1347 | rr_dump(dev); |
| 1348 | }else{ |
| 1349 | tmp |= HALT_NIC | RR_CLEAR_INT; |
| 1350 | writel(tmp, ®s->HostCtrl); |
| 1351 | readl(®s->HostCtrl); |
| 1352 | } |
| 1353 | |
| 1354 | rrpriv->fw_running = 0; |
| 1355 | |
| 1356 | del_timer_sync(&rrpriv->timer); |
| 1357 | |
| 1358 | writel(0, ®s->TxPi); |
| 1359 | writel(0, ®s->IpRxPi); |
| 1360 | |
| 1361 | writel(0, ®s->EvtCon); |
| 1362 | writel(0, ®s->EvtPrd); |
| 1363 | |
| 1364 | for (i = 0; i < CMD_RING_ENTRIES; i++) |
| 1365 | writel(0, ®s->CmdRing[i]); |
| 1366 | |
| 1367 | rrpriv->info->tx_ctrl.entries = 0; |
| 1368 | rrpriv->info->cmd_ctrl.pi = 0; |
| 1369 | rrpriv->info->evt_ctrl.pi = 0; |
| 1370 | rrpriv->rx_ctrl[4].entries = 0; |
| 1371 | |
| 1372 | rr_raz_tx(rrpriv, dev); |
| 1373 | rr_raz_rx(rrpriv, dev); |
| 1374 | |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 1375 | pci_free_consistent(pdev, 256 * sizeof(struct ring_ctrl), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1376 | rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma); |
| 1377 | rrpriv->rx_ctrl = NULL; |
| 1378 | |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 1379 | pci_free_consistent(pdev, sizeof(struct rr_info), rrpriv->info, |
| 1380 | rrpriv->info_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | rrpriv->info = NULL; |
| 1382 | |
Francois Romieu | 0193fc5 | 2012-03-23 19:20:14 +0100 | [diff] [blame] | 1383 | free_irq(pdev->irq, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
| 1385 | |
| 1386 | return 0; |
| 1387 | } |
| 1388 | |
| 1389 | |
Stephen Hemminger | 61357325 | 2009-08-31 19:50:58 +0000 | [diff] [blame] | 1390 | static netdev_tx_t rr_start_xmit(struct sk_buff *skb, |
| 1391 | struct net_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | { |
| 1393 | struct rr_private *rrpriv = netdev_priv(dev); |
| 1394 | struct rr_regs __iomem *regs = rrpriv->regs; |
Stephen Hemminger | 6f1cf16 | 2005-08-09 19:31:17 -0700 | [diff] [blame] | 1395 | struct hippi_cb *hcb = (struct hippi_cb *) skb->cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1396 | struct ring_ctrl *txctrl; |
| 1397 | unsigned long flags; |
| 1398 | u32 index, len = skb->len; |
| 1399 | u32 *ifield; |
| 1400 | struct sk_buff *new_skb; |
| 1401 | |
| 1402 | if (readl(®s->Mode) & FATAL_ERR) |
| 1403 | printk("error codes Fail1 %02x, Fail2 %02x\n", |
| 1404 | readl(®s->Fail1), readl(®s->Fail2)); |
| 1405 | |
| 1406 | /* |
| 1407 | * We probably need to deal with tbusy here to prevent overruns. |
| 1408 | */ |
| 1409 | |
| 1410 | if (skb_headroom(skb) < 8){ |
| 1411 | printk("incoming skb too small - reallocating\n"); |
| 1412 | if (!(new_skb = dev_alloc_skb(len + 8))) { |
| 1413 | dev_kfree_skb(skb); |
| 1414 | netif_wake_queue(dev); |
Patrick McHardy | 3790c8c | 2009-06-12 03:00:35 +0000 | [diff] [blame] | 1415 | return NETDEV_TX_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1416 | } |
| 1417 | skb_reserve(new_skb, 8); |
| 1418 | skb_put(new_skb, len); |
Arnaldo Carvalho de Melo | d626f62 | 2007-03-27 18:55:52 -0300 | [diff] [blame] | 1419 | skb_copy_from_linear_data(skb, new_skb->data, len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | dev_kfree_skb(skb); |
| 1421 | skb = new_skb; |
| 1422 | } |
| 1423 | |
| 1424 | ifield = (u32 *)skb_push(skb, 8); |
| 1425 | |
| 1426 | ifield[0] = 0; |
Stephen Hemminger | 6f1cf16 | 2005-08-09 19:31:17 -0700 | [diff] [blame] | 1427 | ifield[1] = hcb->ifield; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | |
| 1429 | /* |
| 1430 | * We don't need the lock before we are actually going to start |
| 1431 | * fiddling with the control blocks. |
| 1432 | */ |
| 1433 | spin_lock_irqsave(&rrpriv->lock, flags); |
| 1434 | |
| 1435 | txctrl = &rrpriv->info->tx_ctrl; |
| 1436 | |
| 1437 | index = txctrl->pi; |
| 1438 | |
| 1439 | rrpriv->tx_skbuff[index] = skb; |
| 1440 | set_rraddr(&rrpriv->tx_ring[index].addr, pci_map_single( |
| 1441 | rrpriv->pci_dev, skb->data, len + 8, PCI_DMA_TODEVICE)); |
| 1442 | rrpriv->tx_ring[index].size = len + 8; /* include IFIELD */ |
| 1443 | rrpriv->tx_ring[index].mode = PACKET_START | PACKET_END; |
| 1444 | txctrl->pi = (index + 1) % TX_RING_ENTRIES; |
| 1445 | wmb(); |
| 1446 | writel(txctrl->pi, ®s->TxPi); |
| 1447 | |
| 1448 | if (txctrl->pi == rrpriv->dirty_tx){ |
| 1449 | rrpriv->tx_full = 1; |
| 1450 | netif_stop_queue(dev); |
| 1451 | } |
| 1452 | |
| 1453 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
| 1454 | |
Patrick McHardy | 6ed1065 | 2009-06-23 06:03:08 +0000 | [diff] [blame] | 1455 | return NETDEV_TX_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | } |
| 1457 | |
| 1458 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1459 | /* |
| 1460 | * Read the firmware out of the EEPROM and put it into the SRAM |
| 1461 | * (or from user space - later) |
| 1462 | * |
| 1463 | * This operation requires the NIC to be halted and is performed with |
| 1464 | * interrupts disabled and with the spinlock hold. |
| 1465 | */ |
| 1466 | static int rr_load_firmware(struct net_device *dev) |
| 1467 | { |
| 1468 | struct rr_private *rrpriv; |
| 1469 | struct rr_regs __iomem *regs; |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1470 | size_t eptr, segptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1471 | int i, j; |
| 1472 | u32 localctrl, sptr, len, tmp; |
| 1473 | u32 p2len, p2size, nr_seg, revision, io, sram_size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | |
| 1475 | rrpriv = netdev_priv(dev); |
| 1476 | regs = rrpriv->regs; |
| 1477 | |
| 1478 | if (dev->flags & IFF_UP) |
| 1479 | return -EBUSY; |
| 1480 | |
| 1481 | if (!(readl(®s->HostCtrl) & NIC_HALTED)){ |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1482 | printk("%s: Trying to load firmware to a running NIC.\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1483 | dev->name); |
| 1484 | return -EBUSY; |
| 1485 | } |
| 1486 | |
| 1487 | localctrl = readl(®s->LocalCtrl); |
| 1488 | writel(0, ®s->LocalCtrl); |
| 1489 | |
| 1490 | writel(0, ®s->EvtPrd); |
| 1491 | writel(0, ®s->RxPrd); |
| 1492 | writel(0, ®s->TxPrd); |
| 1493 | |
| 1494 | /* |
| 1495 | * First wipe the entire SRAM, otherwise we might run into all |
| 1496 | * kinds of trouble ... sigh, this took almost all afternoon |
| 1497 | * to track down ;-( |
| 1498 | */ |
| 1499 | io = readl(®s->ExtIo); |
| 1500 | writel(0, ®s->ExtIo); |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1501 | sram_size = rr_read_eeprom_word(rrpriv, 8); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1502 | |
| 1503 | for (i = 200; i < sram_size / 4; i++){ |
| 1504 | writel(i * 4, ®s->WinBase); |
| 1505 | mb(); |
| 1506 | writel(0, ®s->WinData); |
| 1507 | mb(); |
| 1508 | } |
| 1509 | writel(io, ®s->ExtIo); |
| 1510 | mb(); |
| 1511 | |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1512 | eptr = rr_read_eeprom_word(rrpriv, |
| 1513 | offsetof(struct eeprom, rncd_info.AddrRunCodeSegs)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | eptr = ((eptr & 0x1fffff) >> 3); |
| 1515 | |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1516 | p2len = rr_read_eeprom_word(rrpriv, 0x83*4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | p2len = (p2len << 2); |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1518 | p2size = rr_read_eeprom_word(rrpriv, 0x84*4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1519 | p2size = ((p2size & 0x1fffff) >> 3); |
| 1520 | |
| 1521 | if ((eptr < p2size) || (eptr > (p2size + p2len))){ |
| 1522 | printk("%s: eptr is invalid\n", dev->name); |
| 1523 | goto out; |
| 1524 | } |
| 1525 | |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1526 | revision = rr_read_eeprom_word(rrpriv, |
| 1527 | offsetof(struct eeprom, manf.HeaderFmt)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1528 | |
| 1529 | if (revision != 1){ |
| 1530 | printk("%s: invalid firmware format (%i)\n", |
| 1531 | dev->name, revision); |
| 1532 | goto out; |
| 1533 | } |
| 1534 | |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1535 | nr_seg = rr_read_eeprom_word(rrpriv, eptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1536 | eptr +=4; |
| 1537 | #if (DEBUG > 1) |
| 1538 | printk("%s: nr_seg %i\n", dev->name, nr_seg); |
| 1539 | #endif |
| 1540 | |
| 1541 | for (i = 0; i < nr_seg; i++){ |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1542 | sptr = rr_read_eeprom_word(rrpriv, eptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1543 | eptr += 4; |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1544 | len = rr_read_eeprom_word(rrpriv, eptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1545 | eptr += 4; |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1546 | segptr = rr_read_eeprom_word(rrpriv, eptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1547 | segptr = ((segptr & 0x1fffff) >> 3); |
| 1548 | eptr += 4; |
| 1549 | #if (DEBUG > 1) |
| 1550 | printk("%s: segment %i, sram address %06x, length %04x, segptr %06x\n", |
| 1551 | dev->name, i, sptr, len, segptr); |
| 1552 | #endif |
| 1553 | for (j = 0; j < len; j++){ |
Al Viro | cf96237 | 2007-12-22 18:55:29 +0000 | [diff] [blame] | 1554 | tmp = rr_read_eeprom_word(rrpriv, segptr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1555 | writel(sptr, ®s->WinBase); |
| 1556 | mb(); |
| 1557 | writel(tmp, ®s->WinData); |
| 1558 | mb(); |
| 1559 | segptr += 4; |
| 1560 | sptr += 4; |
| 1561 | } |
| 1562 | } |
| 1563 | |
| 1564 | out: |
| 1565 | writel(localctrl, ®s->LocalCtrl); |
| 1566 | mb(); |
| 1567 | return 0; |
| 1568 | } |
| 1569 | |
| 1570 | |
| 1571 | static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
| 1572 | { |
| 1573 | struct rr_private *rrpriv; |
| 1574 | unsigned char *image, *oldimage; |
| 1575 | unsigned long flags; |
| 1576 | unsigned int i; |
| 1577 | int error = -EOPNOTSUPP; |
| 1578 | |
| 1579 | rrpriv = netdev_priv(dev); |
| 1580 | |
| 1581 | switch(cmd){ |
| 1582 | case SIOCRRGFW: |
| 1583 | if (!capable(CAP_SYS_RAWIO)){ |
| 1584 | return -EPERM; |
| 1585 | } |
| 1586 | |
| 1587 | image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); |
Joe Perches | e404dec | 2012-01-29 12:56:23 +0000 | [diff] [blame] | 1588 | if (!image) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1589 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1590 | |
| 1591 | if (rrpriv->fw_running){ |
| 1592 | printk("%s: Firmware already running\n", dev->name); |
| 1593 | error = -EPERM; |
| 1594 | goto gf_out; |
| 1595 | } |
| 1596 | |
| 1597 | spin_lock_irqsave(&rrpriv->lock, flags); |
| 1598 | i = rr_read_eeprom(rrpriv, 0, image, EEPROM_BYTES); |
| 1599 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
| 1600 | if (i != EEPROM_BYTES){ |
| 1601 | printk(KERN_ERR "%s: Error reading EEPROM\n", |
| 1602 | dev->name); |
| 1603 | error = -EFAULT; |
| 1604 | goto gf_out; |
| 1605 | } |
| 1606 | error = copy_to_user(rq->ifr_data, image, EEPROM_BYTES); |
| 1607 | if (error) |
| 1608 | error = -EFAULT; |
| 1609 | gf_out: |
| 1610 | kfree(image); |
| 1611 | return error; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1612 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1613 | case SIOCRRPFW: |
| 1614 | if (!capable(CAP_SYS_RAWIO)){ |
| 1615 | return -EPERM; |
| 1616 | } |
| 1617 | |
| 1618 | image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); |
| 1619 | oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); |
| 1620 | if (!image || !oldimage) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1621 | error = -ENOMEM; |
| 1622 | goto wf_out; |
| 1623 | } |
| 1624 | |
| 1625 | error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES); |
| 1626 | if (error) { |
| 1627 | error = -EFAULT; |
| 1628 | goto wf_out; |
| 1629 | } |
| 1630 | |
| 1631 | if (rrpriv->fw_running){ |
| 1632 | printk("%s: Firmware already running\n", dev->name); |
| 1633 | error = -EPERM; |
| 1634 | goto wf_out; |
| 1635 | } |
| 1636 | |
| 1637 | printk("%s: Updating EEPROM firmware\n", dev->name); |
| 1638 | |
| 1639 | spin_lock_irqsave(&rrpriv->lock, flags); |
| 1640 | error = write_eeprom(rrpriv, 0, image, EEPROM_BYTES); |
| 1641 | if (error) |
| 1642 | printk(KERN_ERR "%s: Error writing EEPROM\n", |
| 1643 | dev->name); |
| 1644 | |
| 1645 | i = rr_read_eeprom(rrpriv, 0, oldimage, EEPROM_BYTES); |
| 1646 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
| 1647 | |
| 1648 | if (i != EEPROM_BYTES) |
| 1649 | printk(KERN_ERR "%s: Error reading back EEPROM " |
| 1650 | "image\n", dev->name); |
| 1651 | |
| 1652 | error = memcmp(image, oldimage, EEPROM_BYTES); |
| 1653 | if (error){ |
| 1654 | printk(KERN_ERR "%s: Error verifying EEPROM image\n", |
| 1655 | dev->name); |
| 1656 | error = -EFAULT; |
| 1657 | } |
| 1658 | wf_out: |
Jesper Juhl | b4558ea | 2005-10-28 16:53:13 -0400 | [diff] [blame] | 1659 | kfree(oldimage); |
| 1660 | kfree(image); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1661 | return error; |
Jeff Garzik | 6aa20a2 | 2006-09-13 13:24:59 -0400 | [diff] [blame] | 1662 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1663 | case SIOCRRID: |
| 1664 | return put_user(0x52523032, (int __user *)rq->ifr_data); |
| 1665 | default: |
| 1666 | return error; |
| 1667 | } |
| 1668 | } |
| 1669 | |
Benoit Taine | 9baa3c3 | 2014-08-08 15:56:03 +0200 | [diff] [blame] | 1670 | static const struct pci_device_id rr_pci_tbl[] = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1671 | { PCI_VENDOR_ID_ESSENTIAL, PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER, |
| 1672 | PCI_ANY_ID, PCI_ANY_ID, }, |
| 1673 | { 0,} |
| 1674 | }; |
| 1675 | MODULE_DEVICE_TABLE(pci, rr_pci_tbl); |
| 1676 | |
| 1677 | static struct pci_driver rr_driver = { |
| 1678 | .name = "rrunner", |
| 1679 | .id_table = rr_pci_tbl, |
| 1680 | .probe = rr_init_one, |
Bill Pemberton | 6e94549 | 2012-12-03 09:24:11 -0500 | [diff] [blame] | 1681 | .remove = rr_remove_one, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1682 | }; |
| 1683 | |
Peter Hüwe | ff71505 | 2013-05-21 13:42:53 +0000 | [diff] [blame] | 1684 | module_pci_driver(rr_driver); |