Lines Matching refs:np

592 	struct netdev_private *np = netdev_priv(dev);  in netdev_vlan_rx_add_vid()  local
594 spin_lock(&np->lock); in netdev_vlan_rx_add_vid()
597 set_bit(vid, np->active_vlans); in netdev_vlan_rx_add_vid()
599 spin_unlock(&np->lock); in netdev_vlan_rx_add_vid()
607 struct netdev_private *np = netdev_priv(dev); in netdev_vlan_rx_kill_vid() local
609 spin_lock(&np->lock); in netdev_vlan_rx_kill_vid()
612 clear_bit(vid, np->active_vlans); in netdev_vlan_rx_kill_vid()
614 spin_unlock(&np->lock); in netdev_vlan_rx_kill_vid()
641 struct netdev_private *np; in starfire_init_one() local
660 dev = alloc_etherdev(sizeof(*np)); in starfire_init_one()
729 np = netdev_priv(dev); in starfire_init_one()
730 np->dev = dev; in starfire_init_one()
731 np->base = base; in starfire_init_one()
732 spin_lock_init(&np->lock); in starfire_init_one()
735 np->pci_dev = pdev; in starfire_init_one()
737 np->mii_if.dev = dev; in starfire_init_one()
738 np->mii_if.mdio_read = mdio_read; in starfire_init_one()
739 np->mii_if.mdio_write = mdio_write; in starfire_init_one()
740 np->mii_if.phy_id_mask = 0x1f; in starfire_init_one()
741 np->mii_if.reg_num_mask = 0x1f; in starfire_init_one()
745 np->speed100 = 1; in starfire_init_one()
748 np->intr_timer_ctrl = (((intr_latency * 10) / 1024) & IntrLatencyMask) | in starfire_init_one()
752 np->intr_timer_ctrl |= SmallFrameBypass; in starfire_init_one()
755 np->intr_timer_ctrl |= SmallFrame64; in starfire_init_one()
758 np->intr_timer_ctrl |= SmallFrame128; in starfire_init_one()
761 np->intr_timer_ctrl |= SmallFrame256; in starfire_init_one()
764 np->intr_timer_ctrl |= SmallFrame512; in starfire_init_one()
775 netif_napi_add_weight(dev, &np->napi, netdev_poll, max_interrupt_work); in starfire_init_one()
803 np->phys[phy_idx++] = phy; in starfire_init_one()
804 np->mii_if.advertising = mdio_read(dev, phy, MII_ADVERTISE); in starfire_init_one()
807 dev->name, phy, mii_status, np->mii_if.advertising); in starfire_init_one()
812 np->phy_cnt = phy_idx; in starfire_init_one()
813 if (np->phy_cnt > 0) in starfire_init_one()
814 np->mii_if.phy_id = np->phys[0]; in starfire_init_one()
816 memset(&np->mii_if, 0, sizeof(np->mii_if)); in starfire_init_one()
836 struct netdev_private *np = netdev_priv(dev); in mdio_read() local
837 void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2); in mdio_read()
853 struct netdev_private *np = netdev_priv(dev); in mdio_write() local
854 void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2); in mdio_write()
864 struct netdev_private *np = netdev_priv(dev); in netdev_open() local
865 void __iomem *ioaddr = np->base; in netdev_open()
866 const int irq = np->pci_dev->irq; in netdev_open()
885 if (!np->queue_mem) { in netdev_open()
890 np->queue_mem_size = tx_done_q_size + rx_done_q_size + tx_ring_size + rx_ring_size; in netdev_open()
891 np->queue_mem = dma_alloc_coherent(&np->pci_dev->dev, in netdev_open()
892 np->queue_mem_size, in netdev_open()
893 &np->queue_mem_dma, GFP_ATOMIC); in netdev_open()
894 if (np->queue_mem == NULL) { in netdev_open()
899 np->tx_done_q = np->queue_mem; in netdev_open()
900 np->tx_done_q_dma = np->queue_mem_dma; in netdev_open()
901 np->rx_done_q = (void *) np->tx_done_q + tx_done_q_size; in netdev_open()
902 np->rx_done_q_dma = np->tx_done_q_dma + tx_done_q_size; in netdev_open()
903 np->tx_ring = (void *) np->rx_done_q + rx_done_q_size; in netdev_open()
904 np->tx_ring_dma = np->rx_done_q_dma + rx_done_q_size; in netdev_open()
905 np->rx_ring = (void *) np->tx_ring + tx_ring_size; in netdev_open()
906 np->rx_ring_dma = np->tx_ring_dma + tx_ring_size; in netdev_open()
913 writel((np->rx_buf_sz << RxBufferLenShift) | in netdev_open()
936 writel( (np->queue_mem_dma >> 16) >> 16, ioaddr + RxDescQHiAddr); in netdev_open()
937 writel( (np->queue_mem_dma >> 16) >> 16, ioaddr + TxRingHiAddr); in netdev_open()
938 writel( (np->queue_mem_dma >> 16) >> 16, ioaddr + CompletionHiAddr); in netdev_open()
939 writel(np->rx_ring_dma, ioaddr + RxDescQAddr); in netdev_open()
940 writel(np->tx_ring_dma, ioaddr + TxRingPtr); in netdev_open()
942 writel(np->tx_done_q_dma, ioaddr + TxCompletionAddr); in netdev_open()
943 writel(np->rx_done_q_dma | in netdev_open()
969 np->tx_mode = TxFlowEnable|RxFlowEnable|PadEnable; /* modified when link is up. */ in netdev_open()
970 writel(MiiSoftReset | np->tx_mode, ioaddr + TxMode); in netdev_open()
972 writel(np->tx_mode, ioaddr + TxMode); in netdev_open()
973 np->tx_threshold = 4; in netdev_open()
974 writel(np->tx_threshold, ioaddr + TxThreshold); in netdev_open()
976 writel(np->intr_timer_ctrl, ioaddr + IntrTimerCtrl); in netdev_open()
978 napi_enable(&np->napi); in netdev_open()
986 np->mii_if.advertising = mdio_read(dev, np->phys[0], MII_ADVERTISE); in netdev_open()
1006 retval = request_firmware(&fw_rx, FIRMWARE_RX, &np->pci_dev->dev); in netdev_open()
1018 retval = request_firmware(&fw_tx, FIRMWARE_TX, &np->pci_dev->dev); in netdev_open()
1064 struct netdev_private *np = netdev_priv(dev); in check_duplex() local
1068 mdio_write(dev, np->phys[0], MII_ADVERTISE, np->mii_if.advertising); in check_duplex()
1069 mdio_write(dev, np->phys[0], MII_BMCR, BMCR_RESET); in check_duplex()
1071 while (--silly_count && mdio_read(dev, np->phys[0], MII_BMCR) & BMCR_RESET) in check_duplex()
1078 reg0 = mdio_read(dev, np->phys[0], MII_BMCR); in check_duplex()
1080 if (!np->mii_if.force_media) { in check_duplex()
1084 if (np->speed100) in check_duplex()
1086 if (np->mii_if.full_duplex) in check_duplex()
1090 np->speed100 ? "100" : "10", in check_duplex()
1091 np->mii_if.full_duplex ? "full" : "half"); in check_duplex()
1093 mdio_write(dev, np->phys[0], MII_BMCR, reg0); in check_duplex()
1099 struct netdev_private *np = netdev_priv(dev); in tx_timeout() local
1100 void __iomem *ioaddr = np->base; in tx_timeout()
1129 struct netdev_private *np = netdev_priv(dev); in init_ring() local
1132 np->cur_rx = np->cur_tx = np->reap_tx = 0; in init_ring()
1133 np->dirty_rx = np->dirty_tx = np->rx_done = np->tx_done = 0; in init_ring()
1135 np->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32); in init_ring()
1139 struct sk_buff *skb = netdev_alloc_skb(dev, np->rx_buf_sz); in init_ring()
1140 np->rx_info[i].skb = skb; in init_ring()
1143 np->rx_info[i].mapping = dma_map_single(&np->pci_dev->dev, in init_ring()
1145 np->rx_buf_sz, in init_ring()
1147 if (dma_mapping_error(&np->pci_dev->dev, np->rx_info[i].mapping)) { in init_ring()
1149 np->rx_info[i].skb = NULL; in init_ring()
1153 np->rx_ring[i].rxaddr = cpu_to_dma(np->rx_info[i].mapping | RxDescValid); in init_ring()
1155 writew(i - 1, np->base + RxDescQIdx); in init_ring()
1156 np->dirty_rx = (unsigned int)(i - RX_RING_SIZE); in init_ring()
1160 np->rx_ring[i].rxaddr = 0; in init_ring()
1161 np->rx_info[i].skb = NULL; in init_ring()
1162 np->rx_info[i].mapping = 0; in init_ring()
1165 np->rx_ring[RX_RING_SIZE - 1].rxaddr |= cpu_to_dma(RxDescEndRing); in init_ring()
1169 np->rx_done_q[i].status = 0; in init_ring()
1170 np->tx_done_q[i].status = 0; in init_ring()
1174 memset(&np->tx_info[i], 0, sizeof(np->tx_info[i])); in init_ring()
1180 struct netdev_private *np = netdev_priv(dev); in start_tx() local
1190 if ((np->cur_tx - np->dirty_tx) + skb_num_frags(skb) * 2 > TX_RING_SIZE) { in start_tx()
1202 prev_tx = np->cur_tx; in start_tx()
1203 entry = np->cur_tx % TX_RING_SIZE; in start_tx()
1209 np->tx_info[entry].skb = skb; in start_tx()
1215 if (np->reap_tx) { in start_tx()
1217 np->reap_tx = 0; in start_tx()
1225 np->tx_info[entry].mapping = in start_tx()
1226 dma_map_single(&np->pci_dev->dev, skb->data, in start_tx()
1232 np->tx_info[entry].mapping = in start_tx()
1233 dma_map_single(&np->pci_dev->dev, in start_tx()
1238 if (dma_mapping_error(&np->pci_dev->dev, np->tx_info[entry].mapping)) { in start_tx()
1243 np->tx_ring[entry].addr = cpu_to_dma(np->tx_info[entry].mapping); in start_tx()
1244 np->tx_ring[entry].status = cpu_to_le32(status); in start_tx()
1247 dev->name, np->cur_tx, np->dirty_tx, in start_tx()
1250 np->tx_info[entry].used_slots = TX_RING_SIZE - entry; in start_tx()
1251 np->cur_tx += np->tx_info[entry].used_slots; in start_tx()
1254 np->tx_info[entry].used_slots = 1; in start_tx()
1255 np->cur_tx += np->tx_info[entry].used_slots; in start_tx()
1259 if (np->cur_tx % (TX_RING_SIZE / 2) == 0) in start_tx()
1260 np->reap_tx = 1; in start_tx()
1269 writel(entry * (sizeof(starfire_tx_desc) / 8), np->base + TxProducerIdx); in start_tx()
1272 if ((np->cur_tx - np->dirty_tx) + 4 > TX_RING_SIZE) in start_tx()
1279 np->tx_info[entry].skb = NULL; in start_tx()
1281 dma_unmap_single(&np->pci_dev->dev, in start_tx()
1282 np->tx_info[entry].mapping, in start_tx()
1284 np->tx_info[entry].mapping = 0; in start_tx()
1285 entry = (entry + np->tx_info[entry].used_slots) % TX_RING_SIZE; in start_tx()
1287 dma_unmap_single(&np->pci_dev->dev, in start_tx()
1288 np->tx_info[entry].mapping, in start_tx()
1295 np->cur_tx = prev_tx; in start_tx()
1304 struct netdev_private *np = netdev_priv(dev); in intr_handler() local
1305 void __iomem *ioaddr = np->base; in intr_handler()
1326 if (likely(napi_schedule_prep(&np->napi))) { in intr_handler()
1327 __napi_schedule(&np->napi); in intr_handler()
1354 while ((tx_status = le32_to_cpu(np->tx_done_q[np->tx_done].status)) != 0) { in intr_handler()
1357 dev->name, np->dirty_tx, np->tx_done, tx_status); in intr_handler()
1362 struct sk_buff *skb = np->tx_info[entry].skb; in intr_handler()
1363 np->tx_info[entry].skb = NULL; in intr_handler()
1364 dma_unmap_single(&np->pci_dev->dev, in intr_handler()
1365 np->tx_info[entry].mapping, in intr_handler()
1368 np->tx_info[entry].mapping = 0; in intr_handler()
1369 np->dirty_tx += np->tx_info[entry].used_slots; in intr_handler()
1370 entry = (entry + np->tx_info[entry].used_slots) % TX_RING_SIZE; in intr_handler()
1374 dma_unmap_single(&np->pci_dev->dev, in intr_handler()
1375 np->tx_info[entry].mapping, in intr_handler()
1378 np->dirty_tx++; in intr_handler()
1385 np->tx_done_q[np->tx_done].status = 0; in intr_handler()
1386 np->tx_done = (np->tx_done + 1) % DONE_Q_SIZE; in intr_handler()
1388 writew(np->tx_done, ioaddr + CompletionQConsumerIdx + 2); in intr_handler()
1391 (np->cur_tx - np->dirty_tx + 4 < TX_RING_SIZE)) { in intr_handler()
1430 struct netdev_private *np = netdev_priv(dev); in __netdev_rx() local
1435 while ((desc_status = le32_to_cpu(np->rx_done_q[np->rx_done].status)) != 0) { in __netdev_rx()
1439 rx_done_desc *desc = &np->rx_done_q[np->rx_done]; in __netdev_rx()
1442 printk(KERN_DEBUG " netdev_rx() status of %d was %#8.8x.\n", np->rx_done, desc_status); in __netdev_rx()
1469 dma_sync_single_for_cpu(&np->pci_dev->dev, in __netdev_rx()
1470 np->rx_info[entry].mapping, in __netdev_rx()
1472 skb_copy_to_linear_data(skb, np->rx_info[entry].skb->data, pkt_len); in __netdev_rx()
1473 dma_sync_single_for_device(&np->pci_dev->dev, in __netdev_rx()
1474 np->rx_info[entry].mapping, in __netdev_rx()
1478 dma_unmap_single(&np->pci_dev->dev, in __netdev_rx()
1479 np->rx_info[entry].mapping, in __netdev_rx()
1480 np->rx_buf_sz, DMA_FROM_DEVICE); in __netdev_rx()
1481 skb = np->rx_info[entry].skb; in __netdev_rx()
1483 np->rx_info[entry].skb = NULL; in __netdev_rx()
1484 np->rx_info[entry].mapping = 0; in __netdev_rx()
1498 …printk(KERN_DEBUG " netdev_rx() status2 of %d was %#4.4x.\n", np->rx_done, le16_to_cpu(desc->stat… in __netdev_rx()
1533 np->cur_rx++; in __netdev_rx()
1535 np->rx_done = (np->rx_done + 1) % DONE_Q_SIZE; in __netdev_rx()
1542 writew(np->rx_done, np->base + CompletionQConsumerIdx); in __netdev_rx()
1548 retcode, np->rx_done, desc_status); in __netdev_rx()
1554 struct netdev_private *np = container_of(napi, struct netdev_private, napi); in netdev_poll() local
1555 struct net_device *dev = np->dev; in netdev_poll()
1557 void __iomem *ioaddr = np->base; in netdev_poll()
1585 struct netdev_private *np = netdev_priv(dev); in refill_rx_ring() local
1590 for (; np->cur_rx - np->dirty_rx > 0; np->dirty_rx++) { in refill_rx_ring()
1591 entry = np->dirty_rx % RX_RING_SIZE; in refill_rx_ring()
1592 if (np->rx_info[entry].skb == NULL) { in refill_rx_ring()
1593 skb = netdev_alloc_skb(dev, np->rx_buf_sz); in refill_rx_ring()
1594 np->rx_info[entry].skb = skb; in refill_rx_ring()
1597 np->rx_info[entry].mapping = in refill_rx_ring()
1598 dma_map_single(&np->pci_dev->dev, skb->data, in refill_rx_ring()
1599 np->rx_buf_sz, DMA_FROM_DEVICE); in refill_rx_ring()
1600 if (dma_mapping_error(&np->pci_dev->dev, np->rx_info[entry].mapping)) { in refill_rx_ring()
1602 np->rx_info[entry].skb = NULL; in refill_rx_ring()
1605 np->rx_ring[entry].rxaddr = in refill_rx_ring()
1606 cpu_to_dma(np->rx_info[entry].mapping | RxDescValid); in refill_rx_ring()
1609 np->rx_ring[entry].rxaddr |= cpu_to_dma(RxDescEndRing); in refill_rx_ring()
1612 writew(entry, np->base + RxDescQIdx); in refill_rx_ring()
1618 struct netdev_private *np = netdev_priv(dev); in netdev_media_change() local
1619 void __iomem *ioaddr = np->base; in netdev_media_change()
1625 mdio_read(dev, np->phys[0], MII_BMCR); in netdev_media_change()
1626 mdio_read(dev, np->phys[0], MII_BMSR); in netdev_media_change()
1628 reg0 = mdio_read(dev, np->phys[0], MII_BMCR); in netdev_media_change()
1629 reg1 = mdio_read(dev, np->phys[0], MII_BMSR); in netdev_media_change()
1635 reg4 = mdio_read(dev, np->phys[0], MII_ADVERTISE); in netdev_media_change()
1636 reg5 = mdio_read(dev, np->phys[0], MII_LPA); in netdev_media_change()
1638 np->speed100 = 1; in netdev_media_change()
1639 np->mii_if.full_duplex = 1; in netdev_media_change()
1641 np->speed100 = 1; in netdev_media_change()
1642 np->mii_if.full_duplex = 0; in netdev_media_change()
1644 np->speed100 = 0; in netdev_media_change()
1645 np->mii_if.full_duplex = 1; in netdev_media_change()
1647 np->speed100 = 0; in netdev_media_change()
1648 np->mii_if.full_duplex = 0; in netdev_media_change()
1653 np->speed100 = 1; in netdev_media_change()
1655 np->speed100 = 0; in netdev_media_change()
1657 np->mii_if.full_duplex = 1; in netdev_media_change()
1659 np->mii_if.full_duplex = 0; in netdev_media_change()
1664 np->speed100 ? "100" : "10", in netdev_media_change()
1665 np->mii_if.full_duplex ? "full" : "half"); in netdev_media_change()
1667 new_tx_mode = np->tx_mode & ~FullDuplex; /* duplex setting */ in netdev_media_change()
1668 if (np->mii_if.full_duplex) in netdev_media_change()
1670 if (np->tx_mode != new_tx_mode) { in netdev_media_change()
1671 np->tx_mode = new_tx_mode; in netdev_media_change()
1672 writel(np->tx_mode | MiiSoftReset, ioaddr + TxMode); in netdev_media_change()
1674 writel(np->tx_mode, ioaddr + TxMode); in netdev_media_change()
1677 new_intr_timer_ctrl = np->intr_timer_ctrl & ~Timer10X; in netdev_media_change()
1678 if (np->speed100) in netdev_media_change()
1680 if (np->intr_timer_ctrl != new_intr_timer_ctrl) { in netdev_media_change()
1681 np->intr_timer_ctrl = new_intr_timer_ctrl; in netdev_media_change()
1693 struct netdev_private *np = netdev_priv(dev); in netdev_error() local
1697 if (np->tx_threshold <= PKT_BUF_SZ / 16) { in netdev_error()
1698 writel(++np->tx_threshold, np->base + TxThreshold); in netdev_error()
1700 dev->name, np->tx_threshold * 16); in netdev_error()
1720 struct netdev_private *np = netdev_priv(dev); in get_stats() local
1721 void __iomem *ioaddr = np->base; in get_stats()
1745 static u32 set_vlan_mode(struct netdev_private *np) in set_vlan_mode() argument
1749 void __iomem *filter_addr = np->base + HashTable + 8; in set_vlan_mode()
1752 for_each_set_bit(vid, np->active_vlans, VLAN_N_VID) { in set_vlan_mode()
1773 struct netdev_private *np = netdev_priv(dev); in set_rx_mode() local
1774 void __iomem *ioaddr = np->base; in set_rx_mode()
1780 rx_mode |= set_vlan_mode(np); in set_rx_mode()
1846 struct netdev_private *np = netdev_priv(dev); in get_drvinfo() local
1848 strscpy(info->bus_info, pci_name(np->pci_dev), sizeof(info->bus_info)); in get_drvinfo()
1854 struct netdev_private *np = netdev_priv(dev); in get_link_ksettings() local
1855 spin_lock_irq(&np->lock); in get_link_ksettings()
1856 mii_ethtool_get_link_ksettings(&np->mii_if, cmd); in get_link_ksettings()
1857 spin_unlock_irq(&np->lock); in get_link_ksettings()
1864 struct netdev_private *np = netdev_priv(dev); in set_link_ksettings() local
1866 spin_lock_irq(&np->lock); in set_link_ksettings()
1867 res = mii_ethtool_set_link_ksettings(&np->mii_if, cmd); in set_link_ksettings()
1868 spin_unlock_irq(&np->lock); in set_link_ksettings()
1875 struct netdev_private *np = netdev_priv(dev); in nway_reset() local
1876 return mii_nway_restart(&np->mii_if); in nway_reset()
1881 struct netdev_private *np = netdev_priv(dev); in get_link() local
1882 return mii_link_ok(&np->mii_if); in get_link()
1908 struct netdev_private *np = netdev_priv(dev); in netdev_ioctl() local
1915 spin_lock_irq(&np->lock); in netdev_ioctl()
1916 rc = generic_mii_ioctl(&np->mii_if, data, cmd, NULL); in netdev_ioctl()
1917 spin_unlock_irq(&np->lock); in netdev_ioctl()
1919 if ((cmd == SIOCSMIIREG) && (data->phy_id == np->phys[0])) in netdev_ioctl()
1927 struct netdev_private *np = netdev_priv(dev); in netdev_close() local
1928 void __iomem *ioaddr = np->base; in netdev_close()
1933 napi_disable(&np->napi); in netdev_close()
1939 dev->name, np->cur_tx, np->dirty_tx, in netdev_close()
1940 np->cur_rx, np->dirty_rx); in netdev_close()
1952 (long long) np->tx_ring_dma); in netdev_close()
1955 i, le32_to_cpu(np->tx_ring[i].status), in netdev_close()
1956 (long long) dma_to_cpu(np->tx_ring[i].addr), in netdev_close()
1957 le32_to_cpu(np->tx_done_q[i].status)); in netdev_close()
1959 (long long) np->rx_ring_dma, np->rx_done_q); in netdev_close()
1960 if (np->rx_done_q) in netdev_close()
1963 i, (long long) dma_to_cpu(np->rx_ring[i].rxaddr), le32_to_cpu(np->rx_done_q[i].status)); in netdev_close()
1967 free_irq(np->pci_dev->irq, dev); in netdev_close()
1971 np->rx_ring[i].rxaddr = cpu_to_dma(0xBADF00D0); /* An invalid address. */ in netdev_close()
1972 if (np->rx_info[i].skb != NULL) { in netdev_close()
1973 dma_unmap_single(&np->pci_dev->dev, in netdev_close()
1974 np->rx_info[i].mapping, in netdev_close()
1975 np->rx_buf_sz, DMA_FROM_DEVICE); in netdev_close()
1976 dev_kfree_skb(np->rx_info[i].skb); in netdev_close()
1978 np->rx_info[i].skb = NULL; in netdev_close()
1979 np->rx_info[i].mapping = 0; in netdev_close()
1982 struct sk_buff *skb = np->tx_info[i].skb; in netdev_close()
1985 dma_unmap_single(&np->pci_dev->dev, np->tx_info[i].mapping, in netdev_close()
1987 np->tx_info[i].mapping = 0; in netdev_close()
1989 np->tx_info[i].skb = NULL; in netdev_close()
2022 struct netdev_private *np = netdev_priv(dev); in starfire_remove_one() local
2028 if (np->queue_mem) in starfire_remove_one()
2029 dma_free_coherent(&pdev->dev, np->queue_mem_size, in starfire_remove_one()
2030 np->queue_mem, np->queue_mem_dma); in starfire_remove_one()
2037 iounmap(np->base); in starfire_remove_one()