Lines Matching +full:foo +full:- +full:over +full:- +full:udp
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Questions/comments/discussion to linux-ns83820@kvack.org.
16 * 20010414 0.1 - created
17 * 20010622 0.2 - basic rx and tx.
18 * 20010711 0.3 - added duplex and link state detection support.
19 * 20010713 0.4 - zero copy, no hangs.
20 * 0.5 - 64 bit dma support (davem will hate me for this)
21 * - disable jumbo frames to avoid tx hangs
22 * - work around tx deadlocks on my 1.02 card via
24 * 20010810 0.6 - use pci dma api for ringbuffers, work on ia64
25 * 20010816 0.7 - misc cleanups
26 * 20010826 0.8 - fix critical zero copy bugs
27 * 0.9 - internal experiment
28 * 20010827 0.10 - fix ia64 unaligned access.
29 * 20010906 0.11 - accept all packets with checksum errors as
31 * - fix >> 32 bugs
32 * 0.12 - add statistics counters
33 * - add allmulti/promisc support
34 * 20011009 0.13 - hotplug support, other smaller pci api cleanups
35 * 20011204 0.13a - optical transceiver support added
37 * 20011205 0.13b - call register_netdev earlier in initialization
39 * 20011117 0.14 - ethtool GDRVINFO, GLINK support from jgarzik
43 * 20020610 0.18 - actually use the pci dma api for highmem
44 * - remove pci latency register fiddling
45 * 0.19 - better bist support
46 * - add ihr and reset_phy parameters
47 * - gmii bus probing
48 * - fix missed txok introduced during performance
50 * 0.20 - fix stupid RFEN thinko. i am such a smurf.
51 * 20040828 0.21 - add hardware vlan accleration
53 * 20050406 0.22 - improved DAC ifdefs from Andi Kleen
54 * - removal of dead code from Adrian Bunk
55 * - fix half duplex collision behaviour
71 * Cameo SOHO-GA2000T SOHO-GA2500T
72 * D-Link DGE-500T
73 * PureData PDP8023Z-TG
88 #include <linux/dma-mapping.h>
455 #define __kick_rx(dev) writel(CR_RXE, dev->base + CR)
461 if (test_and_clear_bit(0, &dev->rx_info.idle)) { in kick_rx()
463 writel(dev->rx_info.phy_descs + in kick_rx()
464 (4 * DESC_SIZE * dev->rx_info.next_rx), in kick_rx()
465 dev->base + RXDP); in kick_rx()
466 if (dev->rx_info.next_rx == dev->rx_info.next_empty) in kick_rx()
467 printk(KERN_DEBUG "%s: uh-oh: next_rx == next_empty???\n", in kick_rx()
468 ndev->name); in kick_rx()
473 //free = (tx_done_idx + NR_TX_DESC-2 - free_idx) % NR_TX_DESC
475 (((NR_TX_DESC-2 + dev->tx_done_idx - dev->tx_free_idx) % NR_TX_DESC) > MIN_TX_DESC_FREE)
499 #define nr_rx_empty(dev) ((NR_RX_DESC-2 + dev->rx_info.next_rx - dev->rx_info.next_empty) % NR_RX_D…
507 next_empty = dev->rx_info.next_empty; in ns83820_add_rx_skb()
517 dev->rx_info.next_empty, in ns83820_add_rx_skb()
518 dev->rx_info.nr_used, in ns83820_add_rx_skb()
519 dev->rx_info.next_rx in ns83820_add_rx_skb()
523 sg = dev->rx_info.descs + (next_empty * DESC_SIZE); in ns83820_add_rx_skb()
524 BUG_ON(NULL != dev->rx_info.skbs[next_empty]); in ns83820_add_rx_skb()
525 dev->rx_info.skbs[next_empty] = skb; in ns83820_add_rx_skb()
527 dev->rx_info.next_empty = (next_empty + 1) % NR_RX_DESC; in ns83820_add_rx_skb()
529 buf = dma_map_single(&dev->pci_dev->dev, skb->data, REAL_RX_BUF_SIZE, in ns83820_add_rx_skb()
533 if (likely(next_empty != dev->rx_info.next_rx)) in ns83820_add_rx_skb()
534 …dev->rx_info.descs[((NR_RX_DESC + next_empty - 1) % NR_RX_DESC) * DESC_SIZE] = cpu_to_le32(dev->rx… in ns83820_add_rx_skb()
550 spin_lock_irqsave(&dev->rx_info.lock, flags); in rx_refill()
560 skb_reserve(skb, skb->data - PTR_ALIGN(skb->data, 16)); in rx_refill()
562 spin_lock_irqsave(&dev->rx_info.lock, flags); in rx_refill()
565 spin_unlock_irqrestore(&dev->rx_info.lock, flags); in rx_refill()
572 spin_unlock_irqrestore(&dev->rx_info.lock, flags); in rx_refill()
574 return i ? 0 : -ENOMEM; in rx_refill()
586 struct net_device *ndev = dev->ndev; in queue_refill()
589 if (dev->rx_info.up) in queue_refill()
595 build_rx_desc(dev, dev->rx_info.descs + (DESC_SIZE * i), 0, 0, CMDSTS_OWN, 0); in clear_rx_desc()
606 cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY; in phy_intr()
608 if (dev->CFG_cache & CFG_TBI_EN) { in phy_intr()
612 tbisr = readl(dev->base + TBISR); in phy_intr()
613 tanar = readl(dev->base + TANAR); in phy_intr()
614 tanlpar = readl(dev->base + TANLPAR); in phy_intr()
622 writel(readl(dev->base + TXCFG) in phy_intr()
624 dev->base + TXCFG); in phy_intr()
625 writel(readl(dev->base + RXCFG) | RXCFG_RX_FD, in phy_intr()
626 dev->base + RXCFG); in phy_intr()
628 writel(readl(dev->base + GPIOR) | GPIOR_GP1_OUT, in phy_intr()
629 dev->base + GPIOR); in phy_intr()
639 writel((readl(dev->base + TXCFG) in phy_intr()
641 dev->base + TXCFG); in phy_intr()
642 writel(readl(dev->base + RXCFG) & ~RXCFG_RX_FD, in phy_intr()
643 dev->base + RXCFG); in phy_intr()
645 writel(readl(dev->base + GPIOR) & ~GPIOR_GP1_OUT, in phy_intr()
646 dev->base + GPIOR); in phy_intr()
653 new_cfg = dev->CFG_cache & ~(CFG_SB | CFG_MODE_1000 | CFG_SPDSTS); in phy_intr()
665 writel(readl(dev->base + TXCFG) in phy_intr()
667 dev->base + TXCFG); in phy_intr()
668 writel(readl(dev->base + RXCFG) | RXCFG_RX_FD, in phy_intr()
669 dev->base + RXCFG); in phy_intr()
671 writel(readl(dev->base + TXCFG) in phy_intr()
673 dev->base + TXCFG); in phy_intr()
674 writel(readl(dev->base + RXCFG) & ~(RXCFG_RX_FD), in phy_intr()
675 dev->base + RXCFG); in phy_intr()
679 ((new_cfg ^ dev->CFG_cache) != 0)) { in phy_intr()
680 writel(new_cfg, dev->base + CFG); in phy_intr()
681 dev->CFG_cache = new_cfg; in phy_intr()
684 dev->CFG_cache &= ~CFG_SPDSTS; in phy_intr()
685 dev->CFG_cache |= cfg & CFG_SPDSTS; in phy_intr()
691 dev->linkstate != newlinkstate) { in phy_intr()
695 ndev->name, in phy_intr()
699 dev->linkstate != newlinkstate) { in phy_intr()
701 printk(KERN_INFO "%s: link now down.\n", ndev->name); in phy_intr()
704 dev->linkstate = newlinkstate; in phy_intr()
715 dev->rx_info.idle = 1; in ns83820_setup_rx()
716 dev->rx_info.next_rx = 0; in ns83820_setup_rx()
717 dev->rx_info.next_rx_desc = dev->rx_info.descs; in ns83820_setup_rx()
718 dev->rx_info.next_empty = 0; in ns83820_setup_rx()
723 writel(0, dev->base + RXDP_HI); in ns83820_setup_rx()
724 writel(dev->rx_info.phy_descs, dev->base + RXDP); in ns83820_setup_rx()
730 spin_lock_irq(&dev->rx_info.lock); in ns83820_setup_rx()
732 writel(0x0001, dev->base + CCSR); in ns83820_setup_rx()
733 writel(0, dev->base + RFCR); in ns83820_setup_rx()
734 writel(0x7fc00000, dev->base + RFCR); in ns83820_setup_rx()
735 writel(0xffc00000, dev->base + RFCR); in ns83820_setup_rx()
737 dev->rx_info.up = 1; in ns83820_setup_rx()
742 spin_lock(&dev->misc_lock); in ns83820_setup_rx()
743 dev->IMR_cache |= ISR_PHY; in ns83820_setup_rx()
744 dev->IMR_cache |= ISR_RXRCMP; in ns83820_setup_rx()
745 //dev->IMR_cache |= ISR_RXERR; in ns83820_setup_rx()
746 //dev->IMR_cache |= ISR_RXOK; in ns83820_setup_rx()
747 dev->IMR_cache |= ISR_RXORN; in ns83820_setup_rx()
748 dev->IMR_cache |= ISR_RXSOVR; in ns83820_setup_rx()
749 dev->IMR_cache |= ISR_RXDESC; in ns83820_setup_rx()
750 dev->IMR_cache |= ISR_RXIDLE; in ns83820_setup_rx()
751 dev->IMR_cache |= ISR_TXDESC; in ns83820_setup_rx()
752 dev->IMR_cache |= ISR_TXIDLE; in ns83820_setup_rx()
754 writel(dev->IMR_cache, dev->base + IMR); in ns83820_setup_rx()
755 writel(1, dev->base + IER); in ns83820_setup_rx()
756 spin_unlock(&dev->misc_lock); in ns83820_setup_rx()
760 spin_unlock_irq(&dev->rx_info.lock); in ns83820_setup_rx()
773 spin_lock_irqsave(&dev->misc_lock, flags); in ns83820_cleanup_rx()
774 dev->IMR_cache &= ~(ISR_RXOK | ISR_RXDESC | ISR_RXERR | ISR_RXEARLY | ISR_RXIDLE); in ns83820_cleanup_rx()
775 writel(dev->IMR_cache, dev->base + IMR); in ns83820_cleanup_rx()
776 spin_unlock_irqrestore(&dev->misc_lock, flags); in ns83820_cleanup_rx()
779 dev->rx_info.up = 0; in ns83820_cleanup_rx()
780 synchronize_irq(dev->pci_dev->irq); in ns83820_cleanup_rx()
783 readl(dev->base + IMR); in ns83820_cleanup_rx()
786 writel(0, dev->base + RXDP_HI); in ns83820_cleanup_rx()
787 writel(0, dev->base + RXDP); in ns83820_cleanup_rx()
790 struct sk_buff *skb = dev->rx_info.skbs[i]; in ns83820_cleanup_rx()
791 dev->rx_info.skbs[i] = NULL; in ns83820_cleanup_rx()
801 if (dev->rx_info.up) { in ns83820_rx_kick()
807 if (dev->rx_info.up && nr_rx_empty(dev) > NR_RX_DESC*3/4) in ns83820_rx_kick()
808 schedule_work(&dev->tq_refill); in ns83820_rx_kick()
811 if (dev->rx_info.idle) in ns83820_rx_kick()
812 printk(KERN_DEBUG "%s: BAD\n", ndev->name); in ns83820_rx_kick()
821 struct rx_info *info = &dev->rx_info;
831 readl(dev->base + RXDP),
832 (long)(dev->rx_info.phy_descs),
833 (int)dev->rx_info.next_rx,
834 (dev->rx_info.descs + (DESC_SIZE * dev->rx_info.next_rx)),
835 (int)dev->rx_info.next_empty,
836 (dev->rx_info.descs + (DESC_SIZE * dev->rx_info.next_empty))
839 spin_lock_irqsave(&info->lock, flags);
840 if (!info->up)
844 next_rx = info->next_rx;
845 desc = info->next_rx_desc;
856 skb = info->skbs[next_rx];
857 info->skbs[next_rx] = NULL;
858 info->next_rx = (next_rx + 1) % NR_RX_DESC;
863 dma_unmap_single(&dev->pci_dev->dev, bufptr, RX_BUF_SIZE,
887 ndev->stats.multicast++;
888 ndev->stats.rx_packets++;
889 ndev->stats.rx_bytes += len;
891 skb->ip_summed = CHECKSUM_UNNECESSARY;
895 skb->protocol = eth_type_trans(skb, ndev);
907 ndev->stats.rx_dropped++;
914 next_rx = info->next_rx;
915 desc = info->descs + (DESC_SIZE * next_rx);
917 info->next_rx = next_rx;
918 info->next_rx_desc = info->descs + (DESC_SIZE * next_rx);
925 spin_unlock_irqrestore(&info->lock, flags);
931 struct net_device *ndev = dev->ndev;
933 writel(ihr, dev->base + IHR);
935 spin_lock_irq(&dev->misc_lock);
936 dev->IMR_cache |= ISR_RXDESC;
937 writel(dev->IMR_cache, dev->base + IMR);
938 spin_unlock_irq(&dev->misc_lock);
949 dev, dev->tx_idx, dev->tx_free_idx);
950 writel(CR_TXE, dev->base + CR);
963 tx_done_idx = dev->tx_done_idx;
964 desc = dev->tx_descs + (tx_done_idx * DESC_SIZE);
967 tx_done_idx, dev->tx_free_idx, le32_to_cpu(desc[DESC_CMDSTS]));
968 while ((tx_done_idx != dev->tx_free_idx) &&
975 ndev->stats.tx_errors++;
977 ndev->stats.tx_packets++;
979 ndev->stats.tx_bytes += cmdsts & 0xffff;
982 tx_done_idx, dev->tx_free_idx, cmdsts);
983 skb = dev->tx_skbs[tx_done_idx];
984 dev->tx_skbs[tx_done_idx] = NULL;
990 dma_unmap_single(&dev->pci_dev->dev, addr, len,
993 atomic_dec(&dev->nr_tx_skbs);
995 dma_unmap_page(&dev->pci_dev->dev, addr, len,
999 dev->tx_done_idx = tx_done_idx;
1002 desc = dev->tx_descs + (tx_done_idx * DESC_SIZE);
1020 struct sk_buff *skb = dev->tx_skbs[i];
1021 dev->tx_skbs[i] = NULL;
1023 __le32 *desc = dev->tx_descs + (i * DESC_SIZE);
1024 dma_unmap_single(&dev->pci_dev->dev,
1029 atomic_dec(&dev->nr_tx_skbs);
1033 memset(dev->tx_descs, 0, NR_TX_DESC * DESC_SIZE * 4);
1058 nr_frags = skb_shinfo(skb)->nr_frags;
1060 if (unlikely(dev->CFG_cache & CFG_LNKSTS)) {
1062 if (unlikely(dev->CFG_cache & CFG_LNKSTS))
1067 last_idx = free_idx = dev->tx_free_idx;
1068 tx_done_idx = dev->tx_done_idx;
1069 nr_free = (tx_done_idx + NR_TX_DESC-2 - free_idx) % NR_TX_DESC;
1070 nr_free -= 1;
1072 dprintk("stop_queue - not enough(%p)\n", ndev);
1076 if (dev->tx_done_idx != tx_done_idx) {
1084 if (free_idx == dev->tx_intr_idx) {
1086 dev->tx_intr_idx = (dev->tx_intr_idx + NR_TX_DESC/4) % NR_TX_DESC;
1089 nr_free -= nr_frags;
1091 dprintk("stop_queue - last entry(%p)\n", ndev);
1096 frag = skb_shinfo(skb)->frags;
1100 if (skb->ip_summed == CHECKSUM_PARTIAL) {
1102 if (IPPROTO_TCP == ip_hdr(skb)->protocol)
1104 else if (IPPROTO_UDP == ip_hdr(skb)->protocol)
1119 len = skb->len;
1121 len -= skb->data_len;
1122 buf = dma_map_single(&dev->pci_dev->dev, skb->data, len,
1125 first_desc = dev->tx_descs + (free_idx * DESC_SIZE);
1128 volatile __le32 *desc = dev->tx_descs + (free_idx * DESC_SIZE);
1134 desc[DESC_LINK] = cpu_to_le32(dev->tx_phy_descs + (free_idx * DESC_SIZE * 4));
1146 buf = skb_frag_dma_map(&dev->pci_dev->dev, frag, 0,
1149 (long long)buf, (long) page_to_pfn(frag->page),
1150 frag->page_offset);
1153 nr_frags--;
1157 spin_lock_irq(&dev->tx_lock);
1158 dev->tx_skbs[last_idx] = skb;
1160 dev->tx_free_idx = free_idx;
1161 atomic_inc(&dev->nr_tx_skbs);
1162 spin_unlock_irq(&dev->tx_lock);
1167 if (stopped && (dev->tx_done_idx != tx_done_idx) && start_tx_okay(dev))
1175 struct net_device *ndev = dev->ndev;
1176 u8 __iomem *base = dev->base;
1179 ndev->stats.rx_errors += readl(base + 0x60) & 0xffff;
1180 ndev->stats.rx_crc_errors += readl(base + 0x64) & 0xffff;
1181 ndev->stats.rx_missed_errors += readl(base + 0x68) & 0xffff;
1182 ndev->stats.rx_frame_errors += readl(base + 0x6c) & 0xffff;
1183 /*ndev->stats.rx_symbol_errors +=*/ readl(base + 0x70);
1184 ndev->stats.rx_length_errors += readl(base + 0x74) & 0xffff;
1185 ndev->stats.rx_length_errors += readl(base + 0x78) & 0xffff;
1186 /*ndev->stats.rx_badopcode_errors += */ readl(base + 0x7c);
1187 /*ndev->stats.rx_pause_count += */ readl(base + 0x80);
1188 /*ndev->stats.tx_pause_count += */ readl(base + 0x84);
1189 ndev->stats.tx_carrier_errors += readl(base + 0x88) & 0xff;
1197 spin_lock_irq(&dev->misc_lock);
1199 spin_unlock_irq(&dev->misc_lock);
1201 return &ndev->stats;
1215 * cmd->advertising =
1217 * cmd->duplex =
1218 * cmd->port = 0;
1219 * cmd->phy_address =
1220 * cmd->transceiver = 0;
1221 * cmd->autoneg =
1222 * cmd->maxtxpkt = 0;
1223 * cmd->maxrxpkt = 0;
1227 cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY;
1228 readl(dev->base + TANAR);
1229 tbicr = readl(dev->base + TBICR);
1235 if (dev->CFG_cache & CFG_TBI_EN) {
1240 cmd->base.port = PORT_FIBRE;
1248 cmd->base.port = PORT_MII;
1251 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
1254 cmd->base.duplex = fullduplex ? DUPLEX_FULL : DUPLEX_HALF;
1257 cmd->base.speed = SPEED_1000;
1260 cmd->base.speed = SPEED_100;
1263 cmd->base.speed = SPEED_10;
1266 cmd->base.autoneg = (tbicr & TBICR_MR_AN_ENABLE)
1281 cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY;
1282 tanar = readl(dev->base + TANAR);
1284 if (dev->CFG_cache & CFG_TBI_EN) {
1294 spin_lock_irq(&dev->misc_lock);
1295 spin_lock(&dev->tx_lock);
1298 if (cmd->base.duplex != fullduplex) {
1301 if (cmd->base.duplex == DUPLEX_FULL) {
1303 writel(readl(dev->base + TXCFG)
1305 dev->base + TXCFG);
1306 writel(readl(dev->base + RXCFG) | RXCFG_RX_FD,
1307 dev->base + RXCFG);
1309 writel(readl(dev->base + GPIOR) | GPIOR_GP1_OUT,
1310 dev->base + GPIOR);
1320 ndev->name);
1325 if (cmd->base.autoneg == AUTONEG_ENABLE) {
1328 dev->base + TBICR);
1329 writel(TBICR_MR_AN_ENABLE, dev->base + TBICR);
1330 dev->linkstate = LINK_AUTONEGOTIATE;
1333 ndev->name);
1336 writel(0x00000000, dev->base + TBICR);
1339 printk(KERN_INFO "%s: autoneg %s via ethtool\n", ndev->name,
1340 cmd->base.autoneg ? "ENABLED" : "DISABLED");
1344 spin_unlock(&dev->tx_lock);
1345 spin_unlock_irq(&dev->misc_lock);
1349 /* end ethtool get/set support -df */
1354 strscpy(info->driver, "ns83820", sizeof(info->driver));
1355 strscpy(info->version, VERSION, sizeof(info->version));
1356 strscpy(info->bus_info, pci_name(dev->pci_dev), sizeof(info->bus_info));
1362 u32 cfg = readl(dev->base + CFG) ^ SPDSTS_POLARITY;
1375 writel(0, dev->base + IMR);
1376 writel(0, dev->base + IER);
1377 readl(dev->base + IER);
1384 spin_lock_irqsave(&dev->misc_lock, flags);
1386 spin_unlock_irqrestore(&dev->misc_lock, flags);
1390 static irqreturn_t ns83820_irq(int foo, void *data) argument
1397 dev->ihr = 0;
1399 isr = readl(dev->base + ISR);
1416 dev->rx_info.idle = 1;
1422 prefetch(dev->rx_info.next_rx_desc);
1424 spin_lock_irqsave(&dev->misc_lock, flags);
1425 dev->IMR_cache &= ~(ISR_RXDESC | ISR_RXOK);
1426 writel(dev->IMR_cache, dev->base + IMR);
1427 spin_unlock_irqrestore(&dev->misc_lock, flags);
1429 tasklet_schedule(&dev->rx_tasklet);
1431 //writel(4, dev->base + IHR);
1439 ndev->stats.rx_fifo_errors++;
1444 ndev->stats.rx_fifo_errors++;
1447 if ((ISR_RXRCMP & isr) && dev->rx_info.up)
1448 writel(CR_RXE, dev->base + CR);
1452 txdp = readl(dev->base + TXDP);
1454 txdp -= dev->tx_phy_descs;
1455 dev->tx_idx = txdp / (DESC_SIZE * 4);
1456 if (dev->tx_idx >= NR_TX_DESC) {
1457 printk(KERN_ALERT "%s: BUG -- txdp out of range\n", ndev->name);
1458 dev->tx_idx = 0;
1465 if (dev->tx_idx != dev->tx_free_idx)
1473 spin_lock_irqsave(&dev->tx_lock, flags);
1475 spin_unlock_irqrestore(&dev->tx_lock, flags);
1479 if ((dev->tx_done_idx == dev->tx_free_idx) &&
1480 (dev->IMR_cache & ISR_TXOK)) {
1481 spin_lock_irqsave(&dev->misc_lock, flags);
1482 dev->IMR_cache &= ~ISR_TXOK;
1483 writel(dev->IMR_cache, dev->base + IMR);
1484 spin_unlock_irqrestore(&dev->misc_lock, flags);
1494 if ((ISR_TXIDLE & isr) && (dev->tx_done_idx != dev->tx_free_idx)) {
1495 spin_lock_irqsave(&dev->misc_lock, flags);
1496 dev->IMR_cache |= ISR_TXOK;
1497 writel(dev->IMR_cache, dev->base + IMR);
1498 spin_unlock_irqrestore(&dev->misc_lock, flags);
1510 if (dev->ihr)
1511 writel(dev->ihr, dev->base + IHR);
1518 writel(which, dev->base + CR);
1521 } while (readl(dev->base + CR) & which);
1530 del_timer_sync(&dev->tx_watchdog);
1534 dev->rx_info.up = 0;
1535 synchronize_irq(dev->pci_dev->irq);
1539 synchronize_irq(dev->pci_dev->irq);
1541 spin_lock_irq(&dev->misc_lock);
1542 dev->IMR_cache &= ~(ISR_TXURN | ISR_TXIDLE | ISR_TXERR | ISR_TXDESC | ISR_TXOK);
1543 spin_unlock_irq(&dev->misc_lock);
1558 spin_lock_irqsave(&dev->tx_lock, flags);
1560 tx_done_idx = dev->tx_done_idx;
1561 desc = dev->tx_descs + (tx_done_idx * DESC_SIZE);
1564 ndev->name,
1565 tx_done_idx, dev->tx_free_idx, le32_to_cpu(desc[DESC_CMDSTS]));
1570 isr = readl(dev->base + ISR);
1571 printk("irq: %08x imr: %08x\n", isr, dev->IMR_cache);
1578 tx_done_idx = dev->tx_done_idx;
1579 desc = dev->tx_descs + (tx_done_idx * DESC_SIZE);
1582 ndev->name,
1583 tx_done_idx, dev->tx_free_idx, le32_to_cpu(desc[DESC_CMDSTS]));
1585 spin_unlock_irqrestore(&dev->tx_lock, flags);
1591 struct net_device *ndev = dev->ndev;
1595 dev->tx_done_idx, dev->tx_free_idx, atomic_read(&dev->nr_tx_skbs)
1600 dev->tx_done_idx != dev->tx_free_idx) {
1602 ndev->name,
1603 dev->tx_done_idx, dev->tx_free_idx,
1604 atomic_read(&dev->nr_tx_skbs));
1608 mod_timer(&dev->tx_watchdog, jiffies + 2*HZ);
1620 writel(0, dev->base + PQCR);
1626 memset(dev->tx_descs, 0, 4 * NR_TX_DESC * DESC_SIZE);
1628 dev->tx_descs[(i * DESC_SIZE) + DESC_LINK]
1630 dev->tx_phy_descs
1634 dev->tx_idx = 0;
1635 dev->tx_done_idx = 0;
1636 desc = dev->tx_phy_descs;
1637 writel(0, dev->base + TXDP_HI);
1638 writel(desc, dev->base + TXDP);
1640 timer_setup(&dev->tx_watchdog, ns83820_tx_watch, 0);
1641 mod_timer(&dev->tx_watchdog, jiffies + 2*HZ);
1663 writel(i*2, dev->base + RFCR);
1664 data = readl(dev->base + RFDR);
1675 u8 __iomem *rfcr = dev->base + RFCR;
1680 if (ndev->flags & IFF_PROMISC)
1685 if (ndev->flags & IFF_ALLMULTI || netdev_mc_count(ndev))
1690 spin_lock_irq(&dev->misc_lock);
1695 spin_unlock_irq(&dev->misc_lock);
1706 dprintk("%s: start %s\n", ndev->name, name);
1710 writel(enable, dev->base + PTSCR);
1713 status = readl(dev->base + PTSCR);
1729 ndev->name, name, status, fail);
1732 ndev->name, name, status);
1734 dprintk("%s: done %s in %d loops\n", ndev->name, name, loops);
1741 dev->MEAR_cache &= ~MEAR_MDC;
1742 writel(dev->MEAR_cache, dev->base + MEAR);
1743 readl(dev->base + MEAR);
1746 dev->MEAR_cache |= MEAR_MDDIR;
1748 dev->MEAR_cache |= MEAR_MDIO;
1750 dev->MEAR_cache &= ~MEAR_MDIO;
1753 writel(dev->MEAR_cache, dev->base + MEAR);
1754 readl(dev->base + MEAR);
1760 dev->MEAR_cache |= MEAR_MDC;
1761 writel(dev->MEAR_cache, dev->base + MEAR);
1762 readl(dev->base + MEAR);
1773 dev->MEAR_cache &= ~MEAR_MDC;
1774 dev->MEAR_cache &= ~MEAR_MDDIR;
1775 writel(dev->MEAR_cache, dev->base + MEAR);
1776 readl(dev->base + MEAR);
1782 bit = (readl(dev->base + MEAR) & MEAR_MDIO) ? 1 : 0;
1783 dev->MEAR_cache |= MEAR_MDC;
1784 writel(dev->MEAR_cache, dev->base + MEAR);
1852 ns83820_mii_write_bit(dev, (data >> (15 - i)) & 1);
1865 ndev->name, j,
1907 !dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(64))) {
1909 } else if (!dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32))) {
1912 dev_warn(&pci_dev->dev, "dma_set_mask failed!\n");
1913 return -ENODEV;
1917 err = -ENOMEM;
1922 dev->ndev = ndev;
1924 spin_lock_init(&dev->rx_info.lock);
1925 spin_lock_init(&dev->tx_lock);
1926 spin_lock_init(&dev->misc_lock);
1927 dev->pci_dev = pci_dev;
1929 SET_NETDEV_DEV(ndev, &pci_dev->dev);
1931 INIT_WORK(&dev->tq_refill, queue_refill);
1932 tasklet_setup(&dev->rx_tasklet, rx_action);
1936 dev_info(&pci_dev->dev, "pci_enable_dev failed: %d\n", err);
1942 dev->base = ioremap(addr, PAGE_SIZE);
1943 dev->tx_descs = dma_alloc_coherent(&pci_dev->dev,
1945 &dev->tx_phy_descs, GFP_KERNEL);
1946 dev->rx_info.descs = dma_alloc_coherent(&pci_dev->dev,
1948 &dev->rx_info.phy_descs, GFP_KERNEL);
1949 err = -ENOMEM;
1950 if (!dev->base || !dev->tx_descs || !dev->rx_info.descs)
1954 dev->tx_descs, (long)dev->tx_phy_descs,
1955 dev->rx_info.descs, (long)dev->rx_info.phy_descs);
1959 dev->IMR_cache = 0;
1961 err = request_irq(pci_dev->irq, ns83820_irq, IRQF_SHARED,
1964 dev_info(&pci_dev->dev, "unable to register irq %d, err %d\n",
1965 pci_dev->irq, err);
1970 * FIXME: we are holding rtnl_lock() over obscenely long area only
1971 * because some of the setup code uses dev->name. It's Wrong(tm) -
1972 * we should be using driver-specific names for all that stuff.
1977 err = dev_alloc_name(ndev, ndev->name);
1979 dev_info(&pci_dev->dev, "unable to get netdev name: %d\n", err);
1984 ndev->name, le32_to_cpu(readl(dev->base + 0x22c)),
1985 pci_dev->subsystem_vendor, pci_dev->subsystem_device);
1987 ndev->netdev_ops = &netdev_ops;
1988 ndev->ethtool_ops = &ops;
1989 ndev->watchdog_timeo = 5 * HZ;
1995 writel(PTSCR_RBIST_RST, dev->base + PTSCR);
2003 dev->CFG_cache = readl(dev->base + CFG);
2005 if ((dev->CFG_cache & CFG_PCI64_DET)) {
2007 ndev->name);
2008 /*dev->CFG_cache |= CFG_DATA64_EN;*/
2009 if (!(dev->CFG_cache & CFG_DATA64_EN))
2011 ndev->name);
2013 dev->CFG_cache &= ~(CFG_DATA64_EN);
2015 dev->CFG_cache &= (CFG_TBI_EN | CFG_MRM_DIS | CFG_MWI_DIS |
2018 dev->CFG_cache |= CFG_PINT_DUPSTS | CFG_PINT_LNKSTS | CFG_PINT_SPDSTS |
2020 dev->CFG_cache |= CFG_REQALG;
2021 dev->CFG_cache |= CFG_POW;
2022 dev->CFG_cache |= CFG_TMRTEST;
2028 dev->CFG_cache |= CFG_M64ADDR;
2030 dev->CFG_cache |= CFG_T64ADDR;
2033 dev->CFG_cache &= ~CFG_BEM;
2036 if (dev->CFG_cache & CFG_TBI_EN) {
2038 ndev->name);
2039 writel(readl(dev->base + GPIOR) | 0x3e8, dev->base + GPIOR);
2042 writel(readl(dev->base + TANAR)
2044 dev->base + TANAR);
2048 dev->base + TBICR);
2049 writel(TBICR_MR_AN_ENABLE, dev->base + TBICR);
2050 dev->linkstate = LINK_AUTONEGOTIATE;
2052 dev->CFG_cache |= CFG_MODE_1000;
2055 writel(dev->CFG_cache, dev->base + CFG);
2056 dprintk("CFG: %08x\n", dev->CFG_cache);
2059 printk(KERN_INFO "%s: resetting phy\n", ndev->name);
2060 writel(dev->CFG_cache | CFG_PHY_RST, dev->base + CFG);
2062 writel(dev->CFG_cache, dev->base + CFG);
2068 if (readl(dev->base + SRR))
2069 writel(readl(dev->base+0x20c) | 0xfe00, dev->base + 0x20c);
2074 * can be transmitted is 8192 - FLTH - burst size.
2081 dev->base + TXCFG);
2084 writel(0x000, dev->base + IHR);
2085 writel(0x100, dev->base + IHR);
2086 writel(0x000, dev->base + IHR);
2097 | (RXCFG_MXDMA512) | 0, dev->base + RXCFG);
2100 writel(0, dev->base + PQCR);
2105 * at least for UDP.
2120 writel(VRCR_INIT_VALUE, dev->base + VRCR);
2122 /* Enable per-packet TCP/UDP/IP checksumming
2131 writel(VTCR_INIT_VALUE, dev->base + VTCR);
2134 /* writel(0, dev->base + PCR); */
2137 dev->base + PCR);
2140 writel(0, dev->base + WCSR);
2145 ndev->features |= NETIF_F_SG;
2146 ndev->features |= NETIF_F_IP_CSUM;
2148 ndev->min_mtu = 0;
2152 ndev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX;
2157 ndev->name);
2158 ndev->features |= NETIF_F_HIGHDMA;
2162 ndev->name,
2163 (unsigned)readl(dev->base + SRR) >> 8,
2164 (unsigned)readl(dev->base + SRR) & 0xff,
2165 ndev->dev_addr, addr, pci_dev->irq,
2166 (ndev->features & NETIF_F_HIGHDMA) ? "h,sg" : "sg"
2186 free_irq(pci_dev->irq, ndev);
2188 if (dev->base)
2189 iounmap(dev->base);
2190 dma_free_coherent(&pci_dev->dev, 4 * DESC_SIZE * NR_TX_DESC,
2191 dev->tx_descs, dev->tx_phy_descs);
2192 dma_free_coherent(&pci_dev->dev, 4 * DESC_SIZE * NR_RX_DESC,
2193 dev->rx_info.descs, dev->rx_info.phy_descs);
2212 free_irq(dev->pci_dev->irq, ndev);
2213 iounmap(dev->base);
2214 dma_free_coherent(&dev->pci_dev->dev, 4 * DESC_SIZE * NR_TX_DESC,
2215 dev->tx_descs, dev->tx_phy_descs);
2216 dma_free_coherent(&dev->pci_dev->dev, 4 * DESC_SIZE * NR_RX_DESC,
2217 dev->rx_info.descs, dev->rx_info.phy_descs);
2218 pci_disable_device(dev->pci_dev);
2260 MODULE_PARM_DESC(ihr, "Time in 100 us increments to delay interrupts (range 0-127)");