Lines Matching refs:card
78 spider_net_read_reg(struct spider_net_card *card, u32 reg) in spider_net_read_reg() argument
84 return in_be32(card->regs + reg); in spider_net_read_reg()
94 spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) in spider_net_write_reg() argument
100 out_be32(card->regs + reg, value); in spider_net_write_reg()
118 struct spider_net_card *card = netdev_priv(netdev); in spider_net_write_phy() local
124 spider_net_write_reg(card, SPIDER_NET_GPCWOPCMD, writevalue); in spider_net_write_phy()
141 struct spider_net_card *card = netdev_priv(netdev); in spider_net_read_phy() local
145 spider_net_write_reg(card, SPIDER_NET_GPCROPCMD, readvalue); in spider_net_read_phy()
151 readvalue = spider_net_read_reg(card, SPIDER_NET_GPCROPCMD); in spider_net_read_phy()
164 spider_net_setup_aneg(struct spider_net_card *card) in spider_net_setup_aneg() argument
166 struct mii_phy *phy = &card->phy; in spider_net_setup_aneg()
170 bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); in spider_net_setup_aneg()
171 estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); in spider_net_setup_aneg()
199 spider_net_rx_irq_off(struct spider_net_card *card) in spider_net_rx_irq_off() argument
204 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, regvalue); in spider_net_rx_irq_off()
214 spider_net_rx_irq_on(struct spider_net_card *card) in spider_net_rx_irq_on() argument
219 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, regvalue); in spider_net_rx_irq_on()
230 spider_net_set_promisc(struct spider_net_card *card) in spider_net_set_promisc() argument
233 struct net_device *netdev = card->netdev; in spider_net_set_promisc()
237 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, 0); in spider_net_set_promisc()
238 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, 0); in spider_net_set_promisc()
239 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, in spider_net_set_promisc()
248 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, macu); in spider_net_set_promisc()
249 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, macl); in spider_net_set_promisc()
250 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, in spider_net_set_promisc()
274 spider_net_free_chain(struct spider_net_card *card, in spider_net_free_chain() argument
286 dma_free_coherent(&card->pdev->dev, chain->num_desc * sizeof(struct spider_net_hw_descr), in spider_net_free_chain()
301 spider_net_init_chain(struct spider_net_card *card, in spider_net_init_chain() argument
312 chain->hwring = dma_alloc_coherent(&card->pdev->dev, alloc_size, in spider_net_init_chain()
349 spider_net_free_rx_chain_contents(struct spider_net_card *card) in spider_net_free_rx_chain_contents() argument
353 descr = card->rx_chain.head; in spider_net_free_rx_chain_contents()
356 pci_unmap_single(card->pdev, descr->hwdescr->buf_addr, in spider_net_free_rx_chain_contents()
363 } while (descr != card->rx_chain.head); in spider_net_free_rx_chain_contents()
377 spider_net_prepare_rx_descr(struct spider_net_card *card, in spider_net_prepare_rx_descr() argument
392 descr->skb = netdev_alloc_skb(card->netdev, in spider_net_prepare_rx_descr()
395 if (netif_msg_rx_err(card) && net_ratelimit()) in spider_net_prepare_rx_descr()
396 dev_err(&card->netdev->dev, in spider_net_prepare_rx_descr()
398 card->spider_stats.alloc_rx_skb_error++; in spider_net_prepare_rx_descr()
412 buf = pci_map_single(card->pdev, descr->skb->data, in spider_net_prepare_rx_descr()
414 if (pci_dma_mapping_error(card->pdev, buf)) { in spider_net_prepare_rx_descr()
417 if (netif_msg_rx_err(card) && net_ratelimit()) in spider_net_prepare_rx_descr()
418 dev_err(&card->netdev->dev, "Could not iommu-map rx buffer\n"); in spider_net_prepare_rx_descr()
419 card->spider_stats.rx_iommu_map_error++; in spider_net_prepare_rx_descr()
440 spider_net_enable_rxchtails(struct spider_net_card *card) in spider_net_enable_rxchtails() argument
443 spider_net_write_reg(card, SPIDER_NET_GDADCHA , in spider_net_enable_rxchtails()
444 card->rx_chain.tail->bus_addr); in spider_net_enable_rxchtails()
455 spider_net_enable_rxdmac(struct spider_net_card *card) in spider_net_enable_rxdmac() argument
458 spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, in spider_net_enable_rxdmac()
470 spider_net_disable_rxdmac(struct spider_net_card *card) in spider_net_disable_rxdmac() argument
472 spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, in spider_net_disable_rxdmac()
483 spider_net_refill_rx_chain(struct spider_net_card *card) in spider_net_refill_rx_chain() argument
485 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_refill_rx_chain()
497 if (spider_net_prepare_rx_descr(card, chain->head)) in spider_net_refill_rx_chain()
512 spider_net_alloc_rx_skbs(struct spider_net_card *card) in spider_net_alloc_rx_skbs() argument
514 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_alloc_rx_skbs()
527 if (spider_net_prepare_rx_descr(card, chain->head)) in spider_net_alloc_rx_skbs()
534 spider_net_refill_rx_chain(card); in spider_net_alloc_rx_skbs()
535 spider_net_enable_rxdmac(card); in spider_net_alloc_rx_skbs()
539 spider_net_free_rx_chain_contents(card); in spider_net_alloc_rx_skbs()
590 struct spider_net_card *card = netdev_priv(netdev); in spider_net_set_multi() local
593 spider_net_set_promisc(card); in spider_net_set_multi()
626 spider_net_write_reg(card, SPIDER_NET_GMRMHFILnR + i * 4, reg); in spider_net_set_multi()
641 spider_net_prepare_tx_descr(struct spider_net_card *card, in spider_net_prepare_tx_descr() argument
644 struct spider_net_descr_chain *chain = &card->tx_chain; in spider_net_prepare_tx_descr()
650 buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); in spider_net_prepare_tx_descr()
651 if (pci_dma_mapping_error(card->pdev, buf)) { in spider_net_prepare_tx_descr()
652 if (netif_msg_tx_err(card) && net_ratelimit()) in spider_net_prepare_tx_descr()
653 dev_err(&card->netdev->dev, "could not iommu-map packet (%p, %i). " in spider_net_prepare_tx_descr()
655 card->spider_stats.tx_iommu_map_error++; in spider_net_prepare_tx_descr()
660 descr = card->tx_chain.head; in spider_net_prepare_tx_descr()
663 pci_unmap_single(card->pdev, buf, skb->len, PCI_DMA_TODEVICE); in spider_net_prepare_tx_descr()
693 netif_trans_update(card->netdev); /* set netdev watchdog timer */ in spider_net_prepare_tx_descr()
698 spider_net_set_low_watermark(struct spider_net_card *card) in spider_net_set_low_watermark() argument
700 struct spider_net_descr *descr = card->tx_chain.tail; in spider_net_set_low_watermark()
709 while (descr != card->tx_chain.head) { in spider_net_set_low_watermark()
718 if (cnt < card->tx_chain.num_desc/4) in spider_net_set_low_watermark()
722 descr = card->tx_chain.tail; in spider_net_set_low_watermark()
728 spin_lock_irqsave(&card->tx_chain.lock, flags); in spider_net_set_low_watermark()
730 if (card->low_watermark && card->low_watermark != descr) { in spider_net_set_low_watermark()
731 hwdescr = card->low_watermark->hwdescr; in spider_net_set_low_watermark()
735 card->low_watermark = descr; in spider_net_set_low_watermark()
736 spin_unlock_irqrestore(&card->tx_chain.lock, flags); in spider_net_set_low_watermark()
753 spider_net_release_tx_chain(struct spider_net_card *card, int brutal) in spider_net_release_tx_chain() argument
755 struct net_device *dev = card->netdev; in spider_net_release_tx_chain()
756 struct spider_net_descr_chain *chain = &card->tx_chain; in spider_net_release_tx_chain()
794 if (netif_msg_tx_err(card)) in spider_net_release_tx_chain()
795 dev_err(&card->netdev->dev, "forcing end of tx descriptor " in spider_net_release_tx_chain()
817 pci_unmap_single(card->pdev, buf_addr, skb->len, in spider_net_release_tx_chain()
837 spider_net_kick_tx_dma(struct spider_net_card *card) in spider_net_kick_tx_dma() argument
841 if (spider_net_read_reg(card, SPIDER_NET_GDTDMACCNTR) & in spider_net_kick_tx_dma()
845 descr = card->tx_chain.tail; in spider_net_kick_tx_dma()
849 spider_net_write_reg(card, SPIDER_NET_GDTDCHA, in spider_net_kick_tx_dma()
851 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, in spider_net_kick_tx_dma()
855 if (descr == card->tx_chain.head) in spider_net_kick_tx_dma()
861 mod_timer(&card->tx_timer, jiffies + SPIDER_NET_TX_TIMER); in spider_net_kick_tx_dma()
875 struct spider_net_card *card = netdev_priv(netdev); in spider_net_xmit() local
877 spider_net_release_tx_chain(card, 0); in spider_net_xmit()
879 if (spider_net_prepare_tx_descr(card, skb) != 0) { in spider_net_xmit()
885 cnt = spider_net_set_low_watermark(card); in spider_net_xmit()
887 spider_net_kick_tx_dma(card); in spider_net_xmit()
903 struct spider_net_card *card = from_timer(card, t, tx_timer); in spider_net_cleanup_tx_ring() local
904 if ((spider_net_release_tx_chain(card, 0) != 0) && in spider_net_cleanup_tx_ring()
905 (card->netdev->flags & IFF_UP)) { in spider_net_cleanup_tx_ring()
906 spider_net_kick_tx_dma(card); in spider_net_cleanup_tx_ring()
907 netif_wake_queue(card->netdev); in spider_net_cleanup_tx_ring()
939 struct spider_net_card *card) in spider_net_pass_skb_up() argument
943 struct net_device *netdev = card->netdev; in spider_net_pass_skb_up()
976 static void show_rx_chain(struct spider_net_card *card) in show_rx_chain() argument
978 struct spider_net_descr_chain *chain = &card->rx_chain; in show_rx_chain()
982 struct device *dev = &card->netdev->dev; in show_rx_chain()
996 curr_desc = spider_net_read_reg(card, SPIDER_NET_GDACTDPA); in show_rx_chain()
997 next_desc = spider_net_read_reg(card, SPIDER_NET_GDACNEXTDA); in show_rx_chain()
1073 static void spider_net_resync_head_ptr(struct spider_net_card *card) in spider_net_resync_head_ptr() argument
1076 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_resync_head_ptr()
1101 static int spider_net_resync_tail_ptr(struct spider_net_card *card) in spider_net_resync_tail_ptr() argument
1103 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_resync_tail_ptr()
1136 spider_net_decode_one_descr(struct spider_net_card *card) in spider_net_decode_one_descr() argument
1138 struct net_device *dev = card->netdev; in spider_net_decode_one_descr()
1139 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_decode_one_descr()
1158 pci_unmap_single(card->pdev, hw_buf_addr, in spider_net_decode_one_descr()
1164 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1173 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1174 dev_err(&card->netdev->dev, in spider_net_decode_one_descr()
1176 card->spider_stats.rx_desc_unk_state++; in spider_net_decode_one_descr()
1182 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1183 dev_err(&card->netdev->dev, in spider_net_decode_one_descr()
1191 dev_err(&card->netdev->dev, "bad status, cmd_status=x%08x\n", in spider_net_decode_one_descr()
1200 pr_err("which=%ld\n", descr - card->rx_chain.ring); in spider_net_decode_one_descr()
1202 card->spider_stats.rx_desc_error++; in spider_net_decode_one_descr()
1207 spider_net_pass_skb_up(descr, card); in spider_net_decode_one_descr()
1213 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1214 show_rx_chain(card); in spider_net_decode_one_descr()
1235 struct spider_net_card *card = container_of(napi, struct spider_net_card, napi); in spider_net_poll() local
1239 if (!spider_net_decode_one_descr(card)) in spider_net_poll()
1245 if ((packets_done == 0) && (card->num_rx_ints != 0)) { in spider_net_poll()
1246 if (!spider_net_resync_tail_ptr(card)) in spider_net_poll()
1248 spider_net_resync_head_ptr(card); in spider_net_poll()
1250 card->num_rx_ints = 0; in spider_net_poll()
1252 spider_net_refill_rx_chain(card); in spider_net_poll()
1253 spider_net_enable_rxdmac(card); in spider_net_poll()
1255 spider_net_cleanup_tx_ring(&card->tx_timer); in spider_net_poll()
1261 spider_net_rx_irq_on(card); in spider_net_poll()
1262 card->ignore_rx_ramfull = 0; in spider_net_poll()
1279 struct spider_net_card *card = netdev_priv(netdev); in spider_net_set_mac() local
1289 regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); in spider_net_set_mac()
1291 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); in spider_net_set_mac()
1297 spider_net_write_reg(card, SPIDER_NET_GMACUNIMACU, macu); in spider_net_set_mac()
1298 spider_net_write_reg(card, SPIDER_NET_GMACUNIMACL, macl); in spider_net_set_mac()
1301 regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); in spider_net_set_mac()
1303 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); in spider_net_set_mac()
1305 spider_net_set_promisc(card); in spider_net_set_mac()
1322 struct spider_net_card *card = netdev_priv(netdev); in spider_net_link_reset() local
1324 del_timer_sync(&card->aneg_timer); in spider_net_link_reset()
1327 spider_net_write_reg(card, SPIDER_NET_GMACST, in spider_net_link_reset()
1328 spider_net_read_reg(card, SPIDER_NET_GMACST)); in spider_net_link_reset()
1329 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0); in spider_net_link_reset()
1332 card->aneg_count = 0; in spider_net_link_reset()
1333 card->medium = BCM54XX_COPPER; in spider_net_link_reset()
1334 spider_net_setup_aneg(card); in spider_net_link_reset()
1335 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_link_reset()
1348 spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg, in spider_net_handle_error_irq() argument
1386 if (netif_msg_intr(card)) in spider_net_handle_error_irq()
1387 dev_err(&card->netdev->dev, "PHY write queue full\n"); in spider_net_handle_error_irq()
1458 if (card->ignore_rx_ramfull == 0) { in spider_net_handle_error_irq()
1459 card->ignore_rx_ramfull = 1; in spider_net_handle_error_irq()
1460 spider_net_resync_head_ptr(card); in spider_net_handle_error_irq()
1461 spider_net_refill_rx_chain(card); in spider_net_handle_error_irq()
1462 spider_net_enable_rxdmac(card); in spider_net_handle_error_irq()
1463 card->num_rx_ints ++; in spider_net_handle_error_irq()
1464 napi_schedule(&card->napi); in spider_net_handle_error_irq()
1480 spider_net_resync_head_ptr(card); in spider_net_handle_error_irq()
1481 spider_net_refill_rx_chain(card); in spider_net_handle_error_irq()
1482 spider_net_enable_rxdmac(card); in spider_net_handle_error_irq()
1483 card->num_rx_ints ++; in spider_net_handle_error_irq()
1484 napi_schedule(&card->napi); in spider_net_handle_error_irq()
1494 spider_net_resync_head_ptr(card); in spider_net_handle_error_irq()
1495 spider_net_refill_rx_chain(card); in spider_net_handle_error_irq()
1496 spider_net_enable_rxdmac(card); in spider_net_handle_error_irq()
1497 card->num_rx_ints ++; in spider_net_handle_error_irq()
1498 napi_schedule(&card->napi); in spider_net_handle_error_irq()
1553 if ((show_error) && (netif_msg_intr(card)) && net_ratelimit()) in spider_net_handle_error_irq()
1554 dev_err(&card->netdev->dev, "Error interrupt, GHIINT0STS = 0x%08x, " in spider_net_handle_error_irq()
1559 spider_net_write_reg(card, SPIDER_NET_GHIINT1STS, error_reg1); in spider_net_handle_error_irq()
1560 spider_net_write_reg(card, SPIDER_NET_GHIINT2STS, error_reg2); in spider_net_handle_error_irq()
1578 struct spider_net_card *card = netdev_priv(netdev); in spider_net_interrupt() local
1581 status_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0STS); in spider_net_interrupt()
1582 error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS); in spider_net_interrupt()
1583 error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS); in spider_net_interrupt()
1591 spider_net_rx_irq_off(card); in spider_net_interrupt()
1592 napi_schedule(&card->napi); in spider_net_interrupt()
1593 card->num_rx_ints ++; in spider_net_interrupt()
1596 napi_schedule(&card->napi); in spider_net_interrupt()
1602 spider_net_handle_error_irq(card, status_reg, in spider_net_interrupt()
1606 spider_net_write_reg(card, SPIDER_NET_GHIINT0STS, status_reg); in spider_net_interrupt()
1634 spider_net_enable_interrupts(struct spider_net_card *card) in spider_net_enable_interrupts() argument
1636 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, in spider_net_enable_interrupts()
1638 spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, in spider_net_enable_interrupts()
1640 spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, in spider_net_enable_interrupts()
1651 spider_net_disable_interrupts(struct spider_net_card *card) in spider_net_disable_interrupts() argument
1653 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0); in spider_net_disable_interrupts()
1654 spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0); in spider_net_disable_interrupts()
1655 spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0); in spider_net_disable_interrupts()
1656 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0); in spider_net_disable_interrupts()
1667 spider_net_init_card(struct spider_net_card *card) in spider_net_init_card() argument
1669 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_init_card()
1672 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_init_card()
1676 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, in spider_net_init_card()
1677 spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 0x4); in spider_net_init_card()
1679 spider_net_disable_interrupts(card); in spider_net_init_card()
1689 spider_net_enable_card(struct spider_net_card *card) in spider_net_enable_card() argument
1737 spider_net_write_reg(card, regs[i][0], regs[i][1]); in spider_net_enable_card()
1743 spider_net_write_reg(card, in spider_net_enable_card()
1746 spider_net_write_reg(card, in spider_net_enable_card()
1751 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, 0x08080000); in spider_net_enable_card()
1753 spider_net_write_reg(card, SPIDER_NET_ECMODE, SPIDER_NET_ECMODE_VALUE); in spider_net_enable_card()
1757 spider_net_enable_rxchtails(card); in spider_net_enable_card()
1758 spider_net_enable_rxdmac(card); in spider_net_enable_card()
1760 spider_net_write_reg(card, SPIDER_NET_GRXDMAEN, SPIDER_NET_WOL_VALUE); in spider_net_enable_card()
1762 spider_net_write_reg(card, SPIDER_NET_GMACLENLMT, in spider_net_enable_card()
1764 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, in spider_net_enable_card()
1767 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, in spider_net_enable_card()
1780 spider_net_download_firmware(struct spider_net_card *card, in spider_net_download_firmware() argument
1787 spider_net_write_reg(card, SPIDER_NET_GSINIT, in spider_net_download_firmware()
1792 spider_net_write_reg(card, in spider_net_download_firmware()
1795 spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + in spider_net_download_firmware()
1801 if (spider_net_read_reg(card, SPIDER_NET_GSINIT)) in spider_net_download_firmware()
1804 spider_net_write_reg(card, SPIDER_NET_GSINIT, in spider_net_download_firmware()
1837 spider_net_init_firmware(struct spider_net_card *card) in spider_net_init_firmware() argument
1846 SPIDER_NET_FIRMWARE_NAME, &card->pdev->dev) == 0) { in spider_net_init_firmware()
1848 netif_msg_probe(card) ) { in spider_net_init_firmware()
1849 dev_err(&card->netdev->dev, in spider_net_init_firmware()
1854 err = spider_net_download_firmware(card, firmware->data); in spider_net_init_firmware()
1864 dn = pci_device_to_OF_node(card->pdev); in spider_net_init_firmware()
1873 netif_msg_probe(card) ) { in spider_net_init_firmware()
1874 dev_err(&card->netdev->dev, in spider_net_init_firmware()
1879 err = spider_net_download_firmware(card, fw_prop); in spider_net_init_firmware()
1884 if (netif_msg_probe(card)) in spider_net_init_firmware()
1885 dev_err(&card->netdev->dev, in spider_net_init_firmware()
1903 struct spider_net_card *card = netdev_priv(netdev); in spider_net_open() local
1906 result = spider_net_init_firmware(card); in spider_net_open()
1911 card->aneg_count = 0; in spider_net_open()
1912 card->medium = BCM54XX_COPPER; in spider_net_open()
1913 spider_net_setup_aneg(card); in spider_net_open()
1914 if (card->phy.def->phy_id) in spider_net_open()
1915 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_open()
1917 result = spider_net_init_chain(card, &card->tx_chain); in spider_net_open()
1920 card->low_watermark = NULL; in spider_net_open()
1922 result = spider_net_init_chain(card, &card->rx_chain); in spider_net_open()
1927 result = spider_net_alloc_rx_skbs(card); in spider_net_open()
1940 spider_net_enable_card(card); in spider_net_open()
1944 napi_enable(&card->napi); in spider_net_open()
1946 spider_net_enable_interrupts(card); in spider_net_open()
1951 spider_net_free_rx_chain_contents(card); in spider_net_open()
1953 spider_net_free_chain(card, &card->rx_chain); in spider_net_open()
1955 spider_net_free_chain(card, &card->tx_chain); in spider_net_open()
1957 del_timer_sync(&card->aneg_timer); in spider_net_open()
1969 struct spider_net_card *card = from_timer(card, t, aneg_timer); in spider_net_link_phy() local
1970 struct mii_phy *phy = &card->phy; in spider_net_link_phy()
1973 if (card->aneg_count > SPIDER_NET_ANEG_TIMEOUT) { in spider_net_link_phy()
1976 card->netdev->name); in spider_net_link_phy()
1978 switch (card->medium) { in spider_net_link_phy()
1983 card->medium = BCM54XX_FIBER; in spider_net_link_phy()
1990 card->medium = BCM54XX_UNKNOWN; in spider_net_link_phy()
1996 spider_net_setup_aneg(card); in spider_net_link_phy()
1997 card->medium = BCM54XX_COPPER; in spider_net_link_phy()
2001 card->aneg_count = 0; in spider_net_link_phy()
2002 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_link_phy()
2008 card->aneg_count++; in spider_net_link_phy()
2009 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_link_phy()
2016 spider_net_write_reg(card, SPIDER_NET_GMACST, in spider_net_link_phy()
2017 spider_net_read_reg(card, SPIDER_NET_GMACST)); in spider_net_link_phy()
2018 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0x4); in spider_net_link_phy()
2021 spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0x00000001); in spider_net_link_phy()
2023 spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0); in spider_net_link_phy()
2025 card->aneg_count = 0; in spider_net_link_phy()
2028 card->netdev->name, phy->speed, in spider_net_link_phy()
2042 spider_net_setup_phy(struct spider_net_card *card) in spider_net_setup_phy() argument
2044 struct mii_phy *phy = &card->phy; in spider_net_setup_phy()
2046 spider_net_write_reg(card, SPIDER_NET_GDTDMASEL, in spider_net_setup_phy()
2048 spider_net_write_reg(card, SPIDER_NET_GPCCTRL, in spider_net_setup_phy()
2051 phy->dev = card->netdev; in spider_net_setup_phy()
2057 id = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); in spider_net_setup_phy()
2076 spider_net_workaround_rxramfull(struct spider_net_card *card) in spider_net_workaround_rxramfull() argument
2081 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_workaround_rxramfull()
2087 spider_net_write_reg(card, SPIDER_NET_GSnPRGADR + in spider_net_workaround_rxramfull()
2090 spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + in spider_net_workaround_rxramfull()
2096 spider_net_write_reg(card, SPIDER_NET_GSINIT, 0x000000fe); in spider_net_workaround_rxramfull()
2099 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_workaround_rxramfull()
2112 struct spider_net_card *card = netdev_priv(netdev); in spider_net_stop() local
2114 napi_disable(&card->napi); in spider_net_stop()
2117 del_timer_sync(&card->tx_timer); in spider_net_stop()
2118 del_timer_sync(&card->aneg_timer); in spider_net_stop()
2120 spider_net_disable_interrupts(card); in spider_net_stop()
2124 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, in spider_net_stop()
2128 spider_net_disable_rxdmac(card); in spider_net_stop()
2131 spider_net_release_tx_chain(card, 1); in spider_net_stop()
2132 spider_net_free_rx_chain_contents(card); in spider_net_stop()
2134 spider_net_free_chain(card, &card->tx_chain); in spider_net_stop()
2135 spider_net_free_chain(card, &card->rx_chain); in spider_net_stop()
2150 struct spider_net_card *card = in spider_net_tx_timeout_task() local
2152 struct net_device *netdev = card->netdev; in spider_net_tx_timeout_task()
2160 spider_net_workaround_rxramfull(card); in spider_net_tx_timeout_task()
2161 spider_net_init_card(card); in spider_net_tx_timeout_task()
2163 if (spider_net_setup_phy(card)) in spider_net_tx_timeout_task()
2167 spider_net_kick_tx_dma(card); in spider_net_tx_timeout_task()
2171 atomic_dec(&card->tx_timeout_task_counter); in spider_net_tx_timeout_task()
2183 struct spider_net_card *card; in spider_net_tx_timeout() local
2185 card = netdev_priv(netdev); in spider_net_tx_timeout()
2186 atomic_inc(&card->tx_timeout_task_counter); in spider_net_tx_timeout()
2188 schedule_work(&card->tx_timeout_task); in spider_net_tx_timeout()
2190 atomic_dec(&card->tx_timeout_task_counter); in spider_net_tx_timeout()
2191 card->spider_stats.tx_timeouts++; in spider_net_tx_timeout()
2234 spider_net_setup_netdev(struct spider_net_card *card) in spider_net_setup_netdev() argument
2237 struct net_device *netdev = card->netdev; in spider_net_setup_netdev()
2242 SET_NETDEV_DEV(netdev, &card->pdev->dev); in spider_net_setup_netdev()
2244 pci_set_drvdata(card->pdev, netdev); in spider_net_setup_netdev()
2246 timer_setup(&card->tx_timer, spider_net_cleanup_tx_ring, 0); in spider_net_setup_netdev()
2247 netdev->irq = card->pdev->irq; in spider_net_setup_netdev()
2249 card->aneg_count = 0; in spider_net_setup_netdev()
2250 timer_setup(&card->aneg_timer, spider_net_link_phy, 0); in spider_net_setup_netdev()
2252 netif_napi_add(netdev, &card->napi, in spider_net_setup_netdev()
2268 netdev->irq = card->pdev->irq; in spider_net_setup_netdev()
2269 card->num_rx_ints = 0; in spider_net_setup_netdev()
2270 card->ignore_rx_ramfull = 0; in spider_net_setup_netdev()
2272 dn = pci_device_to_OF_node(card->pdev); in spider_net_setup_netdev()
2282 if ((result) && (netif_msg_probe(card))) in spider_net_setup_netdev()
2283 dev_err(&card->netdev->dev, in spider_net_setup_netdev()
2288 if (netif_msg_probe(card)) in spider_net_setup_netdev()
2289 dev_err(&card->netdev->dev, in spider_net_setup_netdev()
2294 if (netif_msg_probe(card)) in spider_net_setup_netdev()
2311 struct spider_net_card *card; in spider_net_alloc_card() local
2313 netdev = alloc_etherdev(struct_size(card, darray, in spider_net_alloc_card()
2318 card = netdev_priv(netdev); in spider_net_alloc_card()
2319 card->netdev = netdev; in spider_net_alloc_card()
2320 card->msg_enable = SPIDER_NET_DEFAULT_MSG; in spider_net_alloc_card()
2321 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task); in spider_net_alloc_card()
2322 init_waitqueue_head(&card->waitq); in spider_net_alloc_card()
2323 atomic_set(&card->tx_timeout_task_counter, 0); in spider_net_alloc_card()
2325 card->rx_chain.num_desc = rx_descriptors; in spider_net_alloc_card()
2326 card->rx_chain.ring = card->darray; in spider_net_alloc_card()
2327 card->tx_chain.num_desc = tx_descriptors; in spider_net_alloc_card()
2328 card->tx_chain.ring = card->darray + rx_descriptors; in spider_net_alloc_card()
2330 return card; in spider_net_alloc_card()
2340 spider_net_undo_pci_setup(struct spider_net_card *card) in spider_net_undo_pci_setup() argument
2342 iounmap(card->regs); in spider_net_undo_pci_setup()
2343 pci_release_regions(card->pdev); in spider_net_undo_pci_setup()
2361 struct spider_net_card *card; in spider_net_setup_pci_dev() local
2383 card = spider_net_alloc_card(); in spider_net_setup_pci_dev()
2384 if (!card) { in spider_net_setup_pci_dev()
2389 card->pdev = pdev; in spider_net_setup_pci_dev()
2395 card->netdev->mem_start = mmio_start; in spider_net_setup_pci_dev()
2396 card->netdev->mem_end = mmio_start + mmio_len; in spider_net_setup_pci_dev()
2397 card->regs = ioremap(mmio_start, mmio_len); in spider_net_setup_pci_dev()
2399 if (!card->regs) { in spider_net_setup_pci_dev()
2405 return card; in spider_net_setup_pci_dev()
2428 struct spider_net_card *card; in spider_net_probe() local
2430 card = spider_net_setup_pci_dev(pdev); in spider_net_probe()
2431 if (!card) in spider_net_probe()
2434 spider_net_workaround_rxramfull(card); in spider_net_probe()
2435 spider_net_init_card(card); in spider_net_probe()
2437 err = spider_net_setup_phy(card); in spider_net_probe()
2441 err = spider_net_setup_netdev(card); in spider_net_probe()
2448 spider_net_undo_pci_setup(card); in spider_net_probe()
2449 free_netdev(card->netdev); in spider_net_probe()
2467 struct spider_net_card *card; in spider_net_remove() local
2470 card = netdev_priv(netdev); in spider_net_remove()
2472 wait_event(card->waitq, in spider_net_remove()
2473 atomic_read(&card->tx_timeout_task_counter) == 0); in spider_net_remove()
2478 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_remove()
2480 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_remove()
2483 spider_net_undo_pci_setup(card); in spider_net_remove()