3c59x.c (13fe7056bebb4015c6231a07a1be4d3aebbfe979) 3c59x.c (b255e500c8dc111dd9efac1442a85a0dac913feb)
1/* EtherLinkXL.c: A 3Com EtherLink PCI III/XL ethernet driver for linux. */
2/*
3 Written 1996-1999 by Donald Becker.
4
5 This software may be used and distributed according to the terms
6 of the GNU General Public License, incorporated herein by reference.
7
8 This driver is for the 3Com "Vortex" and "Boomerang" series ethercards.

--- 751 unchanged lines hidden (view full) ---

760static void mdio_write(struct net_device *vp, int phy_id, int location, int value);
761static void vortex_timer(struct timer_list *t);
762static netdev_tx_t vortex_start_xmit(struct sk_buff *skb,
763 struct net_device *dev);
764static netdev_tx_t boomerang_start_xmit(struct sk_buff *skb,
765 struct net_device *dev);
766static int vortex_rx(struct net_device *dev);
767static int boomerang_rx(struct net_device *dev);
1/* EtherLinkXL.c: A 3Com EtherLink PCI III/XL ethernet driver for linux. */
2/*
3 Written 1996-1999 by Donald Becker.
4
5 This software may be used and distributed according to the terms
6 of the GNU General Public License, incorporated herein by reference.
7
8 This driver is for the 3Com "Vortex" and "Boomerang" series ethercards.

--- 751 unchanged lines hidden (view full) ---

760static void mdio_write(struct net_device *vp, int phy_id, int location, int value);
761static void vortex_timer(struct timer_list *t);
762static netdev_tx_t vortex_start_xmit(struct sk_buff *skb,
763 struct net_device *dev);
764static netdev_tx_t boomerang_start_xmit(struct sk_buff *skb,
765 struct net_device *dev);
766static int vortex_rx(struct net_device *dev);
767static int boomerang_rx(struct net_device *dev);
768static irqreturn_t vortex_interrupt(int irq, void *dev_id);
769static irqreturn_t boomerang_interrupt(int irq, void *dev_id);
768static irqreturn_t vortex_boomerang_interrupt(int irq, void *dev_id);
769static irqreturn_t _vortex_interrupt(int irq, struct net_device *dev);
770static irqreturn_t _boomerang_interrupt(int irq, struct net_device *dev);
770static int vortex_close(struct net_device *dev);
771static void dump_tx_ring(struct net_device *dev);
772static void update_stats(void __iomem *ioaddr, struct net_device *dev);
773static struct net_device_stats *vortex_get_stats(struct net_device *dev);
774static void set_rx_mode(struct net_device *dev);
775#ifdef CONFIG_PCI
776static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
777#endif

--- 55 unchanged lines hidden (view full) ---

833MODULE_PARM_DESC(compaq_device_id, "3c59x PCI device ID (Compaq BIOS problem workaround)");
834MODULE_PARM_DESC(watchdog, "3c59x transmit timeout in milliseconds");
835MODULE_PARM_DESC(global_use_mmio, "3c59x: same as use_mmio, but applies to all NICs if options is unset");
836MODULE_PARM_DESC(use_mmio, "3c59x: use memory-mapped PCI I/O resource (0-1)");
837
838#ifdef CONFIG_NET_POLL_CONTROLLER
839static void poll_vortex(struct net_device *dev)
840{
771static int vortex_close(struct net_device *dev);
772static void dump_tx_ring(struct net_device *dev);
773static void update_stats(void __iomem *ioaddr, struct net_device *dev);
774static struct net_device_stats *vortex_get_stats(struct net_device *dev);
775static void set_rx_mode(struct net_device *dev);
776#ifdef CONFIG_PCI
777static int vortex_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
778#endif

--- 55 unchanged lines hidden (view full) ---

834MODULE_PARM_DESC(compaq_device_id, "3c59x PCI device ID (Compaq BIOS problem workaround)");
835MODULE_PARM_DESC(watchdog, "3c59x transmit timeout in milliseconds");
836MODULE_PARM_DESC(global_use_mmio, "3c59x: same as use_mmio, but applies to all NICs if options is unset");
837MODULE_PARM_DESC(use_mmio, "3c59x: use memory-mapped PCI I/O resource (0-1)");
838
839#ifdef CONFIG_NET_POLL_CONTROLLER
840static void poll_vortex(struct net_device *dev)
841{
841 struct vortex_private *vp = netdev_priv(dev);
842 unsigned long flags;
843 local_irq_save(flags);
844 (vp->full_bus_master_rx ? boomerang_interrupt:vortex_interrupt)(dev->irq,dev);
845 local_irq_restore(flags);
842 vortex_boomerang_interrupt(dev->irq, dev);
846}
847#endif
848
849#ifdef CONFIG_PM
850
851static int vortex_suspend(struct device *dev)
852{
853 struct pci_dev *pdev = to_pci_dev(dev);

--- 295 unchanged lines hidden (view full) ---

1149 if (option & 0x4000)
1150 vortex_debug = 2;
1151 if (option & 0x0400)
1152 vp->enable_wol = 1;
1153 }
1154
1155 print_info = (vortex_debug > 1);
1156 if (print_info)
843}
844#endif
845
846#ifdef CONFIG_PM
847
848static int vortex_suspend(struct device *dev)
849{
850 struct pci_dev *pdev = to_pci_dev(dev);

--- 295 unchanged lines hidden (view full) ---

1146 if (option & 0x4000)
1147 vortex_debug = 2;
1148 if (option & 0x0400)
1149 vp->enable_wol = 1;
1150 }
1151
1152 print_info = (vortex_debug > 1);
1153 if (print_info)
1157 pr_info("See Documentation/networking/vortex.txt\n");
1154 pr_info("See Documentation/networking/device_drivers/3com/vortex.txt\n");
1158
1159 pr_info("%s: 3Com %s %s at %p.\n",
1160 print_name,
1161 pdev ? "PCI" : "EISA",
1162 vci->name,
1163 ioaddr);
1164
1165 dev->base_addr = (unsigned long)ioaddr;

--- 557 unchanged lines hidden (view full) ---

1723vortex_open(struct net_device *dev)
1724{
1725 struct vortex_private *vp = netdev_priv(dev);
1726 int i;
1727 int retval;
1728 dma_addr_t dma;
1729
1730 /* Use the now-standard shared IRQ implementation. */
1155
1156 pr_info("%s: 3Com %s %s at %p.\n",
1157 print_name,
1158 pdev ? "PCI" : "EISA",
1159 vci->name,
1160 ioaddr);
1161
1162 dev->base_addr = (unsigned long)ioaddr;

