Lines Matching refs:card
92 spider_net_read_reg(struct spider_net_card *card, u32 reg) in spider_net_read_reg() argument
98 return in_be32(card->regs + reg); in spider_net_read_reg()
108 spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) in spider_net_write_reg() argument
114 out_be32(card->regs + reg, value); in spider_net_write_reg()
132 struct spider_net_card *card = netdev_priv(netdev); in spider_net_write_phy() local
138 spider_net_write_reg(card, SPIDER_NET_GPCWOPCMD, writevalue); in spider_net_write_phy()
155 struct spider_net_card *card = netdev_priv(netdev); in spider_net_read_phy() local
159 spider_net_write_reg(card, SPIDER_NET_GPCROPCMD, readvalue); in spider_net_read_phy()
165 readvalue = spider_net_read_reg(card, SPIDER_NET_GPCROPCMD); in spider_net_read_phy()
178 spider_net_setup_aneg(struct spider_net_card *card) in spider_net_setup_aneg() argument
180 struct mii_phy *phy = &card->phy; in spider_net_setup_aneg()
184 bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); in spider_net_setup_aneg()
185 estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); in spider_net_setup_aneg()
213 spider_net_rx_irq_off(struct spider_net_card *card) in spider_net_rx_irq_off() argument
218 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, regvalue); in spider_net_rx_irq_off()
228 spider_net_rx_irq_on(struct spider_net_card *card) in spider_net_rx_irq_on() argument
233 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, regvalue); in spider_net_rx_irq_on()
244 spider_net_set_promisc(struct spider_net_card *card) in spider_net_set_promisc() argument
247 struct net_device *netdev = card->netdev; in spider_net_set_promisc()
251 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, 0); in spider_net_set_promisc()
252 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, 0); in spider_net_set_promisc()
253 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, in spider_net_set_promisc()
262 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, macu); in spider_net_set_promisc()
263 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, macl); in spider_net_set_promisc()
264 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, in spider_net_set_promisc()
278 struct spider_net_card *card = netdev_priv(netdev); in spider_net_get_mac_address() local
281 macl = spider_net_read_reg(card, SPIDER_NET_GMACUNIMACL); in spider_net_get_mac_address()
282 macu = spider_net_read_reg(card, SPIDER_NET_GMACUNIMACU); in spider_net_get_mac_address()
316 spider_net_free_chain(struct spider_net_card *card, in spider_net_free_chain() argument
328 dma_free_coherent(&card->pdev->dev, chain->num_desc, in spider_net_free_chain()
343 spider_net_init_chain(struct spider_net_card *card, in spider_net_init_chain() argument
354 chain->hwring = dma_alloc_coherent(&card->pdev->dev, alloc_size, in spider_net_init_chain()
393 spider_net_free_rx_chain_contents(struct spider_net_card *card) in spider_net_free_rx_chain_contents() argument
397 descr = card->rx_chain.head; in spider_net_free_rx_chain_contents()
400 pci_unmap_single(card->pdev, descr->hwdescr->buf_addr, in spider_net_free_rx_chain_contents()
407 } while (descr != card->rx_chain.head); in spider_net_free_rx_chain_contents()
421 spider_net_prepare_rx_descr(struct spider_net_card *card, in spider_net_prepare_rx_descr() argument
436 descr->skb = netdev_alloc_skb(card->netdev, in spider_net_prepare_rx_descr()
439 if (netif_msg_rx_err(card) && net_ratelimit()) in spider_net_prepare_rx_descr()
440 dev_err(&card->netdev->dev, in spider_net_prepare_rx_descr()
442 card->spider_stats.alloc_rx_skb_error++; in spider_net_prepare_rx_descr()
456 buf = pci_map_single(card->pdev, descr->skb->data, in spider_net_prepare_rx_descr()
458 if (pci_dma_mapping_error(card->pdev, buf)) { in spider_net_prepare_rx_descr()
461 if (netif_msg_rx_err(card) && net_ratelimit()) in spider_net_prepare_rx_descr()
462 dev_err(&card->netdev->dev, "Could not iommu-map rx buffer\n"); in spider_net_prepare_rx_descr()
463 card->spider_stats.rx_iommu_map_error++; in spider_net_prepare_rx_descr()
484 spider_net_enable_rxchtails(struct spider_net_card *card) in spider_net_enable_rxchtails() argument
487 spider_net_write_reg(card, SPIDER_NET_GDADCHA , in spider_net_enable_rxchtails()
488 card->rx_chain.tail->bus_addr); in spider_net_enable_rxchtails()
499 spider_net_enable_rxdmac(struct spider_net_card *card) in spider_net_enable_rxdmac() argument
502 spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, in spider_net_enable_rxdmac()
514 spider_net_disable_rxdmac(struct spider_net_card *card) in spider_net_disable_rxdmac() argument
516 spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, in spider_net_disable_rxdmac()
527 spider_net_refill_rx_chain(struct spider_net_card *card) in spider_net_refill_rx_chain() argument
529 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_refill_rx_chain()
541 if (spider_net_prepare_rx_descr(card, chain->head)) in spider_net_refill_rx_chain()
556 spider_net_alloc_rx_skbs(struct spider_net_card *card) in spider_net_alloc_rx_skbs() argument
558 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_alloc_rx_skbs()
571 if (spider_net_prepare_rx_descr(card, chain->head)) in spider_net_alloc_rx_skbs()
578 spider_net_refill_rx_chain(card); in spider_net_alloc_rx_skbs()
579 spider_net_enable_rxdmac(card); in spider_net_alloc_rx_skbs()
583 spider_net_free_rx_chain_contents(card); in spider_net_alloc_rx_skbs()
634 struct spider_net_card *card = netdev_priv(netdev); in spider_net_set_multi() local
638 spider_net_set_promisc(card); in spider_net_set_multi()
671 spider_net_write_reg(card, SPIDER_NET_GMRMHFILnR + i * 4, reg); in spider_net_set_multi()
686 spider_net_prepare_tx_descr(struct spider_net_card *card, in spider_net_prepare_tx_descr() argument
689 struct spider_net_descr_chain *chain = &card->tx_chain; in spider_net_prepare_tx_descr()
695 buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); in spider_net_prepare_tx_descr()
696 if (pci_dma_mapping_error(card->pdev, buf)) { in spider_net_prepare_tx_descr()
697 if (netif_msg_tx_err(card) && net_ratelimit()) in spider_net_prepare_tx_descr()
698 dev_err(&card->netdev->dev, "could not iommu-map packet (%p, %i). " in spider_net_prepare_tx_descr()
700 card->spider_stats.tx_iommu_map_error++; in spider_net_prepare_tx_descr()
705 descr = card->tx_chain.head; in spider_net_prepare_tx_descr()
708 pci_unmap_single(card->pdev, buf, skb->len, PCI_DMA_TODEVICE); in spider_net_prepare_tx_descr()
738 card->netdev->trans_start = jiffies; /* set netdev watchdog timer */ in spider_net_prepare_tx_descr()
743 spider_net_set_low_watermark(struct spider_net_card *card) in spider_net_set_low_watermark() argument
745 struct spider_net_descr *descr = card->tx_chain.tail; in spider_net_set_low_watermark()
754 while (descr != card->tx_chain.head) { in spider_net_set_low_watermark()
763 if (cnt < card->tx_chain.num_desc/4) in spider_net_set_low_watermark()
767 descr = card->tx_chain.tail; in spider_net_set_low_watermark()
773 spin_lock_irqsave(&card->tx_chain.lock, flags); in spider_net_set_low_watermark()
775 if (card->low_watermark && card->low_watermark != descr) { in spider_net_set_low_watermark()
776 hwdescr = card->low_watermark->hwdescr; in spider_net_set_low_watermark()
780 card->low_watermark = descr; in spider_net_set_low_watermark()
781 spin_unlock_irqrestore(&card->tx_chain.lock, flags); in spider_net_set_low_watermark()
798 spider_net_release_tx_chain(struct spider_net_card *card, int brutal) in spider_net_release_tx_chain() argument
800 struct net_device *dev = card->netdev; in spider_net_release_tx_chain()
801 struct spider_net_descr_chain *chain = &card->tx_chain; in spider_net_release_tx_chain()
838 if (netif_msg_tx_err(card)) in spider_net_release_tx_chain()
839 dev_err(&card->netdev->dev, "forcing end of tx descriptor " in spider_net_release_tx_chain()
861 pci_unmap_single(card->pdev, buf_addr, skb->len, in spider_net_release_tx_chain()
881 spider_net_kick_tx_dma(struct spider_net_card *card) in spider_net_kick_tx_dma() argument
885 if (spider_net_read_reg(card, SPIDER_NET_GDTDMACCNTR) & in spider_net_kick_tx_dma()
889 descr = card->tx_chain.tail; in spider_net_kick_tx_dma()
893 spider_net_write_reg(card, SPIDER_NET_GDTDCHA, in spider_net_kick_tx_dma()
895 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, in spider_net_kick_tx_dma()
899 if (descr == card->tx_chain.head) in spider_net_kick_tx_dma()
905 mod_timer(&card->tx_timer, jiffies + SPIDER_NET_TX_TIMER); in spider_net_kick_tx_dma()
919 struct spider_net_card *card = netdev_priv(netdev); in spider_net_xmit() local
921 spider_net_release_tx_chain(card, 0); in spider_net_xmit()
923 if (spider_net_prepare_tx_descr(card, skb) != 0) { in spider_net_xmit()
929 cnt = spider_net_set_low_watermark(card); in spider_net_xmit()
931 spider_net_kick_tx_dma(card); in spider_net_xmit()
945 spider_net_cleanup_tx_ring(struct spider_net_card *card) in spider_net_cleanup_tx_ring() argument
947 if ((spider_net_release_tx_chain(card, 0) != 0) && in spider_net_cleanup_tx_ring()
948 (card->netdev->flags & IFF_UP)) { in spider_net_cleanup_tx_ring()
949 spider_net_kick_tx_dma(card); in spider_net_cleanup_tx_ring()
950 netif_wake_queue(card->netdev); in spider_net_cleanup_tx_ring()
982 struct spider_net_card *card) in spider_net_pass_skb_up() argument
986 struct net_device *netdev = card->netdev; in spider_net_pass_skb_up()
1019 static void show_rx_chain(struct spider_net_card *card) in show_rx_chain() argument
1021 struct spider_net_descr_chain *chain = &card->rx_chain; in show_rx_chain()
1025 struct device *dev = &card->netdev->dev; in show_rx_chain()
1039 curr_desc = spider_net_read_reg(card, SPIDER_NET_GDACTDPA); in show_rx_chain()
1040 next_desc = spider_net_read_reg(card, SPIDER_NET_GDACNEXTDA); in show_rx_chain()
1116 static void spider_net_resync_head_ptr(struct spider_net_card *card) in spider_net_resync_head_ptr() argument
1119 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_resync_head_ptr()
1144 static int spider_net_resync_tail_ptr(struct spider_net_card *card) in spider_net_resync_tail_ptr() argument
1146 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_resync_tail_ptr()
1179 spider_net_decode_one_descr(struct spider_net_card *card) in spider_net_decode_one_descr() argument
1181 struct net_device *dev = card->netdev; in spider_net_decode_one_descr()
1182 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_decode_one_descr()
1201 pci_unmap_single(card->pdev, hw_buf_addr, in spider_net_decode_one_descr()
1207 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1216 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1217 dev_err(&card->netdev->dev, in spider_net_decode_one_descr()
1219 card->spider_stats.rx_desc_unk_state++; in spider_net_decode_one_descr()
1225 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1226 dev_err(&card->netdev->dev, in spider_net_decode_one_descr()
1234 dev_err(&card->netdev->dev, "bad status, cmd_status=x%08x\n", in spider_net_decode_one_descr()
1243 pr_err("which=%ld\n", descr - card->rx_chain.ring); in spider_net_decode_one_descr()
1245 card->spider_stats.rx_desc_error++; in spider_net_decode_one_descr()
1250 spider_net_pass_skb_up(descr, card); in spider_net_decode_one_descr()
1256 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1257 show_rx_chain(card); in spider_net_decode_one_descr()
1278 struct spider_net_card *card = container_of(napi, struct spider_net_card, napi); in spider_net_poll() local
1282 if (!spider_net_decode_one_descr(card)) in spider_net_poll()
1288 if ((packets_done == 0) && (card->num_rx_ints != 0)) { in spider_net_poll()
1289 if (!spider_net_resync_tail_ptr(card)) in spider_net_poll()
1291 spider_net_resync_head_ptr(card); in spider_net_poll()
1293 card->num_rx_ints = 0; in spider_net_poll()
1295 spider_net_refill_rx_chain(card); in spider_net_poll()
1296 spider_net_enable_rxdmac(card); in spider_net_poll()
1298 spider_net_cleanup_tx_ring(card); in spider_net_poll()
1304 spider_net_rx_irq_on(card); in spider_net_poll()
1305 card->ignore_rx_ramfull = 0; in spider_net_poll()
1341 struct spider_net_card *card = netdev_priv(netdev); in spider_net_set_mac() local
1349 regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); in spider_net_set_mac()
1351 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); in spider_net_set_mac()
1357 spider_net_write_reg(card, SPIDER_NET_GMACUNIMACU, macu); in spider_net_set_mac()
1358 spider_net_write_reg(card, SPIDER_NET_GMACUNIMACL, macl); in spider_net_set_mac()
1361 regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); in spider_net_set_mac()
1363 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); in spider_net_set_mac()
1365 spider_net_set_promisc(card); in spider_net_set_mac()
1388 struct spider_net_card *card = netdev_priv(netdev); in spider_net_link_reset() local
1390 del_timer_sync(&card->aneg_timer); in spider_net_link_reset()
1393 spider_net_write_reg(card, SPIDER_NET_GMACST, in spider_net_link_reset()
1394 spider_net_read_reg(card, SPIDER_NET_GMACST)); in spider_net_link_reset()
1395 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0); in spider_net_link_reset()
1398 card->aneg_count = 0; in spider_net_link_reset()
1399 card->medium = BCM54XX_COPPER; in spider_net_link_reset()
1400 spider_net_setup_aneg(card); in spider_net_link_reset()
1401 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_link_reset()
1414 spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg, in spider_net_handle_error_irq() argument
1452 if (netif_msg_intr(card)) in spider_net_handle_error_irq()
1453 dev_err(&card->netdev->dev, "PHY write queue full\n"); in spider_net_handle_error_irq()
1524 if (card->ignore_rx_ramfull == 0) { in spider_net_handle_error_irq()
1525 card->ignore_rx_ramfull = 1; in spider_net_handle_error_irq()
1526 spider_net_resync_head_ptr(card); in spider_net_handle_error_irq()
1527 spider_net_refill_rx_chain(card); in spider_net_handle_error_irq()
1528 spider_net_enable_rxdmac(card); in spider_net_handle_error_irq()
1529 card->num_rx_ints ++; in spider_net_handle_error_irq()
1530 napi_schedule(&card->napi); in spider_net_handle_error_irq()
1546 spider_net_resync_head_ptr(card); in spider_net_handle_error_irq()
1547 spider_net_refill_rx_chain(card); in spider_net_handle_error_irq()
1548 spider_net_enable_rxdmac(card); in spider_net_handle_error_irq()
1549 card->num_rx_ints ++; in spider_net_handle_error_irq()
1550 napi_schedule(&card->napi); in spider_net_handle_error_irq()
1560 spider_net_resync_head_ptr(card); in spider_net_handle_error_irq()
1561 spider_net_refill_rx_chain(card); in spider_net_handle_error_irq()
1562 spider_net_enable_rxdmac(card); in spider_net_handle_error_irq()
1563 card->num_rx_ints ++; in spider_net_handle_error_irq()
1564 napi_schedule(&card->napi); in spider_net_handle_error_irq()
1619 if ((show_error) && (netif_msg_intr(card)) && net_ratelimit()) in spider_net_handle_error_irq()
1620 dev_err(&card->netdev->dev, "Error interrupt, GHIINT0STS = 0x%08x, " in spider_net_handle_error_irq()
1625 spider_net_write_reg(card, SPIDER_NET_GHIINT1STS, error_reg1); in spider_net_handle_error_irq()
1626 spider_net_write_reg(card, SPIDER_NET_GHIINT2STS, error_reg2); in spider_net_handle_error_irq()
1644 struct spider_net_card *card = netdev_priv(netdev); in spider_net_interrupt() local
1647 status_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0STS); in spider_net_interrupt()
1648 error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS); in spider_net_interrupt()
1649 error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS); in spider_net_interrupt()
1657 spider_net_rx_irq_off(card); in spider_net_interrupt()
1658 napi_schedule(&card->napi); in spider_net_interrupt()
1659 card->num_rx_ints ++; in spider_net_interrupt()
1662 napi_schedule(&card->napi); in spider_net_interrupt()
1668 spider_net_handle_error_irq(card, status_reg, in spider_net_interrupt()
1672 spider_net_write_reg(card, SPIDER_NET_GHIINT0STS, status_reg); in spider_net_interrupt()
1700 spider_net_enable_interrupts(struct spider_net_card *card) in spider_net_enable_interrupts() argument
1702 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, in spider_net_enable_interrupts()
1704 spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, in spider_net_enable_interrupts()
1706 spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, in spider_net_enable_interrupts()
1717 spider_net_disable_interrupts(struct spider_net_card *card) in spider_net_disable_interrupts() argument
1719 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0); in spider_net_disable_interrupts()
1720 spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0); in spider_net_disable_interrupts()
1721 spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0); in spider_net_disable_interrupts()
1722 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0); in spider_net_disable_interrupts()
1733 spider_net_init_card(struct spider_net_card *card) in spider_net_init_card() argument
1735 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_init_card()
1738 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_init_card()
1742 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, in spider_net_init_card()
1743 spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 0x4); in spider_net_init_card()
1745 spider_net_disable_interrupts(card); in spider_net_init_card()
1755 spider_net_enable_card(struct spider_net_card *card) in spider_net_enable_card() argument
1803 spider_net_write_reg(card, regs[i][0], regs[i][1]); in spider_net_enable_card()
1809 spider_net_write_reg(card, in spider_net_enable_card()
1812 spider_net_write_reg(card, in spider_net_enable_card()
1817 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, 0x08080000); in spider_net_enable_card()
1819 spider_net_write_reg(card, SPIDER_NET_ECMODE, SPIDER_NET_ECMODE_VALUE); in spider_net_enable_card()
1823 spider_net_enable_rxchtails(card); in spider_net_enable_card()
1824 spider_net_enable_rxdmac(card); in spider_net_enable_card()
1826 spider_net_write_reg(card, SPIDER_NET_GRXDMAEN, SPIDER_NET_WOL_VALUE); in spider_net_enable_card()
1828 spider_net_write_reg(card, SPIDER_NET_GMACLENLMT, in spider_net_enable_card()
1830 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, in spider_net_enable_card()
1833 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, in spider_net_enable_card()
1846 spider_net_download_firmware(struct spider_net_card *card, in spider_net_download_firmware() argument
1853 spider_net_write_reg(card, SPIDER_NET_GSINIT, in spider_net_download_firmware()
1858 spider_net_write_reg(card, in spider_net_download_firmware()
1861 spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + in spider_net_download_firmware()
1867 if (spider_net_read_reg(card, SPIDER_NET_GSINIT)) in spider_net_download_firmware()
1870 spider_net_write_reg(card, SPIDER_NET_GSINIT, in spider_net_download_firmware()
1903 spider_net_init_firmware(struct spider_net_card *card) in spider_net_init_firmware() argument
1912 SPIDER_NET_FIRMWARE_NAME, &card->pdev->dev) == 0) { in spider_net_init_firmware()
1914 netif_msg_probe(card) ) { in spider_net_init_firmware()
1915 dev_err(&card->netdev->dev, in spider_net_init_firmware()
1920 err = spider_net_download_firmware(card, firmware->data); in spider_net_init_firmware()
1930 dn = pci_device_to_OF_node(card->pdev); in spider_net_init_firmware()
1939 netif_msg_probe(card) ) { in spider_net_init_firmware()
1940 dev_err(&card->netdev->dev, in spider_net_init_firmware()
1945 err = spider_net_download_firmware(card, fw_prop); in spider_net_init_firmware()
1950 if (netif_msg_probe(card)) in spider_net_init_firmware()
1951 dev_err(&card->netdev->dev, in spider_net_init_firmware()
1969 struct spider_net_card *card = netdev_priv(netdev); in spider_net_open() local
1972 result = spider_net_init_firmware(card); in spider_net_open()
1977 card->aneg_count = 0; in spider_net_open()
1978 card->medium = BCM54XX_COPPER; in spider_net_open()
1979 spider_net_setup_aneg(card); in spider_net_open()
1980 if (card->phy.def->phy_id) in spider_net_open()
1981 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_open()
1983 result = spider_net_init_chain(card, &card->tx_chain); in spider_net_open()
1986 card->low_watermark = NULL; in spider_net_open()
1988 result = spider_net_init_chain(card, &card->rx_chain); in spider_net_open()
1993 result = spider_net_alloc_rx_skbs(card); in spider_net_open()
2006 spider_net_enable_card(card); in spider_net_open()
2010 napi_enable(&card->napi); in spider_net_open()
2012 spider_net_enable_interrupts(card); in spider_net_open()
2017 spider_net_free_rx_chain_contents(card); in spider_net_open()
2019 spider_net_free_chain(card, &card->rx_chain); in spider_net_open()
2021 spider_net_free_chain(card, &card->tx_chain); in spider_net_open()
2023 del_timer_sync(&card->aneg_timer); in spider_net_open()
2035 struct spider_net_card *card = (struct spider_net_card *)data; in spider_net_link_phy() local
2036 struct mii_phy *phy = &card->phy; in spider_net_link_phy()
2039 if (card->aneg_count > SPIDER_NET_ANEG_TIMEOUT) { in spider_net_link_phy()
2042 card->netdev->name); in spider_net_link_phy()
2044 switch (card->medium) { in spider_net_link_phy()
2049 card->medium = BCM54XX_FIBER; in spider_net_link_phy()
2056 card->medium = BCM54XX_UNKNOWN; in spider_net_link_phy()
2062 spider_net_setup_aneg(card); in spider_net_link_phy()
2063 card->medium = BCM54XX_COPPER; in spider_net_link_phy()
2067 card->aneg_count = 0; in spider_net_link_phy()
2068 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_link_phy()
2074 card->aneg_count++; in spider_net_link_phy()
2075 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_link_phy()
2082 spider_net_write_reg(card, SPIDER_NET_GMACST, in spider_net_link_phy()
2083 spider_net_read_reg(card, SPIDER_NET_GMACST)); in spider_net_link_phy()
2084 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0x4); in spider_net_link_phy()
2087 spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0x00000001); in spider_net_link_phy()
2089 spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0); in spider_net_link_phy()
2091 card->aneg_count = 0; in spider_net_link_phy()
2094 card->netdev->name, phy->speed, in spider_net_link_phy()
2108 spider_net_setup_phy(struct spider_net_card *card) in spider_net_setup_phy() argument
2110 struct mii_phy *phy = &card->phy; in spider_net_setup_phy()
2112 spider_net_write_reg(card, SPIDER_NET_GDTDMASEL, in spider_net_setup_phy()
2114 spider_net_write_reg(card, SPIDER_NET_GPCCTRL, in spider_net_setup_phy()
2117 phy->dev = card->netdev; in spider_net_setup_phy()
2123 id = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); in spider_net_setup_phy()
2142 spider_net_workaround_rxramfull(struct spider_net_card *card) in spider_net_workaround_rxramfull() argument
2147 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_workaround_rxramfull()
2153 spider_net_write_reg(card, SPIDER_NET_GSnPRGADR + in spider_net_workaround_rxramfull()
2156 spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + in spider_net_workaround_rxramfull()
2162 spider_net_write_reg(card, SPIDER_NET_GSINIT, 0x000000fe); in spider_net_workaround_rxramfull()
2165 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_workaround_rxramfull()
2178 struct spider_net_card *card = netdev_priv(netdev); in spider_net_stop() local
2180 napi_disable(&card->napi); in spider_net_stop()
2183 del_timer_sync(&card->tx_timer); in spider_net_stop()
2184 del_timer_sync(&card->aneg_timer); in spider_net_stop()
2186 spider_net_disable_interrupts(card); in spider_net_stop()
2190 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, in spider_net_stop()
2194 spider_net_disable_rxdmac(card); in spider_net_stop()
2197 spider_net_release_tx_chain(card, 1); in spider_net_stop()
2198 spider_net_free_rx_chain_contents(card); in spider_net_stop()
2200 spider_net_free_chain(card, &card->tx_chain); in spider_net_stop()
2201 spider_net_free_chain(card, &card->rx_chain); in spider_net_stop()
2216 struct spider_net_card *card = in spider_net_tx_timeout_task() local
2218 struct net_device *netdev = card->netdev; in spider_net_tx_timeout_task()
2226 spider_net_workaround_rxramfull(card); in spider_net_tx_timeout_task()
2227 spider_net_init_card(card); in spider_net_tx_timeout_task()
2229 if (spider_net_setup_phy(card)) in spider_net_tx_timeout_task()
2233 spider_net_kick_tx_dma(card); in spider_net_tx_timeout_task()
2237 atomic_dec(&card->tx_timeout_task_counter); in spider_net_tx_timeout_task()
2249 struct spider_net_card *card; in spider_net_tx_timeout() local
2251 card = netdev_priv(netdev); in spider_net_tx_timeout()
2252 atomic_inc(&card->tx_timeout_task_counter); in spider_net_tx_timeout()
2254 schedule_work(&card->tx_timeout_task); in spider_net_tx_timeout()
2256 atomic_dec(&card->tx_timeout_task_counter); in spider_net_tx_timeout()
2257 card->spider_stats.tx_timeouts++; in spider_net_tx_timeout()
2301 spider_net_setup_netdev(struct spider_net_card *card) in spider_net_setup_netdev() argument
2304 struct net_device *netdev = card->netdev; in spider_net_setup_netdev()
2309 SET_NETDEV_DEV(netdev, &card->pdev->dev); in spider_net_setup_netdev()
2311 pci_set_drvdata(card->pdev, netdev); in spider_net_setup_netdev()
2313 init_timer(&card->tx_timer); in spider_net_setup_netdev()
2314 card->tx_timer.function = in spider_net_setup_netdev()
2316 card->tx_timer.data = (unsigned long) card; in spider_net_setup_netdev()
2317 netdev->irq = card->pdev->irq; in spider_net_setup_netdev()
2319 card->aneg_count = 0; in spider_net_setup_netdev()
2320 init_timer(&card->aneg_timer); in spider_net_setup_netdev()
2321 card->aneg_timer.function = spider_net_link_phy; in spider_net_setup_netdev()
2322 card->aneg_timer.data = (unsigned long) card; in spider_net_setup_netdev()
2324 netif_napi_add(netdev, &card->napi, in spider_net_setup_netdev()
2336 netdev->irq = card->pdev->irq; in spider_net_setup_netdev()
2337 card->num_rx_ints = 0; in spider_net_setup_netdev()
2338 card->ignore_rx_ramfull = 0; in spider_net_setup_netdev()
2340 dn = pci_device_to_OF_node(card->pdev); in spider_net_setup_netdev()
2350 if ((result) && (netif_msg_probe(card))) in spider_net_setup_netdev()
2351 dev_err(&card->netdev->dev, in spider_net_setup_netdev()
2356 if (netif_msg_probe(card)) in spider_net_setup_netdev()
2357 dev_err(&card->netdev->dev, in spider_net_setup_netdev()
2362 if (netif_msg_probe(card)) in spider_net_setup_netdev()
2379 struct spider_net_card *card; in spider_net_alloc_card() local
2388 card = netdev_priv(netdev); in spider_net_alloc_card()
2389 card->netdev = netdev; in spider_net_alloc_card()
2390 card->msg_enable = SPIDER_NET_DEFAULT_MSG; in spider_net_alloc_card()
2391 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task); in spider_net_alloc_card()
2392 init_waitqueue_head(&card->waitq); in spider_net_alloc_card()
2393 atomic_set(&card->tx_timeout_task_counter, 0); in spider_net_alloc_card()
2395 card->rx_chain.num_desc = rx_descriptors; in spider_net_alloc_card()
2396 card->rx_chain.ring = card->darray; in spider_net_alloc_card()
2397 card->tx_chain.num_desc = tx_descriptors; in spider_net_alloc_card()
2398 card->tx_chain.ring = card->darray + rx_descriptors; in spider_net_alloc_card()
2400 return card; in spider_net_alloc_card()
2410 spider_net_undo_pci_setup(struct spider_net_card *card) in spider_net_undo_pci_setup() argument
2412 iounmap(card->regs); in spider_net_undo_pci_setup()
2413 pci_release_regions(card->pdev); in spider_net_undo_pci_setup()
2431 struct spider_net_card *card; in spider_net_setup_pci_dev() local
2453 card = spider_net_alloc_card(); in spider_net_setup_pci_dev()
2454 if (!card) { in spider_net_setup_pci_dev()
2459 card->pdev = pdev; in spider_net_setup_pci_dev()
2465 card->netdev->mem_start = mmio_start; in spider_net_setup_pci_dev()
2466 card->netdev->mem_end = mmio_start + mmio_len; in spider_net_setup_pci_dev()
2467 card->regs = ioremap(mmio_start, mmio_len); in spider_net_setup_pci_dev()
2469 if (!card->regs) { in spider_net_setup_pci_dev()
2475 return card; in spider_net_setup_pci_dev()
2499 struct spider_net_card *card; in spider_net_probe() local
2501 card = spider_net_setup_pci_dev(pdev); in spider_net_probe()
2502 if (!card) in spider_net_probe()
2505 spider_net_workaround_rxramfull(card); in spider_net_probe()
2506 spider_net_init_card(card); in spider_net_probe()
2508 err = spider_net_setup_phy(card); in spider_net_probe()
2512 err = spider_net_setup_netdev(card); in spider_net_probe()
2519 spider_net_undo_pci_setup(card); in spider_net_probe()
2520 free_netdev(card->netdev); in spider_net_probe()
2538 struct spider_net_card *card; in spider_net_remove() local
2541 card = netdev_priv(netdev); in spider_net_remove()
2543 wait_event(card->waitq, in spider_net_remove()
2544 atomic_read(&card->tx_timeout_task_counter) == 0); in spider_net_remove()
2549 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_remove()
2551 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_remove()
2554 spider_net_undo_pci_setup(card); in spider_net_remove()