• Home
  • Raw
  • Download

Lines Matching +full:100 +full:base +full:- +full:fx

3 	Written 1999-2000 by Donald Becker.
19 [link no longer provides useful info -jgarzik]
27 #define DRV_RELDATE "11-Sep-2006"
30 /* The user-configurable values.
33 /* Maximum number of multicast addresses to filter (vs. rx-all-multicast).
37 /* Set the copy breakpoint for the copy-only-tiny-frames scheme.
40 need a copy-align. */
48 100mbps_hd 100Mbps half duplex.
49 100mbps_fd 100Mbps full duplex.
53 3 100Mbps half duplex.
54 4 100Mbps full duplex.
69 #define TX_QUEUE_LEN (TX_RING_SIZE - 1) /* Limit ring entries actually used. */
99 #include <linux/dma-mapping.h>
104 /* These identify the driver base version and may not be removed. */
117 MODULE_PARM_DESC(debug, "Sundance Alta debug level (0-5)");
118 MODULE_PARM_DESC(rx_copybreak, "Sundance Alta copy breakpoint for copy-only-tiny-frames");
128 II. Board-specific settings
134 This driver uses two statically allocated fixed-size descriptor lists
142 This driver uses a zero-copy receive and transmit scheme.
144 open() time and passes the skb->data field to the chip as receive data
151 The RX_COPYBREAK value is chosen to trade-off the memory wasted by
152 using a full-sized skbuff for small frames vs. the copying costs of larger
163 frames are received into the skbuff at an offset of "+2", 16-byte aligning
168 The driver runs as two independent, single-threaded flows of control. One
169 is the send-packet routine, which enforces single-threaded use by the
170 dev->tbusy flag. The other thread is the interrupt handler, which is single
173 The send packet thread has partial control over the Tx ring and 'dev->tbusy'
176 the 'lp->tx_full' flag.
180 empty by incrementing the dirty_tx mark. Iff the 'lp->tx_full' flag is set, it
190 http://www.scyld.com/expert/100mbps.html
197 /* Work-around for Kendin chip bugs. */
222 {"D-Link DFE-550TX FAST Ethernet Adapter"},
223 {"D-Link DFE-550FX 100Mbps Fiber-optics Adapter"},
224 {"D-Link DFE-580TX 4 port Server Adapter"},
225 {"D-Link DFE-530TXS FAST Ethernet Adapter"},
226 {"D-Link DL10050-based FAST Ethernet Adapter"},
232 /* This driver was written to use PCI memory space, however x86-oriented
236 Unlike software-only systems, device drivers interact with complex hardware.
346 /* Note that using only 32 bit fields simplifies conversion to big-endian
401 unsigned int default_port:4; /* Last dev->if_port value. */
417 void __iomem *base; member
456 void __iomem *ioaddr = np->base + ASICCtrl; in sundance_reset()
464 if (--countdown == 0) { in sundance_reset()
465 printk(KERN_WARNING "%s : reset not completed !!\n", dev->name); in sundance_reset()
468 udelay(100); in sundance_reset()
477 disable_irq(np->pci_dev->irq); in sundance_poll_controller()
478 intr_handler(np->pci_dev->irq, dev); in sundance_poll_controller()
479 enable_irq(np->pci_dev->irq); in sundance_poll_controller()
505 int chip_idx = ent->driver_data; in sundance_probe1()
527 return -EIO; in sundance_probe1()
530 irq = pdev->irq; in sundance_probe1()
534 return -ENOMEM; in sundance_probe1()
535 SET_NETDEV_DEV(dev, &pdev->dev); in sundance_probe1()
545 ((__le16 *)dev->dev_addr)[i] = in sundance_probe1()
549 np->base = ioaddr; in sundance_probe1()
550 np->pci_dev = pdev; in sundance_probe1()
551 np->chip_id = chip_idx; in sundance_probe1()
552 np->msg_enable = (1 << debug) - 1; in sundance_probe1()
553 spin_lock_init(&np->lock); in sundance_probe1()
554 spin_lock_init(&np->statlock); in sundance_probe1()
555 tasklet_init(&np->rx_tasklet, rx_poll, (unsigned long)dev); in sundance_probe1()
556 tasklet_init(&np->tx_tasklet, tx_poll, (unsigned long)dev); in sundance_probe1()
558 ring_space = dma_alloc_coherent(&pdev->dev, TX_TOTAL_SIZE, in sundance_probe1()
562 np->tx_ring = (struct netdev_desc *)ring_space; in sundance_probe1()
563 np->tx_ring_dma = ring_dma; in sundance_probe1()
565 ring_space = dma_alloc_coherent(&pdev->dev, RX_TOTAL_SIZE, in sundance_probe1()
569 np->rx_ring = (struct netdev_desc *)ring_space; in sundance_probe1()
570 np->rx_ring_dma = ring_dma; in sundance_probe1()
572 np->mii_if.dev = dev; in sundance_probe1()
573 np->mii_if.mdio_read = mdio_read; in sundance_probe1()
574 np->mii_if.mdio_write = mdio_write; in sundance_probe1()
575 np->mii_if.phy_id_mask = 0x1f; in sundance_probe1()
576 np->mii_if.reg_num_mask = 0x1f; in sundance_probe1()
578 /* The chip-specific entries in the device structure. */ in sundance_probe1()
579 dev->netdev_ops = &netdev_ops; in sundance_probe1()
580 dev->ethtool_ops = &ethtool_ops; in sundance_probe1()
581 dev->watchdog_timeo = TX_TIMEOUT; in sundance_probe1()
583 /* MTU range: 68 - 8191 */ in sundance_probe1()
584 dev->min_mtu = ETH_MIN_MTU; in sundance_probe1()
585 dev->max_mtu = 8191; in sundance_probe1()
594 dev->name, pci_id_tbl[chip_idx].name, ioaddr, in sundance_probe1()
595 dev->dev_addr, irq); in sundance_probe1()
597 np->phys[0] = 1; /* Default setting */ in sundance_probe1()
598 np->mii_preamble_required++; in sundance_probe1()
604 if (sundance_pci_tbl[np->chip_id].device == 0x0200) { in sundance_probe1()
615 np->phys[phy_idx++] = phyx; in sundance_probe1()
616 np->mii_if.advertising = mdio_read(dev, phyx, MII_ADVERTISE); in sundance_probe1()
618 np->mii_preamble_required++; in sundance_probe1()
621 dev->name, phyx, mii_status, np->mii_if.advertising); in sundance_probe1()
624 np->mii_preamble_required--; in sundance_probe1()
628 dev->name, ioread32(ioaddr + ASICCtrl)); in sundance_probe1()
632 np->mii_if.phy_id = np->phys[0]; in sundance_probe1()
635 np->an_enable = 1; in sundance_probe1()
638 np->an_enable = 0; in sundance_probe1()
639 if (strcmp (media[card_idx], "100mbps_fd") == 0 || in sundance_probe1()
641 np->speed = 100; in sundance_probe1()
642 np->mii_if.full_duplex = 1; in sundance_probe1()
643 } else if (strcmp (media[card_idx], "100mbps_hd") == 0 || in sundance_probe1()
645 np->speed = 100; in sundance_probe1()
646 np->mii_if.full_duplex = 0; in sundance_probe1()
649 np->speed = 10; in sundance_probe1()
650 np->mii_if.full_duplex = 1; in sundance_probe1()
653 np->speed = 10; in sundance_probe1()
654 np->mii_if.full_duplex = 0; in sundance_probe1()
656 np->an_enable = 1; in sundance_probe1()
660 np->flowctrl = 1; in sundance_probe1()
665 /* Default 100Mbps Full */ in sundance_probe1()
666 if (np->an_enable) { in sundance_probe1()
667 np->speed = 100; in sundance_probe1()
668 np->mii_if.full_duplex = 1; in sundance_probe1()
669 np->an_enable = 0; in sundance_probe1()
673 mdio_write (dev, np->phys[0], MII_BMCR, BMCR_RESET); in sundance_probe1()
676 if (np->flowctrl) in sundance_probe1()
677 mdio_write (dev, np->phys[0], MII_ADVERTISE, np->mii_if.advertising | 0x0400); in sundance_probe1()
678 mdio_write (dev, np->phys[0], MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART); in sundance_probe1()
680 if (!np->an_enable) { in sundance_probe1()
682 mii_ctl |= (np->speed == 100) ? BMCR_SPEED100 : 0; in sundance_probe1()
683 mii_ctl |= (np->mii_if.full_duplex) ? BMCR_FULLDPLX : 0; in sundance_probe1()
684 mdio_write (dev, np->phys[0], MII_BMCR, mii_ctl); in sundance_probe1()
686 np->speed, np->mii_if.full_duplex ? "Full" : "Half"); in sundance_probe1()
704 dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, in sundance_probe1()
705 np->rx_ring, np->rx_ring_dma); in sundance_probe1()
707 dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, in sundance_probe1()
708 np->tx_ring, np->tx_ring_dma); in sundance_probe1()
715 return -ENODEV; in sundance_probe1()
721 return -EBUSY; in change_mtu()
722 dev->mtu = new_mtu; in change_mtu()
737 } while (--boguscnt > 0); in eeprom_read()
742 Read and write the MII registers using software-generated serial
747 met by back-to-back 33Mhz PCI cycles. */
764 while (--bits >= 0) { in mdio_sync()
775 void __iomem *mdio_addr = np->base + MIICtrl; in mdio_read()
779 if (np->mii_preamble_required) in mdio_read()
783 for (i = 15; i >= 0; i--) { in mdio_read()
791 /* Read the two transition, 16 data, and wire-idle bits. */ in mdio_read()
792 for (i = 19; i > 0; i--) { in mdio_read()
805 void __iomem *mdio_addr = np->base + MIICtrl; in mdio_write()
809 if (np->mii_preamble_required) in mdio_write()
813 for (i = 31; i >= 0; i--) { in mdio_write()
822 for (i = 2; i > 0; i--) { in mdio_write()
837 phy_id = np->phys[0]; in mdio_wait_link()
844 } while (--wait > 0); in mdio_wait_link()
845 return -1; in mdio_wait_link()
851 void __iomem *ioaddr = np->base; in netdev_open()
852 const int irq = np->pci_dev->irq; in netdev_open()
858 i = request_irq(irq, intr_handler, IRQF_SHARED, dev->name, dev); in netdev_open()
863 printk(KERN_DEBUG "%s: netdev_open() irq %d\n", dev->name, irq); in netdev_open()
867 iowrite32(np->rx_ring_dma, ioaddr + RxListPtr); in netdev_open()
873 iowrite16(dev->mtu + 18, ioaddr + MaxFrameSize); in netdev_open()
875 iowrite16(dev->mtu + 14, ioaddr + MaxFrameSize); in netdev_open()
877 if (dev->mtu > 2047) in netdev_open()
882 if (dev->if_port == 0) in netdev_open()
883 dev->if_port = np->default_port; in netdev_open()
885 spin_lock_init(&np->mcastlock); in netdev_open()
891 iowrite8(100, ioaddr + RxDMAPollPeriod); in netdev_open()
893 /* Fix DFE-580TX packet drop issue */ in netdev_open()
894 if (np->pci_dev->revision >= 0x14) in netdev_open()
898 spin_lock_irqsave(&np->lock, flags); in netdev_open()
900 spin_unlock_irqrestore(&np->lock, flags); in netdev_open()
906 np->wol_enabled = 0; in netdev_open()
911 dev->name, ioread32(ioaddr + RxStatus), ioread8(ioaddr + TxStatus), in netdev_open()
916 timer_setup(&np->timer, netdev_timer, 0); in netdev_open()
917 np->timer.expires = jiffies + 3*HZ; in netdev_open()
918 add_timer(&np->timer); in netdev_open()
929 void __iomem *ioaddr = np->base; in check_duplex()
930 int mii_lpa = mdio_read(dev, np->phys[0], MII_LPA); in check_duplex()
931 int negotiated = mii_lpa & np->mii_if.advertising; in check_duplex()
935 if (!np->an_enable || mii_lpa == 0xffff) { in check_duplex()
936 if (np->mii_if.full_duplex) in check_duplex()
944 if (np->mii_if.full_duplex != duplex) { in check_duplex()
945 np->mii_if.full_duplex = duplex; in check_duplex()
947 printk(KERN_INFO "%s: Setting %s-duplex based on MII #%d " in check_duplex()
948 "negotiated capability %4.4x.\n", dev->name, in check_duplex()
949 duplex ? "full" : "half", np->phys[0], negotiated); in check_duplex()
957 struct net_device *dev = np->mii_if.dev; in netdev_timer()
958 void __iomem *ioaddr = np->base; in netdev_timer()
964 dev->name, ioread16(ioaddr + IntrEnable), in netdev_timer()
968 np->timer.expires = jiffies + next_tick; in netdev_timer()
969 add_timer(&np->timer); in netdev_timer()
975 void __iomem *ioaddr = np->base; in tx_timeout()
979 tasklet_disable(&np->tx_tasklet); in tx_timeout()
983 " resetting...\n", dev->name, ioread8(ioaddr + TxStatus), in tx_timeout()
990 (unsigned long long)(np->tx_ring_dma + i*sizeof(*np->tx_ring)), in tx_timeout()
991 le32_to_cpu(np->tx_ring[i].next_desc), in tx_timeout()
992 le32_to_cpu(np->tx_ring[i].status), in tx_timeout()
993 (le32_to_cpu(np->tx_ring[i].status) >> 2) & 0xff, in tx_timeout()
994 le32_to_cpu(np->tx_ring[i].frag[0].addr), in tx_timeout()
995 le32_to_cpu(np->tx_ring[i].frag[0].length)); in tx_timeout()
998 ioread32(np->base + TxListPtr), in tx_timeout()
1001 np->cur_tx, np->cur_tx % TX_RING_SIZE, in tx_timeout()
1002 np->dirty_tx, np->dirty_tx % TX_RING_SIZE); in tx_timeout()
1003 printk(KERN_DEBUG "cur_rx=%d dirty_rx=%d\n", np->cur_rx, np->dirty_rx); in tx_timeout()
1004 printk(KERN_DEBUG "cur_task=%d\n", np->cur_task); in tx_timeout()
1006 spin_lock_irqsave(&np->lock, flag); in tx_timeout()
1010 spin_unlock_irqrestore(&np->lock, flag); in tx_timeout()
1012 dev->if_port = 0; in tx_timeout()
1015 dev->stats.tx_errors++; in tx_timeout()
1016 if (np->cur_tx - np->dirty_tx < TX_QUEUE_LEN - 4) { in tx_timeout()
1020 tasklet_enable(&np->tx_tasklet); in tx_timeout()
1030 np->cur_rx = np->cur_tx = 0; in init_ring()
1031 np->dirty_rx = np->dirty_tx = 0; in init_ring()
1032 np->cur_task = 0; in init_ring()
1034 np->rx_buf_sz = (dev->mtu <= 1520 ? PKT_BUF_SZ : dev->mtu + 16); in init_ring()
1038 np->rx_ring[i].next_desc = cpu_to_le32(np->rx_ring_dma + in init_ring()
1039 ((i+1)%RX_RING_SIZE)*sizeof(*np->rx_ring)); in init_ring()
1040 np->rx_ring[i].status = 0; in init_ring()
1041 np->rx_ring[i].frag[0].length = 0; in init_ring()
1042 np->rx_skbuff[i] = NULL; in init_ring()
1048 netdev_alloc_skb(dev, np->rx_buf_sz + 2); in init_ring()
1049 np->rx_skbuff[i] = skb; in init_ring()
1053 np->rx_ring[i].frag[0].addr = cpu_to_le32( in init_ring()
1054 dma_map_single(&np->pci_dev->dev, skb->data, in init_ring()
1055 np->rx_buf_sz, DMA_FROM_DEVICE)); in init_ring()
1056 if (dma_mapping_error(&np->pci_dev->dev, in init_ring()
1057 np->rx_ring[i].frag[0].addr)) { in init_ring()
1059 np->rx_skbuff[i] = NULL; in init_ring()
1062 np->rx_ring[i].frag[0].length = cpu_to_le32(np->rx_buf_sz | LastFrag); in init_ring()
1064 np->dirty_rx = (unsigned int)(i - RX_RING_SIZE); in init_ring()
1067 np->tx_skbuff[i] = NULL; in init_ring()
1068 np->tx_ring[i].status = 0; in init_ring()
1076 unsigned head = np->cur_task % TX_RING_SIZE; in tx_poll()
1078 &np->tx_ring[(np->cur_tx - 1) % TX_RING_SIZE]; in tx_poll()
1081 for (; np->cur_tx - np->cur_task > 0; np->cur_task++) { in tx_poll()
1082 int entry = np->cur_task % TX_RING_SIZE; in tx_poll()
1083 txdesc = &np->tx_ring[entry]; in tx_poll()
1084 if (np->last_tx) { in tx_poll()
1085 np->last_tx->next_desc = cpu_to_le32(np->tx_ring_dma + in tx_poll()
1088 np->last_tx = txdesc; in tx_poll()
1091 txdesc->status |= cpu_to_le32(DescIntrOnTx); in tx_poll()
1093 if (ioread32 (np->base + TxListPtr) == 0) in tx_poll()
1094 iowrite32 (np->tx_ring_dma + head * sizeof(struct netdev_desc), in tx_poll()
1095 np->base + TxListPtr); in tx_poll()
1106 entry = np->cur_tx % TX_RING_SIZE; in start_tx()
1107 np->tx_skbuff[entry] = skb; in start_tx()
1108 txdesc = &np->tx_ring[entry]; in start_tx()
1110 txdesc->next_desc = 0; in start_tx()
1111 txdesc->status = cpu_to_le32 ((entry << 2) | DisableAlign); in start_tx()
1112 txdesc->frag[0].addr = cpu_to_le32(dma_map_single(&np->pci_dev->dev, in start_tx()
1113 skb->data, skb->len, DMA_TO_DEVICE)); in start_tx()
1114 if (dma_mapping_error(&np->pci_dev->dev, in start_tx()
1115 txdesc->frag[0].addr)) in start_tx()
1117 txdesc->frag[0].length = cpu_to_le32 (skb->len | LastFrag); in start_tx()
1120 np->cur_tx++; in start_tx()
1123 tasklet_schedule(&np->tx_tasklet); in start_tx()
1126 if (np->cur_tx - np->dirty_tx < TX_QUEUE_LEN - 1 && in start_tx()
1135 dev->name, np->cur_tx, entry); in start_tx()
1141 np->tx_skbuff[entry] = NULL; in start_tx()
1142 dev->stats.tx_dropped++; in start_tx()
1151 void __iomem *ioaddr = np->base; in reset_tx()
1161 np->tx_ring[i].next_desc = 0; in reset_tx()
1163 skb = np->tx_skbuff[i]; in reset_tx()
1165 dma_unmap_single(&np->pci_dev->dev, in reset_tx()
1166 le32_to_cpu(np->tx_ring[i].frag[0].addr), in reset_tx()
1167 skb->len, DMA_TO_DEVICE); in reset_tx()
1169 np->tx_skbuff[i] = NULL; in reset_tx()
1170 dev->stats.tx_dropped++; in reset_tx()
1173 np->cur_tx = np->dirty_tx = 0; in reset_tx()
1174 np->cur_task = 0; in reset_tx()
1176 np->last_tx = NULL; in reset_tx()
1189 void __iomem *ioaddr = np->base; in intr_handler()
1203 dev->name, intr_status); in intr_handler()
1213 if (np->budget < 0) in intr_handler()
1214 np->budget = RX_BUDGET; in intr_handler()
1215 tasklet_schedule(&np->rx_tasklet); in intr_handler()
1219 for (tx_cnt=32; tx_status & 0x80; --tx_cnt) { in intr_handler()
1223 dev->name, tx_status); in intr_handler()
1227 dev->name, tx_status); in intr_handler()
1228 dev->stats.tx_errors++; in intr_handler()
1230 dev->stats.tx_fifo_errors++; in intr_handler()
1232 dev->stats.collisions++; in intr_handler()
1234 dev->stats.tx_fifo_errors++; in intr_handler()
1236 dev->stats.tx_window_errors++; in intr_handler()
1240 ** DFE-580TX boards ! phdm@macqel.be. in intr_handler()
1254 } while (--i); in intr_handler()
1269 if (np->pci_dev->revision >= 0x14) { in intr_handler()
1270 spin_lock(&np->lock); in intr_handler()
1271 for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) { in intr_handler()
1272 int entry = np->dirty_tx % TX_RING_SIZE; in intr_handler()
1276 np->tx_ring[entry].status) >> 2) & 0xff; in intr_handler()
1278 !(le32_to_cpu(np->tx_ring[entry].status) in intr_handler()
1284 skb = np->tx_skbuff[entry]; in intr_handler()
1286 dma_unmap_single(&np->pci_dev->dev, in intr_handler()
1287 le32_to_cpu(np->tx_ring[entry].frag[0].addr), in intr_handler()
1288 skb->len, DMA_TO_DEVICE); in intr_handler()
1289 dev_kfree_skb_irq (np->tx_skbuff[entry]); in intr_handler()
1290 np->tx_skbuff[entry] = NULL; in intr_handler()
1291 np->tx_ring[entry].frag[0].addr = 0; in intr_handler()
1292 np->tx_ring[entry].frag[0].length = 0; in intr_handler()
1294 spin_unlock(&np->lock); in intr_handler()
1296 spin_lock(&np->lock); in intr_handler()
1297 for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) { in intr_handler()
1298 int entry = np->dirty_tx % TX_RING_SIZE; in intr_handler()
1300 if (!(le32_to_cpu(np->tx_ring[entry].status) in intr_handler()
1303 skb = np->tx_skbuff[entry]; in intr_handler()
1305 dma_unmap_single(&np->pci_dev->dev, in intr_handler()
1306 le32_to_cpu(np->tx_ring[entry].frag[0].addr), in intr_handler()
1307 skb->len, DMA_TO_DEVICE); in intr_handler()
1308 dev_kfree_skb_irq (np->tx_skbuff[entry]); in intr_handler()
1309 np->tx_skbuff[entry] = NULL; in intr_handler()
1310 np->tx_ring[entry].frag[0].addr = 0; in intr_handler()
1311 np->tx_ring[entry].frag[0].length = 0; in intr_handler()
1313 spin_unlock(&np->lock); in intr_handler()
1317 np->cur_tx - np->dirty_tx < TX_QUEUE_LEN - 4) { in intr_handler()
1327 dev->name, ioread16(ioaddr + IntrStatus)); in intr_handler()
1335 int entry = np->cur_rx % RX_RING_SIZE; in rx_poll()
1336 int boguscnt = np->budget; in rx_poll()
1337 void __iomem *ioaddr = np->base; in rx_poll()
1342 struct netdev_desc *desc = &(np->rx_ring[entry]); in rx_poll()
1343 u32 frame_status = le32_to_cpu(desc->status); in rx_poll()
1346 if (--boguscnt < 0) { in rx_poll()
1360 dev->stats.rx_errors++; in rx_poll()
1362 dev->stats.rx_length_errors++; in rx_poll()
1364 dev->stats.rx_fifo_errors++; in rx_poll()
1366 dev->stats.rx_frame_errors++; in rx_poll()
1368 dev->stats.rx_crc_errors++; in rx_poll()
1372 dev->name, frame_status); in rx_poll()
1383 to a minimally-sized skbuff. */ in rx_poll()
1387 dma_sync_single_for_cpu(&np->pci_dev->dev, in rx_poll()
1388 le32_to_cpu(desc->frag[0].addr), in rx_poll()
1389 np->rx_buf_sz, DMA_FROM_DEVICE); in rx_poll()
1390 skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len); in rx_poll()
1391 dma_sync_single_for_device(&np->pci_dev->dev, in rx_poll()
1392 le32_to_cpu(desc->frag[0].addr), in rx_poll()
1393 np->rx_buf_sz, DMA_FROM_DEVICE); in rx_poll()
1396 dma_unmap_single(&np->pci_dev->dev, in rx_poll()
1397 le32_to_cpu(desc->frag[0].addr), in rx_poll()
1398 np->rx_buf_sz, DMA_FROM_DEVICE); in rx_poll()
1399 skb_put(skb = np->rx_skbuff[entry], pkt_len); in rx_poll()
1400 np->rx_skbuff[entry] = NULL; in rx_poll()
1402 skb->protocol = eth_type_trans(skb, dev); in rx_poll()
1403 /* Note: checksum -> skb->ip_summed = CHECKSUM_UNNECESSARY; */ in rx_poll()
1409 np->cur_rx = entry; in rx_poll()
1411 np->budget -= received; in rx_poll()
1416 np->cur_rx = entry; in rx_poll()
1420 np->budget -= received; in rx_poll()
1421 if (np->budget <= 0) in rx_poll()
1422 np->budget = RX_BUDGET; in rx_poll()
1423 tasklet_schedule(&np->rx_tasklet); in rx_poll()
1433 for (;(np->cur_rx - np->dirty_rx + RX_RING_SIZE) % RX_RING_SIZE > 0; in refill_rx()
1434 np->dirty_rx = (np->dirty_rx + 1) % RX_RING_SIZE) { in refill_rx()
1436 entry = np->dirty_rx % RX_RING_SIZE; in refill_rx()
1437 if (np->rx_skbuff[entry] == NULL) { in refill_rx()
1438 skb = netdev_alloc_skb(dev, np->rx_buf_sz + 2); in refill_rx()
1439 np->rx_skbuff[entry] = skb; in refill_rx()
1443 np->rx_ring[entry].frag[0].addr = cpu_to_le32( in refill_rx()
1444 dma_map_single(&np->pci_dev->dev, skb->data, in refill_rx()
1445 np->rx_buf_sz, DMA_FROM_DEVICE)); in refill_rx()
1446 if (dma_mapping_error(&np->pci_dev->dev, in refill_rx()
1447 np->rx_ring[entry].frag[0].addr)) { in refill_rx()
1449 np->rx_skbuff[entry] = NULL; in refill_rx()
1454 np->rx_ring[entry].frag[0].length = in refill_rx()
1455 cpu_to_le32(np->rx_buf_sz | LastFrag); in refill_rx()
1456 np->rx_ring[entry].status = 0; in refill_rx()
1463 void __iomem *ioaddr = np->base; in netdev_error()
1469 printk(KERN_INFO "%s: Link up\n", dev->name); in netdev_error()
1470 if (np->an_enable) { in netdev_error()
1471 mii_advertise = mdio_read(dev, np->phys[0], in netdev_error()
1473 mii_lpa = mdio_read(dev, np->phys[0], MII_LPA); in netdev_error()
1476 dev->name); in netdev_error()
1478 np->speed = 100; in netdev_error()
1479 printk("100Mbps, full duplex\n"); in netdev_error()
1481 np->speed = 100; in netdev_error()
1482 printk("100Mbps, half duplex\n"); in netdev_error()
1484 np->speed = 10; in netdev_error()
1487 np->speed = 10; in netdev_error()
1493 mii_ctl = mdio_read(dev, np->phys[0], MII_BMCR); in netdev_error()
1494 speed = (mii_ctl & BMCR_SPEED100) ? 100 : 10; in netdev_error()
1495 np->speed = speed; in netdev_error()
1497 dev->name, speed); in netdev_error()
1503 if (np->flowctrl && np->mii_if.full_duplex) { in netdev_error()
1511 printk(KERN_INFO "%s: Link down\n", dev->name); in netdev_error()
1520 dev->name, intr_status); in netdev_error()
1528 void __iomem *ioaddr = np->base; in get_stats()
1532 spin_lock_irqsave(&np->statlock, flags); in get_stats()
1534 dev->stats.rx_missed_errors += ioread8(ioaddr + RxMissed); in get_stats()
1535 dev->stats.tx_packets += ioread16(ioaddr + TxFramesOK); in get_stats()
1536 dev->stats.rx_packets += ioread16(ioaddr + RxFramesOK); in get_stats()
1537 dev->stats.tx_carrier_errors += ioread8(ioaddr + StatsCarrierError); in get_stats()
1540 np->xstats.tx_multiple_collisions += mult_coll; in get_stats()
1542 np->xstats.tx_single_collisions += single_coll; in get_stats()
1544 np->xstats.tx_late_collisions += late_coll; in get_stats()
1545 dev->stats.collisions += mult_coll in get_stats()
1549 np->xstats.tx_deferred += ioread8(ioaddr + StatsTxDefer); in get_stats()
1550 np->xstats.tx_deferred_excessive += ioread8(ioaddr + StatsTxXSDefer); in get_stats()
1551 np->xstats.tx_aborted += ioread8(ioaddr + StatsTxAbort); in get_stats()
1552 np->xstats.tx_bcasts += ioread8(ioaddr + StatsBcastTx); in get_stats()
1553 np->xstats.rx_bcasts += ioread8(ioaddr + StatsBcastRx); in get_stats()
1554 np->xstats.tx_mcasts += ioread8(ioaddr + StatsMcastTx); in get_stats()
1555 np->xstats.rx_mcasts += ioread8(ioaddr + StatsMcastRx); in get_stats()
1557 dev->stats.tx_bytes += ioread16(ioaddr + TxOctetsLow); in get_stats()
1558 dev->stats.tx_bytes += ioread16(ioaddr + TxOctetsHigh) << 16; in get_stats()
1559 dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsLow); in get_stats()
1560 dev->stats.rx_bytes += ioread16(ioaddr + RxOctetsHigh) << 16; in get_stats()
1562 spin_unlock_irqrestore(&np->statlock, flags); in get_stats()
1564 return &dev->stats; in get_stats()
1570 void __iomem *ioaddr = np->base; in set_rx_mode()
1575 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ in set_rx_mode()
1579 (dev->flags & IFF_ALLMULTI)) { in set_rx_mode()
1590 crc = ether_crc_le(ETH_ALEN, ha->addr); in set_rx_mode()
1600 if (np->mii_if.full_duplex && np->flowctrl) in set_rx_mode()
1613 addr16 = (dev->dev_addr[0] | (dev->dev_addr[1] << 8)); in __set_mac_addr()
1614 iowrite16(addr16, np->base + StationAddr); in __set_mac_addr()
1615 addr16 = (dev->dev_addr[2] | (dev->dev_addr[3] << 8)); in __set_mac_addr()
1616 iowrite16(addr16, np->base + StationAddr+2); in __set_mac_addr()
1617 addr16 = (dev->dev_addr[4] | (dev->dev_addr[5] << 8)); in __set_mac_addr()
1618 iowrite16(addr16, np->base + StationAddr+4); in __set_mac_addr()
1627 if (!is_valid_ether_addr(addr->sa_data)) in sundance_set_mac_addr()
1628 return -EADDRNOTAVAIL; in sundance_set_mac_addr()
1629 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); in sundance_set_mac_addr()
1653 return -EINVAL; in check_if_running()
1660 strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); in get_drvinfo()
1661 strlcpy(info->version, DRV_VERSION, sizeof(info->version)); in get_drvinfo()
1662 strlcpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); in get_drvinfo()
1669 spin_lock_irq(&np->lock); in get_link_ksettings()
1670 mii_ethtool_get_link_ksettings(&np->mii_if, cmd); in get_link_ksettings()
1671 spin_unlock_irq(&np->lock); in get_link_ksettings()
1680 spin_lock_irq(&np->lock); in set_link_ksettings()
1681 res = mii_ethtool_set_link_ksettings(&np->mii_if, cmd); in set_link_ksettings()
1682 spin_unlock_irq(&np->lock); in set_link_ksettings()
1689 return mii_nway_restart(&np->mii_if); in nway_reset()
1695 return mii_link_ok(&np->mii_if); in get_link()
1701 return np->msg_enable; in get_msglevel()
1707 np->msg_enable = val; in set_msglevel()
1723 return -EOPNOTSUPP; in get_sset_count()
1734 data[i++] = np->xstats.tx_multiple_collisions; in get_ethtool_stats()
1735 data[i++] = np->xstats.tx_single_collisions; in get_ethtool_stats()
1736 data[i++] = np->xstats.tx_late_collisions; in get_ethtool_stats()
1737 data[i++] = np->xstats.tx_deferred; in get_ethtool_stats()
1738 data[i++] = np->xstats.tx_deferred_excessive; in get_ethtool_stats()
1739 data[i++] = np->xstats.tx_aborted; in get_ethtool_stats()
1740 data[i++] = np->xstats.tx_bcasts; in get_ethtool_stats()
1741 data[i++] = np->xstats.rx_bcasts; in get_ethtool_stats()
1742 data[i++] = np->xstats.tx_mcasts; in get_ethtool_stats()
1743 data[i++] = np->xstats.rx_mcasts; in get_ethtool_stats()
1752 void __iomem *ioaddr = np->base; in sundance_get_wol()
1755 wol->wolopts = 0; in sundance_get_wol()
1757 wol->supported = (WAKE_PHY | WAKE_MAGIC); in sundance_get_wol()
1758 if (!np->wol_enabled) in sundance_get_wol()
1763 wol->wolopts |= WAKE_MAGIC; in sundance_get_wol()
1765 wol->wolopts |= WAKE_PHY; in sundance_get_wol()
1772 void __iomem *ioaddr = np->base; in sundance_set_wol()
1775 if (!device_can_wakeup(&np->pci_dev->dev)) in sundance_set_wol()
1776 return -EOPNOTSUPP; in sundance_set_wol()
1778 np->wol_enabled = !!(wol->wolopts); in sundance_set_wol()
1783 if (np->wol_enabled) { in sundance_set_wol()
1784 if (wol->wolopts & WAKE_MAGIC) in sundance_set_wol()
1786 if (wol->wolopts & WAKE_PHY) in sundance_set_wol()
1791 device_set_wakeup_enable(&np->pci_dev->dev, np->wol_enabled); in sundance_set_wol()
1822 return -EINVAL; in netdev_ioctl()
1824 spin_lock_irq(&np->lock); in netdev_ioctl()
1825 rc = generic_mii_ioctl(&np->mii_if, if_mii(rq), cmd, NULL); in netdev_ioctl()
1826 spin_unlock_irq(&np->lock); in netdev_ioctl()
1834 void __iomem *ioaddr = np->base; in netdev_close()
1839 tasklet_kill(&np->rx_tasklet); in netdev_close()
1840 tasklet_kill(&np->tx_tasklet); in netdev_close()
1841 np->cur_tx = 0; in netdev_close()
1842 np->dirty_tx = 0; in netdev_close()
1843 np->cur_task = 0; in netdev_close()
1844 np->last_tx = NULL; in netdev_close()
1851 dev->name, ioread8(ioaddr + TxStatus), in netdev_close()
1854 dev->name, np->cur_tx, np->dirty_tx, np->cur_rx, np->dirty_rx); in netdev_close()
1866 for (i = 2000; i > 0; i--) { in netdev_close()
1875 for (i = 2000; i > 0; i--) { in netdev_close()
1884 (int)(np->tx_ring_dma)); in netdev_close()
1887 i, np->tx_ring[i].status, np->tx_ring[i].frag[0].addr, in netdev_close()
1888 np->tx_ring[i].frag[0].length); in netdev_close()
1890 (int)(np->rx_ring_dma)); in netdev_close()
1893 i, np->rx_ring[i].status, np->rx_ring[i].frag[0].addr, in netdev_close()
1894 np->rx_ring[i].frag[0].length); in netdev_close()
1899 free_irq(np->pci_dev->irq, dev); in netdev_close()
1901 del_timer_sync(&np->timer); in netdev_close()
1905 np->rx_ring[i].status = 0; in netdev_close()
1906 skb = np->rx_skbuff[i]; in netdev_close()
1908 dma_unmap_single(&np->pci_dev->dev, in netdev_close()
1909 le32_to_cpu(np->rx_ring[i].frag[0].addr), in netdev_close()
1910 np->rx_buf_sz, DMA_FROM_DEVICE); in netdev_close()
1912 np->rx_skbuff[i] = NULL; in netdev_close()
1914 np->rx_ring[i].frag[0].addr = cpu_to_le32(0xBADF00D0); /* poison */ in netdev_close()
1917 np->tx_ring[i].next_desc = 0; in netdev_close()
1918 skb = np->tx_skbuff[i]; in netdev_close()
1920 dma_unmap_single(&np->pci_dev->dev, in netdev_close()
1921 le32_to_cpu(np->tx_ring[i].frag[0].addr), in netdev_close()
1922 skb->len, DMA_TO_DEVICE); in netdev_close()
1924 np->tx_skbuff[i] = NULL; in netdev_close()
1938 dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, in sundance_remove1()
1939 np->rx_ring, np->rx_ring_dma); in sundance_remove1()
1940 dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, in sundance_remove1()
1941 np->tx_ring, np->tx_ring_dma); in sundance_remove1()
1942 pci_iounmap(pdev, np->base); in sundance_remove1()
1954 void __iomem *ioaddr = np->base; in sundance_suspend()
1963 if (np->wol_enabled) { in sundance_suspend()
1968 np->wol_enabled); in sundance_suspend()
1989 dev->name); in sundance_resume()