--- 557 unchanged lines hidden (view full) ---

1720vortex_open(struct net_device *dev)
1721{
1722 struct vortex_private *vp = netdev_priv(dev);
1723 int i;
1724 int retval;
1725 dma_addr_t dma;
1726
1727 /* Use the now-standard shared IRQ implementation. */
1731 if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ?
1732 boomerang_interrupt : vortex_interrupt, IRQF_SHARED, dev->name, dev))) {
1728 if ((retval = request_irq(dev->irq, vortex_boomerang_interrupt, IRQF_SHARED, dev->name, dev))) {
1733 pr_err("%s: Could not reserve IRQ %d\n", dev->name, dev->irq);
1734 goto err;
1735 }
1736
1737 if (vp->full_bus_master_rx) { /* Boomerang bus master. */
1738 if (vortex_debug > 2)
1739 pr_debug("%s: Filling in the Rx ring.\n", dev->name);
1740 for (i = 0; i < RX_RING_SIZE; i++) {

--- 158 unchanged lines hidden (view full) ---

1899 /* Slight code bloat to be user friendly. */
1900 if ((ioread8(ioaddr + TxStatus) & 0x88) == 0x88)
1901 pr_err("%s: Transmitter encountered 16 collisions --"
1902 " network cable problem?\n", dev->name);
1903 if (ioread16(ioaddr + EL3_STATUS) & IntLatch) {
1904 pr_err("%s: Interrupt posted but not delivered --"
1905 " IRQ blocked by another device?\n", dev->name);
1906 /* Bad idea here.. but we might as well handle a few events. */
1729 pr_err("%s: Could not reserve IRQ %d\n", dev->name, dev->irq);
1730 goto err;
1731 }
1732
1733 if (vp->full_bus_master_rx) { /* Boomerang bus master. */
1734 if (vortex_debug > 2)
1735 pr_debug("%s: Filling in the Rx ring.\n", dev->name);
1736 for (i = 0; i < RX_RING_SIZE; i++) {

--- 158 unchanged lines hidden (view full) ---

1895 /* Slight code bloat to be user friendly. */
1896 if ((ioread8(ioaddr + TxStatus) & 0x88) == 0x88)
1897 pr_err("%s: Transmitter encountered 16 collisions --"
1898 " network cable problem?\n", dev->name);
1899 if (ioread16(ioaddr + EL3_STATUS) & IntLatch) {
1900 pr_err("%s: Interrupt posted but not delivered --"
1901 " IRQ blocked by another device?\n", dev->name);
1902 /* Bad idea here.. but we might as well handle a few events. */
1907 {
1908 /*
1909 * Block interrupts because vortex_interrupt does a bare spin_lock()
1910 */
1911 unsigned long flags;
1912 local_irq_save(flags);
1913 if (vp->full_bus_master_tx)
1914 boomerang_interrupt(dev->irq, dev);
1915 else
1916 vortex_interrupt(dev->irq, dev);
1917 local_irq_restore(flags);
1918 }
1903 vortex_boomerang_interrupt(dev->irq, dev);
1919 }
1920
1921 if (vortex_debug > 0)
1922 dump_tx_ring(dev);
1923
1924 issue_and_wait(dev, TxReset);
1925
1926 dev->stats.tx_errors++;

--- 39 unchanged lines hidden (view full) ---

1966 tx_status = ioread8(ioaddr + TxStatus);
1967 /* Presumably a tx-timeout. We must merely re-enable. */
1968 if (vortex_debug > 2 ||
1969 (tx_status != 0x88 && vortex_debug > 0)) {
1970 pr_err("%s: Transmit error, Tx status register %2.2x.\n",
1971 dev->name, tx_status);
1972 if (tx_status == 0x82) {
1973 pr_err("Probably a duplex mismatch. See "
1904 }
1905
1906 if (vortex_debug > 0)
1907 dump_tx_ring(dev);
1908
1909 issue_and_wait(dev, TxReset);
1910
1911 dev->stats.tx_errors++;

--- 39 unchanged lines hidden (view full) ---

1951 tx_status = ioread8(ioaddr + TxStatus);
1952 /* Presumably a tx-timeout. We must merely re-enable. */
1953 if (vortex_debug > 2 ||
1954 (tx_status != 0x88 && vortex_debug > 0)) {
1955 pr_err("%s: Transmit error, Tx status register %2.2x.\n",
1956 dev->name, tx_status);
1957 if (tx_status == 0x82) {
1958 pr_err("Probably a duplex mismatch. See "
1974 "Documentation/networking/vortex.txt\n");
1959 "Documentation/networking/device_drivers/3com/vortex.txt\n");
1975 }
1976 dump_tx_ring(dev);
1977 }
1978 if (tx_status & 0x14) dev->stats.tx_fifo_errors++;
1979 if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
1980 if (tx_status & 0x08) vp->xstats.tx_max_collisions++;
1981 iowrite8(0, ioaddr + TxStatus);
1982 if (tx_status & 0x30) { /* txJabber or txUnderrun */

--- 278 unchanged lines hidden (view full) ---

2261 after the Tx thread. */
2262
2263/*
2264 * This is the ISR for the vortex series chips.
2265 * full_bus_master_tx == 0 && full_bus_master_rx == 0
2266 */
2267
2268static irqreturn_t
1960 }
1961 dump_tx_ring(dev);
1962 }
1963 if (tx_status & 0x14) dev->stats.tx_fifo_errors++;
1964 if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
1965 if (tx_status & 0x08) vp->xstats.tx_max_collisions++;
1966 iowrite8(0, ioaddr + TxStatus);
1967 if (tx_status & 0x30) { /* txJabber or txUnderrun */

--- 278 unchanged lines hidden (view full) ---

2246 after the Tx thread. */
2247
2248/*
2249 * This is the ISR for the vortex series chips.
2250 * full_bus_master_tx == 0 && full_bus_master_rx == 0
2251 */
2252
2253static irqreturn_t
2269vortex_interrupt(int irq, void *dev_id)
2254_vortex_interrupt(int irq, struct net_device *dev)
2270{
2255{
2271 struct net_device *dev = dev_id;
2272 struct vortex_private *vp = netdev_priv(dev);
2273 void __iomem *ioaddr;
2274 int status;
2275 int work_done = max_interrupt_work;
2276 int handled = 0;
2277 unsigned int bytes_compl = 0, pkts_compl = 0;
2278
2279 ioaddr = vp->ioaddr;
2256 struct vortex_private *vp = netdev_priv(dev);
2257 void __iomem *ioaddr;
2258 int status;
2259 int work_done = max_interrupt_work;
2260 int handled = 0;
2261 unsigned int bytes_compl = 0, pkts_compl = 0;
2262
2263 ioaddr = vp->ioaddr;
2280 spin_lock(&vp->lock);
2281
2282 status = ioread16(ioaddr + EL3_STATUS);
2283
2284 if (vortex_debug > 6)
2285 pr_debug("vortex_interrupt(). status=0x%4x\n", status);
2286
2287 if ((status & IntLatch) == 0)
2288 goto handler_exit; /* No interrupt: shared IRQs cause this */

--- 81 unchanged lines hidden (view full) ---

2370
2371 netdev_completed_queue(dev, pkts_compl, bytes_compl);
2372 spin_unlock(&vp->window_lock);
2373
2374 if (vortex_debug > 4)
2375 pr_debug("%s: exiting interrupt, status %4.4x.\n",
2376 dev->name, status);
2377handler_exit:
2264
2265 status = ioread16(ioaddr + EL3_STATUS);
2266
2267 if (vortex_debug > 6)
2268 pr_debug("vortex_interrupt(). status=0x%4x\n", status);
2269
2270 if ((status & IntLatch) == 0)
2271 goto handler_exit; /* No interrupt: shared IRQs cause this */

--- 81 unchanged lines hidden (view full) ---

2353
2354 netdev_completed_queue(dev, pkts_compl, bytes_compl);
2355 spin_unlock(&vp->window_lock);
2356
2357 if (vortex_debug > 4)
2358 pr_debug("%s: exiting interrupt, status %4.4x.\n",
2359 dev->name, status);
2360handler_exit:
2378 spin_unlock(&vp->lock);
2379 return IRQ_RETVAL(handled);
2380}
2381
2382/*
2383 * This is the ISR for the boomerang series chips.
2384 * full_bus_master_tx == 1 && full_bus_master_rx == 1
2385 */
2386
2387static irqreturn_t
2361 return IRQ_RETVAL(handled);
2362}
2363
2364/*
2365 * This is the ISR for the boomerang series chips.
2366 * full_bus_master_tx == 1 && full_bus_master_rx == 1
2367 */
2368
2369static irqreturn_t
2388boomerang_interrupt(int irq, void *dev_id)
2370_boomerang_interrupt(int irq, struct net_device *dev)
2389{
2371{
2390 struct net_device *dev = dev_id;
2391 struct vortex_private *vp = netdev_priv(dev);
2392 void __iomem *ioaddr;
2393 int status;
2394 int work_done = max_interrupt_work;
2395 int handled = 0;
2396 unsigned int bytes_compl = 0, pkts_compl = 0;
2397
2398 ioaddr = vp->ioaddr;
2399
2372 struct vortex_private *vp = netdev_priv(dev);
2373 void __iomem *ioaddr;
2374 int status;
2375 int work_done = max_interrupt_work;
2376 int handled = 0;
2377 unsigned int bytes_compl = 0, pkts_compl = 0;
2378
2379 ioaddr = vp->ioaddr;
2380
2400
2401 /*
2402 * It seems dopey to put the spinlock this early, but we could race against vortex_tx_timeout
2403 * and boomerang_start_xmit
2404 */
2405 spin_lock(&vp->lock);
2406 vp->handling_irq = 1;
2407
2408 status = ioread16(ioaddr + EL3_STATUS);
2409
2410 if (vortex_debug > 6)
2411 pr_debug("boomerang_interrupt. status=0x%4x\n", status);
2412
2413 if ((status & IntLatch) == 0)

--- 102 unchanged lines hidden (view full) ---

2516 } while ((status = ioread16(ioaddr + EL3_STATUS)) & IntLatch);
2517 netdev_completed_queue(dev, pkts_compl, bytes_compl);
2518
2519 if (vortex_debug > 4)
2520 pr_debug("%s: exiting interrupt, status %4.4x.\n",
2521 dev->name, status);
2522handler_exit:
2523 vp->handling_irq = 0;
2381 vp->handling_irq = 1;
2382
2383 status = ioread16(ioaddr + EL3_STATUS);
2384
2385 if (vortex_debug > 6)
2386 pr_debug("boomerang_interrupt. status=0x%4x\n", status);
2387
2388 if ((status & IntLatch) == 0)

--- 102 unchanged lines hidden (view full) ---

2491 } while ((status = ioread16(ioaddr + EL3_STATUS)) & IntLatch);
2492 netdev_completed_queue(dev, pkts_compl, bytes_compl);
2493
2494 if (vortex_debug > 4)
2495 pr_debug("%s: exiting interrupt, status %4.4x.\n",
2496 dev->name, status);
2497handler_exit:
2498 vp->handling_irq = 0;
2524 spin_unlock(&vp->lock);
2525 return IRQ_RETVAL(handled);
2526}
2527
2499 return IRQ_RETVAL(handled);
2500}
2501
2502static irqreturn_t
2503vortex_boomerang_interrupt(int irq, void *dev_id)
2504{
2505 struct net_device *dev = dev_id;
2506 struct vortex_private *vp = netdev_priv(dev);
2507 unsigned long flags;
2508 irqreturn_t ret;
2509
2510 spin_lock_irqsave(&vp->lock, flags);
2511
2512 if (vp->full_bus_master_rx)
2513 ret = _boomerang_interrupt(dev->irq, dev);
2514 else
2515 ret = _vortex_interrupt(dev->irq, dev);
2516
2517 spin_unlock_irqrestore(&vp->lock, flags);
2518
2519 return ret;
2520}
2521
2528static int vortex_rx(struct net_device *dev)
2529{
2530 struct vortex_private *vp = netdev_priv(dev);
2531 void __iomem *ioaddr = vp->ioaddr;
2532 int i;
2533 short rx_status;
2534
2535 if (vortex_debug > 5)

--- 828 unchanged lines hidden ---
2522static int vortex_rx(struct net_device *dev)
2523{
2524 struct vortex_private *vp = netdev_priv(dev);
2525 void __iomem *ioaddr = vp->ioaddr;
2526 int i;
2527 short rx_status;
2528
2529 if (vortex_debug > 5)

--- 828 unchanged lines hidden ---