Lines Matching full:card

72  * spider_net_read_reg - reads an SMMIO register of a card
73 * @card: device structure
79 spider_net_read_reg(struct spider_net_card *card, u32 reg) in spider_net_read_reg() argument
85 return in_be32(card->regs + reg); in spider_net_read_reg()
89 * spider_net_write_reg - writes to an SMMIO register of a card
90 * @card: device structure
95 spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) in spider_net_write_reg() argument
101 out_be32(card->regs + reg, value); in spider_net_write_reg()
119 struct spider_net_card *card = netdev_priv(netdev); in spider_net_write_phy() local
125 spider_net_write_reg(card, SPIDER_NET_GPCWOPCMD, writevalue); in spider_net_write_phy()
142 struct spider_net_card *card = netdev_priv(netdev); in spider_net_read_phy() local
146 spider_net_write_reg(card, SPIDER_NET_GPCROPCMD, readvalue); in spider_net_read_phy()
153 readvalue = spider_net_read_reg(card, SPIDER_NET_GPCROPCMD); in spider_net_read_phy()
163 * @card: device structure
166 spider_net_setup_aneg(struct spider_net_card *card) in spider_net_setup_aneg() argument
168 struct mii_phy *phy = &card->phy; in spider_net_setup_aneg()
172 bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); in spider_net_setup_aneg()
173 estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); in spider_net_setup_aneg()
195 * spider_net_rx_irq_off - switch off rx irq on this spider card
196 * @card: device structure
201 spider_net_rx_irq_off(struct spider_net_card *card) in spider_net_rx_irq_off() argument
206 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, regvalue); in spider_net_rx_irq_off()
210 * spider_net_rx_irq_on - switch on rx irq on this spider card
211 * @card: device structure
216 spider_net_rx_irq_on(struct spider_net_card *card) in spider_net_rx_irq_on() argument
221 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, regvalue); in spider_net_rx_irq_on()
226 * @card: card structure
232 spider_net_set_promisc(struct spider_net_card *card) in spider_net_set_promisc() argument
235 struct net_device *netdev = card->netdev; in spider_net_set_promisc()
239 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, 0); in spider_net_set_promisc()
240 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, 0); in spider_net_set_promisc()
241 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, in spider_net_set_promisc()
250 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, macu); in spider_net_set_promisc()
251 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, macl); in spider_net_set_promisc()
252 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, in spider_net_set_promisc()
271 * @card: card structure
276 spider_net_free_chain(struct spider_net_card *card, in spider_net_free_chain() argument
288 dma_free_coherent(&card->pdev->dev, chain->num_desc * sizeof(struct spider_net_hw_descr), in spider_net_free_chain()
294 * @card: card structure
303 spider_net_init_chain(struct spider_net_card *card, in spider_net_init_chain() argument
314 chain->hwring = dma_alloc_coherent(&card->pdev->dev, alloc_size, in spider_net_init_chain()
346 * @card: card structure
351 spider_net_free_rx_chain_contents(struct spider_net_card *card) in spider_net_free_rx_chain_contents() argument
355 descr = card->rx_chain.head; in spider_net_free_rx_chain_contents()
358 dma_unmap_single(&card->pdev->dev, in spider_net_free_rx_chain_contents()
366 } while (descr != card->rx_chain.head); in spider_net_free_rx_chain_contents()
371 * @card: card structure
380 spider_net_prepare_rx_descr(struct spider_net_card *card, in spider_net_prepare_rx_descr() argument
396 descr->skb = netdev_alloc_skb(card->netdev, in spider_net_prepare_rx_descr()
399 if (netif_msg_rx_err(card) && net_ratelimit()) in spider_net_prepare_rx_descr()
400 dev_err(&card->netdev->dev, in spider_net_prepare_rx_descr()
402 card->spider_stats.alloc_rx_skb_error++; in spider_net_prepare_rx_descr()
416 buf = dma_map_single(&card->pdev->dev, descr->skb->data, in spider_net_prepare_rx_descr()
418 if (dma_mapping_error(&card->pdev->dev, buf)) { in spider_net_prepare_rx_descr()
421 if (netif_msg_rx_err(card) && net_ratelimit()) in spider_net_prepare_rx_descr()
422 dev_err(&card->netdev->dev, "Could not iommu-map rx buffer\n"); in spider_net_prepare_rx_descr()
423 card->spider_stats.rx_iommu_map_error++; in spider_net_prepare_rx_descr()
437 * @card: card structure
444 spider_net_enable_rxchtails(struct spider_net_card *card) in spider_net_enable_rxchtails() argument
447 spider_net_write_reg(card, SPIDER_NET_GDADCHA , in spider_net_enable_rxchtails()
448 card->rx_chain.tail->bus_addr); in spider_net_enable_rxchtails()
453 * @card: card structure
459 spider_net_enable_rxdmac(struct spider_net_card *card) in spider_net_enable_rxdmac() argument
462 spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, in spider_net_enable_rxdmac()
468 * @card: card structure
474 spider_net_disable_rxdmac(struct spider_net_card *card) in spider_net_disable_rxdmac() argument
476 spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, in spider_net_disable_rxdmac()
482 * @card: card structure
487 spider_net_refill_rx_chain(struct spider_net_card *card) in spider_net_refill_rx_chain() argument
489 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_refill_rx_chain()
502 if (spider_net_prepare_rx_descr(card, chain->head)) in spider_net_refill_rx_chain()
512 * @card: card structure
517 spider_net_alloc_rx_skbs(struct spider_net_card *card) in spider_net_alloc_rx_skbs() argument
519 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_alloc_rx_skbs()
533 if (spider_net_prepare_rx_descr(card, chain->head)) in spider_net_alloc_rx_skbs()
541 spider_net_refill_rx_chain(card); in spider_net_alloc_rx_skbs()
542 spider_net_enable_rxdmac(card); in spider_net_alloc_rx_skbs()
546 spider_net_free_rx_chain_contents(card); in spider_net_alloc_rx_skbs()
598 struct spider_net_card *card = netdev_priv(netdev); in spider_net_set_multi() local
601 spider_net_set_promisc(card); in spider_net_set_multi()
634 spider_net_write_reg(card, SPIDER_NET_GMRMHFILnR + i * 4, reg); in spider_net_set_multi()
640 * @card: card structure
649 spider_net_prepare_tx_descr(struct spider_net_card *card, in spider_net_prepare_tx_descr() argument
652 struct spider_net_descr_chain *chain = &card->tx_chain; in spider_net_prepare_tx_descr()
658 buf = dma_map_single(&card->pdev->dev, skb->data, skb->len, in spider_net_prepare_tx_descr()
660 if (dma_mapping_error(&card->pdev->dev, buf)) { in spider_net_prepare_tx_descr()
661 if (netif_msg_tx_err(card) && net_ratelimit()) in spider_net_prepare_tx_descr()
662 dev_err(&card->netdev->dev, "could not iommu-map packet (%p, %i). " in spider_net_prepare_tx_descr()
664 card->spider_stats.tx_iommu_map_error++; in spider_net_prepare_tx_descr()
669 descr = card->tx_chain.head; in spider_net_prepare_tx_descr()
672 dma_unmap_single(&card->pdev->dev, buf, skb->len, in spider_net_prepare_tx_descr()
703 netif_trans_update(card->netdev); /* set netdev watchdog timer */ in spider_net_prepare_tx_descr()
708 spider_net_set_low_watermark(struct spider_net_card *card) in spider_net_set_low_watermark() argument
710 struct spider_net_descr *descr = card->tx_chain.tail; in spider_net_set_low_watermark()
720 while (descr != card->tx_chain.head) { in spider_net_set_low_watermark()
729 if (cnt < card->tx_chain.num_desc/4) in spider_net_set_low_watermark()
733 descr = card->tx_chain.tail; in spider_net_set_low_watermark()
739 spin_lock_irqsave(&card->tx_chain.lock, flags); in spider_net_set_low_watermark()
741 if (card->low_watermark && card->low_watermark != descr) { in spider_net_set_low_watermark()
742 hwdescr = card->low_watermark->hwdescr; in spider_net_set_low_watermark()
746 card->low_watermark = descr; in spider_net_set_low_watermark()
747 spin_unlock_irqrestore(&card->tx_chain.lock, flags); in spider_net_set_low_watermark()
753 * @card: adapter structure
764 spider_net_release_tx_chain(struct spider_net_card *card, int brutal) in spider_net_release_tx_chain() argument
766 struct net_device *dev = card->netdev; in spider_net_release_tx_chain()
767 struct spider_net_descr_chain *chain = &card->tx_chain; in spider_net_release_tx_chain()
806 if (netif_msg_tx_err(card)) in spider_net_release_tx_chain()
807 dev_err(&card->netdev->dev, "forcing end of tx descriptor " in spider_net_release_tx_chain()
829 dma_unmap_single(&card->pdev->dev, buf_addr, skb->len, in spider_net_release_tx_chain()
839 * @card: card structure
849 spider_net_kick_tx_dma(struct spider_net_card *card) in spider_net_kick_tx_dma() argument
853 if (spider_net_read_reg(card, SPIDER_NET_GDTDMACCNTR) & in spider_net_kick_tx_dma()
857 descr = card->tx_chain.tail; in spider_net_kick_tx_dma()
861 spider_net_write_reg(card, SPIDER_NET_GDTDCHA, in spider_net_kick_tx_dma()
863 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, in spider_net_kick_tx_dma()
867 if (descr == card->tx_chain.head) in spider_net_kick_tx_dma()
873 mod_timer(&card->tx_timer, jiffies + SPIDER_NET_TX_TIMER); in spider_net_kick_tx_dma()
887 struct spider_net_card *card = netdev_priv(netdev); in spider_net_xmit() local
889 spider_net_release_tx_chain(card, 0); in spider_net_xmit()
891 if (spider_net_prepare_tx_descr(card, skb) != 0) { in spider_net_xmit()
897 cnt = spider_net_set_low_watermark(card); in spider_net_xmit()
899 spider_net_kick_tx_dma(card); in spider_net_xmit()
905 * @t: timer context used to obtain the pointer to net card data structure
915 struct spider_net_card *card = from_timer(card, t, tx_timer); in spider_net_cleanup_tx_ring() local
916 if ((spider_net_release_tx_chain(card, 0) != 0) && in spider_net_cleanup_tx_ring()
917 (card->netdev->flags & IFF_UP)) { in spider_net_cleanup_tx_ring()
918 spider_net_kick_tx_dma(card); in spider_net_cleanup_tx_ring()
919 netif_wake_queue(card->netdev); in spider_net_cleanup_tx_ring()
944 * @card: card structure
951 struct spider_net_card *card) in spider_net_pass_skb_up() argument
955 struct net_device *netdev = card->netdev; in spider_net_pass_skb_up()
961 /* the card seems to add 2 bytes of junk in front in spider_net_pass_skb_up()
989 static void show_rx_chain(struct spider_net_card *card) in show_rx_chain() argument
991 struct spider_net_descr_chain *chain = &card->rx_chain; in show_rx_chain()
995 struct device *dev = &card->netdev->dev; in show_rx_chain()
1009 curr_desc = spider_net_read_reg(card, SPIDER_NET_GDACTDPA); in show_rx_chain()
1010 next_desc = spider_net_read_reg(card, SPIDER_NET_GDACNEXTDA); in show_rx_chain()
1079 * @card: card structure
1087 static void spider_net_resync_head_ptr(struct spider_net_card *card) in spider_net_resync_head_ptr() argument
1090 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_resync_head_ptr()
1115 static int spider_net_resync_tail_ptr(struct spider_net_card *card) in spider_net_resync_tail_ptr() argument
1117 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_resync_tail_ptr()
1140 * @card: card structure
1150 spider_net_decode_one_descr(struct spider_net_card *card) in spider_net_decode_one_descr() argument
1152 struct net_device *dev = card->netdev; in spider_net_decode_one_descr()
1153 struct spider_net_descr_chain *chain = &card->rx_chain; in spider_net_decode_one_descr()
1172 dma_unmap_single(&card->pdev->dev, hw_buf_addr, SPIDER_NET_MAX_FRAME, in spider_net_decode_one_descr()
1178 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1187 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1188 dev_err(&card->netdev->dev, in spider_net_decode_one_descr()
1190 card->spider_stats.rx_desc_unk_state++; in spider_net_decode_one_descr()
1196 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1197 dev_err(&card->netdev->dev, in spider_net_decode_one_descr()
1205 dev_err(&card->netdev->dev, "bad status, cmd_status=x%08x\n", in spider_net_decode_one_descr()
1214 pr_err("which=%ld\n", descr - card->rx_chain.ring); in spider_net_decode_one_descr()
1216 card->spider_stats.rx_desc_error++; in spider_net_decode_one_descr()
1221 spider_net_pass_skb_up(descr, card); in spider_net_decode_one_descr()
1227 if (netif_msg_rx_err(card)) in spider_net_decode_one_descr()
1228 show_rx_chain(card); in spider_net_decode_one_descr()
1249 struct spider_net_card *card = container_of(napi, struct spider_net_card, napi); in spider_net_poll() local
1253 if (!spider_net_decode_one_descr(card)) in spider_net_poll()
1259 if ((packets_done == 0) && (card->num_rx_ints != 0)) { in spider_net_poll()
1260 if (!spider_net_resync_tail_ptr(card)) in spider_net_poll()
1262 spider_net_resync_head_ptr(card); in spider_net_poll()
1264 card->num_rx_ints = 0; in spider_net_poll()
1266 spider_net_refill_rx_chain(card); in spider_net_poll()
1267 spider_net_enable_rxdmac(card); in spider_net_poll()
1269 spider_net_cleanup_tx_ring(&card->tx_timer); in spider_net_poll()
1275 spider_net_rx_irq_on(card); in spider_net_poll()
1276 card->ignore_rx_ramfull = 0; in spider_net_poll()
1293 struct spider_net_card *card = netdev_priv(netdev); in spider_net_set_mac() local
1303 regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); in spider_net_set_mac()
1305 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); in spider_net_set_mac()
1311 spider_net_write_reg(card, SPIDER_NET_GMACUNIMACU, macu); in spider_net_set_mac()
1312 spider_net_write_reg(card, SPIDER_NET_GMACUNIMACL, macl); in spider_net_set_mac()
1315 regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); in spider_net_set_mac()
1317 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); in spider_net_set_mac()
1319 spider_net_set_promisc(card); in spider_net_set_mac()
1336 struct spider_net_card *card = netdev_priv(netdev); in spider_net_link_reset() local
1338 del_timer_sync(&card->aneg_timer); in spider_net_link_reset()
1341 spider_net_write_reg(card, SPIDER_NET_GMACST, in spider_net_link_reset()
1342 spider_net_read_reg(card, SPIDER_NET_GMACST)); in spider_net_link_reset()
1343 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0); in spider_net_link_reset()
1346 card->aneg_count = 0; in spider_net_link_reset()
1347 card->medium = BCM54XX_COPPER; in spider_net_link_reset()
1348 spider_net_setup_aneg(card); in spider_net_link_reset()
1349 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_link_reset()
1355 * @card: card structure
1364 spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg, in spider_net_handle_error_irq() argument
1403 if (netif_msg_intr(card)) in spider_net_handle_error_irq()
1404 dev_err(&card->netdev->dev, "PHY write queue full\n"); in spider_net_handle_error_irq()
1448 if (card->tx_chain.tail != card->tx_chain.head) in spider_net_handle_error_irq()
1449 spider_net_kick_tx_dma(card); in spider_net_handle_error_irq()
1476 if (card->ignore_rx_ramfull == 0) { in spider_net_handle_error_irq()
1477 card->ignore_rx_ramfull = 1; in spider_net_handle_error_irq()
1478 spider_net_resync_head_ptr(card); in spider_net_handle_error_irq()
1479 spider_net_refill_rx_chain(card); in spider_net_handle_error_irq()
1480 spider_net_enable_rxdmac(card); in spider_net_handle_error_irq()
1481 card->num_rx_ints ++; in spider_net_handle_error_irq()
1482 napi_schedule(&card->napi); in spider_net_handle_error_irq()
1498 spider_net_resync_head_ptr(card); in spider_net_handle_error_irq()
1499 spider_net_refill_rx_chain(card); in spider_net_handle_error_irq()
1500 spider_net_enable_rxdmac(card); in spider_net_handle_error_irq()
1501 card->num_rx_ints ++; in spider_net_handle_error_irq()
1502 napi_schedule(&card->napi); in spider_net_handle_error_irq()
1512 spider_net_resync_head_ptr(card); in spider_net_handle_error_irq()
1513 spider_net_refill_rx_chain(card); in spider_net_handle_error_irq()
1514 spider_net_enable_rxdmac(card); in spider_net_handle_error_irq()
1515 card->num_rx_ints ++; in spider_net_handle_error_irq()
1516 napi_schedule(&card->napi); in spider_net_handle_error_irq()
1571 if ((show_error) && (netif_msg_intr(card)) && net_ratelimit()) in spider_net_handle_error_irq()
1572 dev_err(&card->netdev->dev, "Error interrupt, GHIINT0STS = 0x%08x, " in spider_net_handle_error_irq()
1577 spider_net_write_reg(card, SPIDER_NET_GHIINT1STS, error_reg1); in spider_net_handle_error_irq()
1578 spider_net_write_reg(card, SPIDER_NET_GHIINT2STS, error_reg2); in spider_net_handle_error_irq()
1587 * interrupt found raised by card.
1596 struct spider_net_card *card = netdev_priv(netdev); in spider_net_interrupt() local
1599 status_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0STS); in spider_net_interrupt()
1600 error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS); in spider_net_interrupt()
1601 error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS); in spider_net_interrupt()
1609 spider_net_rx_irq_off(card); in spider_net_interrupt()
1610 napi_schedule(&card->napi); in spider_net_interrupt()
1611 card->num_rx_ints ++; in spider_net_interrupt()
1614 napi_schedule(&card->napi); in spider_net_interrupt()
1620 spider_net_handle_error_irq(card, status_reg, in spider_net_interrupt()
1624 spider_net_write_reg(card, SPIDER_NET_GHIINT0STS, status_reg); in spider_net_interrupt()
1647 * @card: card structure
1652 spider_net_enable_interrupts(struct spider_net_card *card) in spider_net_enable_interrupts() argument
1654 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, in spider_net_enable_interrupts()
1656 spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, in spider_net_enable_interrupts()
1658 spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, in spider_net_enable_interrupts()
1664 * @card: card structure
1669 spider_net_disable_interrupts(struct spider_net_card *card) in spider_net_disable_interrupts() argument
1671 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0); in spider_net_disable_interrupts()
1672 spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0); in spider_net_disable_interrupts()
1673 spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0); in spider_net_disable_interrupts()
1674 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0); in spider_net_disable_interrupts()
1678 * spider_net_init_card - initializes the card
1679 * @card: card structure
1681 * spider_net_init_card initializes the card so that other registers can
1685 spider_net_init_card(struct spider_net_card *card) in spider_net_init_card() argument
1687 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_init_card()
1690 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_init_card()
1694 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, in spider_net_init_card()
1695 spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 0x4); in spider_net_init_card()
1697 spider_net_disable_interrupts(card); in spider_net_init_card()
1701 * spider_net_enable_card - enables the card by setting all kinds of regs
1702 * @card: card structure
1707 spider_net_enable_card(struct spider_net_card *card) in spider_net_enable_card() argument
1756 spider_net_write_reg(card, regs[i][0], regs[i][1]); in spider_net_enable_card()
1762 spider_net_write_reg(card, in spider_net_enable_card()
1765 spider_net_write_reg(card, in spider_net_enable_card()
1770 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, 0x08080000); in spider_net_enable_card()
1772 spider_net_write_reg(card, SPIDER_NET_ECMODE, SPIDER_NET_ECMODE_VALUE); in spider_net_enable_card()
1777 spider_net_enable_rxchtails(card); in spider_net_enable_card()
1778 spider_net_enable_rxdmac(card); in spider_net_enable_card()
1780 spider_net_write_reg(card, SPIDER_NET_GRXDMAEN, SPIDER_NET_WOL_VALUE); in spider_net_enable_card()
1782 spider_net_write_reg(card, SPIDER_NET_GMACLENLMT, in spider_net_enable_card()
1784 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, in spider_net_enable_card()
1787 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, in spider_net_enable_card()
1793 * @card: card structure
1800 spider_net_download_firmware(struct spider_net_card *card, in spider_net_download_firmware() argument
1807 spider_net_write_reg(card, SPIDER_NET_GSINIT, in spider_net_download_firmware()
1812 spider_net_write_reg(card, in spider_net_download_firmware()
1815 spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + in spider_net_download_firmware()
1821 if (spider_net_read_reg(card, SPIDER_NET_GSINIT)) in spider_net_download_firmware()
1824 spider_net_write_reg(card, SPIDER_NET_GSINIT, in spider_net_download_firmware()
1832 * @card: card structure
1857 spider_net_init_firmware(struct spider_net_card *card) in spider_net_init_firmware() argument
1866 SPIDER_NET_FIRMWARE_NAME, &card->pdev->dev) == 0) { in spider_net_init_firmware()
1868 netif_msg_probe(card) ) { in spider_net_init_firmware()
1869 dev_err(&card->netdev->dev, in spider_net_init_firmware()
1874 err = spider_net_download_firmware(card, firmware->data); in spider_net_init_firmware()
1884 dn = pci_device_to_OF_node(card->pdev); in spider_net_init_firmware()
1893 netif_msg_probe(card) ) { in spider_net_init_firmware()
1894 dev_err(&card->netdev->dev, in spider_net_init_firmware()
1899 err = spider_net_download_firmware(card, fw_prop); in spider_net_init_firmware()
1904 if (netif_msg_probe(card)) in spider_net_init_firmware()
1905 dev_err(&card->netdev->dev, in spider_net_init_firmware()
1923 struct spider_net_card *card = netdev_priv(netdev); in spider_net_open() local
1926 result = spider_net_init_firmware(card); in spider_net_open()
1931 card->aneg_count = 0; in spider_net_open()
1932 card->medium = BCM54XX_COPPER; in spider_net_open()
1933 spider_net_setup_aneg(card); in spider_net_open()
1934 if (card->phy.def->phy_id) in spider_net_open()
1935 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_open()
1937 result = spider_net_init_chain(card, &card->tx_chain); in spider_net_open()
1940 card->low_watermark = NULL; in spider_net_open()
1942 result = spider_net_init_chain(card, &card->rx_chain); in spider_net_open()
1947 result = spider_net_alloc_rx_skbs(card); in spider_net_open()
1960 spider_net_enable_card(card); in spider_net_open()
1964 napi_enable(&card->napi); in spider_net_open()
1966 spider_net_enable_interrupts(card); in spider_net_open()
1971 spider_net_free_rx_chain_contents(card); in spider_net_open()
1973 spider_net_free_chain(card, &card->rx_chain); in spider_net_open()
1975 spider_net_free_chain(card, &card->tx_chain); in spider_net_open()
1977 del_timer_sync(&card->aneg_timer); in spider_net_open()
1984 * @t: timer context used to obtain the pointer to net card data structure
1988 struct spider_net_card *card = from_timer(card, t, aneg_timer); in spider_net_link_phy() local
1989 struct mii_phy *phy = &card->phy; in spider_net_link_phy()
1992 if (card->aneg_count > SPIDER_NET_ANEG_TIMEOUT) { in spider_net_link_phy()
1995 card->netdev->name); in spider_net_link_phy()
1997 switch (card->medium) { in spider_net_link_phy()
2002 card->medium = BCM54XX_FIBER; in spider_net_link_phy()
2009 card->medium = BCM54XX_UNKNOWN; in spider_net_link_phy()
2016 spider_net_setup_aneg(card); in spider_net_link_phy()
2017 card->medium = BCM54XX_COPPER; in spider_net_link_phy()
2021 card->aneg_count = 0; in spider_net_link_phy()
2022 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_link_phy()
2028 card->aneg_count++; in spider_net_link_phy()
2029 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); in spider_net_link_phy()
2036 spider_net_write_reg(card, SPIDER_NET_GMACST, in spider_net_link_phy()
2037 spider_net_read_reg(card, SPIDER_NET_GMACST)); in spider_net_link_phy()
2038 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0x4); in spider_net_link_phy()
2041 spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0x00000001); in spider_net_link_phy()
2043 spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0); in spider_net_link_phy()
2045 card->aneg_count = 0; in spider_net_link_phy()
2048 card->netdev->name, phy->speed, in spider_net_link_phy()
2055 * @card: card structure
2062 spider_net_setup_phy(struct spider_net_card *card) in spider_net_setup_phy() argument
2064 struct mii_phy *phy = &card->phy; in spider_net_setup_phy()
2066 spider_net_write_reg(card, SPIDER_NET_GDTDMASEL, in spider_net_setup_phy()
2068 spider_net_write_reg(card, SPIDER_NET_GPCCTRL, in spider_net_setup_phy()
2071 phy->dev = card->netdev; in spider_net_setup_phy()
2077 id = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); in spider_net_setup_phy()
2091 * @card: card structure
2096 spider_net_workaround_rxramfull(struct spider_net_card *card) in spider_net_workaround_rxramfull() argument
2101 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_workaround_rxramfull()
2107 spider_net_write_reg(card, SPIDER_NET_GSnPRGADR + in spider_net_workaround_rxramfull()
2110 spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + in spider_net_workaround_rxramfull()
2116 spider_net_write_reg(card, SPIDER_NET_GSINIT, 0x000000fe); in spider_net_workaround_rxramfull()
2119 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_workaround_rxramfull()
2132 struct spider_net_card *card = netdev_priv(netdev); in spider_net_stop() local
2134 napi_disable(&card->napi); in spider_net_stop()
2137 del_timer_sync(&card->tx_timer); in spider_net_stop()
2138 del_timer_sync(&card->aneg_timer); in spider_net_stop()
2140 spider_net_disable_interrupts(card); in spider_net_stop()
2144 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, in spider_net_stop()
2148 spider_net_disable_rxdmac(card); in spider_net_stop()
2151 spider_net_release_tx_chain(card, 1); in spider_net_stop()
2152 spider_net_free_rx_chain_contents(card); in spider_net_stop()
2154 spider_net_free_chain(card, &card->tx_chain); in spider_net_stop()
2155 spider_net_free_chain(card, &card->rx_chain); in spider_net_stop()
2163 * @work: work context used to obtain the pointer to net card data structure
2170 struct spider_net_card *card = in spider_net_tx_timeout_task() local
2172 struct net_device *netdev = card->netdev; in spider_net_tx_timeout_task()
2180 spider_net_workaround_rxramfull(card); in spider_net_tx_timeout_task()
2181 spider_net_init_card(card); in spider_net_tx_timeout_task()
2183 if (spider_net_setup_phy(card)) in spider_net_tx_timeout_task()
2187 spider_net_kick_tx_dma(card); in spider_net_tx_timeout_task()
2191 atomic_dec(&card->tx_timeout_task_counter); in spider_net_tx_timeout_task()
2204 struct spider_net_card *card; in spider_net_tx_timeout() local
2206 card = netdev_priv(netdev); in spider_net_tx_timeout()
2207 atomic_inc(&card->tx_timeout_task_counter); in spider_net_tx_timeout()
2209 schedule_work(&card->tx_timeout_task); in spider_net_tx_timeout()
2211 atomic_dec(&card->tx_timeout_task_counter); in spider_net_tx_timeout()
2212 card->spider_stats.tx_timeouts++; in spider_net_tx_timeout()
2248 * @card: card structure
2255 spider_net_setup_netdev(struct spider_net_card *card) in spider_net_setup_netdev() argument
2258 struct net_device *netdev = card->netdev; in spider_net_setup_netdev()
2263 SET_NETDEV_DEV(netdev, &card->pdev->dev); in spider_net_setup_netdev()
2265 pci_set_drvdata(card->pdev, netdev); in spider_net_setup_netdev()
2267 timer_setup(&card->tx_timer, spider_net_cleanup_tx_ring, 0); in spider_net_setup_netdev()
2268 netdev->irq = card->pdev->irq; in spider_net_setup_netdev()
2270 card->aneg_count = 0; in spider_net_setup_netdev()
2271 timer_setup(&card->aneg_timer, spider_net_link_phy, 0); in spider_net_setup_netdev()
2273 netif_napi_add(netdev, &card->napi, spider_net_poll); in spider_net_setup_netdev()
2290 netdev->irq = card->pdev->irq; in spider_net_setup_netdev()
2291 card->num_rx_ints = 0; in spider_net_setup_netdev()
2292 card->ignore_rx_ramfull = 0; in spider_net_setup_netdev()
2294 dn = pci_device_to_OF_node(card->pdev); in spider_net_setup_netdev()
2304 if ((result) && (netif_msg_probe(card))) in spider_net_setup_netdev()
2305 dev_err(&card->netdev->dev, in spider_net_setup_netdev()
2310 if (netif_msg_probe(card)) in spider_net_setup_netdev()
2311 dev_err(&card->netdev->dev, in spider_net_setup_netdev()
2316 if (netif_msg_probe(card)) in spider_net_setup_netdev()
2323 * spider_net_alloc_card - allocates net_device and card structure
2325 * returns the card structure or NULL in case of errors
2327 * the card and net_device structures are linked to each other
2333 struct spider_net_card *card; in spider_net_alloc_card() local
2335 netdev = alloc_etherdev(struct_size(card, darray, in spider_net_alloc_card()
2340 card = netdev_priv(netdev); in spider_net_alloc_card()
2341 card->netdev = netdev; in spider_net_alloc_card()
2342 card->msg_enable = SPIDER_NET_DEFAULT_MSG; in spider_net_alloc_card()
2343 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task); in spider_net_alloc_card()
2344 init_waitqueue_head(&card->waitq); in spider_net_alloc_card()
2345 atomic_set(&card->tx_timeout_task_counter, 0); in spider_net_alloc_card()
2347 card->rx_chain.num_desc = rx_descriptors; in spider_net_alloc_card()
2348 card->rx_chain.ring = card->darray; in spider_net_alloc_card()
2349 card->tx_chain.num_desc = tx_descriptors; in spider_net_alloc_card()
2350 card->tx_chain.ring = card->darray + rx_descriptors; in spider_net_alloc_card()
2352 return card; in spider_net_alloc_card()
2357 * @card: card structure
2362 spider_net_undo_pci_setup(struct spider_net_card *card) in spider_net_undo_pci_setup() argument
2364 iounmap(card->regs); in spider_net_undo_pci_setup()
2365 pci_release_regions(card->pdev); in spider_net_undo_pci_setup()
2372 * Returns the card structure or NULL if any errors occur
2377 * The net_device structure is attached to the card structure, if the
2383 struct spider_net_card *card; in spider_net_setup_pci_dev() local
2405 card = spider_net_alloc_card(); in spider_net_setup_pci_dev()
2406 if (!card) { in spider_net_setup_pci_dev()
2411 card->pdev = pdev; in spider_net_setup_pci_dev()
2417 card->netdev->mem_start = mmio_start; in spider_net_setup_pci_dev()
2418 card->netdev->mem_end = mmio_start + mmio_len; in spider_net_setup_pci_dev()
2419 card->regs = ioremap(mmio_start, mmio_len); in spider_net_setup_pci_dev()
2421 if (!card->regs) { in spider_net_setup_pci_dev()
2427 return card; in spider_net_setup_pci_dev()
2450 struct spider_net_card *card; in spider_net_probe() local
2452 card = spider_net_setup_pci_dev(pdev); in spider_net_probe()
2453 if (!card) in spider_net_probe()
2456 spider_net_workaround_rxramfull(card); in spider_net_probe()
2457 spider_net_init_card(card); in spider_net_probe()
2459 err = spider_net_setup_phy(card); in spider_net_probe()
2463 err = spider_net_setup_netdev(card); in spider_net_probe()
2470 spider_net_undo_pci_setup(card); in spider_net_probe()
2471 free_netdev(card->netdev); in spider_net_probe()
2489 struct spider_net_card *card; in spider_net_remove() local
2492 card = netdev_priv(netdev); in spider_net_remove()
2494 wait_event(card->waitq, in spider_net_remove()
2495 atomic_read(&card->tx_timeout_task_counter) == 0); in spider_net_remove()
2499 /* switch off card */ in spider_net_remove()
2500 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_remove()
2502 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, in spider_net_remove()
2505 spider_net_undo_pci_setup(card); in spider_net_remove()