Lines Matching +full:pme +full:- +full:active +full:- +full:high
3 Written/copyright 1999-2001 by Donald Becker.
23 [link no longer provides useful info -jgarzik]
62 /* Updated to recommendations in pci-skeleton v2.03. */
64 /* The user-configurable values.
72 static int debug = -1;
76 /* Maximum number of multicast addresses to filter (vs. rx-all-multicast).
80 /* Set the copy breakpoint for the copy-only-tiny-frames scheme.
101 There are no ill effects from too-large receive rings. */
121 * The nic writes 32-bit values, even if the upper bytes of
122 * a 32-bit value are beyond the end of the buffer.
149 "DP8381x copy breakpoint for copy-only-tiny-frames");
152 "DP8381x: Bits 0-3: media type, bit 17: full duplex");
163 II. Board-specific settings
166 It honors the EEPROM-set values.
172 This driver uses two statically allocated fixed-size descriptor lists
180 This driver uses a zero-copy receive and transmit scheme.
182 open() time and passes the skb->data field to the chip as receive data
189 The RX_COPYBREAK value is chosen to trade-off the memory wasted by
190 using a full-sized skbuff for small frames vs. the copying costs of larger
201 skbuff at an offset of "+2", 16-byte aligning the IP header.
205 Most operations are synchronized on the np->lock irq spinlock, except the
232 MII_FX_SEL = 0x0001, /* 100BASE-FX (fiber) */
258 Unlike software-only systems, device drivers interact with complex hardware.
385 * MIB Service, Phy Interrupt, High Bits,
413 * - 256 byte DMA burst length
414 * - fill threshold 512 bytes (i.e. restart DMA when 512 bytes are free)
415 * - 64 bytes initial drain threshold (i.e. begin actual transmission
417 * - on tx underruns, increase drain threshold by 64.
418 * - at most use a drain threshold of 1472 bytes: The sum of the fill
511 /* Note that using only 32 bit fields simplifies conversion to big-endian
543 /* The addresses of receive-in-place skbuffs */
546 /* address of a sent-in-place packet/buffer, for later free() */
569 /* external phy that is used: only valid if dev->if_port != PORT_TP */
662 device_create_file(&_dev->dev, &dev_attr_##_name)
664 device_remove_file(&_dev->dev, &dev_attr_##_name)
674 return sprintf(buf, "%s\n", np->dspcfg_workaround ? "on" : "off"); in natsemi_show_dspcfg_workaround()
686 if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1)) in natsemi_set_dspcfg_workaround()
688 else if (!strncmp("off", buf, count - 1) || in natsemi_set_dspcfg_workaround()
689 !strncmp("0", buf, count - 1)) in natsemi_set_dspcfg_workaround()
694 spin_lock_irqsave(&np->lock, flags); in natsemi_set_dspcfg_workaround()
696 np->dspcfg_workaround = new_setting; in natsemi_set_dspcfg_workaround()
698 spin_unlock_irqrestore(&np->lock, flags); in natsemi_set_dspcfg_workaround()
707 return np->ioaddr; in ns_ioaddr()
732 * - the address on the external phy that is used for transmission. in move_int_phy()
733 * - the address that we want to access. User space can access phys in move_int_phy()
739 target--; in move_int_phy()
740 if (target == np->phy_addr_external) in move_int_phy()
741 target--; in move_int_phy()
752 if (np->ignore_phy) in natsemi_init_media()
759 np->speed = (tmp & BMCR_SPEED100)? SPEED_100 : SPEED_10; in natsemi_init_media()
760 np->duplex = (tmp & BMCR_FULLDPLX)? DUPLEX_FULL : DUPLEX_HALF; in natsemi_init_media()
761 np->autoneg = (tmp & BMCR_ANENABLE)? AUTONEG_ENABLE: AUTONEG_DISABLE; in natsemi_init_media()
762 np->advertising= mdio_read(dev, MII_ADVERTISE); in natsemi_init_media()
764 if ((np->advertising & ADVERTISE_ALL) != ADVERTISE_ALL && in natsemi_init_media()
768 pci_name(np->pci_dev), in natsemi_init_media()
771 (np->advertising & in natsemi_init_media()
774 (np->advertising & in natsemi_init_media()
781 pci_name(np->pci_dev), mdio_read(dev, MII_BMSR), in natsemi_init_media()
782 np->advertising); in natsemi_init_media()
806 int i, option, irq, chip_idx = ent->driver_data; in natsemi_probe1()
807 static int find_cnt = -1; in natsemi_probe1()
826 /* natsemi has a non-standard PM control register in natsemi_probe1()
832 /* D0 state, disable PME assertion */ in natsemi_probe1()
840 irq = pdev->irq; in natsemi_probe1()
846 return -ENOMEM; in natsemi_probe1()
847 SET_NETDEV_DEV(dev, &pdev->dev); in natsemi_probe1()
855 i = -ENOMEM; in natsemi_probe1()
870 np->ioaddr = ioaddr; in natsemi_probe1()
872 netif_napi_add(dev, &np->napi, natsemi_poll); in natsemi_probe1()
873 np->dev = dev; in natsemi_probe1()
875 np->pci_dev = pdev; in natsemi_probe1()
877 np->iosize = iosize; in natsemi_probe1()
878 spin_lock_init(&np->lock); in natsemi_probe1()
879 np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG; in natsemi_probe1()
880 np->hands_off = 0; in natsemi_probe1()
881 np->intr_status = 0; in natsemi_probe1()
882 np->eeprom_size = natsemi_pci_info[chip_idx].eeprom_size; in natsemi_probe1()
884 np->ignore_phy = 1; in natsemi_probe1()
886 np->ignore_phy = 0; in natsemi_probe1()
887 np->dspcfg_workaround = dspcfg_workaround; in natsemi_probe1()
890 * - If configured to ignore the PHY set up for external. in natsemi_probe1()
891 * - If the nic was configured to use an external phy and if find_mii in natsemi_probe1()
893 * - Otherwise: internal port. in natsemi_probe1()
898 if (np->ignore_phy || readl(ioaddr + ChipConfig) & CfgExtPhy) in natsemi_probe1()
899 dev->if_port = PORT_MII; in natsemi_probe1()
901 dev->if_port = PORT_TP; in natsemi_probe1()
906 if (dev->if_port != PORT_TP) { in natsemi_probe1()
907 np->phy_addr_external = find_mii(dev); in natsemi_probe1()
910 if (!np->ignore_phy && np->phy_addr_external == PHY_ADDR_NONE) { in natsemi_probe1()
911 dev->if_port = PORT_TP; in natsemi_probe1()
912 np->phy_addr_external = PHY_ADDR_INTERNAL; in natsemi_probe1()
915 np->phy_addr_external = PHY_ADDR_INTERNAL; in natsemi_probe1()
922 np->full_duplex = 1; in natsemi_probe1()
926 pci_name(np->pci_dev), option & 15); in natsemi_probe1()
929 np->full_duplex = 1; in natsemi_probe1()
931 dev->netdev_ops = &natsemi_netdev_ops; in natsemi_probe1()
932 dev->watchdog_timeo = TX_TIMEOUT; in natsemi_probe1()
934 dev->ethtool_ops = ðtool_ops; in natsemi_probe1()
936 /* MTU range: 64 - 2024 */ in natsemi_probe1()
937 dev->min_mtu = ETH_ZLEN + ETH_FCS_LEN; in natsemi_probe1()
938 dev->max_mtu = NATSEMI_RX_LIMIT - NATSEMI_HEADERS; in natsemi_probe1()
941 dev->mtu = mtu; in natsemi_probe1()
946 np->srr = readl(ioaddr + SiliconRev); in natsemi_probe1()
949 pci_name(np->pci_dev), np->srr); in natsemi_probe1()
961 dev->name, natsemi_pci_info[chip_idx].name, in natsemi_probe1()
962 (unsigned long long)iostart, pci_name(np->pci_dev), in natsemi_probe1()
963 dev->dev_addr, irq); in natsemi_probe1()
964 if (dev->if_port == PORT_TP) in natsemi_probe1()
966 else if (np->ignore_phy) in natsemi_probe1()
969 printk(", port MII, phy ad %d.\n", np->phy_addr_external); in natsemi_probe1()
990 a delay. Note that pre-2.0.34 kernels had a cache-alignment bug that
998 /* The EEPROM commands include the alway-set leading bit. */
1013 for (i = 10; i >= 0; i--) { in eeprom_read()
1065 for (i = (1 << (len-1)); i; i >>= 1) in mii_send_bits()
1122 * - an internal transceiver in mdio_read()
1123 * - an external mii bus in mdio_read()
1125 if (dev->if_port == PORT_TP) in mdio_read()
1128 return miiport_read(dev, np->phy_addr_external, reg); in mdio_read()
1137 if (dev->if_port == PORT_TP) in mdio_write()
1140 miiport_write(dev, np->phy_addr_external, reg, data); in mdio_write()
1153 if (np->autoneg == AUTONEG_ENABLE) { in init_phy_fixup()
1156 np->advertising != mdio_read(dev, MII_ADVERTISE)) in init_phy_fixup()
1160 mdio_write(dev, MII_ADVERTISE, np->advertising); in init_phy_fixup()
1165 if (np->speed == SPEED_100) in init_phy_fixup()
1167 if (np->duplex == DUPLEX_FULL) in init_phy_fixup()
1182 np->mii = (mdio_read(dev, MII_PHYSID1) << 16) in init_phy_fixup()
1186 switch (np->mii) { in init_phy_fixup()
1191 if (dev->if_port == PORT_FIBRE) in init_phy_fixup()
1221 np->dspcfg = (np->srr <= SRR_DP83815_C)? in init_phy_fixup()
1223 writew(np->dspcfg, ioaddr + DSPCFG); in init_phy_fixup()
1232 if (np->dspcfg == dspcfg) in init_phy_fixup()
1240 dev->name, i*10); in init_phy_fixup()
1244 dev->name, i*10); in init_phy_fixup()
1249 * and Auto-Negotiation Completion are among the affected. in init_phy_fixup()
1268 dev->name); in switch_port_external()
1283 move_int_phy(dev, np->phy_addr_external); in switch_port_external()
1303 dev->name); in switch_port_internal()
1325 dev->name, i*10); in switch_port_internal()
1335 * - Do not scan while the internal phy is enabled. The internal phy will
1338 * - The internal phy must be moved around, an external phy could
1362 np->mii = (mdio_read(dev, MII_PHYSID1) << 16) in find_mii()
1366 pci_name(np->pci_dev), np->mii, i); in find_mii()
1399 * on a normal power-up (see the spec EEPROM map). This assumes in natsemi_reset()
1429 dev->name, i*5); in natsemi_reset()
1432 dev->name, i*5); in natsemi_reset()
1438 if (dev->if_port == PORT_TP) in natsemi_reset()
1467 np->intr_status &= ~RxResetDone; in reset_rx()
1472 np->intr_status |= readl(ioaddr + IntrStatus); in reset_rx()
1473 if (np->intr_status & RxResetDone) in reset_rx()
1479 dev->name, i*15); in reset_rx()
1482 dev->name, i*15); in reset_rx()
1500 pci_name(np->pci_dev), i*50); in natsemi_reload_eeprom()
1503 pci_name(np->pci_dev), i*50); in natsemi_reload_eeprom()
1521 dev->name, i*5); in natsemi_stop_rxtx()
1524 dev->name, i*5); in natsemi_stop_rxtx()
1532 const int irq = np->pci_dev->irq; in netdev_open()
1538 i = request_irq(irq, intr_handler, IRQF_SHARED, dev->name, dev); in netdev_open()
1543 dev->name, irq); in netdev_open()
1549 napi_enable(&np->napi); in netdev_open()
1552 spin_lock_irq(&np->lock); in netdev_open()
1554 /* now set the MAC address according to dev->dev_addr */ in netdev_open()
1556 u16 mac = (dev->dev_addr[2*i+1]<<8) + dev->dev_addr[2*i]; in netdev_open()
1561 writel(np->cur_rx_mode, ioaddr + RxFilterAddr); in netdev_open()
1562 spin_unlock_irq(&np->lock); in netdev_open()
1568 dev->name, (int)readl(ioaddr + ChipCmd)); in netdev_open()
1571 timer_setup(&np->timer, netdev_timer, 0); in netdev_open()
1572 np->timer.expires = round_jiffies(jiffies + NATSEMI_TIMER_FREQ); in netdev_open()
1573 add_timer(&np->timer); in netdev_open()
1583 if (dev->if_port != PORT_TP) in do_cable_magic()
1586 if (np->srr >= SRR_DP83816_A5) in do_cable_magic()
1611 /* the bug has been triggered - fix the coefficient */ in do_cable_magic()
1615 np->dspcfg = data | DSPCFG_LOCK; in do_cable_magic()
1616 writew(np->dspcfg, ioaddr + DSPCFG); in do_cable_magic()
1628 if (dev->if_port != PORT_TP) in undo_cable_magic()
1631 if (np->srr >= SRR_DP83816_A5) in undo_cable_magic()
1637 np->dspcfg = data & ~DSPCFG_LOCK; in undo_cable_magic()
1638 writew(np->dspcfg, ioaddr + DSPCFG); in undo_cable_magic()
1646 int duplex = np->duplex; in check_link()
1650 if (np->ignore_phy) in check_link()
1664 dev->name); in check_link()
1672 printk(KERN_NOTICE "%s: link up.\n", dev->name); in check_link()
1677 duplex = np->full_duplex; in check_link()
1681 np->advertising & mdio_read(dev, MII_LPA)); in check_link()
1690 if (duplex ^ !!(np->rx_config & RxAcceptTx)) { in check_link()
1693 "%s: Setting %s-duplex based on negotiated " in check_link()
1694 "link capability.\n", dev->name, in check_link()
1697 np->rx_config |= RxAcceptTx; in check_link()
1698 np->tx_config |= TxCarrierIgn | TxHeartIgn; in check_link()
1700 np->rx_config &= ~RxAcceptTx; in check_link()
1701 np->tx_config &= ~(TxCarrierIgn | TxHeartIgn); in check_link()
1703 writel(np->tx_config, ioaddr + TxConfig); in check_link()
1704 writel(np->rx_config, ioaddr + RxConfig); in check_link()
1718 writel(np->ring_dma, ioaddr + RxRingPtr); in init_registers()
1719 writel(np->ring_dma + RX_RING_SIZE * sizeof(struct netdev_desc), in init_registers()
1724 * Configure for standard, in-spec Ethernet. in init_registers()
1725 * Start with half-duplex. check_link will update in init_registers()
1736 np->tx_config = TxAutoPad | TxCollRetry | TxMxdma_256 | in init_registers()
1738 writel(np->tx_config, ioaddr + TxConfig); in init_registers()
1743 np->rx_config = RxMxdma_256 | RX_DRTH_VAL; in init_registers()
1745 if (np->rx_buf_sz > NATSEMI_LONGPKT) in init_registers()
1746 np->rx_config |= RxAcceptLong; in init_registers()
1748 writel(np->rx_config, ioaddr + RxConfig); in init_registers()
1750 /* Disable PME: in init_registers()
1751 * The PME bit is initialized from the EEPROM contents. in init_registers()
1752 * PCI cards probably have PME disabled, but motherboard in init_registers()
1753 * implementations may have PME set to enable WakeOnLan. in init_registers()
1754 * With PME set the chip will scan incoming packets but in init_registers()
1756 np->SavedClkRun = readl(ioaddr + ClkRun); in init_registers()
1757 writel(np->SavedClkRun & ~PMEEnable, ioaddr + ClkRun); in init_registers()
1758 if (np->SavedClkRun & PMEStatus && netif_msg_wol(np)) { in init_registers()
1759 printk(KERN_NOTICE "%s: Wake-up event %#08x\n", in init_registers()
1760 dev->name, readl(ioaddr + WOLCmd)); in init_registers()
1790 struct net_device *dev = np->dev; in netdev_timer()
1793 const int irq = np->pci_dev->irq; in netdev_timer()
1800 dev->name); in netdev_timer()
1803 if (dev->if_port == PORT_TP) { in netdev_timer()
1806 spin_lock_irq(&np->lock); in netdev_timer()
1807 /* check for a nasty random phy-reset - use dspcfg as a flag */ in netdev_timer()
1811 if (np->dspcfg_workaround && dspcfg != np->dspcfg) { in netdev_timer()
1813 spin_unlock_irq(&np->lock); in netdev_timer()
1816 "re-initializing\n", dev->name); in netdev_timer()
1818 spin_lock_irq(&np->lock); in netdev_timer()
1823 spin_unlock_irq(&np->lock); in netdev_timer()
1828 spin_unlock_irq(&np->lock); in netdev_timer()
1833 spin_unlock_irq(&np->lock); in netdev_timer()
1836 spin_lock_irq(&np->lock); in netdev_timer()
1838 spin_unlock_irq(&np->lock); in netdev_timer()
1840 if (np->oom) { in netdev_timer()
1842 np->oom = 0; in netdev_timer()
1845 if (!np->oom) { in netdev_timer()
1853 mod_timer(&np->timer, round_jiffies(jiffies + next_tick)); in netdev_timer()
1855 mod_timer(&np->timer, jiffies + next_tick); in netdev_timer()
1864 printk(KERN_DEBUG " Tx ring at %p:\n", np->tx_ring); in dump_ring()
1867 i, np->tx_ring[i].next_desc, in dump_ring()
1868 np->tx_ring[i].cmd_status, in dump_ring()
1869 np->tx_ring[i].addr); in dump_ring()
1871 printk(KERN_DEBUG " Rx ring %p:\n", np->rx_ring); in dump_ring()
1874 i, np->rx_ring[i].next_desc, in dump_ring()
1875 np->rx_ring[i].cmd_status, in dump_ring()
1876 np->rx_ring[i].addr); in dump_ring()
1885 const int irq = np->pci_dev->irq; in ns_tx_timeout()
1888 spin_lock_irq(&np->lock); in ns_tx_timeout()
1889 if (!np->hands_off) { in ns_tx_timeout()
1894 dev->name, readl(ioaddr + IntrStatus)); in ns_tx_timeout()
1903 dev->name); in ns_tx_timeout()
1905 spin_unlock_irq(&np->lock); in ns_tx_timeout()
1909 dev->stats.tx_errors++; in ns_tx_timeout()
1916 np->rx_ring = dma_alloc_coherent(&np->pci_dev->dev, in alloc_ring()
1918 &np->ring_dma, GFP_KERNEL); in alloc_ring()
1919 if (!np->rx_ring) in alloc_ring()
1920 return -ENOMEM; in alloc_ring()
1921 np->tx_ring = &np->rx_ring[RX_RING_SIZE]; in alloc_ring()
1930 for (; np->cur_rx - np->dirty_rx > 0; np->dirty_rx++) { in refill_rx()
1932 int entry = np->dirty_rx % RX_RING_SIZE; in refill_rx()
1933 if (np->rx_skbuff[entry] == NULL) { in refill_rx()
1934 unsigned int buflen = np->rx_buf_sz+NATSEMI_PADDING; in refill_rx()
1936 np->rx_skbuff[entry] = skb; in refill_rx()
1939 np->rx_dma[entry] = dma_map_single(&np->pci_dev->dev, in refill_rx()
1940 skb->data, buflen, in refill_rx()
1942 if (dma_mapping_error(&np->pci_dev->dev, np->rx_dma[entry])) { in refill_rx()
1944 np->rx_skbuff[entry] = NULL; in refill_rx()
1947 np->rx_ring[entry].addr = cpu_to_le32(np->rx_dma[entry]); in refill_rx()
1949 np->rx_ring[entry].cmd_status = cpu_to_le32(np->rx_buf_sz); in refill_rx()
1951 if (np->cur_rx - np->dirty_rx == RX_RING_SIZE) { in refill_rx()
1953 printk(KERN_WARNING "%s: going OOM.\n", dev->name); in refill_rx()
1954 np->oom = 1; in refill_rx()
1961 if (dev->mtu <= ETH_DATA_LEN) in set_bufsize()
1962 np->rx_buf_sz = ETH_DATA_LEN + NATSEMI_HEADERS; in set_bufsize()
1964 np->rx_buf_sz = dev->mtu + NATSEMI_HEADERS; in set_bufsize()
1974 np->dirty_tx = np->cur_tx = 0; in init_ring()
1976 np->tx_skbuff[i] = NULL; in init_ring()
1977 np->tx_ring[i].next_desc = cpu_to_le32(np->ring_dma in init_ring()
1980 np->tx_ring[i].cmd_status = 0; in init_ring()
1984 np->dirty_rx = 0; in init_ring()
1985 np->cur_rx = RX_RING_SIZE; in init_ring()
1986 np->oom = 0; in init_ring()
1989 np->rx_head_desc = &np->rx_ring[0]; in init_ring()
1991 /* Please be careful before changing this loop - at least gcc-2.95.1 in init_ring()
1996 np->rx_ring[i].next_desc = cpu_to_le32(np->ring_dma in init_ring()
1999 np->rx_ring[i].cmd_status = cpu_to_le32(DescOwn); in init_ring()
2000 np->rx_skbuff[i] = NULL; in init_ring()
2012 if (np->tx_skbuff[i]) { in drain_tx()
2013 dma_unmap_single(&np->pci_dev->dev, np->tx_dma[i], in drain_tx()
2014 np->tx_skbuff[i]->len, DMA_TO_DEVICE); in drain_tx()
2015 dev_kfree_skb(np->tx_skbuff[i]); in drain_tx()
2016 dev->stats.tx_dropped++; in drain_tx()
2018 np->tx_skbuff[i] = NULL; in drain_tx()
2025 unsigned int buflen = np->rx_buf_sz; in drain_rx()
2030 np->rx_ring[i].cmd_status = 0; in drain_rx()
2031 np->rx_ring[i].addr = cpu_to_le32(0xBADF00D0); /* An invalid address. */ in drain_rx()
2032 if (np->rx_skbuff[i]) { in drain_rx()
2033 dma_unmap_single(&np->pci_dev->dev, np->rx_dma[i], in drain_rx()
2036 dev_kfree_skb(np->rx_skbuff[i]); in drain_rx()
2038 np->rx_skbuff[i] = NULL; in drain_rx()
2051 dma_free_coherent(&np->pci_dev->dev, in free_ring()
2053 np->rx_ring, np->ring_dma); in free_ring()
2062 np->dirty_rx = 0; in reinit_rx()
2063 np->cur_rx = RX_RING_SIZE; in reinit_rx()
2064 np->rx_head_desc = &np->rx_ring[0]; in reinit_rx()
2067 np->rx_ring[i].cmd_status = cpu_to_le32(DescOwn); in reinit_rx()
2079 np->dirty_tx = np->cur_tx = 0; in reinit_ring()
2081 np->tx_ring[i].cmd_status = 0; in reinit_ring()
2097 entry = np->cur_tx % TX_RING_SIZE; in start_tx()
2099 np->tx_skbuff[entry] = skb; in start_tx()
2100 np->tx_dma[entry] = dma_map_single(&np->pci_dev->dev, skb->data, in start_tx()
2101 skb->len, DMA_TO_DEVICE); in start_tx()
2102 if (dma_mapping_error(&np->pci_dev->dev, np->tx_dma[entry])) { in start_tx()
2103 np->tx_skbuff[entry] = NULL; in start_tx()
2105 dev->stats.tx_dropped++; in start_tx()
2109 np->tx_ring[entry].addr = cpu_to_le32(np->tx_dma[entry]); in start_tx()
2111 spin_lock_irqsave(&np->lock, flags); in start_tx()
2113 if (!np->hands_off) { in start_tx()
2114 np->tx_ring[entry].cmd_status = cpu_to_le32(DescOwn | skb->len); in start_tx()
2115 /* StrongARM: Explicitly cache flush np->tx_ring and in start_tx()
2116 * skb->data,skb->len. */ in start_tx()
2118 np->cur_tx++; in start_tx()
2119 if (np->cur_tx - np->dirty_tx >= TX_QUEUE_LEN - 1) { in start_tx()
2121 if (np->cur_tx - np->dirty_tx >= TX_QUEUE_LEN - 1) in start_tx()
2124 /* Wake the potentially-idle transmit channel. */ in start_tx()
2128 dev->stats.tx_dropped++; in start_tx()
2130 spin_unlock_irqrestore(&np->lock, flags); in start_tx()
2134 dev->name, np->cur_tx, entry); in start_tx()
2143 for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) { in netdev_tx_done()
2144 int entry = np->dirty_tx % TX_RING_SIZE; in netdev_tx_done()
2145 if (np->tx_ring[entry].cmd_status & cpu_to_le32(DescOwn)) in netdev_tx_done()
2150 dev->name, np->dirty_tx, in netdev_tx_done()
2151 le32_to_cpu(np->tx_ring[entry].cmd_status)); in netdev_tx_done()
2152 if (np->tx_ring[entry].cmd_status & cpu_to_le32(DescPktOK)) { in netdev_tx_done()
2153 dev->stats.tx_packets++; in netdev_tx_done()
2154 dev->stats.tx_bytes += np->tx_skbuff[entry]->len; in netdev_tx_done()
2157 le32_to_cpu(np->tx_ring[entry].cmd_status); in netdev_tx_done()
2159 dev->stats.tx_aborted_errors++; in netdev_tx_done()
2161 dev->stats.tx_fifo_errors++; in netdev_tx_done()
2163 dev->stats.tx_carrier_errors++; in netdev_tx_done()
2165 dev->stats.tx_window_errors++; in netdev_tx_done()
2166 dev->stats.tx_errors++; in netdev_tx_done()
2168 dma_unmap_single(&np->pci_dev->dev, np->tx_dma[entry], in netdev_tx_done()
2169 np->tx_skbuff[entry]->len, DMA_TO_DEVICE); in netdev_tx_done()
2171 dev_consume_skb_irq(np->tx_skbuff[entry]); in netdev_tx_done()
2172 np->tx_skbuff[entry] = NULL; in netdev_tx_done()
2175 np->cur_tx - np->dirty_tx < TX_QUEUE_LEN - 4) { in netdev_tx_done()
2192 if (np->hands_off || !readl(ioaddr + IntrEnable)) in intr_handler()
2195 np->intr_status = readl(ioaddr + IntrStatus); in intr_handler()
2197 if (!np->intr_status) in intr_handler()
2203 dev->name, np->intr_status, in intr_handler()
2206 prefetch(&np->rx_skbuff[np->cur_rx % RX_RING_SIZE]); in intr_handler()
2208 if (napi_schedule_prep(&np->napi)) { in intr_handler()
2211 __napi_schedule(&np->napi); in intr_handler()
2215 dev->name, np->intr_status, in intr_handler()
2227 struct net_device *dev = np->dev; in natsemi_poll()
2235 dev->name, np->intr_status, in natsemi_poll()
2240 if (np->intr_status & in natsemi_poll()
2246 if (np->intr_status & in natsemi_poll()
2248 spin_lock(&np->lock); in natsemi_poll()
2250 spin_unlock(&np->lock); in natsemi_poll()
2254 if (np->intr_status & IntrAbnormalSummary) in natsemi_poll()
2255 netdev_error(dev, np->intr_status); in natsemi_poll()
2260 np->intr_status = readl(ioaddr + IntrStatus); in natsemi_poll()
2261 } while (np->intr_status); in natsemi_poll()
2267 spin_lock(&np->lock); in natsemi_poll()
2268 if (!np->hands_off) in natsemi_poll()
2270 spin_unlock(&np->lock); in natsemi_poll()
2280 int entry = np->cur_rx % RX_RING_SIZE; in netdev_rx()
2281 int boguscnt = np->dirty_rx + RX_RING_SIZE - np->cur_rx; in netdev_rx()
2282 s32 desc_status = le32_to_cpu(np->rx_head_desc->cmd_status); in netdev_rx()
2283 unsigned int buflen = np->rx_buf_sz; in netdev_rx()
2293 if (--boguscnt < 0) in netdev_rx()
2301 pkt_len = (desc_status & DescSizeMask) - 4; in netdev_rx()
2311 "status %#08x.\n", dev->name, in netdev_rx()
2312 np->cur_rx, desc_status); in netdev_rx()
2313 dev->stats.rx_length_errors++; in netdev_rx()
2318 * AN-1287. */ in netdev_rx()
2320 spin_lock_irqsave(&np->lock, flags); in netdev_rx()
2323 writel(np->ring_dma, ioaddr + RxRingPtr); in netdev_rx()
2325 spin_unlock_irqrestore(&np->lock, flags); in netdev_rx()
2333 dev->stats.rx_errors++; in netdev_rx()
2335 dev->stats.rx_over_errors++; in netdev_rx()
2337 dev->stats.rx_length_errors++; in netdev_rx()
2339 dev->stats.rx_frame_errors++; in netdev_rx()
2341 dev->stats.rx_crc_errors++; in netdev_rx()
2343 } else if (pkt_len > np->rx_buf_sz) { in netdev_rx()
2352 * without copying to a minimally-sized skbuff. */ in netdev_rx()
2357 dma_sync_single_for_cpu(&np->pci_dev->dev, in netdev_rx()
2358 np->rx_dma[entry], in netdev_rx()
2362 np->rx_skbuff[entry]->data, pkt_len); in netdev_rx()
2364 dma_sync_single_for_device(&np->pci_dev->dev, in netdev_rx()
2365 np->rx_dma[entry], in netdev_rx()
2369 dma_unmap_single(&np->pci_dev->dev, in netdev_rx()
2370 np->rx_dma[entry], in netdev_rx()
2373 skb_put(skb = np->rx_skbuff[entry], pkt_len); in netdev_rx()
2374 np->rx_skbuff[entry] = NULL; in netdev_rx()
2376 skb->protocol = eth_type_trans(skb, dev); in netdev_rx()
2378 dev->stats.rx_packets++; in netdev_rx()
2379 dev->stats.rx_bytes += pkt_len; in netdev_rx()
2381 entry = (++np->cur_rx) % RX_RING_SIZE; in netdev_rx()
2382 np->rx_head_desc = &np->rx_ring[entry]; in netdev_rx()
2383 desc_status = le32_to_cpu(np->rx_head_desc->cmd_status); in netdev_rx()
2388 if (np->oom) in netdev_rx()
2389 mod_timer(&np->timer, jiffies + 1); in netdev_rx()
2399 spin_lock(&np->lock); in netdev_error()
2406 " %#04x partner %#04x.\n", dev->name, in netdev_error()
2407 np->advertising, lpa); in netdev_error()
2418 if ((np->tx_config & TxDrthMask) < TX_DRTH_VAL_LIMIT) { in netdev_error()
2419 np->tx_config += TX_DRTH_VAL_INC; in netdev_error()
2423 dev->name, np->tx_config); in netdev_error()
2428 dev->name, np->tx_config); in netdev_error()
2430 writel(np->tx_config, ioaddr + TxConfig); in netdev_error()
2434 printk(KERN_NOTICE "%s: Link wake-up event %#08x\n", in netdev_error()
2435 dev->name, wol_status); in netdev_error()
2440 dev->name); in netdev_error()
2442 dev->stats.rx_fifo_errors++; in netdev_error()
2443 dev->stats.rx_errors++; in netdev_error()
2447 printk(KERN_NOTICE "%s: PCI error %#08x\n", dev->name, in netdev_error()
2449 dev->stats.tx_fifo_errors++; in netdev_error()
2450 dev->stats.tx_errors++; in netdev_error()
2451 dev->stats.rx_fifo_errors++; in netdev_error()
2452 dev->stats.rx_errors++; in netdev_error()
2454 spin_unlock(&np->lock); in netdev_error()
2462 dev->stats.rx_crc_errors += readl(ioaddr + RxCRCErrs); in __get_stats()
2463 dev->stats.rx_missed_errors += readl(ioaddr + RxMissed); in __get_stats()
2471 spin_lock_irq(&np->lock); in get_stats()
2472 if (netif_running(dev) && !np->hands_off) in get_stats()
2474 spin_unlock_irq(&np->lock); in get_stats()
2476 return &dev->stats; in get_stats()
2483 const int irq = np->pci_dev->irq; in natsemi_poll_controller()
2499 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ in __set_rx_mode()
2503 (dev->flags & IFF_ALLMULTI)) { in __set_rx_mode()
2512 int b = (ether_crc(ETH_ALEN, ha->addr) >> 23) & 0x1ff; in __set_rx_mode()
2524 np->cur_rx_mode = rx_mode; in __set_rx_mode()
2529 WRITE_ONCE(dev->mtu, new_mtu); in natsemi_change_mtu()
2535 const int irq = np->pci_dev->irq; in natsemi_change_mtu()
2538 spin_lock(&np->lock); in natsemi_change_mtu()
2546 writel(np->ring_dma, ioaddr + RxRingPtr); in natsemi_change_mtu()
2549 spin_unlock(&np->lock); in natsemi_change_mtu()
2558 spin_lock_irq(&np->lock); in set_rx_mode()
2559 if (!np->hands_off) in set_rx_mode()
2561 spin_unlock_irq(&np->lock); in set_rx_mode()
2567 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in get_drvinfo()
2568 strscpy(info->version, DRV_VERSION, sizeof(info->version)); in get_drvinfo()
2569 strscpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); in get_drvinfo()
2580 return np->eeprom_size; in get_eeprom_len()
2587 spin_lock_irq(&np->lock); in get_link_ksettings()
2589 spin_unlock_irq(&np->lock); in get_link_ksettings()
2598 spin_lock_irq(&np->lock); in set_link_ksettings()
2600 spin_unlock_irq(&np->lock); in set_link_ksettings()
2607 spin_lock_irq(&np->lock); in get_wol()
2608 netdev_get_wol(dev, &wol->supported, &wol->wolopts); in get_wol()
2609 netdev_get_sopass(dev, wol->sopass); in get_wol()
2610 spin_unlock_irq(&np->lock); in get_wol()
2617 spin_lock_irq(&np->lock); in set_wol()
2618 netdev_set_wol(dev, wol->wolopts); in set_wol()
2619 res = netdev_set_sopass(dev, wol->sopass); in set_wol()
2620 spin_unlock_irq(&np->lock); in set_wol()
2627 regs->version = NATSEMI_REGS_VER; in get_regs()
2628 spin_lock_irq(&np->lock); in get_regs()
2630 spin_unlock_irq(&np->lock); in get_regs()
2636 return np->msg_enable; in get_msglevel()
2642 np->msg_enable = val; in set_msglevel()
2648 int r = -EINVAL; in nway_reset()
2661 /* LSTATUS is latched low until a read - so read twice */ in get_link()
2672 eebuf = kmalloc(np->eeprom_size, GFP_KERNEL); in get_eeprom()
2674 return -ENOMEM; in get_eeprom()
2676 eeprom->magic = PCI_VENDOR_ID_NS | (PCI_DEVICE_ID_NS_83815<<16); in get_eeprom()
2677 spin_lock_irq(&np->lock); in get_eeprom()
2679 spin_unlock_irq(&np->lock); in get_eeprom()
2681 memcpy(data, eebuf+eeprom->offset, eeprom->len); in get_eeprom()
2721 if (np->srr >= SRR_DP83815_D) { in netdev_set_wol()
2741 if (np->srr >= SRR_DP83815_D) { in netdev_get_wol()
2775 if (np->srr < SRR_DP83815_D) { in netdev_set_sopass()
2794 /* re-enable the RX filter */ in netdev_set_sopass()
2807 if (np->srr < SRR_DP83815_D) { in netdev_get_sopass()
2836 ecmd->base.port = dev->if_port; in netdev_get_ecmd()
2837 ecmd->base.speed = np->speed; in netdev_get_ecmd()
2838 ecmd->base.duplex = np->duplex; in netdev_get_ecmd()
2839 ecmd->base.autoneg = np->autoneg; in netdev_get_ecmd()
2842 if (np->advertising & ADVERTISE_10HALF) in netdev_get_ecmd()
2844 if (np->advertising & ADVERTISE_10FULL) in netdev_get_ecmd()
2846 if (np->advertising & ADVERTISE_100HALF) in netdev_get_ecmd()
2848 if (np->advertising & ADVERTISE_100FULL) in netdev_get_ecmd()
2854 ecmd->base.phy_address = np->phy_addr_external; in netdev_get_ecmd()
2859 * It's only possible to query the settings of the active in netdev_get_ecmd()
2861 * # ethtool -s ethX port mii in netdev_get_ecmd()
2863 * settings that are used for the current active port. in netdev_get_ecmd()
2866 * # ethtool -s ethX port tp;ethtool -s ethX port mii in netdev_get_ecmd()
2873 /* set information based on active port type */ in netdev_get_ecmd()
2874 switch (ecmd->base.port) { in netdev_get_ecmd()
2887 /* if autonegotiation is on, try to return the active speed/duplex */ in netdev_get_ecmd()
2888 if (ecmd->base.autoneg == AUTONEG_ENABLE) { in netdev_get_ecmd()
2891 np->advertising & mdio_read(dev, MII_LPA)); in netdev_get_ecmd()
2893 ecmd->base.speed = SPEED_100; in netdev_get_ecmd()
2895 ecmd->base.speed = SPEED_10; in netdev_get_ecmd()
2897 ecmd->base.duplex = DUPLEX_FULL; in netdev_get_ecmd()
2899 ecmd->base.duplex = DUPLEX_HALF; in netdev_get_ecmd()
2904 ethtool_convert_legacy_u32_to_link_mode(ecmd->link_modes.supported, in netdev_get_ecmd()
2906 ethtool_convert_legacy_u32_to_link_mode(ecmd->link_modes.advertising, in netdev_get_ecmd()
2919 ecmd->link_modes.advertising); in netdev_set_ecmd()
2921 if (ecmd->base.port != PORT_TP && in netdev_set_ecmd()
2922 ecmd->base.port != PORT_MII && in netdev_set_ecmd()
2923 ecmd->base.port != PORT_FIBRE) in netdev_set_ecmd()
2924 return -EINVAL; in netdev_set_ecmd()
2925 if (ecmd->base.autoneg == AUTONEG_ENABLE) { in netdev_set_ecmd()
2930 return -EINVAL; in netdev_set_ecmd()
2932 } else if (ecmd->base.autoneg == AUTONEG_DISABLE) { in netdev_set_ecmd()
2933 u32 speed = ecmd->base.speed; in netdev_set_ecmd()
2935 return -EINVAL; in netdev_set_ecmd()
2936 if (ecmd->base.duplex != DUPLEX_HALF && in netdev_set_ecmd()
2937 ecmd->base.duplex != DUPLEX_FULL) in netdev_set_ecmd()
2938 return -EINVAL; in netdev_set_ecmd()
2940 return -EINVAL; in netdev_set_ecmd()
2948 if (np->ignore_phy && (ecmd->base.autoneg == AUTONEG_ENABLE || in netdev_set_ecmd()
2949 ecmd->base.port == PORT_TP)) in netdev_set_ecmd()
2950 return -EINVAL; in netdev_set_ecmd()
2957 * XCVR_EXTERNAL. The implementation thus ignores ecmd->transceiver and in netdev_set_ecmd()
2958 * selects based on ecmd->port. in netdev_set_ecmd()
2968 dev->if_port = ecmd->base.port; in netdev_set_ecmd()
2969 np->autoneg = ecmd->base.autoneg; in netdev_set_ecmd()
2970 np->phy_addr_external = ecmd->base.phy_address & PhyAddrMask; in netdev_set_ecmd()
2971 if (np->autoneg == AUTONEG_ENABLE) { in netdev_set_ecmd()
2973 np->advertising &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4); in netdev_set_ecmd()
2975 np->advertising |= ADVERTISE_10HALF; in netdev_set_ecmd()
2977 np->advertising |= ADVERTISE_10FULL; in netdev_set_ecmd()
2979 np->advertising |= ADVERTISE_100HALF; in netdev_set_ecmd()
2981 np->advertising |= ADVERTISE_100FULL; in netdev_set_ecmd()
2983 np->speed = ecmd->base.speed; in netdev_set_ecmd()
2984 np->duplex = ecmd->base.duplex; in netdev_set_ecmd()
2986 if (np->duplex == DUPLEX_HALF) in netdev_set_ecmd()
2987 np->full_duplex = 0; in netdev_set_ecmd()
2991 if (ecmd->base.port == PORT_TP) in netdev_set_ecmd()
3010 /* read non-mii page 0 of registers */ in netdev_get_regs()
3035 /* the interrupt status is clear-on-read - see if we missed any */ in netdev_get_regs()
3039 dev->name, rbuf[4] & rbuf[5]); in netdev_get_regs()
3062 for (i = 0; i < np->eeprom_size/2; i++) { in netdev_get_eeprom()
3064 /* The EEPROM itself stores data bit-swapped, but eeprom_read in netdev_get_eeprom()
3079 data->phy_id = np->phy_addr_external; in netdev_ioctl()
3087 if (dev->if_port == PORT_TP) { in netdev_ioctl()
3088 if ((data->phy_id & 0x1f) == np->phy_addr_external) in netdev_ioctl()
3089 data->val_out = mdio_read(dev, in netdev_ioctl()
3090 data->reg_num & 0x1f); in netdev_ioctl()
3092 data->val_out = 0; in netdev_ioctl()
3094 move_int_phy(dev, data->phy_id & 0x1f); in netdev_ioctl()
3095 data->val_out = miiport_read(dev, data->phy_id & 0x1f, in netdev_ioctl()
3096 data->reg_num & 0x1f); in netdev_ioctl()
3101 if (dev->if_port == PORT_TP) { in netdev_ioctl()
3102 if ((data->phy_id & 0x1f) == np->phy_addr_external) { in netdev_ioctl()
3103 if ((data->reg_num & 0x1f) == MII_ADVERTISE) in netdev_ioctl()
3104 np->advertising = data->val_in; in netdev_ioctl()
3105 mdio_write(dev, data->reg_num & 0x1f, in netdev_ioctl()
3106 data->val_in); in netdev_ioctl()
3109 if ((data->phy_id & 0x1f) == np->phy_addr_external) { in netdev_ioctl()
3110 if ((data->reg_num & 0x1f) == MII_ADVERTISE) in netdev_ioctl()
3111 np->advertising = data->val_in; in netdev_ioctl()
3113 move_int_phy(dev, data->phy_id & 0x1f); in netdev_ioctl()
3114 miiport_write(dev, data->phy_id & 0x1f, in netdev_ioctl()
3115 data->reg_num & 0x1f, in netdev_ioctl()
3116 data->val_in); in netdev_ioctl()
3120 return -EOPNOTSUPP; in netdev_ioctl()
3130 printk(KERN_INFO "%s: remaining active for wake-on-lan\n", in enable_wol_mode()
3131 dev->name); in enable_wol_mode()
3142 /* PME on, clear status */ in enable_wol_mode()
3143 writel(np->SavedClkRun | PMEEnable | PMEStatus, ioaddr + ClkRun); in enable_wol_mode()
3161 const int irq = np->pci_dev->irq; in netdev_close()
3166 dev->name, (int)readl(ioaddr + ChipCmd)); in netdev_close()
3170 dev->name, np->cur_tx, np->dirty_tx, in netdev_close()
3171 np->cur_rx, np->dirty_rx); in netdev_close()
3173 napi_disable(&np->napi); in netdev_close()
3182 del_timer_sync(&np->timer); in netdev_close()
3184 spin_lock_irq(&np->lock); in netdev_close()
3186 np->hands_off = 1; in netdev_close()
3187 spin_unlock_irq(&np->lock); in netdev_close()
3196 spin_lock_irq(&np->lock); in netdev_close()
3197 np->hands_off = 0; in netdev_close()
3208 spin_unlock_irq(&np->lock); in netdev_close()
3210 /* clear the carrier last - an interrupt could reenable it otherwise */ in netdev_close()
3226 /* Restore PME enable bit unmolested */ in netdev_close()
3227 writel(np->SavedClkRun, ioaddr + ClkRun); in netdev_close()
3255 * No function accesses the hardware without checking np->hands_off.
3256 * the check occurs under spin_lock_irq(&np->lock);
3279 const int irq = np->pci_dev->irq; in natsemi_suspend()
3281 del_timer_sync(&np->timer); in natsemi_suspend()
3284 spin_lock_irq(&np->lock); in natsemi_suspend()
3287 np->hands_off = 1; in natsemi_suspend()
3291 spin_unlock_irq(&np->lock); in natsemi_suspend()
3294 napi_disable(&np->napi); in natsemi_suspend()
3299 /* pci_power_off(pdev, -1); */ in natsemi_suspend()
3303 /* Restore PME enable bit */ in natsemi_suspend()
3311 /* Restore PME enable bit unmolested */ in natsemi_suspend()
3312 writel(np->SavedClkRun, ioaddr + ClkRun); in natsemi_suspend()
3331 const int irq = np->pci_dev->irq; in natsemi_resume()
3333 BUG_ON(!np->hands_off); in natsemi_resume()
3336 napi_enable(&np->napi); in natsemi_resume()
3341 spin_lock_irq(&np->lock); in natsemi_resume()
3342 np->hands_off = 0; in natsemi_resume()
3345 spin_unlock_irq(&np->lock); in natsemi_resume()
3348 mod_timer(&np->timer, round_jiffies(jiffies + 1*HZ)); in natsemi_resume()