Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/net: delete old 8bit ISA 3c501 driver.

It was amusing that linux was able to make use of this 1980's
technology on machines long past its intended lifespan, but
it probably should go now.

To set some context, the 3c501 was designed in the 1980's to be
used on 8088 PC-XT 8bit ISA machines. It was built using a large
number of discrete TTL components and truly looks like a relic
of the ancient past before large scale integration was common.

But from a functional point of view, the real issue, as stated
in the (also obsolete) Ethernet-HowTo, is that "...the 3c501 can
only do one thing at a time -- while you are removing one packet
from the single-packet buffer it cannot receive another packet,
nor can it receive a packet while loading a transmit packet."

You know things are not good when the Kconfig help text suggests
you make a cron job doing a ping every minute.

Hardware that old and crippled is simply not going to be used by
anyone in a time where 10 year old 100Mbit PCI cards (that are
still functional) are largely give-away items.

Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>

-1007
-4
drivers/net/Space.c
··· 51 51 extern struct net_device *eth16i_probe(int unit); 52 52 extern struct net_device *i82596_probe(int unit); 53 53 extern struct net_device *ewrk3_probe(int unit); 54 - extern struct net_device *el1_probe(int unit); 55 54 extern struct net_device *el16_probe(int unit); 56 55 extern struct net_device *elplus_probe(int unit); 57 56 extern struct net_device *e2100_probe(int unit); ··· 166 167 #endif 167 168 #if defined(CONFIG_MVME16x_NET) || defined(CONFIG_BVME6000_NET) /* Intel I82596 */ 168 169 {i82596_probe, 0}, 169 - #endif 170 - #ifdef CONFIG_EL1 /* 3c501 */ 171 - {el1_probe, 0}, 172 170 #endif 173 171 #ifdef CONFIG_EL16 /* 3c507 */ 174 172 {el16_probe, 0},
-897
drivers/net/ethernet/3com/3c501.c
··· 1 - /* 3c501.c: A 3Com 3c501 Ethernet driver for Linux. */ 2 - /* 3 - Written 1992,1993,1994 Donald Becker 4 - 5 - Copyright 1993 United States Government as represented by the 6 - Director, National Security Agency. This software may be used and 7 - distributed according to the terms of the GNU General Public License, 8 - incorporated herein by reference. 9 - 10 - This is a device driver for the 3Com Etherlink 3c501. 11 - Do not purchase this card, even as a joke. It's performance is horrible, 12 - and it breaks in many ways. 13 - 14 - The original author may be reached as becker@scyld.com, or C/O 15 - Scyld Computing Corporation 16 - 410 Severn Ave., Suite 210 17 - Annapolis MD 21403 18 - 19 - Fixed (again!) the missing interrupt locking on TX/RX shifting. 20 - Alan Cox <alan@lxorguk.ukuu.org.uk> 21 - 22 - Removed calls to init_etherdev since they are no longer needed, and 23 - cleaned up modularization just a bit. The driver still allows only 24 - the default address for cards when loaded as a module, but that's 25 - really less braindead than anyone using a 3c501 board. :) 26 - 19950208 (invid@msen.com) 27 - 28 - Added traps for interrupts hitting the window as we clear and TX load 29 - the board. Now getting 150K/second FTP with a 3c501 card. Still playing 30 - with a TX-TX optimisation to see if we can touch 180-200K/second as seems 31 - theoretically maximum. 32 - 19950402 Alan Cox <alan@lxorguk.ukuu.org.uk> 33 - 34 - Cleaned up for 2.3.x because we broke SMP now. 35 - 20000208 Alan Cox <alan@lxorguk.ukuu.org.uk> 36 - 37 - Check up pass for 2.5. Nothing significant changed 38 - 20021009 Alan Cox <alan@lxorguk.ukuu.org.uk> 39 - 40 - Fixed zero fill corner case 41 - 20030104 Alan Cox <alan@lxorguk.ukuu.org.uk> 42 - 43 - 44 - For the avoidance of doubt the "preferred form" of this code is one which 45 - is in an open non patent encumbered format. Where cryptographic key signing 46 - forms part of the process of creating an executable the information 47 - including keys needed to generate an equivalently functional executable 48 - are deemed to be part of the source code. 49 - 50 - */ 51 - 52 - 53 - /** 54 - * DOC: 3c501 Card Notes 55 - * 56 - * Some notes on this thing if you have to hack it. [Alan] 57 - * 58 - * Some documentation is available from 3Com. Due to the boards age 59 - * standard responses when you ask for this will range from 'be serious' 60 - * to 'give it to a museum'. The documentation is incomplete and mostly 61 - * of historical interest anyway. 62 - * 63 - * The basic system is a single buffer which can be used to receive or 64 - * transmit a packet. A third command mode exists when you are setting 65 - * things up. 66 - * 67 - * If it's transmitting it's not receiving and vice versa. In fact the 68 - * time to get the board back into useful state after an operation is 69 - * quite large. 70 - * 71 - * The driver works by keeping the board in receive mode waiting for a 72 - * packet to arrive. When one arrives it is copied out of the buffer 73 - * and delivered to the kernel. The card is reloaded and off we go. 74 - * 75 - * When transmitting lp->txing is set and the card is reset (from 76 - * receive mode) [possibly losing a packet just received] to command 77 - * mode. A packet is loaded and transmit mode triggered. The interrupt 78 - * handler runs different code for transmit interrupts and can handle 79 - * returning to receive mode or retransmissions (yes you have to help 80 - * out with those too). 81 - * 82 - * DOC: Problems 83 - * 84 - * There are a wide variety of undocumented error returns from the card 85 - * and you basically have to kick the board and pray if they turn up. Most 86 - * only occur under extreme load or if you do something the board doesn't 87 - * like (eg touching a register at the wrong time). 88 - * 89 - * The driver is less efficient than it could be. It switches through 90 - * receive mode even if more transmits are queued. If this worries you buy 91 - * a real Ethernet card. 92 - * 93 - * The combination of slow receive restart and no real multicast 94 - * filter makes the board unusable with a kernel compiled for IP 95 - * multicasting in a real multicast environment. That's down to the board, 96 - * but even with no multicast programs running a multicast IP kernel is 97 - * in group 224.0.0.1 and you will therefore be listening to all multicasts. 98 - * One nv conference running over that Ethernet and you can give up. 99 - * 100 - */ 101 - 102 - #define DRV_NAME "3c501" 103 - #define DRV_VERSION "2002/10/09" 104 - 105 - 106 - static const char version[] = 107 - DRV_NAME ".c: " DRV_VERSION " Alan Cox (alan@lxorguk.ukuu.org.uk).\n"; 108 - 109 - /* 110 - * Braindamage remaining: 111 - * The 3c501 board. 112 - */ 113 - 114 - #include <linux/module.h> 115 - 116 - #include <linux/kernel.h> 117 - #include <linux/fcntl.h> 118 - #include <linux/ioport.h> 119 - #include <linux/interrupt.h> 120 - #include <linux/string.h> 121 - #include <linux/errno.h> 122 - #include <linux/spinlock.h> 123 - #include <linux/ethtool.h> 124 - #include <linux/delay.h> 125 - #include <linux/bitops.h> 126 - 127 - #include <asm/uaccess.h> 128 - #include <asm/io.h> 129 - 130 - #include <linux/netdevice.h> 131 - #include <linux/etherdevice.h> 132 - #include <linux/skbuff.h> 133 - #include <linux/init.h> 134 - 135 - #include "3c501.h" 136 - 137 - /* 138 - * The boilerplate probe code. 139 - */ 140 - 141 - static int io = 0x280; 142 - static int irq = 5; 143 - static int mem_start; 144 - 145 - /** 146 - * el1_probe - probe for a 3c501 147 - * @dev: The device structure passed in to probe. 148 - * 149 - * This can be called from two places. The network layer will probe using 150 - * a device structure passed in with the probe information completed. For a 151 - * modular driver we use #init_module to fill in our own structure and probe 152 - * for it. 153 - * 154 - * Returns 0 on success. ENXIO if asked not to probe and ENODEV if asked to 155 - * probe and failing to find anything. 156 - */ 157 - 158 - struct net_device * __init el1_probe(int unit) 159 - { 160 - struct net_device *dev = alloc_etherdev(sizeof(struct net_local)); 161 - static const unsigned ports[] = { 0x280, 0x300, 0}; 162 - const unsigned *port; 163 - int err = 0; 164 - 165 - if (!dev) 166 - return ERR_PTR(-ENOMEM); 167 - 168 - if (unit >= 0) { 169 - sprintf(dev->name, "eth%d", unit); 170 - netdev_boot_setup_check(dev); 171 - io = dev->base_addr; 172 - irq = dev->irq; 173 - mem_start = dev->mem_start & 7; 174 - } 175 - 176 - if (io > 0x1ff) { /* Check a single specified location. */ 177 - err = el1_probe1(dev, io); 178 - } else if (io != 0) { 179 - err = -ENXIO; /* Don't probe at all. */ 180 - } else { 181 - for (port = ports; *port && el1_probe1(dev, *port); port++) 182 - ; 183 - if (!*port) 184 - err = -ENODEV; 185 - } 186 - if (err) 187 - goto out; 188 - err = register_netdev(dev); 189 - if (err) 190 - goto out1; 191 - return dev; 192 - out1: 193 - release_region(dev->base_addr, EL1_IO_EXTENT); 194 - out: 195 - free_netdev(dev); 196 - return ERR_PTR(err); 197 - } 198 - 199 - static const struct net_device_ops el_netdev_ops = { 200 - .ndo_open = el_open, 201 - .ndo_stop = el1_close, 202 - .ndo_start_xmit = el_start_xmit, 203 - .ndo_tx_timeout = el_timeout, 204 - .ndo_set_rx_mode = set_multicast_list, 205 - .ndo_change_mtu = eth_change_mtu, 206 - .ndo_set_mac_address = eth_mac_addr, 207 - .ndo_validate_addr = eth_validate_addr, 208 - }; 209 - 210 - /** 211 - * el1_probe1: 212 - * @dev: The device structure to use 213 - * @ioaddr: An I/O address to probe at. 214 - * 215 - * The actual probe. This is iterated over by #el1_probe in order to 216 - * check all the applicable device locations. 217 - * 218 - * Returns 0 for a success, in which case the device is activated, 219 - * EAGAIN if the IRQ is in use by another driver, and ENODEV if the 220 - * board cannot be found. 221 - */ 222 - 223 - static int __init el1_probe1(struct net_device *dev, int ioaddr) 224 - { 225 - struct net_local *lp; 226 - const char *mname; /* Vendor name */ 227 - unsigned char station_addr[6]; 228 - int autoirq = 0; 229 - int i; 230 - 231 - /* 232 - * Reserve I/O resource for exclusive use by this driver 233 - */ 234 - 235 - if (!request_region(ioaddr, EL1_IO_EXTENT, DRV_NAME)) 236 - return -ENODEV; 237 - 238 - /* 239 - * Read the station address PROM data from the special port. 240 - */ 241 - 242 - for (i = 0; i < 6; i++) { 243 - outw(i, ioaddr + EL1_DATAPTR); 244 - station_addr[i] = inb(ioaddr + EL1_SAPROM); 245 - } 246 - /* 247 - * Check the first three octets of the S.A. for 3Com's prefix, or 248 - * for the Sager NP943 prefix. 249 - */ 250 - 251 - if (station_addr[0] == 0x02 && station_addr[1] == 0x60 && 252 - station_addr[2] == 0x8c) 253 - mname = "3c501"; 254 - else if (station_addr[0] == 0x00 && station_addr[1] == 0x80 && 255 - station_addr[2] == 0xC8) 256 - mname = "NP943"; 257 - else { 258 - release_region(ioaddr, EL1_IO_EXTENT); 259 - return -ENODEV; 260 - } 261 - 262 - /* 263 - * We auto-IRQ by shutting off the interrupt line and letting it 264 - * float high. 265 - */ 266 - 267 - dev->irq = irq; 268 - 269 - if (dev->irq < 2) { 270 - unsigned long irq_mask; 271 - 272 - irq_mask = probe_irq_on(); 273 - inb(RX_STATUS); /* Clear pending interrupts. */ 274 - inb(TX_STATUS); 275 - outb(AX_LOOP + 1, AX_CMD); 276 - 277 - outb(0x00, AX_CMD); 278 - 279 - mdelay(20); 280 - autoirq = probe_irq_off(irq_mask); 281 - 282 - if (autoirq == 0) { 283 - pr_warning("%s probe at %#x failed to detect IRQ line.\n", 284 - mname, ioaddr); 285 - release_region(ioaddr, EL1_IO_EXTENT); 286 - return -EAGAIN; 287 - } 288 - } 289 - 290 - outb(AX_RESET+AX_LOOP, AX_CMD); /* Loopback mode. */ 291 - dev->base_addr = ioaddr; 292 - memcpy(dev->dev_addr, station_addr, ETH_ALEN); 293 - 294 - if (mem_start & 0xf) 295 - el_debug = mem_start & 0x7; 296 - if (autoirq) 297 - dev->irq = autoirq; 298 - 299 - pr_info("%s: %s EtherLink at %#lx, using %sIRQ %d.\n", 300 - dev->name, mname, dev->base_addr, 301 - autoirq ? "auto":"assigned ", dev->irq); 302 - 303 - #ifdef CONFIG_IP_MULTICAST 304 - pr_warning("WARNING: Use of the 3c501 in a multicast kernel is NOT recommended.\n"); 305 - #endif 306 - 307 - if (el_debug) 308 - pr_debug("%s", version); 309 - 310 - lp = netdev_priv(dev); 311 - memset(lp, 0, sizeof(struct net_local)); 312 - spin_lock_init(&lp->lock); 313 - 314 - /* 315 - * The EL1-specific entries in the device structure. 316 - */ 317 - 318 - dev->netdev_ops = &el_netdev_ops; 319 - dev->watchdog_timeo = HZ; 320 - dev->ethtool_ops = &netdev_ethtool_ops; 321 - return 0; 322 - } 323 - 324 - /** 325 - * el1_open: 326 - * @dev: device that is being opened 327 - * 328 - * When an ifconfig is issued which changes the device flags to include 329 - * IFF_UP this function is called. It is only called when the change 330 - * occurs, not when the interface remains up. #el1_close will be called 331 - * when it goes down. 332 - * 333 - * Returns 0 for a successful open, or -EAGAIN if someone has run off 334 - * with our interrupt line. 335 - */ 336 - 337 - static int el_open(struct net_device *dev) 338 - { 339 - int retval; 340 - int ioaddr = dev->base_addr; 341 - struct net_local *lp = netdev_priv(dev); 342 - unsigned long flags; 343 - 344 - if (el_debug > 2) 345 - pr_debug("%s: Doing el_open()...\n", dev->name); 346 - 347 - retval = request_irq(dev->irq, el_interrupt, 0, dev->name, dev); 348 - if (retval) 349 - return retval; 350 - 351 - spin_lock_irqsave(&lp->lock, flags); 352 - el_reset(dev); 353 - spin_unlock_irqrestore(&lp->lock, flags); 354 - 355 - lp->txing = 0; /* Board in RX mode */ 356 - outb(AX_RX, AX_CMD); /* Aux control, irq and receive enabled */ 357 - netif_start_queue(dev); 358 - return 0; 359 - } 360 - 361 - /** 362 - * el_timeout: 363 - * @dev: The 3c501 card that has timed out 364 - * 365 - * Attempt to restart the board. This is basically a mixture of extreme 366 - * violence and prayer 367 - * 368 - */ 369 - 370 - static void el_timeout(struct net_device *dev) 371 - { 372 - struct net_local *lp = netdev_priv(dev); 373 - int ioaddr = dev->base_addr; 374 - 375 - if (el_debug) 376 - pr_debug("%s: transmit timed out, txsr %#2x axsr=%02x rxsr=%02x.\n", 377 - dev->name, inb(TX_STATUS), 378 - inb(AX_STATUS), inb(RX_STATUS)); 379 - dev->stats.tx_errors++; 380 - outb(TX_NORM, TX_CMD); 381 - outb(RX_NORM, RX_CMD); 382 - outb(AX_OFF, AX_CMD); /* Just trigger a false interrupt. */ 383 - outb(AX_RX, AX_CMD); /* Aux control, irq and receive enabled */ 384 - lp->txing = 0; /* Ripped back in to RX */ 385 - netif_wake_queue(dev); 386 - } 387 - 388 - 389 - /** 390 - * el_start_xmit: 391 - * @skb: The packet that is queued to be sent 392 - * @dev: The 3c501 card we want to throw it down 393 - * 394 - * Attempt to send a packet to a 3c501 card. There are some interesting 395 - * catches here because the 3c501 is an extremely old and therefore 396 - * stupid piece of technology. 397 - * 398 - * If we are handling an interrupt on the other CPU we cannot load a packet 399 - * as we may still be attempting to retrieve the last RX packet buffer. 400 - * 401 - * When a transmit times out we dump the card into control mode and just 402 - * start again. It happens enough that it isn't worth logging. 403 - * 404 - * We avoid holding the spin locks when doing the packet load to the board. 405 - * The device is very slow, and its DMA mode is even slower. If we held the 406 - * lock while loading 1500 bytes onto the controller we would drop a lot of 407 - * serial port characters. This requires we do extra locking, but we have 408 - * no real choice. 409 - */ 410 - 411 - static netdev_tx_t el_start_xmit(struct sk_buff *skb, struct net_device *dev) 412 - { 413 - struct net_local *lp = netdev_priv(dev); 414 - int ioaddr = dev->base_addr; 415 - unsigned long flags; 416 - 417 - /* 418 - * Avoid incoming interrupts between us flipping txing and flipping 419 - * mode as the driver assumes txing is a faithful indicator of card 420 - * state 421 - */ 422 - 423 - spin_lock_irqsave(&lp->lock, flags); 424 - 425 - /* 426 - * Avoid timer-based retransmission conflicts. 427 - */ 428 - 429 - netif_stop_queue(dev); 430 - 431 - do { 432 - int len = skb->len; 433 - int pad = 0; 434 - int gp_start; 435 - unsigned char *buf = skb->data; 436 - 437 - if (len < ETH_ZLEN) 438 - pad = ETH_ZLEN - len; 439 - 440 - gp_start = 0x800 - (len + pad); 441 - 442 - lp->tx_pkt_start = gp_start; 443 - lp->collisions = 0; 444 - 445 - dev->stats.tx_bytes += skb->len; 446 - 447 - /* 448 - * Command mode with status cleared should [in theory] 449 - * mean no more interrupts can be pending on the card. 450 - */ 451 - 452 - outb_p(AX_SYS, AX_CMD); 453 - inb_p(RX_STATUS); 454 - inb_p(TX_STATUS); 455 - 456 - lp->loading = 1; 457 - lp->txing = 1; 458 - 459 - /* 460 - * Turn interrupts back on while we spend a pleasant 461 - * afternoon loading bytes into the board 462 - */ 463 - 464 - spin_unlock_irqrestore(&lp->lock, flags); 465 - 466 - /* Set rx packet area to 0. */ 467 - outw(0x00, RX_BUF_CLR); 468 - /* aim - packet will be loaded into buffer start */ 469 - outw(gp_start, GP_LOW); 470 - /* load buffer (usual thing each byte increments the pointer) */ 471 - outsb(DATAPORT, buf, len); 472 - if (pad) { 473 - while (pad--) /* Zero fill buffer tail */ 474 - outb(0, DATAPORT); 475 - } 476 - /* the board reuses the same register */ 477 - outw(gp_start, GP_LOW); 478 - 479 - if (lp->loading != 2) { 480 - /* fire ... Trigger xmit. */ 481 - outb(AX_XMIT, AX_CMD); 482 - lp->loading = 0; 483 - if (el_debug > 2) 484 - pr_debug(" queued xmit.\n"); 485 - dev_kfree_skb(skb); 486 - return NETDEV_TX_OK; 487 - } 488 - /* A receive upset our load, despite our best efforts */ 489 - if (el_debug > 2) 490 - pr_debug("%s: burped during tx load.\n", dev->name); 491 - spin_lock_irqsave(&lp->lock, flags); 492 - } while (1); 493 - } 494 - 495 - /** 496 - * el_interrupt: 497 - * @irq: Interrupt number 498 - * @dev_id: The 3c501 that burped 499 - * 500 - * Handle the ether interface interrupts. The 3c501 needs a lot more 501 - * hand holding than most cards. In particular we get a transmit interrupt 502 - * with a collision error because the board firmware isn't capable of rewinding 503 - * its own transmit buffer pointers. It can however count to 16 for us. 504 - * 505 - * On the receive side the card is also very dumb. It has no buffering to 506 - * speak of. We simply pull the packet out of its PIO buffer (which is slow) 507 - * and queue it for the kernel. Then we reset the card for the next packet. 508 - * 509 - * We sometimes get surprise interrupts late both because the SMP IRQ delivery 510 - * is message passing and because the card sometimes seems to deliver late. I 511 - * think if it is part way through a receive and the mode is changed it carries 512 - * on receiving and sends us an interrupt. We have to band aid all these cases 513 - * to get a sensible 150kBytes/second performance. Even then you want a small 514 - * TCP window. 515 - */ 516 - 517 - static irqreturn_t el_interrupt(int irq, void *dev_id) 518 - { 519 - struct net_device *dev = dev_id; 520 - struct net_local *lp; 521 - int ioaddr; 522 - int axsr; /* Aux. status reg. */ 523 - 524 - ioaddr = dev->base_addr; 525 - lp = netdev_priv(dev); 526 - 527 - spin_lock(&lp->lock); 528 - 529 - /* 530 - * What happened ? 531 - */ 532 - 533 - axsr = inb(AX_STATUS); 534 - 535 - /* 536 - * Log it 537 - */ 538 - 539 - if (el_debug > 3) 540 - pr_debug("%s: el_interrupt() aux=%#02x\n", dev->name, axsr); 541 - 542 - if (lp->loading == 1 && !lp->txing) 543 - pr_warning("%s: Inconsistent state loading while not in tx\n", 544 - dev->name); 545 - 546 - if (lp->txing) { 547 - /* 548 - * Board in transmit mode. May be loading. If we are 549 - * loading we shouldn't have got this. 550 - */ 551 - int txsr = inb(TX_STATUS); 552 - 553 - if (lp->loading == 1) { 554 - if (el_debug > 2) 555 - pr_debug("%s: Interrupt while loading [txsr=%02x gp=%04x rp=%04x]\n", 556 - dev->name, txsr, inw(GP_LOW), inw(RX_LOW)); 557 - 558 - /* Force a reload */ 559 - lp->loading = 2; 560 - spin_unlock(&lp->lock); 561 - goto out; 562 - } 563 - if (el_debug > 6) 564 - pr_debug("%s: txsr=%02x gp=%04x rp=%04x\n", dev->name, 565 - txsr, inw(GP_LOW), inw(RX_LOW)); 566 - 567 - if ((axsr & 0x80) && (txsr & TX_READY) == 0) { 568 - /* 569 - * FIXME: is there a logic to whether to keep 570 - * on trying or reset immediately ? 571 - */ 572 - if (el_debug > 1) 573 - pr_debug("%s: Unusual interrupt during Tx, txsr=%02x axsr=%02x gp=%03x rp=%03x.\n", 574 - dev->name, txsr, axsr, 575 - inw(ioaddr + EL1_DATAPTR), 576 - inw(ioaddr + EL1_RXPTR)); 577 - lp->txing = 0; 578 - netif_wake_queue(dev); 579 - } else if (txsr & TX_16COLLISIONS) { 580 - /* 581 - * Timed out 582 - */ 583 - if (el_debug) 584 - pr_debug("%s: Transmit failed 16 times, Ethernet jammed?\n", dev->name); 585 - outb(AX_SYS, AX_CMD); 586 - lp->txing = 0; 587 - dev->stats.tx_aborted_errors++; 588 - netif_wake_queue(dev); 589 - } else if (txsr & TX_COLLISION) { 590 - /* 591 - * Retrigger xmit. 592 - */ 593 - 594 - if (el_debug > 6) 595 - pr_debug("%s: retransmitting after a collision.\n", dev->name); 596 - /* 597 - * Poor little chip can't reset its own start 598 - * pointer 599 - */ 600 - 601 - outb(AX_SYS, AX_CMD); 602 - outw(lp->tx_pkt_start, GP_LOW); 603 - outb(AX_XMIT, AX_CMD); 604 - dev->stats.collisions++; 605 - spin_unlock(&lp->lock); 606 - goto out; 607 - } else { 608 - /* 609 - * It worked.. we will now fall through and receive 610 - */ 611 - dev->stats.tx_packets++; 612 - if (el_debug > 6) 613 - pr_debug("%s: Tx succeeded %s\n", dev->name, 614 - (txsr & TX_RDY) ? "." : "but tx is busy!"); 615 - /* 616 - * This is safe the interrupt is atomic WRT itself. 617 - */ 618 - lp->txing = 0; 619 - /* In case more to transmit */ 620 - netif_wake_queue(dev); 621 - } 622 - } else { 623 - /* 624 - * In receive mode. 625 - */ 626 - 627 - int rxsr = inb(RX_STATUS); 628 - if (el_debug > 5) 629 - pr_debug("%s: rxsr=%02x txsr=%02x rp=%04x\n", 630 - dev->name, rxsr, inb(TX_STATUS), inw(RX_LOW)); 631 - /* 632 - * Just reading rx_status fixes most errors. 633 - */ 634 - if (rxsr & RX_MISSED) 635 - dev->stats.rx_missed_errors++; 636 - else if (rxsr & RX_RUNT) { 637 - /* Handled to avoid board lock-up. */ 638 - dev->stats.rx_length_errors++; 639 - if (el_debug > 5) 640 - pr_debug("%s: runt.\n", dev->name); 641 - } else if (rxsr & RX_GOOD) { 642 - /* 643 - * Receive worked. 644 - */ 645 - el_receive(dev); 646 - } else { 647 - /* 648 - * Nothing? Something is broken! 649 - */ 650 - if (el_debug > 2) 651 - pr_debug("%s: No packet seen, rxsr=%02x **resetting 3c501***\n", 652 - dev->name, rxsr); 653 - el_reset(dev); 654 - } 655 - } 656 - 657 - /* 658 - * Move into receive mode 659 - */ 660 - 661 - outb(AX_RX, AX_CMD); 662 - outw(0x00, RX_BUF_CLR); 663 - inb(RX_STATUS); /* Be certain that interrupts are cleared. */ 664 - inb(TX_STATUS); 665 - spin_unlock(&lp->lock); 666 - out: 667 - return IRQ_HANDLED; 668 - } 669 - 670 - 671 - /** 672 - * el_receive: 673 - * @dev: Device to pull the packets from 674 - * 675 - * We have a good packet. Well, not really "good", just mostly not broken. 676 - * We must check everything to see if it is good. In particular we occasionally 677 - * get wild packet sizes from the card. If the packet seems sane we PIO it 678 - * off the card and queue it for the protocol layers. 679 - */ 680 - 681 - static void el_receive(struct net_device *dev) 682 - { 683 - int ioaddr = dev->base_addr; 684 - int pkt_len; 685 - struct sk_buff *skb; 686 - 687 - pkt_len = inw(RX_LOW); 688 - 689 - if (el_debug > 4) 690 - pr_debug(" el_receive %d.\n", pkt_len); 691 - 692 - if (pkt_len < 60 || pkt_len > 1536) { 693 - if (el_debug) 694 - pr_debug("%s: bogus packet, length=%d\n", 695 - dev->name, pkt_len); 696 - dev->stats.rx_over_errors++; 697 - return; 698 - } 699 - 700 - /* 701 - * Command mode so we can empty the buffer 702 - */ 703 - 704 - outb(AX_SYS, AX_CMD); 705 - skb = netdev_alloc_skb(dev, pkt_len + 2); 706 - 707 - /* 708 - * Start of frame 709 - */ 710 - 711 - outw(0x00, GP_LOW); 712 - if (skb == NULL) { 713 - pr_info("%s: Memory squeeze, dropping packet.\n", dev->name); 714 - dev->stats.rx_dropped++; 715 - return; 716 - } else { 717 - skb_reserve(skb, 2); /* Force 16 byte alignment */ 718 - /* 719 - * The read increments through the bytes. The interrupt 720 - * handler will fix the pointer when it returns to 721 - * receive mode. 722 - */ 723 - insb(DATAPORT, skb_put(skb, pkt_len), pkt_len); 724 - skb->protocol = eth_type_trans(skb, dev); 725 - netif_rx(skb); 726 - dev->stats.rx_packets++; 727 - dev->stats.rx_bytes += pkt_len; 728 - } 729 - } 730 - 731 - /** 732 - * el_reset: Reset a 3c501 card 733 - * @dev: The 3c501 card about to get zapped 734 - * 735 - * Even resetting a 3c501 isn't simple. When you activate reset it loses all 736 - * its configuration. You must hold the lock when doing this. The function 737 - * cannot take the lock itself as it is callable from the irq handler. 738 - */ 739 - 740 - static void el_reset(struct net_device *dev) 741 - { 742 - struct net_local *lp = netdev_priv(dev); 743 - int ioaddr = dev->base_addr; 744 - 745 - if (el_debug > 2) 746 - pr_info("3c501 reset...\n"); 747 - outb(AX_RESET, AX_CMD); /* Reset the chip */ 748 - /* Aux control, irq and loopback enabled */ 749 - outb(AX_LOOP, AX_CMD); 750 - { 751 - int i; 752 - for (i = 0; i < 6; i++) /* Set the station address. */ 753 - outb(dev->dev_addr[i], ioaddr + i); 754 - } 755 - 756 - outw(0, RX_BUF_CLR); /* Set rx packet area to 0. */ 757 - outb(TX_NORM, TX_CMD); /* tx irq on done, collision */ 758 - outb(RX_NORM, RX_CMD); /* Set Rx commands. */ 759 - inb(RX_STATUS); /* Clear status. */ 760 - inb(TX_STATUS); 761 - lp->txing = 0; 762 - } 763 - 764 - /** 765 - * el1_close: 766 - * @dev: 3c501 card to shut down 767 - * 768 - * Close a 3c501 card. The IFF_UP flag has been cleared by the user via 769 - * the SIOCSIFFLAGS ioctl. We stop any further transmissions being queued, 770 - * and then disable the interrupts. Finally we reset the chip. The effects 771 - * of the rest will be cleaned up by #el1_open. Always returns 0 indicating 772 - * a success. 773 - */ 774 - 775 - static int el1_close(struct net_device *dev) 776 - { 777 - int ioaddr = dev->base_addr; 778 - 779 - if (el_debug > 2) 780 - pr_info("%s: Shutting down Ethernet card at %#x.\n", 781 - dev->name, ioaddr); 782 - 783 - netif_stop_queue(dev); 784 - 785 - /* 786 - * Free and disable the IRQ. 787 - */ 788 - 789 - free_irq(dev->irq, dev); 790 - outb(AX_RESET, AX_CMD); /* Reset the chip */ 791 - 792 - return 0; 793 - } 794 - 795 - /** 796 - * set_multicast_list: 797 - * @dev: The device to adjust 798 - * 799 - * Set or clear the multicast filter for this adaptor to use the best-effort 800 - * filtering supported. The 3c501 supports only three modes of filtering. 801 - * It always receives broadcasts and packets for itself. You can choose to 802 - * optionally receive all packets, or all multicast packets on top of this. 803 - */ 804 - 805 - static void set_multicast_list(struct net_device *dev) 806 - { 807 - int ioaddr = dev->base_addr; 808 - 809 - if (dev->flags & IFF_PROMISC) { 810 - outb(RX_PROM, RX_CMD); 811 - inb(RX_STATUS); 812 - } else if (!netdev_mc_empty(dev) || dev->flags & IFF_ALLMULTI) { 813 - /* Multicast or all multicast is the same */ 814 - outb(RX_MULT, RX_CMD); 815 - inb(RX_STATUS); /* Clear status. */ 816 - } else { 817 - outb(RX_NORM, RX_CMD); 818 - inb(RX_STATUS); 819 - } 820 - } 821 - 822 - 823 - static void netdev_get_drvinfo(struct net_device *dev, 824 - struct ethtool_drvinfo *info) 825 - { 826 - strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); 827 - strlcpy(info->version, DRV_VERSION, sizeof(info->version)); 828 - snprintf(info->bus_info, sizeof(info->bus_info), "ISA 0x%lx", 829 - dev->base_addr); 830 - } 831 - 832 - static u32 netdev_get_msglevel(struct net_device *dev) 833 - { 834 - return debug; 835 - } 836 - 837 - static void netdev_set_msglevel(struct net_device *dev, u32 level) 838 - { 839 - debug = level; 840 - } 841 - 842 - static const struct ethtool_ops netdev_ethtool_ops = { 843 - .get_drvinfo = netdev_get_drvinfo, 844 - .get_msglevel = netdev_get_msglevel, 845 - .set_msglevel = netdev_set_msglevel, 846 - }; 847 - 848 - #ifdef MODULE 849 - 850 - static struct net_device *dev_3c501; 851 - 852 - module_param(io, int, 0); 853 - module_param(irq, int, 0); 854 - MODULE_PARM_DESC(io, "EtherLink I/O base address"); 855 - MODULE_PARM_DESC(irq, "EtherLink IRQ number"); 856 - 857 - /** 858 - * init_module: 859 - * 860 - * When the driver is loaded as a module this function is called. We fake up 861 - * a device structure with the base I/O and interrupt set as if it were being 862 - * called from Space.c. This minimises the extra code that would otherwise 863 - * be required. 864 - * 865 - * Returns 0 for success or -EIO if a card is not found. Returning an error 866 - * here also causes the module to be unloaded 867 - */ 868 - 869 - int __init init_module(void) 870 - { 871 - dev_3c501 = el1_probe(-1); 872 - if (IS_ERR(dev_3c501)) 873 - return PTR_ERR(dev_3c501); 874 - return 0; 875 - } 876 - 877 - /** 878 - * cleanup_module: 879 - * 880 - * The module is being unloaded. We unhook our network device from the system 881 - * and then free up the resources we took when the card was found. 882 - */ 883 - 884 - void __exit cleanup_module(void) 885 - { 886 - struct net_device *dev = dev_3c501; 887 - unregister_netdev(dev); 888 - release_region(dev->base_addr, EL1_IO_EXTENT); 889 - free_netdev(dev); 890 - } 891 - 892 - #endif /* MODULE */ 893 - 894 - MODULE_AUTHOR("Donald Becker, Alan Cox"); 895 - MODULE_DESCRIPTION("Support for the ancient 3Com 3c501 ethernet card"); 896 - MODULE_LICENSE("GPL"); 897 -
-91
drivers/net/ethernet/3com/3c501.h
··· 1 - 2 - /* 3 - * Index to functions. 4 - */ 5 - 6 - static int el1_probe1(struct net_device *dev, int ioaddr); 7 - static int el_open(struct net_device *dev); 8 - static void el_timeout(struct net_device *dev); 9 - static netdev_tx_t el_start_xmit(struct sk_buff *skb, struct net_device *dev); 10 - static irqreturn_t el_interrupt(int irq, void *dev_id); 11 - static void el_receive(struct net_device *dev); 12 - static void el_reset(struct net_device *dev); 13 - static int el1_close(struct net_device *dev); 14 - static void set_multicast_list(struct net_device *dev); 15 - static const struct ethtool_ops netdev_ethtool_ops; 16 - 17 - #define EL1_IO_EXTENT 16 18 - 19 - #ifndef EL_DEBUG 20 - #define EL_DEBUG 0 /* use 0 for production, 1 for devel., >2 for debug */ 21 - #endif /* Anything above 5 is wordy death! */ 22 - #define debug el_debug 23 - static int el_debug = EL_DEBUG; 24 - 25 - /* 26 - * Board-specific info in netdev_priv(dev). 27 - */ 28 - 29 - struct net_local 30 - { 31 - int tx_pkt_start; /* The length of the current Tx packet. */ 32 - int collisions; /* Tx collisions this packet */ 33 - int loading; /* Spot buffer load collisions */ 34 - int txing; /* True if card is in TX mode */ 35 - spinlock_t lock; /* Serializing lock */ 36 - }; 37 - 38 - 39 - #define RX_STATUS (ioaddr + 0x06) 40 - #define RX_CMD RX_STATUS 41 - #define TX_STATUS (ioaddr + 0x07) 42 - #define TX_CMD TX_STATUS 43 - #define GP_LOW (ioaddr + 0x08) 44 - #define GP_HIGH (ioaddr + 0x09) 45 - #define RX_BUF_CLR (ioaddr + 0x0A) 46 - #define RX_LOW (ioaddr + 0x0A) 47 - #define RX_HIGH (ioaddr + 0x0B) 48 - #define SAPROM (ioaddr + 0x0C) 49 - #define AX_STATUS (ioaddr + 0x0E) 50 - #define AX_CMD AX_STATUS 51 - #define DATAPORT (ioaddr + 0x0F) 52 - #define TX_RDY 0x08 /* In TX_STATUS */ 53 - 54 - #define EL1_DATAPTR 0x08 55 - #define EL1_RXPTR 0x0A 56 - #define EL1_SAPROM 0x0C 57 - #define EL1_DATAPORT 0x0f 58 - 59 - /* 60 - * Writes to the ax command register. 61 - */ 62 - 63 - #define AX_OFF 0x00 /* Irq off, buffer access on */ 64 - #define AX_SYS 0x40 /* Load the buffer */ 65 - #define AX_XMIT 0x44 /* Transmit a packet */ 66 - #define AX_RX 0x48 /* Receive a packet */ 67 - #define AX_LOOP 0x0C /* Loopback mode */ 68 - #define AX_RESET 0x80 69 - 70 - /* 71 - * Normal receive mode written to RX_STATUS. We must intr on short packets 72 - * to avoid bogus rx lockups. 73 - */ 74 - 75 - #define RX_NORM 0xA8 /* 0x68 == all addrs, 0xA8 only to me. */ 76 - #define RX_PROM 0x68 /* Senior Prom, uhmm promiscuous mode. */ 77 - #define RX_MULT 0xE8 /* Accept multicast packets. */ 78 - #define TX_NORM 0x0A /* Interrupt on everything that might hang the chip */ 79 - 80 - /* 81 - * TX_STATUS register. 82 - */ 83 - 84 - #define TX_COLLISION 0x02 85 - #define TX_16COLLISIONS 0x04 86 - #define TX_READY 0x08 87 - 88 - #define RX_RUNT 0x08 89 - #define RX_MISSED 0x01 /* Missed a packet due to 3c501 braindamage. */ 90 - #define RX_GOOD 0x30 /* Good packet 0x20, or simple overflow 0x10. */ 91 -
-14
drivers/net/ethernet/3com/Kconfig
··· 18 18 19 19 if NET_VENDOR_3COM 20 20 21 - config EL1 22 - tristate "3c501 \"EtherLink\" support" 23 - depends on ISA 24 - ---help--- 25 - If you have a network (Ethernet) card of this type, say Y and read 26 - the Ethernet-HOWTO, available from 27 - <http://www.tldp.org/docs.html#howto>. Also, consider buying a 28 - new card, since the 3c501 is slow, broken, and obsolete: you will 29 - have problems. Some people suggest to ping ("man ping") a nearby 30 - machine every minute ("man cron") when using this card. 31 - 32 - To compile this driver as a module, choose M here. The module 33 - will be called 3c501. 34 - 35 21 config EL3 36 22 tristate "3c509/3c579 \"EtherLink III\" support" 37 23 depends on (ISA || EISA)
-1
drivers/net/ethernet/3com/Makefile
··· 2 2 # Makefile for the 3Com Ethernet device drivers 3 3 # 4 4 5 - obj-$(CONFIG_EL1) += 3c501.o 6 5 obj-$(CONFIG_EL3) += 3c509.o 7 6 obj-$(CONFIG_3C515) += 3c515.o 8 7 obj-$(CONFIG_PCMCIA_3C589) += 3c589_cs.o