32 #define DRV_NAME "3c59x"
38 #define TX_RING_SIZE 16
39 #define RX_RING_SIZE 32
40 #define PKT_BUF_SZ 1536
46 static int rx_copybreak = 200;
50 static int rx_copybreak = 1513;
53 static const int mtu = 1500;
55 static int max_interrupt_work = 32;
63 #define tx_interrupt_mitigation 1
66 #define vortex_debug debug
73 #include <linux/module.h>
74 #include <linux/kernel.h>
75 #include <linux/string.h>
77 #include <linux/errno.h>
81 #include <linux/pci.h>
82 #include <linux/mii.h>
84 #include <linux/netdevice.h>
87 #include <linux/ethtool.h>
90 #include <linux/bitops.h>
95 #include <asm/uaccess.h>
100 #define RUN_AT(x) (jiffies + (x))
106 DRV_NAME ": Donald Becker and others.\n";
119 #define VORTEX_TOTAL_SIZE 0x20
120 #define BOOMERANG_TOTAL_SIZE 0x40
125 static char mii_preamble_required;
127 #define PFX DRV_NAME ": "
275 static struct vortex_chip_info {
281 {
"3c590 Vortex 10Mbps",
283 {
"3c592 EISA 10Mbps Demon/Vortex",
285 {
"3c597 EISA Fast Demon/Vortex",
287 {
"3c595 Vortex 100baseTx",
289 {
"3c595 Vortex 100baseT4",
292 {
"3c595 Vortex 100base-MII",
294 {
"3c900 Boomerang 10baseT",
296 {
"3c900 Boomerang 10Mbps Combo",
298 {
"3c900 Cyclone 10Mbps TPO",
300 {
"3c900 Cyclone 10Mbps Combo",
303 {
"3c900 Cyclone 10Mbps TPC",
305 {
"3c900B-FL Cyclone 10base-FL",
307 {
"3c905 Boomerang 100baseTx",
309 {
"3c905 Boomerang 100baseT4",
311 {
"3C905B-TX Fast Etherlink XL PCI",
313 {
"3c905B Cyclone 100baseTx",
316 {
"3c905B Cyclone 10/100/BNC",
318 {
"3c905B-FX Cyclone 100baseFx",
322 {
"3c920B-EMB-WNM (ATI Radeon 9100 IGP)",
329 {
"3cSOHO100-TX Hurricane",
331 {
"3c555 Laptop Hurricane",
333 {
"3c556 Laptop Tornado",
336 {
"3c556B Laptop Hurricane",
340 {
"3c575 [Megahertz] 10/100 LAN CardBus",
342 {
"3c575 Boomerang CardBus",
344 {
"3CCFE575BT Cyclone CardBus",
347 {
"3CCFE575CT Tornado CardBus",
350 {
"3CCFE656 Cyclone CardBus",
354 {
"3CCFEM656B Cyclone+Winmodem CardBus",
357 {
"3CXFEM656C Tornado+Winmodem CardBus",
360 {
"3c450 HomePNA Tornado",
364 {
"3c982 Hydra Dual Port A",
367 {
"3c982 Hydra Dual Port B",
371 {
"3c920B-EMB-WNM Tornado",
439 #define EL3_STATUS 0x0e
504 #define BFEXT(value, offset, bitcount) \
505 ((((unsigned long)(value)) >> (offset)) & ((1 << (bitcount)) - 1))
507 #define BFINS(lhs, rhs, offset, bitcount) \
508 (((lhs) & ~((((1 << (bitcount)) - 1)) << (offset))) | \
509 (((rhs) & ((1 << (bitcount)) - 1)) << (offset)))
511 #define RAM_SIZE(v) BFEXT(v, 0, 3)
512 #define RAM_WIDTH(v) BFEXT(v, 3, 1)
513 #define RAM_SPEED(v) BFEXT(v, 4, 2)
514 #define ROM_SIZE(v) BFEXT(v, 6, 2)
515 #define RAM_SPLIT(v) BFEXT(v, 16, 2)
516 #define XCVR(v) BFEXT(v, 20, 4)
517 #define AUTOSELECT(v) BFEXT(v, 24, 1)
541 #define LAST_FRAG 0x80000000
542 #define DN_COMPLETE 0x00010000
558 #define DO_ZEROCOPY 1
560 #define DO_ZEROCOPY 0
664 if (window != vp->
window) {
670 #define DEFINE_WINDOW_IO(size) \
672 window_read ## size(struct vortex_private *vp, int window, int addr) \
674 unsigned long flags; \
676 spin_lock_irqsave(&vp->window_lock, flags); \
677 window_set(vp, window); \
678 ret = ioread ## size(vp->ioaddr + addr); \
679 spin_unlock_irqrestore(&vp->window_lock, flags); \
683 window_write ## size(struct vortex_private *vp, u ## size value, \
684 int window, int addr) \
686 unsigned long flags; \
687 spin_lock_irqsave(&vp->window_lock, flags); \
688 window_set(vp, window); \
689 iowrite ## size(value, vp->ioaddr + addr); \
690 spin_unlock_irqrestore(&vp->window_lock, flags); \
697 #define DEVICE_PCI(dev) (((dev)->bus == &pci_bus_type) ? to_pci_dev((dev)) : NULL)
699 #define DEVICE_PCI(dev) NULL
702 #define VORTEX_PCI(vp) \
703 ((struct pci_dev *) (((vp)->gendev) ? DEVICE_PCI((vp)->gendev) : NULL))
706 #define DEVICE_EISA(dev) (((dev)->bus == &eisa_bus_type) ? to_eisa_device((dev)) : NULL)
708 #define DEVICE_EISA(dev) NULL
711 #define VORTEX_EISA(vp) \
712 ((struct eisa_device *) (((vp)->gendev) ? DEVICE_EISA((vp)->gendev) : NULL))
722 static const struct media_table {
724 unsigned int media_bits:16,
744 } ethtool_stats_keys[] = {
746 {
"tx_max_collisions" },
747 {
"tx_multiple_collisions" },
748 {
"tx_single_collisions" },
753 #define VORTEX_NUM_STATS 5
755 static int vortex_probe1(
struct device *gendev,
void __iomem *ioaddr,
int irq,
756 int chip_idx,
int card_idx);
763 static void vortex_timer(
unsigned long arg);
764 static void rx_oom_timer(
unsigned long arg);
783 static const struct ethtool_ops vortex_ethtool_ops;
795 static int global_options = -1;
796 static int global_full_duplex = -1;
797 static int global_enable_wol = -1;
798 static int global_use_mmio = -1;
801 static int compaq_ioaddr, compaq_irq, compaq_device_id = 0x5900;
804 static int vortex_cards_found;
824 MODULE_PARM_DESC(options,
"3c59x: Bits 0-3: media type, bit 4: bus mastering, bit 9: full duplex");
825 MODULE_PARM_DESC(global_options,
"3c59x: same as options, but applies to all NICs if options is unset");
827 MODULE_PARM_DESC(global_full_duplex,
"3c59x: same as full_duplex, but applies to all NICs if full_duplex is unset");
828 MODULE_PARM_DESC(hw_checksums,
"3c59x Hardware checksum checking by adapter(s) (0-1)");
829 MODULE_PARM_DESC(flow_ctrl,
"3c59x 802.3x flow control usage (PAUSE only) (0-1)");
830 MODULE_PARM_DESC(enable_wol,
"3c59x: Turn on Wake-on-LAN for adapter(s) (0-1)");
831 MODULE_PARM_DESC(global_enable_wol,
"3c59x: same as enable_wol, but applies to all NICs if enable_wol is unset");
832 MODULE_PARM_DESC(rx_copybreak,
"3c59x copy breakpoint for copy-only-tiny-frames");
833 MODULE_PARM_DESC(max_interrupt_work,
"3c59x maximum events handled per interrupt");
834 MODULE_PARM_DESC(compaq_ioaddr,
"3c59x PCI I/O base address (Compaq BIOS problem workaround)");
835 MODULE_PARM_DESC(compaq_irq,
"3c59x PCI IRQ number (Compaq BIOS problem workaround)");
836 MODULE_PARM_DESC(compaq_device_id,
"3c59x PCI device ID (Compaq BIOS problem workaround)");
838 MODULE_PARM_DESC(global_use_mmio,
"3c59x: same as use_mmio, but applies to all NICs if options is unset");
839 MODULE_PARM_DESC(use_mmio,
"3c59x: use memory-mapped PCI I/O resource (0-1)");
841 #ifdef CONFIG_NET_POLL_CONTROLLER
854 static int vortex_suspend(
struct device *dev)
859 if (!ndev || !netif_running(ndev))
863 vortex_down(ndev, 1);
868 static int vortex_resume(
struct device *dev)
871 struct net_device *ndev = pci_get_drvdata(pdev);
874 if (!ndev || !netif_running(ndev))
877 err = vortex_up(ndev);
886 static const struct dev_pm_ops vortex_pm_ops = {
888 .resume = vortex_resume,
889 .freeze = vortex_suspend,
890 .thaw = vortex_resume,
891 .poweroff = vortex_suspend,
892 .restore = vortex_resume,
895 #define VORTEX_PM_OPS (&vortex_pm_ops)
899 #define VORTEX_PM_OPS NULL
923 if (vortex_probe1(device, ioaddr,
ioread16(ioaddr + 0xC88) >> 12,
924 edev->
id.driver_data, vortex_cards_found)) {
929 vortex_cards_found++;
934 static int __devexit vortex_eisa_remove(
struct device *device)
942 dev = eisa_get_drvdata(edev);
945 pr_err(
"vortex_eisa_remove called for Compaq device!\n");
949 vp = netdev_priv(dev);
964 .probe = vortex_eisa_probe,
972 static int __init vortex_eisa_init(
void)
975 int orig_cards_found = vortex_cards_found;
996 compaq_irq, compaq_device_id, vortex_cards_found++);
999 return vortex_cards_found - orig_cards_found + eisa_found;
1007 struct vortex_chip_info *vci;
1015 unit = vortex_cards_found;
1017 if (global_use_mmio < 0 && (unit >=
MAX_UNITS || use_mmio[unit] < 0)) {
1021 }
else if (unit <
MAX_UNITS && use_mmio[unit] >= 0)
1022 pci_bar = use_mmio[
unit] ? 1 : 0;
1024 pci_bar = global_use_mmio ? 1 : 0;
1026 ioaddr = pci_iomap(pdev, pci_bar, 0);
1028 ioaddr = pci_iomap(pdev, 0, 0);
1035 rc = vortex_probe1(&pdev->
dev, ioaddr, pdev->
irq,
1043 vortex_cards_found++;
1050 .ndo_open = vortex_open,
1051 .ndo_stop = vortex_close,
1052 .ndo_start_xmit = boomerang_start_xmit,
1053 .ndo_tx_timeout = vortex_tx_timeout,
1054 .ndo_get_stats = vortex_get_stats,
1056 .ndo_do_ioctl = vortex_ioctl,
1058 .ndo_set_rx_mode = set_rx_mode,
1062 #ifdef CONFIG_NET_POLL_CONTROLLER
1063 .ndo_poll_controller = poll_vortex,
1068 .ndo_open = vortex_open,
1069 .ndo_stop = vortex_close,
1070 .ndo_start_xmit = vortex_start_xmit,
1071 .ndo_tx_timeout = vortex_tx_timeout,
1072 .ndo_get_stats = vortex_get_stats,
1074 .ndo_do_ioctl = vortex_ioctl,
1076 .ndo_set_rx_mode = set_rx_mode,
1080 #ifdef CONFIG_NET_POLL_CONTROLLER
1081 .ndo_poll_controller = poll_vortex,
1091 static int __devinit vortex_probe1(
struct device *gendev,
1092 void __iomem *ioaddr,
int irq,
1093 int chip_idx,
int card_idx)
1100 static int printed_version;
1102 struct vortex_chip_info *
const vci = &vortex_info_tbl[chip_idx];
1103 const char *print_name =
"3c59x";
1107 if (!printed_version) {
1109 printed_version = 1;
1114 print_name = pci_name(pdev);
1118 print_name = dev_name(&edev->
dev);
1122 dev = alloc_etherdev(
sizeof(*vp));
1128 vp = netdev_priv(dev);
1130 option = global_options;
1141 if (options[card_idx] >= 0)
1142 option = options[card_idx];
1146 if (option & 0x8000)
1148 if (option & 0x4000)
1150 if (option & 0x0400)
1156 pr_info(
"See Documentation/networking/vortex.txt\n");
1158 pr_info(
"%s: 3Com %s %s at %p.\n",
1160 pdev ?
"PCI" :
"EISA",
1176 if (gendev ==
NULL) {
1177 compaq_net_device =
dev;
1193 u8 new_latency = 248;
1200 if (pci_latency < new_latency) {
1201 pr_info(
"%s: Overriding PCI latency timer (CFLT) setting of %d, new value is %d.\n",
1202 print_name, pci_latency, new_latency);
1213 vp->
mii.mdio_read = mdio_read;
1214 vp->
mii.mdio_write = mdio_write;
1215 vp->
mii.phy_id_mask = 0x1f;
1216 vp->
mii.reg_num_mask = 0x1f;
1232 pci_set_drvdata(pdev, dev);
1234 eisa_set_drvdata(edev, dev);
1245 if (global_full_duplex > 0)
1247 if (global_enable_wol > 0)
1251 if (full_duplex[card_idx] > 0)
1253 if (flow_ctrl[card_idx] > 0)
1255 if (enable_wol[card_idx] > 0)
1272 for (i = 0; i < 0x40; i++) {
1276 for (timer = 10; timer >= 0; timer--) {
1285 for (i = 0; i < 0x18; i++)
1286 checksum ^= eeprom[i];
1287 checksum = (checksum ^ (checksum >> 8)) & 0xff;
1288 if (checksum != 0x00) {
1290 checksum ^= eeprom[i++];
1291 checksum = (checksum ^ (checksum >> 8)) & 0xff;
1293 if ((checksum != 0x00) && !(vci->drv_flags &
IS_TORNADO))
1294 pr_cont(
" ***INVALID CHECKSUM %4.4x*** ", checksum);
1295 for (i = 0; i < 3; i++)
1302 if (!is_valid_ether_addr(dev->
dev_addr)) {
1304 pr_err(
"*** EEPROM MAC address is invalid.\n");
1307 for (i = 0; i < 6; i++)
1308 window_write8(vp, dev->
dev_addr[i], 2, i);
1314 pr_warning(
" *** Warning: IRQ %d is unlikely to work! ***\n",
1317 step = (window_read8(vp, 4,
Wn4_NetDiag) & 0x1e) >> 1;
1319 pr_info(
" product code %02x%02x rev %02x.%d date %02d-%02d-%02d\n",
1320 eeprom[6]&0xff, eeprom[6]>>8, eeprom[0x14],
1321 step, (eeprom[4]>>5) & 15, eeprom[4] & 31, eeprom[4]>>9);
1335 pr_info(
"%s: CardBus functions mapped %16.16llx->%p\n",
1348 window_write16(vp, 0x0800, 0, 0);
1353 vp->
info1 = eeprom[13];
1354 vp->
info2 = eeprom[15];
1357 if (vp->
info1 & 0x8000) {
1360 pr_info(
"Full duplex capable\n");
1364 static const char *
const ram_split[] = {
"5:3",
"3:1",
"1:1",
"3:5"};
1371 pr_debug(
" Internal config register is %4.4x, transceivers %#x.\n",
1373 pr_info(
" %dK %s-wide RAM %s Rx:Tx split, %s%s interface.\n",
1388 pr_info(
"%s: Media override to transceiver type %d (%s).\n",
1397 int phy, phy_idx = 0;
1398 mii_preamble_required++;
1400 mii_preamble_required++;
1403 for (phy = 0; phy < 32 && phy_idx < 1; phy++) {
1404 int mii_status, phyx;
1416 mii_status = mdio_read(dev, phyx,
MII_BMSR);
1417 if (mii_status && mii_status != 0xffff) {
1418 vp->
phys[phy_idx++] = phyx;
1420 pr_info(
" MII transceiver found at address %d, status %4x.\n",
1423 if ((mii_status & 0x0040) == 0)
1424 mii_preamble_required++;
1427 mii_preamble_required--;
1429 pr_warning(
" ***WARNING*** No MII transceivers found!\n");
1445 pr_info(
" Enabling bus-master transmits and %s receives.\n",
1446 (vp->
info2 & 1) ?
"early" :
"whole-frame" );
1458 hw_checksums[card_idx] == 1)) {
1465 pr_info(
"%s: scatter/gather %sabled. h/w checksums %sabled\n",
1493 pr_err(
PFX "vortex_probe1 fails. Returns %d\n", retval);
1506 for (i = 0; i < 2000; i++) {
1512 for (i = 0; i < 100000; i++) {
1515 pr_info(
"%s: command 0x%04x took %d usecs\n",
1516 dev->
name, cmd, i * 10);
1521 pr_err(
"%s: command 0x%04x did not complete! Status=0x%x\n",
1530 pr_info(
"%s: setting %s-duplex.\n",
1542 static void vortex_check_media(
struct net_device *dev,
unsigned int init)
1545 unsigned int ok_to_print = 0;
1552 vortex_set_duplex(dev);
1554 vortex_set_duplex(dev);
1564 int i, mii_reg1, mii_reg5, err = 0;
1582 pr_info(
"%s: Media override to transceiver %d (%s).\n",
1589 pr_info(
"%s: using NWAY device table, not %d\n",
1598 pr_info(
"%s: first available media type: %s\n",
1604 pr_info(
"%s: using default media %s\n",
1611 vp->
timer.function = vortex_timer;
1619 pr_debug(
"%s: Initial media type %s.\n",
1625 pr_debug(
"vortex_up(): writing 0x%x to InternalConfig\n", config);
1634 vortex_check_media(dev, 1);
1637 vortex_set_duplex(dev);
1643 issue_and_wait(dev,
RxReset|0x04);
1649 pr_debug(
"%s: vortex_up() irq %d media status %4.4x.\n",
1654 for (i = 0; i < 6; i++)
1655 window_write8(vp, dev->
dev_addr[i], 2, i);
1656 for (; i < 12; i+=2)
1657 window_write16(vp, 0, 2, i);
1668 if (dev->
if_port == XCVR_10base2)
1675 media_tbl[dev->
if_port].media_bits,
1681 for (i = 0; i < 10; i++)
1682 window_read8(vp, 6, i);
1683 window_read16(vp, 6, 10);
1684 window_read16(vp, 6, 12);
1686 window_read8(vp, 4, 12);
1711 set_8021q_mode(dev, 1);
1732 netif_start_queue (dev);
1746 boomerang_interrupt : vortex_interrupt,
IRQF_SHARED, dev->
name, dev))) {
1747 pr_err(
"%s: Could not reserve IRQ %d\n", dev->
name, dev->
irq);
1769 if (i != RX_RING_SIZE) {
1772 for (j = 0; j <
i; j++) {
1785 retval = vortex_up(dev);
1793 pr_err(
"%s: vortex_open() fails: returning %d\n", dev->
name, retval);
1799 vortex_timer(
unsigned long data)
1804 int next_tick = 60*
HZ;
1809 pr_debug(
"%s: Media selection timer tick happened, %s.\n",
1814 media_status = window_read16(vp, 4,
Wn4_Media);
1821 pr_debug(
"%s: Media %s has link beat, %x.\n",
1822 dev->
name, media_tbl[dev->
if_port].name, media_status);
1826 pr_debug(
"%s: Media %s has no link beat, %x.\n",
1827 dev->
name, media_tbl[dev->
if_port].name, media_status);
1834 vortex_check_media(dev, 0);
1839 pr_debug(
"%s: Media %s has no indication, %x.\n",
1840 dev->
name, media_tbl[dev->
if_port].name, media_status);
1848 goto leave_media_alone;
1853 spin_lock_irq(&vp->
lock);
1858 if (dev->
if_port == XCVR_Default) {
1861 pr_debug(
"%s: Media selection failing, using default %s port.\n",
1865 pr_debug(
"%s: Media selection failed, now trying %s port.\n",
1867 next_tick = media_tbl[dev->
if_port].wait;
1871 media_tbl[dev->
if_port].media_bits,
1881 pr_debug(
"wrote 0x%08x to Wn3_Config\n", config);
1884 spin_unlock_irq(&vp->
lock);
1889 pr_debug(
"%s: Media selection timer finished, %s.\n",
1897 static void vortex_tx_timeout(
struct net_device *dev)
1902 pr_err(
"%s: transmit timed out, tx_status %2.2x status %4.4x.\n",
1905 pr_err(
" diagnostics: net %04x media %04x dma %08x fifo %04x\n",
1912 pr_err(
"%s: Transmitter encountered 16 collisions --"
1913 " network cable problem?\n", dev->
name);
1915 pr_err(
"%s: Interrupt posted but not delivered --"
1916 " IRQ blocked by another device?\n", dev->
name);
1922 unsigned long flags;
1925 boomerang_interrupt(dev->
irq, dev);
1927 vortex_interrupt(dev->
irq, dev);
1937 dev->
stats.tx_errors++;
1939 pr_debug(
"%s: Resetting the Tx ring pointer.\n", dev->
name);
1944 netif_wake_queue (dev);
1949 dev->
stats.tx_dropped++;
1950 netif_wake_queue(dev);
1967 int do_tx_reset = 0, reset_mask = 0;
1971 pr_err(
"%s: vortex_error(), status=0x%x\n", dev->
name, status);
1979 pr_err(
"%s: Transmit error, Tx status register %2.2x.\n",
1980 dev->
name, tx_status);
1981 if (tx_status == 0x82) {
1982 pr_err(
"Probably a duplex mismatch. See "
1983 "Documentation/networking/vortex.txt\n");
1987 if (tx_status & 0x14) dev->
stats.tx_fifo_errors++;
1988 if (tx_status & 0x38) dev->
stats.tx_aborted_errors++;
1989 if (tx_status & 0x08) vp->
xstats.tx_max_collisions++;
1991 if (tx_status & 0x30) {
1995 reset_mask = 0x0108;
2005 static int DoneDidThat;
2008 update_stats(ioaddr, dev);
2011 if (DoneDidThat == 0 &&
2013 pr_warning(
"%s: Updating statistics failed, disabling "
2014 "stats as an interrupt source.\n", dev->
name);
2016 (window_read16(vp, 5, 10) & ~StatsFull),
2029 pr_err(
"%s: Host error, FIFO diagnostic register %4.4x.\n",
2030 dev->
name, fifo_diag);
2037 pr_err(
"%s: PCI bus error, bus status %8.8x\n", dev->
name, bus_status);
2041 vortex_down(dev, 0);
2044 }
else if (fifo_diag & 0x0400)
2046 if (fifo_diag & 0x3000) {
2048 issue_and_wait(dev,
RxReset|0x07);
2052 set_8021q_mode(dev, 1);
2059 issue_and_wait(dev,
TxReset|reset_mask);
2062 netif_wake_queue(dev);
2076 int len = (skb->
len + 3) & ~3;
2090 dev_kfree_skb (skb);
2092 netif_start_queue (dev);
2095 netif_stop_queue(dev);
2107 if (tx_status & 0x3C) {
2109 pr_debug(
"%s: Tx error, status %2.2x.\n",
2110 dev->
name, tx_status);
2111 if (tx_status & 0x04) dev->
stats.tx_fifo_errors++;
2112 if (tx_status & 0x38) dev->
stats.tx_aborted_errors++;
2113 if (tx_status & 0x30) {
2132 unsigned long flags;
2135 pr_debug(
"boomerang_start_xmit()\n");
2136 pr_debug(
"%s: Trying to send a packet, Tx index %d.\n",
2151 pr_warning(
"%s: BUG! Tx Ring full, refusing to send buffer.\n",
2153 netif_stop_queue(dev);
2166 if (!skb_shinfo(skb)->nr_frags) {
2177 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
2183 (
void *)skb_frag_address(frag),
2186 if (i == skb_shinfo(skb)->nr_frags-1)
2209 netif_stop_queue (dev);
2211 #if defined(tx_interrupt_mitigation)
2219 spin_unlock_irqrestore(&vp->
lock, flags);
2232 vortex_interrupt(
int irq,
void *
dev_id)
2238 int work_done = max_interrupt_work;
2242 spin_lock(&vp->
lock);
2247 pr_debug(
"vortex_interrupt(). status=0x%4x\n", status);
2249 if ((status & IntLatch) == 0)
2253 if (status & IntReq) {
2258 if (status == 0xffff)
2262 pr_debug(
"%s: interrupt, status %4.4x, latency %d ticks.\n",
2270 pr_debug(
"%s: In interrupt loop, status %4.4x.\n",
2272 if (status & RxComplete)
2277 pr_debug(
" TX room bit was handled.\n");
2280 netif_wake_queue (dev);
2294 netif_wake_queue(dev);
2297 netif_stop_queue(dev);
2302 if (status & (HostError | RxEarly | StatsFull | TxComplete | IntReq)) {
2303 if (status == 0xffff)
2305 if (status & RxEarly)
2308 vortex_error(dev, status);
2313 if (--work_done < 0) {
2314 pr_warning(
"%s: Too much work in interrupt, status %4.4x.\n",
2334 pr_debug(
"%s: exiting interrupt, status %4.4x.\n",
2337 spin_unlock(&vp->
lock);
2347 boomerang_interrupt(
int irq,
void *dev_id)
2353 int work_done = max_interrupt_work;
2362 spin_lock(&vp->
lock);
2368 pr_debug(
"boomerang_interrupt. status=0x%4x\n", status);
2370 if ((status & IntLatch) == 0)
2373 if (status == 0xffff) {
2375 pr_debug(
"boomerang_interrupt(1): status = 0xffff\n");
2379 if (status & IntReq) {
2385 pr_debug(
"%s: interrupt, status %4.4x, latency %d ticks.\n",
2389 pr_debug(
"%s: In interrupt loop, status %4.4x.\n",
2394 pr_debug(
"boomerang_interrupt->boomerang_rx\n");
2402 while (vp->
cur_tx - dirty_tx > 0) {
2417 for (i=0; i<=skb_shinfo(skb)->nr_frags; i++)
2429 pr_debug(
"boomerang_interrupt: no skb!\n");
2435 if (vp->
cur_tx - dirty_tx <= TX_RING_SIZE - 1) {
2437 pr_debug(
"boomerang_interrupt: wake queue\n");
2438 netif_wake_queue (dev);
2443 if (status & (HostError | RxEarly | StatsFull | TxComplete | IntReq))
2444 vortex_error(dev, status);
2446 if (--work_done < 0) {
2447 pr_warning(
"%s: Too much work in interrupt, status %4.4x.\n",
2468 pr_debug(
"%s: exiting interrupt, status %4.4x.\n",
2472 spin_unlock(&vp->
lock);
2484 pr_debug(
"vortex_rx(): status %4.4x, rx_status %4.4x.\n",
2487 if (rx_status & 0x4000) {
2490 pr_debug(
" Rx error: status %2.2x.\n", rx_error);
2491 dev->
stats.rx_errors++;
2492 if (rx_error & 0x01) dev->
stats.rx_over_errors++;
2493 if (rx_error & 0x02) dev->
stats.rx_length_errors++;
2494 if (rx_error & 0x04) dev->
stats.rx_frame_errors++;
2495 if (rx_error & 0x08) dev->
stats.rx_crc_errors++;
2496 if (rx_error & 0x10) dev->
stats.rx_length_errors++;
2499 int pkt_len = rx_status & 0x1fff;
2502 skb = netdev_alloc_skb(dev, pkt_len + 5);
2504 pr_debug(
"Receiving packet size %d status %4.4x.\n",
2505 pkt_len, rx_status);
2507 skb_reserve(skb, 2);
2522 (pkt_len + 3) >> 2);
2527 dev->
stats.rx_packets++;
2529 for (i = 200; i >= 0; i--)
2534 pr_notice(
"%s: No memory to allocate a sk_buff of size %d.\n",
2535 dev->
name, pkt_len);
2536 dev->
stats.rx_dropped++;
2557 if (--rx_work_limit < 0)
2560 unsigned char rx_error = rx_status >> 16;
2562 pr_debug(
" Rx error: status %2.2x.\n", rx_error);
2563 dev->
stats.rx_errors++;
2564 if (rx_error & 0x01) dev->
stats.rx_over_errors++;
2565 if (rx_error & 0x02) dev->
stats.rx_length_errors++;
2566 if (rx_error & 0x04) dev->
stats.rx_frame_errors++;
2567 if (rx_error & 0x08) dev->
stats.rx_crc_errors++;
2568 if (rx_error & 0x10) dev->
stats.rx_length_errors++;
2571 int pkt_len = rx_status & 0x1fff;
2576 pr_debug(
"Receiving packet size %d status %4.4x.\n",
2577 pkt_len, rx_status);
2581 if (pkt_len < rx_copybreak &&
2582 (skb = netdev_alloc_skb(dev, pkt_len + 2)) !=
NULL) {
2583 skb_reserve(skb, 2);
2601 int csum_bits = rx_status & 0xee000000;
2610 dev->
stats.rx_packets++;
2612 entry = (++vp->
cur_rx) % RX_RING_SIZE;
2619 skb = netdev_alloc_skb_ip_align(dev,
PKT_BUF_SZ);
2621 static unsigned long last_jif;
2645 rx_oom_timer(
unsigned long arg)
2650 spin_lock_irq(&vp->
lock);
2655 ((vp->
cur_rx - vp->
dirty_rx) != RX_RING_SIZE) ?
"succeeded" :
"retrying");
2657 spin_unlock_irq(&vp->
lock);
2661 vortex_down(
struct net_device *dev,
int final_down)
2666 netif_stop_queue (dev);
2679 set_8021q_mode(dev, 0);
2681 if (dev->
if_port == XCVR_10base2)
2687 update_stats(ioaddr, dev);
2707 if (netif_device_present(dev))
2708 vortex_down(dev, 1);
2711 pr_debug(
"%s: vortex_close() status %4.4x, Tx status %2.2x.\n",
2713 pr_debug(
"%s: vortex close stats: rx_nocopy %d rx_copy %d"
2714 " tx_queued %d Rx pre-checksummed %d.\n",
2722 pr_warning(
"%s supports hardware checksums, and we're not using them!\n", dev->
name);
2744 for (k=0; k<=skb_shinfo(skb)->nr_frags; k++)
2772 pr_err(
" Flags; bus-master %d, dirty %d(%d) current %d(%d)\n",
2776 pr_err(
" Transmit list %8.8x vs. %p.\n",
2788 pr_err(
" %d: @%p length %8.8x status %8.8x\n",
2802 unsigned long flags;
2804 if (netif_device_present(dev)) {
2806 update_stats(ioaddr, dev);
2807 spin_unlock_irqrestore (&vp->
lock, flags);
2825 dev->
stats.tx_carrier_errors += window_read8(vp, 6, 0);
2826 dev->
stats.tx_heartbeat_errors += window_read8(vp, 6, 1);
2827 dev->
stats.tx_window_errors += window_read8(vp, 6, 4);
2828 dev->
stats.rx_fifo_errors += window_read8(vp, 6, 5);
2829 dev->
stats.tx_packets += window_read8(vp, 6, 6);
2830 dev->
stats.tx_packets += (window_read8(vp, 6, 9) &
2832 window_read8(vp, 6, 7);
2836 dev->
stats.rx_bytes += window_read16(vp, 6, 10);
2837 dev->
stats.tx_bytes += window_read16(vp, 6, 12);
2839 vp->
xstats.tx_multiple_collisions += window_read8(vp, 6, 2);
2840 vp->
xstats.tx_single_collisions += window_read8(vp, 6, 3);
2841 vp->
xstats.tx_deferred += window_read8(vp, 6, 8);
2842 vp->
xstats.rx_bad_ssd += window_read8(vp, 4, 12);
2844 dev->
stats.collisions = vp->
xstats.tx_multiple_collisions
2845 + vp->
xstats.tx_single_collisions
2846 + vp->
xstats.tx_max_collisions;
2849 u8 up = window_read8(vp, 4, 13);
2850 dev->
stats.rx_bytes += (up & 0x0f) << 16;
2851 dev->
stats.tx_bytes += (up & 0xf0) << 12;
2855 static int vortex_nway_reset(
struct net_device *dev)
2886 static int vortex_get_sset_count(
struct net_device *dev,
int sset)
2896 static void vortex_get_ethtool_stats(
struct net_device *dev,
2901 unsigned long flags;
2904 update_stats(ioaddr, dev);
2905 spin_unlock_irqrestore(&vp->
lock, flags);
2907 data[0] = vp->
xstats.tx_deferred;
2908 data[1] = vp->
xstats.tx_max_collisions;
2909 data[2] = vp->
xstats.tx_multiple_collisions;
2910 data[3] = vp->
xstats.tx_single_collisions;
2911 data[4] = vp->
xstats.rx_bad_ssd;
2915 static void vortex_get_strings(
struct net_device *dev,
u32 stringset,
u8 *data)
2917 switch (stringset) {
2919 memcpy(data, ðtool_stats_keys,
sizeof(ethtool_stats_keys));
2927 static void vortex_get_drvinfo(
struct net_device *dev,
2979 static const struct ethtool_ops vortex_ethtool_ops = {
2980 .get_drvinfo = vortex_get_drvinfo,
2981 .get_strings = vortex_get_strings,
2982 .get_msglevel = vortex_get_msglevel,
2983 .set_msglevel = vortex_set_msglevel,
2984 .get_ethtool_stats = vortex_get_ethtool_stats,
2985 .get_sset_count = vortex_get_sset_count,
2986 .get_settings = vortex_get_settings,
2987 .set_settings = vortex_set_settings,
2989 .nway_reset = vortex_nway_reset,
2990 .get_wol = vortex_get_wol,
2991 .set_wol = vortex_set_wol,
3023 static void set_rx_mode(
struct net_device *dev)
3041 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
3047 #define VLAN_ETHER_TYPE 0x8100
3058 int max_pkt_size = dev->
mtu+14;
3082 static void set_8021q_mode(
struct net_device *dev,
int enable)
3102 #define MDIO_SHIFT_CLK 0x01
3103 #define MDIO_DIR_WRITE 0x04
3104 #define MDIO_DATA_WRITE0 (0x00 | MDIO_DIR_WRITE)
3105 #define MDIO_DATA_WRITE1 (0x02 | MDIO_DIR_WRITE)
3106 #define MDIO_DATA_READ 0x02
3107 #define MDIO_ENB_IN 0x00
3114 while (-- bits >= 0) {
3127 int read_cmd = (0xf6 << 10) | (phy_id << 5) |
location;
3128 unsigned int retval = 0;
3132 if (mii_preamble_required)
3136 for (i = 14; i >= 0; i--) {
3145 for (i = 19; i > 0; i--) {
3148 retval = (retval << 1) |
3158 return retval & 0x20000 ? 0xffff : retval>>1 & 0xffff;
3161 static void mdio_write(
struct net_device *dev,
int phy_id,
int location,
int value)
3164 int write_cmd = 0x50020000 | (phy_id << 23) | (location << 18) |
value;
3169 if (mii_preamble_required)
3173 for (i = 31; i >= 0; i--) {
3182 for (i = 1; i >= 0; i--) {
3195 static void acpi_set_WOL(
struct net_device *dev)
3204 window_write16(vp, 2, 7, 0x0c);
3227 struct net_device *dev = pci_get_drvdata(pdev);
3231 pr_err(
"vortex_remove_one called for Compaq device!\n");
3235 vp = netdev_priv(dev);
3267 .probe = vortex_init_one,
3269 .id_table = vortex_pci_tbl,
3274 static int vortex_have_pci;
3275 static int vortex_have_eisa;
3278 static int __init vortex_init(
void)
3280 int pci_rc, eisa_rc;
3282 pci_rc = pci_register_driver(&vortex_driver);
3283 eisa_rc = vortex_eisa_init();
3286 vortex_have_pci = 1;
3288 vortex_have_eisa = 1;
3290 return (vortex_have_pci + vortex_have_eisa) ? 0 : -
ENODEV;
3294 static void __exit vortex_eisa_cleanup(
void)
3304 if (compaq_net_device) {
3305 vp = netdev_priv(compaq_net_device);
3319 static void __exit vortex_cleanup(
void)
3321 if (vortex_have_pci)
3323 if (vortex_have_eisa)
3324 vortex_eisa_cleanup();