Lines Matching refs:np
52 static void dl2k_enable_int(struct netdev_private *np) in dl2k_enable_int() argument
54 void __iomem *ioaddr = np->ioaddr; in dl2k_enable_int()
106 struct netdev_private *np; in rio_probe1() local
127 dev = alloc_etherdev (sizeof (*np)); in rio_probe1()
132 np = netdev_priv(dev); in rio_probe1()
138 np->eeprom_addr = ioaddr; in rio_probe1()
146 np->ioaddr = ioaddr; in rio_probe1()
147 np->chip_id = chip_idx; in rio_probe1()
148 np->pdev = pdev; in rio_probe1()
149 spin_lock_init (&np->tx_lock); in rio_probe1()
150 spin_lock_init (&np->rx_lock); in rio_probe1()
153 np->an_enable = 1; in rio_probe1()
154 np->tx_coalesce = 1; in rio_probe1()
157 np->an_enable = 0; in rio_probe1()
161 np->an_enable = 2; in rio_probe1()
164 np->speed = 100; in rio_probe1()
165 np->full_duplex = 1; in rio_probe1()
168 np->speed = 100; in rio_probe1()
169 np->full_duplex = 0; in rio_probe1()
172 np->speed = 10; in rio_probe1()
173 np->full_duplex = 1; in rio_probe1()
176 np->speed = 10; in rio_probe1()
177 np->full_duplex = 0; in rio_probe1()
180 np->speed=1000; in rio_probe1()
181 np->full_duplex=1; in rio_probe1()
184 np->speed = 1000; in rio_probe1()
185 np->full_duplex = 0; in rio_probe1()
187 np->an_enable = 1; in rio_probe1()
191 np->jumbo = 1; in rio_probe1()
194 np->jumbo = 0; in rio_probe1()
198 np->vlan = (vlan[card_idx] > 0 && vlan[card_idx] < 4096) ? in rio_probe1()
201 np->rx_coalesce = rx_coalesce; in rio_probe1()
202 np->rx_timeout = rx_timeout; in rio_probe1()
203 np->coalesce = 1; in rio_probe1()
205 np->tx_flow = (tx_flow == 0) ? 0 : 1; in rio_probe1()
206 np->rx_flow = (rx_flow == 0) ? 0 : 1; in rio_probe1()
221 dev->max_mtu = np->jumbo ? MAX_JUMBO : PACKET_SIZE; in rio_probe1()
229 np->tx_ring = ring_space; in rio_probe1()
230 np->tx_ring_dma = ring_dma; in rio_probe1()
236 np->rx_ring = ring_space; in rio_probe1()
237 np->rx_ring_dma = ring_dma; in rio_probe1()
248 np->phy_media = (dr16(ASICCtrl) & PhyMedia) ? 1 : 0; in rio_probe1()
249 np->link_status = 0; in rio_probe1()
251 if (np->phy_media) { in rio_probe1()
253 if (np->an_enable == 2) { in rio_probe1()
254 np->an_enable = 1; in rio_probe1()
259 if (np->speed == 1000) in rio_probe1()
260 np->an_enable = 1; in rio_probe1()
270 dev->name, np->name, dev->dev_addr, irq); in rio_probe1()
274 if (np->coalesce) in rio_probe1()
278 np->rx_coalesce, np->rx_timeout*640); in rio_probe1()
279 if (np->vlan) in rio_probe1()
280 printk(KERN_INFO "vlan(id):\t%d\n", np->vlan); in rio_probe1()
284 dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, np->rx_ring, in rio_probe1()
285 np->rx_ring_dma); in rio_probe1()
287 dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, np->tx_ring, in rio_probe1()
288 np->tx_ring_dma); in rio_probe1()
291 pci_iounmap(pdev, np->ioaddr); in rio_probe1()
293 pci_iounmap(pdev, np->eeprom_addr); in rio_probe1()
306 struct netdev_private *np = netdev_priv(dev); in find_miiphy() local
309 np->phy_addr = 1; in find_miiphy()
314 np->phy_addr = i; in find_miiphy()
328 struct netdev_private *np = netdev_priv(dev); in parse_eeprom() local
329 void __iomem *ioaddr = np->ioaddr; in parse_eeprom()
339 ((__le16 *) sromdata)[i] = cpu_to_le16(read_eeprom(np, i)); in parse_eeprom()
341 if (np->pdev->vendor == PCI_VENDOR_ID_DLINK) { /* D-Link Only */ in parse_eeprom()
354 if (np->chip_id == CHIP_IP1000A) { in parse_eeprom()
355 np->led_mode = psrom->led_mode; in parse_eeprom()
359 if (np->pdev->vendor != PCI_VENDOR_ID_DLINK) { in parse_eeprom()
379 np->duplex_polarity = psib[i]; in parse_eeprom()
383 np->wake_polarity = psib[i]; in parse_eeprom()
387 memcpy (np->name, &(psib[i]), j); in parse_eeprom()
406 struct netdev_private *np = netdev_priv(dev); in rio_set_led_mode() local
407 void __iomem *ioaddr = np->ioaddr; in rio_set_led_mode()
410 if (np->chip_id != CHIP_IP1000A) in rio_set_led_mode()
416 if (np->led_mode & 0x01) in rio_set_led_mode()
418 if (np->led_mode & 0x02) in rio_set_led_mode()
420 if (np->led_mode & 0x08) in rio_set_led_mode()
433 struct netdev_private *np = netdev_priv(dev); in free_list() local
439 skb = np->rx_skbuff[i]; in free_list()
441 dma_unmap_single(&np->pdev->dev, in free_list()
442 desc_to_dma(&np->rx_ring[i]), in free_list()
445 np->rx_skbuff[i] = NULL; in free_list()
447 np->rx_ring[i].status = 0; in free_list()
448 np->rx_ring[i].fraginfo = 0; in free_list()
451 skb = np->tx_skbuff[i]; in free_list()
453 dma_unmap_single(&np->pdev->dev, in free_list()
454 desc_to_dma(&np->tx_ring[i]), in free_list()
457 np->tx_skbuff[i] = NULL; in free_list()
462 static void rio_reset_ring(struct netdev_private *np) in rio_reset_ring() argument
466 np->cur_rx = 0; in rio_reset_ring()
467 np->cur_tx = 0; in rio_reset_ring()
468 np->old_rx = 0; in rio_reset_ring()
469 np->old_tx = 0; in rio_reset_ring()
472 np->tx_ring[i].status = cpu_to_le64(TFDDone); in rio_reset_ring()
475 np->rx_ring[i].status = 0; in rio_reset_ring()
481 struct netdev_private *np = netdev_priv(dev); in alloc_list() local
484 rio_reset_ring(np); in alloc_list()
485 np->rx_buf_sz = (dev->mtu <= 1500 ? PACKET_SIZE : dev->mtu + 32); in alloc_list()
489 np->tx_skbuff[i] = NULL; in alloc_list()
490 np->tx_ring[i].next_desc = cpu_to_le64(np->tx_ring_dma + in alloc_list()
500 skb = netdev_alloc_skb_ip_align(dev, np->rx_buf_sz); in alloc_list()
501 np->rx_skbuff[i] = skb; in alloc_list()
507 np->rx_ring[i].next_desc = cpu_to_le64(np->rx_ring_dma + in alloc_list()
511 np->rx_ring[i].fraginfo = in alloc_list()
512 cpu_to_le64(dma_map_single(&np->pdev->dev, skb->data, in alloc_list()
513 np->rx_buf_sz, DMA_FROM_DEVICE)); in alloc_list()
514 np->rx_ring[i].fraginfo |= cpu_to_le64((u64)np->rx_buf_sz << 48); in alloc_list()
522 struct netdev_private *np = netdev_priv(dev); in rio_hw_init() local
523 void __iomem *ioaddr = np->ioaddr; in rio_hw_init()
537 if (np->chip_id == CHIP_IP1000A && in rio_hw_init()
538 (np->pdev->revision == 0x40 || np->pdev->revision == 0x41)) { in rio_hw_init()
540 mii_write(dev, np->phy_addr, 31, 0x0001); in rio_hw_init()
541 mii_write(dev, np->phy_addr, 27, 0x01e0); in rio_hw_init()
542 mii_write(dev, np->phy_addr, 31, 0x0002); in rio_hw_init()
543 mii_write(dev, np->phy_addr, 27, 0xeb8e); in rio_hw_init()
544 mii_write(dev, np->phy_addr, 31, 0x0000); in rio_hw_init()
545 mii_write(dev, np->phy_addr, 30, 0x005e); in rio_hw_init()
547 mii_write(dev, np->phy_addr, MII_CTRL1000, 0x0700); in rio_hw_init()
550 if (np->phy_media) in rio_hw_init()
556 if (np->jumbo != 0) in rio_hw_init()
560 dw32(RFDListPtr0, np->rx_ring_dma); in rio_hw_init()
572 if (np->coalesce) { in rio_hw_init()
573 dw32(RxDMAIntCtrl, np->rx_coalesce | np->rx_timeout << 16); in rio_hw_init()
585 if (np->vlan) { in rio_hw_init()
589 dw16(VLANId, np->vlan); in rio_hw_init()
591 dw32(VLANTag, 0x8100 << 16 | np->vlan); in rio_hw_init()
601 macctrl |= (np->vlan) ? AutoVLANuntagging : 0; in rio_hw_init()
602 macctrl |= (np->full_duplex) ? DuplexSelect : 0; in rio_hw_init()
603 macctrl |= (np->tx_flow) ? TxFlowControlEnable : 0; in rio_hw_init()
604 macctrl |= (np->rx_flow) ? RxFlowControlEnable : 0; in rio_hw_init()
610 struct netdev_private *np = netdev_priv(dev); in rio_hw_stop() local
611 void __iomem *ioaddr = np->ioaddr; in rio_hw_stop()
622 struct netdev_private *np = netdev_priv(dev); in rio_open() local
623 const int irq = np->pdev->irq; in rio_open()
639 timer_setup(&np->timer, rio_timer, 0); in rio_open()
640 np->timer.expires = jiffies + 1 * HZ; in rio_open()
641 add_timer(&np->timer); in rio_open()
645 dl2k_enable_int(np); in rio_open()
652 struct netdev_private *np = from_timer(np, t, timer); in rio_timer() local
653 struct net_device *dev = pci_get_drvdata(np->pdev); in rio_timer()
658 spin_lock_irqsave(&np->rx_lock, flags); in rio_timer()
660 if (np->cur_rx - np->old_rx >= RX_RING_SIZE) { in rio_timer()
663 for (; np->cur_rx - np->old_rx > 0; np->old_rx++) { in rio_timer()
665 entry = np->old_rx % RX_RING_SIZE; in rio_timer()
667 if (np->rx_skbuff[entry] == NULL) { in rio_timer()
669 np->rx_buf_sz); in rio_timer()
671 np->rx_ring[entry].fraginfo = 0; in rio_timer()
677 np->rx_skbuff[entry] = skb; in rio_timer()
678 np->rx_ring[entry].fraginfo = in rio_timer()
679 cpu_to_le64 (dma_map_single(&np->pdev->dev, skb->data, in rio_timer()
680 np->rx_buf_sz, DMA_FROM_DEVICE)); in rio_timer()
682 np->rx_ring[entry].fraginfo |= in rio_timer()
683 cpu_to_le64((u64)np->rx_buf_sz << 48); in rio_timer()
684 np->rx_ring[entry].status = 0; in rio_timer()
687 spin_unlock_irqrestore (&np->rx_lock, flags); in rio_timer()
688 np->timer.expires = jiffies + next_tick; in rio_timer()
689 add_timer(&np->timer); in rio_timer()
695 struct netdev_private *np = netdev_priv(dev); in rio_tx_timeout() local
696 void __iomem *ioaddr = np->ioaddr; in rio_tx_timeout()
708 struct netdev_private *np = netdev_priv(dev); in start_xmit() local
709 void __iomem *ioaddr = np->ioaddr; in start_xmit()
714 if (np->link_status == 0) { /* Link Down */ in start_xmit()
718 entry = np->cur_tx % TX_RING_SIZE; in start_xmit()
719 np->tx_skbuff[entry] = skb; in start_xmit()
720 txdesc = &np->tx_ring[entry]; in start_xmit()
729 if (np->vlan) { in start_xmit()
731 ((u64)np->vlan << 32) | in start_xmit()
734 txdesc->fraginfo = cpu_to_le64 (dma_map_single(&np->pdev->dev, skb->data, in start_xmit()
740 if (entry % np->tx_coalesce == 0 || np->speed == 10) in start_xmit()
754 np->cur_tx = (np->cur_tx + 1) % TX_RING_SIZE; in start_xmit()
755 if ((np->cur_tx - np->old_tx + TX_RING_SIZE) % TX_RING_SIZE in start_xmit()
756 < TX_QUEUE_LEN - 1 && np->speed != 10) { in start_xmit()
764 dw32(TFDListPtr0, np->tx_ring_dma + in start_xmit()
776 struct netdev_private *np = netdev_priv(dev); in rio_interrupt() local
777 void __iomem *ioaddr = np->ioaddr; in rio_interrupt()
807 if (np->cur_tx != np->old_tx) in rio_interrupt()
815 struct netdev_private *np = netdev_priv(dev); in rio_free_tx() local
816 int entry = np->old_tx % TX_RING_SIZE; in rio_free_tx()
820 spin_lock(&np->tx_lock); in rio_free_tx()
822 spin_lock_irqsave(&np->tx_lock, flag); in rio_free_tx()
825 while (entry != np->cur_tx) { in rio_free_tx()
828 if (!(np->tx_ring[entry].status & cpu_to_le64(TFDDone))) in rio_free_tx()
830 skb = np->tx_skbuff[entry]; in rio_free_tx()
831 dma_unmap_single(&np->pdev->dev, in rio_free_tx()
832 desc_to_dma(&np->tx_ring[entry]), skb->len, in rio_free_tx()
839 np->tx_skbuff[entry] = NULL; in rio_free_tx()
843 spin_unlock(&np->tx_lock); in rio_free_tx()
845 spin_unlock_irqrestore(&np->tx_lock, flag); in rio_free_tx()
846 np->old_tx = entry; in rio_free_tx()
852 ((np->cur_tx - np->old_tx + TX_RING_SIZE) % TX_RING_SIZE in rio_free_tx()
853 < TX_QUEUE_LEN - 1 || np->speed == 10)) { in rio_free_tx()
861 struct netdev_private *np = netdev_priv(dev); in tx_error() local
862 void __iomem *ioaddr = np->ioaddr; in tx_error()
886 dw32(TFDListPtr0, np->tx_ring_dma + in tx_error()
887 np->old_tx * sizeof (struct netdev_desc)); in tx_error()
916 struct netdev_private *np = netdev_priv(dev); in receive_packet() local
917 int entry = np->cur_rx % RX_RING_SIZE; in receive_packet()
922 struct netdev_desc *desc = &np->rx_ring[entry]; in receive_packet()
943 if (frame_status & RxAlignmentError && np->speed != 1000) in receive_packet()
952 dma_unmap_single(&np->pdev->dev, in receive_packet()
954 np->rx_buf_sz, in receive_packet()
956 skb_put (skb = np->rx_skbuff[entry], pkt_len); in receive_packet()
957 np->rx_skbuff[entry] = NULL; in receive_packet()
959 dma_sync_single_for_cpu(&np->pdev->dev, in receive_packet()
961 np->rx_buf_sz, in receive_packet()
964 np->rx_skbuff[entry]->data, in receive_packet()
967 dma_sync_single_for_device(&np->pdev->dev, in receive_packet()
969 np->rx_buf_sz, in receive_packet()
975 if (np->pdev->pci_rev_id >= 0x0c && in receive_packet()
984 spin_lock(&np->rx_lock); in receive_packet()
985 np->cur_rx = entry; in receive_packet()
987 entry = np->old_rx; in receive_packet()
988 while (entry != np->cur_rx) { in receive_packet()
991 if (np->rx_skbuff[entry] == NULL) { in receive_packet()
992 skb = netdev_alloc_skb_ip_align(dev, np->rx_buf_sz); in receive_packet()
994 np->rx_ring[entry].fraginfo = 0; in receive_packet()
1001 np->rx_skbuff[entry] = skb; in receive_packet()
1002 np->rx_ring[entry].fraginfo = in receive_packet()
1003 cpu_to_le64(dma_map_single(&np->pdev->dev, skb->data, in receive_packet()
1004 np->rx_buf_sz, DMA_FROM_DEVICE)); in receive_packet()
1006 np->rx_ring[entry].fraginfo |= in receive_packet()
1007 cpu_to_le64((u64)np->rx_buf_sz << 48); in receive_packet()
1008 np->rx_ring[entry].status = 0; in receive_packet()
1011 np->old_rx = entry; in receive_packet()
1012 spin_unlock(&np->rx_lock); in receive_packet()
1019 struct netdev_private *np = netdev_priv(dev); in rio_error() local
1020 void __iomem *ioaddr = np->ioaddr; in rio_error()
1027 if (np->phy_media) in rio_error()
1031 if (np->speed == 1000) in rio_error()
1032 np->tx_coalesce = tx_coalesce; in rio_error()
1034 np->tx_coalesce = 1; in rio_error()
1036 macctrl |= (np->vlan) ? AutoVLANuntagging : 0; in rio_error()
1037 macctrl |= (np->full_duplex) ? DuplexSelect : 0; in rio_error()
1038 macctrl |= (np->tx_flow) ? in rio_error()
1040 macctrl |= (np->rx_flow) ? in rio_error()
1043 np->link_status = 1; in rio_error()
1047 np->link_status = 0; in rio_error()
1071 struct netdev_private *np = netdev_priv(dev); in get_stats() local
1072 void __iomem *ioaddr = np->ioaddr; in get_stats()
1133 struct netdev_private *np = netdev_priv(dev); in clear_stats() local
1134 void __iomem *ioaddr = np->ioaddr; in clear_stats()
1188 struct netdev_private *np = netdev_priv(dev); in set_multicast() local
1189 void __iomem *ioaddr = np->ioaddr; in set_multicast()
1222 if (np->vlan) { in set_multicast()
1234 struct netdev_private *np = netdev_priv(dev); in rio_get_drvinfo() local
1237 strscpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info)); in rio_get_drvinfo()
1243 struct netdev_private *np = netdev_priv(dev); in rio_get_link_ksettings() local
1246 if (np->phy_media) { in rio_get_link_ksettings()
1263 if (np->link_status) { in rio_get_link_ksettings()
1264 cmd->base.speed = np->speed; in rio_get_link_ksettings()
1265 cmd->base.duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF; in rio_get_link_ksettings()
1270 if (np->an_enable) in rio_get_link_ksettings()
1275 cmd->base.phy_address = np->phy_addr; in rio_get_link_ksettings()
1288 struct netdev_private *np = netdev_priv(dev); in rio_set_link_ksettings() local
1294 if (np->an_enable) { in rio_set_link_ksettings()
1297 np->an_enable = 1; in rio_set_link_ksettings()
1302 np->an_enable = 0; in rio_set_link_ksettings()
1303 if (np->speed == 1000) { in rio_set_link_ksettings()
1310 np->speed = 10; in rio_set_link_ksettings()
1311 np->full_duplex = (duplex == DUPLEX_FULL); in rio_set_link_ksettings()
1314 np->speed = 100; in rio_set_link_ksettings()
1315 np->full_duplex = (duplex == DUPLEX_FULL); in rio_set_link_ksettings()
1328 struct netdev_private *np = netdev_priv(dev); in rio_get_link() local
1329 return np->link_status; in rio_get_link()
1343 struct netdev_private *np = netdev_priv(dev); in rio_ioctl() local
1346 phy_addr = np->phy_addr; in rio_ioctl()
1369 static int read_eeprom(struct netdev_private *np, int eep_addr) in read_eeprom() argument
1371 void __iomem *ioaddr = np->eeprom_addr; in read_eeprom()
1391 struct netdev_private *np = netdev_priv(dev); in mii_sendbit() local
1392 void __iomem *ioaddr = np->ioaddr; in mii_sendbit()
1404 struct netdev_private *np = netdev_priv(dev); in mii_getbit() local
1405 void __iomem *ioaddr = np->ioaddr; in mii_getbit()
1474 struct netdev_private *np; in mii_wait_link() local
1476 np = netdev_priv(dev); in mii_wait_link()
1477 phy_addr = np->phy_addr; in mii_wait_link()
1495 struct netdev_private *np; in mii_get_media() local
1497 np = netdev_priv(dev); in mii_get_media()
1498 phy_addr = np->phy_addr; in mii_get_media()
1501 if (np->an_enable) { in mii_get_media()
1511 np->speed = 1000; in mii_get_media()
1512 np->full_duplex = 1; in mii_get_media()
1515 np->speed = 1000; in mii_get_media()
1516 np->full_duplex = 0; in mii_get_media()
1519 np->speed = 100; in mii_get_media()
1520 np->full_duplex = 1; in mii_get_media()
1523 np->speed = 100; in mii_get_media()
1524 np->full_duplex = 0; in mii_get_media()
1527 np->speed = 10; in mii_get_media()
1528 np->full_duplex = 1; in mii_get_media()
1531 np->speed = 10; in mii_get_media()
1532 np->full_duplex = 0; in mii_get_media()
1536 np->tx_flow &= 1; in mii_get_media()
1537 np->rx_flow &= 1; in mii_get_media()
1539 np->tx_flow = 0; in mii_get_media()
1540 np->rx_flow &= 1; in mii_get_media()
1561 if (np->tx_flow) in mii_get_media()
1565 if (np->rx_flow) in mii_get_media()
1581 struct netdev_private *np; in mii_set_media() local
1582 np = netdev_priv(dev); in mii_set_media()
1583 phy_addr = np->phy_addr; in mii_set_media()
1586 if (np->an_enable) { in mii_set_media()
1638 if (np->speed == 100) { in mii_set_media()
1641 } else if (np->speed == 10) { in mii_set_media()
1644 if (np->full_duplex) { in mii_set_media()
1668 struct netdev_private *np; in mii_get_media_pcs() local
1670 np = netdev_priv(dev); in mii_get_media_pcs()
1671 phy_addr = np->phy_addr; in mii_get_media_pcs()
1674 if (np->an_enable) { in mii_get_media_pcs()
1681 np->speed = 1000; in mii_get_media_pcs()
1684 np->full_duplex = 1; in mii_get_media_pcs()
1687 np->full_duplex = 0; in mii_get_media_pcs()
1690 np->tx_flow &= 1; in mii_get_media_pcs()
1691 np->rx_flow &= 1; in mii_get_media_pcs()
1693 np->tx_flow = 0; in mii_get_media_pcs()
1694 np->rx_flow &= 1; in mii_get_media_pcs()
1706 if (np->tx_flow) in mii_get_media_pcs()
1710 if (np->rx_flow) in mii_get_media_pcs()
1725 struct netdev_private *np; in mii_set_media_pcs() local
1726 np = netdev_priv(dev); in mii_set_media_pcs()
1727 phy_addr = np->phy_addr; in mii_set_media_pcs()
1730 if (np->an_enable) { in mii_set_media_pcs()
1754 if (np->full_duplex) { in mii_set_media_pcs()
1774 struct netdev_private *np = netdev_priv(dev); in rio_close() local
1775 struct pci_dev *pdev = np->pdev; in rio_close()
1782 del_timer_sync (&np->timer); in rio_close()
1795 struct netdev_private *np = netdev_priv(dev); in rio_remove1() local
1798 dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, np->rx_ring, in rio_remove1()
1799 np->rx_ring_dma); in rio_remove1()
1800 dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, np->tx_ring, in rio_remove1()
1801 np->tx_ring_dma); in rio_remove1()
1803 pci_iounmap(pdev, np->ioaddr); in rio_remove1()
1805 pci_iounmap(pdev, np->eeprom_addr); in rio_remove1()
1816 struct netdev_private *np = netdev_priv(dev); in rio_suspend() local
1822 del_timer_sync(&np->timer); in rio_suspend()
1831 struct netdev_private *np = netdev_priv(dev); in rio_resume() local
1836 rio_reset_ring(np); in rio_resume()
1838 np->timer.expires = jiffies + 1 * HZ; in rio_resume()
1839 add_timer(&np->timer); in rio_resume()
1841 dl2k_enable_int(np); in rio_resume()