Lines Matching refs:np
322 static void free_rxtx_rings(struct netdev_private *np);
326 static void free_ringdesc(struct netdev_private *np);
353 struct netdev_private *np; in w840_probe1() local
373 dev = alloc_etherdev(sizeof(*np)); in w840_probe1()
393 np = netdev_priv(dev); in w840_probe1()
394 np->pci_dev = pdev; in w840_probe1()
395 np->chip_id = chip_idx; in w840_probe1()
396 np->drv_flags = pci_id_tbl[chip_idx].drv_flags; in w840_probe1()
397 spin_lock_init(&np->lock); in w840_probe1()
398 np->mii_if.dev = dev; in w840_probe1()
399 np->mii_if.mdio_read = mdio_read; in w840_probe1()
400 np->mii_if.mdio_write = mdio_write; in w840_probe1()
401 np->base_addr = ioaddr; in w840_probe1()
411 np->mii_if.full_duplex = 1; in w840_probe1()
418 np->mii_if.full_duplex = 1; in w840_probe1()
420 if (np->mii_if.full_duplex) in w840_probe1()
421 np->mii_if.force_media = 1; in w840_probe1()
435 if (np->drv_flags & CanHaveMII) { in w840_probe1()
440 np->phys[phy_idx++] = phy; in w840_probe1()
441 np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE); in w840_probe1()
442 np->mii = (mdio_read(dev, phy, MII_PHYSID1) << 16)+ in w840_probe1()
446 np->mii, phy, mii_status, in w840_probe1()
447 np->mii_if.advertising); in w840_probe1()
450 np->mii_cnt = phy_idx; in w840_probe1()
451 np->mii_if.phy_id = np->phys[0]; in w840_probe1()
556 struct netdev_private *np = netdev_priv(dev); in mdio_read() local
557 void __iomem *mdio_addr = np->base_addr + MIICtrl; in mdio_read()
586 struct netdev_private *np = netdev_priv(dev); in mdio_write() local
587 void __iomem *mdio_addr = np->base_addr + MIICtrl; in mdio_write()
591 if (location == 4 && phy_id == np->phys[0]) in mdio_write()
592 np->mii_if.advertising = value; in mdio_write()
618 struct netdev_private *np = netdev_priv(dev); in netdev_open() local
619 void __iomem *ioaddr = np->base_addr; in netdev_open()
620 const int irq = np->pci_dev->irq; in netdev_open()
637 spin_lock_irq(&np->lock); in netdev_open()
640 spin_unlock_irq(&np->lock); in netdev_open()
647 timer_setup(&np->timer, netdev_timer, 0); in netdev_open()
648 np->timer.expires = jiffies + 1*HZ; in netdev_open()
649 add_timer(&np->timer); in netdev_open()
660 struct netdev_private *np = netdev_priv(dev); in update_link() local
664 mii_reg = mdio_read(dev, np->phys[0], MII_BMSR); in update_link()
667 return np->csr6; in update_link()
669 mii_reg = mdio_read(dev, np->phys[0], MII_BMSR); in update_link()
675 np->phys[0]); in update_link()
678 return np->csr6; in update_link()
684 np->phys[0]); in update_link()
688 if ((np->mii & ~0xf) == MII_DAVICOM_DM9101) { in update_link()
697 mii_reg = mdio_read(dev, np->phys[0], MII_BMCR); in update_link()
702 mii_reg = mdio_read(dev, np->phys[0], MII_LPA); in update_link()
703 negotiated = mii_reg & np->mii_if.advertising; in update_link()
708 duplex |= np->mii_if.force_media; in update_link()
710 result = np->csr6 & ~0x20000200; in update_link()
715 if (result != np->csr6 && debug) in update_link()
719 np->phys[0]); in update_link()
726 struct netdev_private *np = netdev_priv(dev); in update_csr6() local
727 void __iomem *ioaddr = np->base_addr; in update_csr6()
732 if (new==np->csr6) in update_csr6()
735 iowrite32(np->csr6 & ~0x2002, ioaddr + NetworkConfig); in update_csr6()
757 np->csr6 = new; in update_csr6()
759 iowrite32(np->csr6, ioaddr + NetworkConfig); in update_csr6()
761 np->mii_if.full_duplex = 1; in update_csr6()
766 struct netdev_private *np = from_timer(np, t, timer); in netdev_timer() local
767 struct net_device *dev = pci_get_drvdata(np->pci_dev); in netdev_timer()
768 void __iomem *ioaddr = np->base_addr; in netdev_timer()
774 spin_lock_irq(&np->lock); in netdev_timer()
776 spin_unlock_irq(&np->lock); in netdev_timer()
777 np->timer.expires = jiffies + 10*HZ; in netdev_timer()
778 add_timer(&np->timer); in netdev_timer()
783 struct netdev_private *np = netdev_priv(dev); in init_rxtx_rings() local
786 np->rx_head_desc = &np->rx_ring[0]; in init_rxtx_rings()
787 np->tx_ring = (struct w840_tx_desc*)&np->rx_ring[RX_RING_SIZE]; in init_rxtx_rings()
791 np->rx_ring[i].length = np->rx_buf_sz; in init_rxtx_rings()
792 np->rx_ring[i].status = 0; in init_rxtx_rings()
793 np->rx_skbuff[i] = NULL; in init_rxtx_rings()
796 np->rx_ring[i-1].length |= DescEndRing; in init_rxtx_rings()
800 struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz); in init_rxtx_rings()
801 np->rx_skbuff[i] = skb; in init_rxtx_rings()
804 np->rx_addr[i] = dma_map_single(&np->pci_dev->dev, skb->data, in init_rxtx_rings()
805 np->rx_buf_sz, in init_rxtx_rings()
808 np->rx_ring[i].buffer1 = np->rx_addr[i]; in init_rxtx_rings()
809 np->rx_ring[i].status = DescOwned; in init_rxtx_rings()
812 np->cur_rx = 0; in init_rxtx_rings()
813 np->dirty_rx = (unsigned int)(i - RX_RING_SIZE); in init_rxtx_rings()
817 np->tx_skbuff[i] = NULL; in init_rxtx_rings()
818 np->tx_ring[i].status = 0; in init_rxtx_rings()
820 np->tx_full = 0; in init_rxtx_rings()
821 np->tx_q_bytes = np->dirty_tx = np->cur_tx = 0; in init_rxtx_rings()
823 iowrite32(np->ring_dma_addr, np->base_addr + RxRingPtr); in init_rxtx_rings()
824 iowrite32(np->ring_dma_addr+sizeof(struct w840_rx_desc)*RX_RING_SIZE, in init_rxtx_rings()
825 np->base_addr + TxRingPtr); in init_rxtx_rings()
829 static void free_rxtx_rings(struct netdev_private* np) in free_rxtx_rings() argument
834 np->rx_ring[i].status = 0; in free_rxtx_rings()
835 if (np->rx_skbuff[i]) { in free_rxtx_rings()
836 dma_unmap_single(&np->pci_dev->dev, np->rx_addr[i], in free_rxtx_rings()
837 np->rx_skbuff[i]->len, in free_rxtx_rings()
839 dev_kfree_skb(np->rx_skbuff[i]); in free_rxtx_rings()
841 np->rx_skbuff[i] = NULL; in free_rxtx_rings()
844 if (np->tx_skbuff[i]) { in free_rxtx_rings()
845 dma_unmap_single(&np->pci_dev->dev, np->tx_addr[i], in free_rxtx_rings()
846 np->tx_skbuff[i]->len, DMA_TO_DEVICE); in free_rxtx_rings()
847 dev_kfree_skb(np->tx_skbuff[i]); in free_rxtx_rings()
849 np->tx_skbuff[i] = NULL; in free_rxtx_rings()
855 struct netdev_private *np = netdev_priv(dev); in init_registers() local
856 void __iomem *ioaddr = np->base_addr; in init_registers()
899 np->csr6 = 0; in init_registers()
913 struct netdev_private *np = netdev_priv(dev); in tx_timeout() local
914 void __iomem *ioaddr = np->base_addr; in tx_timeout()
915 const int irq = np->pci_dev->irq; in tx_timeout()
922 printk(KERN_DEBUG " Rx ring %p: ", np->rx_ring); in tx_timeout()
924 printk(KERN_CONT " %08x", (unsigned int)np->rx_ring[i].status); in tx_timeout()
926 printk(KERN_DEBUG " Tx ring %p: ", np->tx_ring); in tx_timeout()
928 printk(KERN_CONT " %08x", np->tx_ring[i].status); in tx_timeout()
932 np->cur_tx, np->dirty_tx, np->tx_full, np->tx_q_bytes); in tx_timeout()
936 spin_lock_irq(&np->lock); in tx_timeout()
943 iowrite32(1, np->base_addr+PCIBusCfg); in tx_timeout()
946 free_rxtx_rings(np); in tx_timeout()
949 spin_unlock_irq(&np->lock); in tx_timeout()
954 np->stats.tx_errors++; in tx_timeout()
960 struct netdev_private *np = netdev_priv(dev); in alloc_ringdesc() local
962 np->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32); in alloc_ringdesc()
964 np->rx_ring = dma_alloc_coherent(&np->pci_dev->dev, in alloc_ringdesc()
967 &np->ring_dma_addr, GFP_KERNEL); in alloc_ringdesc()
968 if(!np->rx_ring) in alloc_ringdesc()
974 static void free_ringdesc(struct netdev_private *np) in free_ringdesc() argument
976 dma_free_coherent(&np->pci_dev->dev, in free_ringdesc()
979 np->rx_ring, np->ring_dma_addr); in free_ringdesc()
985 struct netdev_private *np = netdev_priv(dev); in start_tx() local
992 entry = np->cur_tx % TX_RING_SIZE; in start_tx()
994 np->tx_addr[entry] = dma_map_single(&np->pci_dev->dev, skb->data, in start_tx()
996 np->tx_skbuff[entry] = skb; in start_tx()
998 np->tx_ring[entry].buffer1 = np->tx_addr[entry]; in start_tx()
1000 np->tx_ring[entry].length = DescWholePkt | skb->len; in start_tx()
1004 np->tx_ring[entry].buffer2 = np->tx_addr[entry]+TX_BUFLIMIT; in start_tx()
1005 np->tx_ring[entry].length = DescWholePkt | (len << 11) | TX_BUFLIMIT; in start_tx()
1008 np->tx_ring[entry].length |= DescEndRing; in start_tx()
1020 spin_lock_irq(&np->lock); in start_tx()
1021 np->cur_tx++; in start_tx()
1024 np->tx_ring[entry].status = DescOwned; in start_tx()
1026 iowrite32(0, np->base_addr + TxStartDemand); in start_tx()
1027 np->tx_q_bytes += skb->len; in start_tx()
1030 if (np->cur_tx - np->dirty_tx > TX_QUEUE_LEN || in start_tx()
1031 ((np->drv_flags & HasBrokenTx) && np->tx_q_bytes > TX_BUG_FIFO_LIMIT)) { in start_tx()
1034 np->tx_full = 1; in start_tx()
1036 spin_unlock_irq(&np->lock); in start_tx()
1040 np->cur_tx, entry); in start_tx()
1047 struct netdev_private *np = netdev_priv(dev); in netdev_tx_done() local
1048 for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) { in netdev_tx_done()
1049 int entry = np->dirty_tx % TX_RING_SIZE; in netdev_tx_done()
1050 int tx_status = np->tx_ring[entry].status; in netdev_tx_done()
1060 np->stats.tx_errors++; in netdev_tx_done()
1061 if (tx_status & 0x0104) np->stats.tx_aborted_errors++; in netdev_tx_done()
1062 if (tx_status & 0x0C80) np->stats.tx_carrier_errors++; in netdev_tx_done()
1063 if (tx_status & 0x0200) np->stats.tx_window_errors++; in netdev_tx_done()
1064 if (tx_status & 0x0002) np->stats.tx_fifo_errors++; in netdev_tx_done()
1065 if ((tx_status & 0x0080) && np->mii_if.full_duplex == 0) in netdev_tx_done()
1066 np->stats.tx_heartbeat_errors++; in netdev_tx_done()
1073 np->stats.tx_bytes += np->tx_skbuff[entry]->len; in netdev_tx_done()
1074 np->stats.collisions += (tx_status >> 3) & 15; in netdev_tx_done()
1075 np->stats.tx_packets++; in netdev_tx_done()
1078 dma_unmap_single(&np->pci_dev->dev, np->tx_addr[entry], in netdev_tx_done()
1079 np->tx_skbuff[entry]->len, DMA_TO_DEVICE); in netdev_tx_done()
1080 np->tx_q_bytes -= np->tx_skbuff[entry]->len; in netdev_tx_done()
1081 dev_kfree_skb_irq(np->tx_skbuff[entry]); in netdev_tx_done()
1082 np->tx_skbuff[entry] = NULL; in netdev_tx_done()
1084 if (np->tx_full && in netdev_tx_done()
1085 np->cur_tx - np->dirty_tx < TX_QUEUE_LEN_RESTART && in netdev_tx_done()
1086 np->tx_q_bytes < TX_BUG_FIFO_LIMIT) { in netdev_tx_done()
1088 np->tx_full = 0; in netdev_tx_done()
1099 struct netdev_private *np = netdev_priv(dev); in intr_handler() local
1100 void __iomem *ioaddr = np->base_addr; in intr_handler()
1126 np->cur_tx != np->dirty_tx) { in intr_handler()
1127 spin_lock(&np->lock); in intr_handler()
1129 spin_unlock(&np->lock); in intr_handler()
1143 spin_lock(&np->lock); in intr_handler()
1148 spin_unlock(&np->lock); in intr_handler()
1163 struct netdev_private *np = netdev_priv(dev); in netdev_rx() local
1164 int entry = np->cur_rx % RX_RING_SIZE; in netdev_rx()
1165 int work_limit = np->dirty_rx + RX_RING_SIZE - np->cur_rx; in netdev_rx()
1169 entry, np->rx_ring[entry].status); in netdev_rx()
1174 struct w840_rx_desc *desc = np->rx_head_desc; in netdev_rx()
1188 np->cur_rx, status); in netdev_rx()
1189 np->stats.rx_length_errors++; in netdev_rx()
1196 np->stats.rx_errors++; /* end of a packet.*/ in netdev_rx()
1197 if (status & 0x0890) np->stats.rx_length_errors++; in netdev_rx()
1198 if (status & 0x004C) np->stats.rx_frame_errors++; in netdev_rx()
1199 if (status & 0x0002) np->stats.rx_crc_errors++; in netdev_rx()
1216 dma_sync_single_for_cpu(&np->pci_dev->dev, in netdev_rx()
1217 np->rx_addr[entry], in netdev_rx()
1218 np->rx_skbuff[entry]->len, in netdev_rx()
1220 skb_copy_to_linear_data(skb, np->rx_skbuff[entry]->data, pkt_len); in netdev_rx()
1222 dma_sync_single_for_device(&np->pci_dev->dev, in netdev_rx()
1223 np->rx_addr[entry], in netdev_rx()
1224 np->rx_skbuff[entry]->len, in netdev_rx()
1227 dma_unmap_single(&np->pci_dev->dev, in netdev_rx()
1228 np->rx_addr[entry], in netdev_rx()
1229 np->rx_skbuff[entry]->len, in netdev_rx()
1231 skb_put(skb = np->rx_skbuff[entry], pkt_len); in netdev_rx()
1232 np->rx_skbuff[entry] = NULL; in netdev_rx()
1244 np->stats.rx_packets++; in netdev_rx()
1245 np->stats.rx_bytes += pkt_len; in netdev_rx()
1247 entry = (++np->cur_rx) % RX_RING_SIZE; in netdev_rx()
1248 np->rx_head_desc = &np->rx_ring[entry]; in netdev_rx()
1252 for (; np->cur_rx - np->dirty_rx > 0; np->dirty_rx++) { in netdev_rx()
1254 entry = np->dirty_rx % RX_RING_SIZE; in netdev_rx()
1255 if (np->rx_skbuff[entry] == NULL) { in netdev_rx()
1256 skb = netdev_alloc_skb(dev, np->rx_buf_sz); in netdev_rx()
1257 np->rx_skbuff[entry] = skb; in netdev_rx()
1260 np->rx_addr[entry] = dma_map_single(&np->pci_dev->dev, in netdev_rx()
1262 np->rx_buf_sz, in netdev_rx()
1264 np->rx_ring[entry].buffer1 = np->rx_addr[entry]; in netdev_rx()
1267 np->rx_ring[entry].status = DescOwned; in netdev_rx()
1275 struct netdev_private *np = netdev_priv(dev); in netdev_error() local
1276 void __iomem *ioaddr = np->base_addr; in netdev_error()
1282 spin_lock(&np->lock); in netdev_error()
1290 new = np->csr6 + 0x4000; in netdev_error()
1292 new = (np->csr6 >> 14)&0x7f; in netdev_error()
1297 new = (np->csr6 & ~(0x7F << 14)) | (new<<14); in netdev_error()
1303 np->stats.rx_errors++; in netdev_error()
1310 np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff; in netdev_error()
1312 spin_unlock(&np->lock); in netdev_error()
1317 struct netdev_private *np = netdev_priv(dev); in get_stats() local
1318 void __iomem *ioaddr = np->base_addr; in get_stats()
1321 spin_lock_irq(&np->lock); in get_stats()
1323 np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff; in get_stats()
1324 spin_unlock_irq(&np->lock); in get_stats()
1326 return &np->stats; in get_stats()
1332 struct netdev_private *np = netdev_priv(dev); in __set_rx_mode() local
1333 void __iomem *ioaddr = np->base_addr; in __set_rx_mode()
1366 struct netdev_private *np = netdev_priv(dev); in set_rx_mode() local
1368 spin_lock_irq(&np->lock); in set_rx_mode()
1369 update_csr6(dev, (np->csr6 & ~0x00F8) | rx_mode); in set_rx_mode()
1370 spin_unlock_irq(&np->lock); in set_rx_mode()
1375 struct netdev_private *np = netdev_priv(dev); in netdev_get_drvinfo() local
1378 strscpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); in netdev_get_drvinfo()
1384 struct netdev_private *np = netdev_priv(dev); in netdev_get_link_ksettings() local
1386 spin_lock_irq(&np->lock); in netdev_get_link_ksettings()
1387 mii_ethtool_get_link_ksettings(&np->mii_if, cmd); in netdev_get_link_ksettings()
1388 spin_unlock_irq(&np->lock); in netdev_get_link_ksettings()
1396 struct netdev_private *np = netdev_priv(dev); in netdev_set_link_ksettings() local
1399 spin_lock_irq(&np->lock); in netdev_set_link_ksettings()
1400 rc = mii_ethtool_set_link_ksettings(&np->mii_if, cmd); in netdev_set_link_ksettings()
1401 spin_unlock_irq(&np->lock); in netdev_set_link_ksettings()
1408 struct netdev_private *np = netdev_priv(dev); in netdev_nway_reset() local
1409 return mii_nway_restart(&np->mii_if); in netdev_nway_reset()
1414 struct netdev_private *np = netdev_priv(dev); in netdev_get_link() local
1415 return mii_link_ok(&np->mii_if); in netdev_get_link()
1441 struct netdev_private *np = netdev_priv(dev); in netdev_ioctl() local
1449 spin_lock_irq(&np->lock); in netdev_ioctl()
1451 spin_unlock_irq(&np->lock); in netdev_ioctl()
1455 spin_lock_irq(&np->lock); in netdev_ioctl()
1457 spin_unlock_irq(&np->lock); in netdev_ioctl()
1466 struct netdev_private *np = netdev_priv(dev); in netdev_close() local
1467 void __iomem *ioaddr = np->base_addr; in netdev_close()
1476 np->cur_tx, np->dirty_tx, in netdev_close()
1477 np->cur_rx, np->dirty_rx); in netdev_close()
1481 spin_lock_irq(&np->lock); in netdev_close()
1485 spin_unlock_irq(&np->lock); in netdev_close()
1487 free_irq(np->pci_dev->irq, dev); in netdev_close()
1492 np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff; in netdev_close()
1498 printk(KERN_DEBUG" Tx ring at %p:\n", np->tx_ring); in netdev_close()
1501 i, np->tx_ring[i].length, in netdev_close()
1502 np->tx_ring[i].status, np->tx_ring[i].buffer1); in netdev_close()
1503 printk(KERN_DEBUG " Rx ring %p:\n", np->rx_ring); in netdev_close()
1506 i, np->rx_ring[i].length, in netdev_close()
1507 np->rx_ring[i].status, np->rx_ring[i].buffer1); in netdev_close()
1512 del_timer_sync(&np->timer); in netdev_close()
1514 free_rxtx_rings(np); in netdev_close()
1515 free_ringdesc(np); in netdev_close()
1525 struct netdev_private *np = netdev_priv(dev); in w840_remove1() local
1527 pci_iounmap(pdev, np->base_addr); in w840_remove1()
1558 struct netdev_private *np = netdev_priv(dev); in w840_suspend() local
1559 void __iomem *ioaddr = np->base_addr; in w840_suspend()
1563 del_timer_sync(&np->timer); in w840_suspend()
1565 spin_lock_irq(&np->lock); in w840_suspend()
1569 spin_unlock_irq(&np->lock); in w840_suspend()
1571 synchronize_irq(np->pci_dev->irq); in w840_suspend()
1574 np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff; in w840_suspend()
1578 BUG_ON(np->csr6 || ioread32(ioaddr + IntrEnable)); in w840_suspend()
1582 free_rxtx_rings(np); in w840_suspend()
1593 struct netdev_private *np = netdev_priv(dev); in w840_resume() local
1599 spin_lock_irq(&np->lock); in w840_resume()
1600 iowrite32(1, np->base_addr+PCIBusCfg); in w840_resume()
1601 ioread32(np->base_addr+PCIBusCfg); in w840_resume()
1606 spin_unlock_irq(&np->lock); in w840_resume()
1610 mod_timer(&np->timer, jiffies + 1*HZ); in w840_resume()