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()
821 spin_lock(&np->tx_lock); in rio_free_tx()
823 spin_lock_irqsave(&np->tx_lock, flag); in rio_free_tx()
826 while (entry != np->cur_tx) { in rio_free_tx()
829 if (!(np->tx_ring[entry].status & cpu_to_le64(TFDDone))) in rio_free_tx()
831 skb = np->tx_skbuff[entry]; in rio_free_tx()
832 dma_unmap_single(&np->pdev->dev, in rio_free_tx()
833 desc_to_dma(&np->tx_ring[entry]), skb->len, in rio_free_tx()
840 np->tx_skbuff[entry] = NULL; in rio_free_tx()
845 spin_unlock(&np->tx_lock); in rio_free_tx()
847 spin_unlock_irqrestore(&np->tx_lock, flag); in rio_free_tx()
848 np->old_tx = entry; in rio_free_tx()
854 ((np->cur_tx - np->old_tx + TX_RING_SIZE) % TX_RING_SIZE in rio_free_tx()
855 < TX_QUEUE_LEN - 1 || np->speed == 10)) { in rio_free_tx()
863 struct netdev_private *np = netdev_priv(dev); in tx_error() local
864 void __iomem *ioaddr = np->ioaddr; in tx_error()
888 dw32(TFDListPtr0, np->tx_ring_dma + in tx_error()
889 np->old_tx * sizeof (struct netdev_desc)); in tx_error()
918 struct netdev_private *np = netdev_priv(dev); in receive_packet() local
919 int entry = np->cur_rx % RX_RING_SIZE; in receive_packet()
924 struct netdev_desc *desc = &np->rx_ring[entry]; in receive_packet()
945 if (frame_status & RxAlignmentError && np->speed != 1000) in receive_packet()
954 dma_unmap_single(&np->pdev->dev, in receive_packet()
956 np->rx_buf_sz, in receive_packet()
958 skb_put (skb = np->rx_skbuff[entry], pkt_len); in receive_packet()
959 np->rx_skbuff[entry] = NULL; in receive_packet()
961 dma_sync_single_for_cpu(&np->pdev->dev, in receive_packet()
963 np->rx_buf_sz, in receive_packet()
966 np->rx_skbuff[entry]->data, in receive_packet()
969 dma_sync_single_for_device(&np->pdev->dev, in receive_packet()
971 np->rx_buf_sz, in receive_packet()
977 if (np->pdev->pci_rev_id >= 0x0c && in receive_packet()
986 spin_lock(&np->rx_lock); in receive_packet()
987 np->cur_rx = entry; in receive_packet()
989 entry = np->old_rx; in receive_packet()
990 while (entry != np->cur_rx) { in receive_packet()
993 if (np->rx_skbuff[entry] == NULL) { in receive_packet()
994 skb = netdev_alloc_skb_ip_align(dev, np->rx_buf_sz); in receive_packet()
996 np->rx_ring[entry].fraginfo = 0; in receive_packet()
1003 np->rx_skbuff[entry] = skb; in receive_packet()
1004 np->rx_ring[entry].fraginfo = in receive_packet()
1005 cpu_to_le64(dma_map_single(&np->pdev->dev, skb->data, in receive_packet()
1006 np->rx_buf_sz, DMA_FROM_DEVICE)); in receive_packet()
1008 np->rx_ring[entry].fraginfo |= in receive_packet()
1009 cpu_to_le64((u64)np->rx_buf_sz << 48); in receive_packet()
1010 np->rx_ring[entry].status = 0; in receive_packet()
1013 np->old_rx = entry; in receive_packet()
1014 spin_unlock(&np->rx_lock); in receive_packet()
1021 struct netdev_private *np = netdev_priv(dev); in rio_error() local
1022 void __iomem *ioaddr = np->ioaddr; in rio_error()
1029 if (np->phy_media) in rio_error()
1033 if (np->speed == 1000) in rio_error()
1034 np->tx_coalesce = tx_coalesce; in rio_error()
1036 np->tx_coalesce = 1; in rio_error()
1038 macctrl |= (np->vlan) ? AutoVLANuntagging : 0; in rio_error()
1039 macctrl |= (np->full_duplex) ? DuplexSelect : 0; in rio_error()
1040 macctrl |= (np->tx_flow) ? in rio_error()
1042 macctrl |= (np->rx_flow) ? in rio_error()
1045 np->link_status = 1; in rio_error()
1049 np->link_status = 0; in rio_error()
1073 struct netdev_private *np = netdev_priv(dev); in get_stats() local
1074 void __iomem *ioaddr = np->ioaddr; in get_stats()
1135 struct netdev_private *np = netdev_priv(dev); in clear_stats() local
1136 void __iomem *ioaddr = np->ioaddr; in clear_stats()
1190 struct netdev_private *np = netdev_priv(dev); in set_multicast() local
1191 void __iomem *ioaddr = np->ioaddr; in set_multicast()
1224 if (np->vlan) { in set_multicast()
1236 struct netdev_private *np = netdev_priv(dev); in rio_get_drvinfo() local
1239 strscpy(info->bus_info, pci_name(np->pdev), sizeof(info->bus_info)); in rio_get_drvinfo()
1245 struct netdev_private *np = netdev_priv(dev); in rio_get_link_ksettings() local
1248 if (np->phy_media) { in rio_get_link_ksettings()
1265 if (np->link_status) { in rio_get_link_ksettings()
1266 cmd->base.speed = np->speed; in rio_get_link_ksettings()
1267 cmd->base.duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF; in rio_get_link_ksettings()
1272 if (np->an_enable) in rio_get_link_ksettings()
1277 cmd->base.phy_address = np->phy_addr; in rio_get_link_ksettings()
1290 struct netdev_private *np = netdev_priv(dev); in rio_set_link_ksettings() local
1296 if (np->an_enable) { in rio_set_link_ksettings()
1299 np->an_enable = 1; in rio_set_link_ksettings()
1304 np->an_enable = 0; in rio_set_link_ksettings()
1305 if (np->speed == 1000) { in rio_set_link_ksettings()
1312 np->speed = 10; in rio_set_link_ksettings()
1313 np->full_duplex = (duplex == DUPLEX_FULL); in rio_set_link_ksettings()
1316 np->speed = 100; in rio_set_link_ksettings()
1317 np->full_duplex = (duplex == DUPLEX_FULL); in rio_set_link_ksettings()
1330 struct netdev_private *np = netdev_priv(dev); in rio_get_link() local
1331 return np->link_status; in rio_get_link()
1345 struct netdev_private *np = netdev_priv(dev); in rio_ioctl() local
1348 phy_addr = np->phy_addr; in rio_ioctl()
1371 static int read_eeprom(struct netdev_private *np, int eep_addr) in read_eeprom() argument
1373 void __iomem *ioaddr = np->eeprom_addr; in read_eeprom()
1393 struct netdev_private *np = netdev_priv(dev); in mii_sendbit() local
1394 void __iomem *ioaddr = np->ioaddr; in mii_sendbit()
1406 struct netdev_private *np = netdev_priv(dev); in mii_getbit() local
1407 void __iomem *ioaddr = np->ioaddr; in mii_getbit()
1476 struct netdev_private *np; in mii_wait_link() local
1478 np = netdev_priv(dev); in mii_wait_link()
1479 phy_addr = np->phy_addr; in mii_wait_link()
1497 struct netdev_private *np; in mii_get_media() local
1499 np = netdev_priv(dev); in mii_get_media()
1500 phy_addr = np->phy_addr; in mii_get_media()
1503 if (np->an_enable) { in mii_get_media()
1513 np->speed = 1000; in mii_get_media()
1514 np->full_duplex = 1; in mii_get_media()
1517 np->speed = 1000; in mii_get_media()
1518 np->full_duplex = 0; in mii_get_media()
1521 np->speed = 100; in mii_get_media()
1522 np->full_duplex = 1; in mii_get_media()
1525 np->speed = 100; in mii_get_media()
1526 np->full_duplex = 0; in mii_get_media()
1529 np->speed = 10; in mii_get_media()
1530 np->full_duplex = 1; in mii_get_media()
1533 np->speed = 10; in mii_get_media()
1534 np->full_duplex = 0; in mii_get_media()
1538 np->tx_flow &= 1; in mii_get_media()
1539 np->rx_flow &= 1; in mii_get_media()
1541 np->tx_flow = 0; in mii_get_media()
1542 np->rx_flow &= 1; in mii_get_media()
1563 if (np->tx_flow) in mii_get_media()
1567 if (np->rx_flow) in mii_get_media()
1583 struct netdev_private *np; in mii_set_media() local
1584 np = netdev_priv(dev); in mii_set_media()
1585 phy_addr = np->phy_addr; in mii_set_media()
1588 if (np->an_enable) { in mii_set_media()
1640 if (np->speed == 100) { in mii_set_media()
1643 } else if (np->speed == 10) { in mii_set_media()
1646 if (np->full_duplex) { in mii_set_media()
1670 struct netdev_private *np; in mii_get_media_pcs() local
1672 np = netdev_priv(dev); in mii_get_media_pcs()
1673 phy_addr = np->phy_addr; in mii_get_media_pcs()
1676 if (np->an_enable) { in mii_get_media_pcs()
1683 np->speed = 1000; in mii_get_media_pcs()
1686 np->full_duplex = 1; in mii_get_media_pcs()
1689 np->full_duplex = 0; in mii_get_media_pcs()
1692 np->tx_flow &= 1; in mii_get_media_pcs()
1693 np->rx_flow &= 1; in mii_get_media_pcs()
1695 np->tx_flow = 0; in mii_get_media_pcs()
1696 np->rx_flow &= 1; in mii_get_media_pcs()
1708 if (np->tx_flow) in mii_get_media_pcs()
1712 if (np->rx_flow) in mii_get_media_pcs()
1727 struct netdev_private *np; in mii_set_media_pcs() local
1728 np = netdev_priv(dev); in mii_set_media_pcs()
1729 phy_addr = np->phy_addr; in mii_set_media_pcs()
1732 if (np->an_enable) { in mii_set_media_pcs()
1756 if (np->full_duplex) { in mii_set_media_pcs()
1776 struct netdev_private *np = netdev_priv(dev); in rio_close() local
1777 struct pci_dev *pdev = np->pdev; in rio_close()
1784 del_timer_sync (&np->timer); in rio_close()
1797 struct netdev_private *np = netdev_priv(dev); in rio_remove1() local
1800 dma_free_coherent(&pdev->dev, RX_TOTAL_SIZE, np->rx_ring, in rio_remove1()
1801 np->rx_ring_dma); in rio_remove1()
1802 dma_free_coherent(&pdev->dev, TX_TOTAL_SIZE, np->tx_ring, in rio_remove1()
1803 np->tx_ring_dma); in rio_remove1()
1805 pci_iounmap(pdev, np->ioaddr); in rio_remove1()
1807 pci_iounmap(pdev, np->eeprom_addr); in rio_remove1()
1818 struct netdev_private *np = netdev_priv(dev); in rio_suspend() local
1824 del_timer_sync(&np->timer); in rio_suspend()
1833 struct netdev_private *np = netdev_priv(dev); in rio_resume() local
1838 rio_reset_ring(np); in rio_resume()
1840 np->timer.expires = jiffies + 1 * HZ; in rio_resume()
1841 add_timer(&np->timer); in rio_resume()
1843 dl2k_enable_int(np); in rio_resume()