Lines Matching refs:ndev

160 	struct net_device *ndev;  member
191 static void hip04_config_port(struct net_device *ndev, u32 speed, u32 duplex) in hip04_config_port() argument
193 struct hip04_priv *priv = netdev_priv(ndev); in hip04_config_port()
215 netdev_warn(ndev, "not supported mode\n"); in hip04_config_port()
296 static void hip04_mac_enable(struct net_device *ndev) in hip04_mac_enable() argument
298 struct hip04_priv *priv = netdev_priv(ndev); in hip04_mac_enable()
319 static void hip04_mac_disable(struct net_device *ndev) in hip04_mac_disable() argument
321 struct hip04_priv *priv = netdev_priv(ndev); in hip04_mac_disable()
349 static void hip04_update_mac_address(struct net_device *ndev) in hip04_update_mac_address() argument
351 struct hip04_priv *priv = netdev_priv(ndev); in hip04_update_mac_address()
353 writel_relaxed(((ndev->dev_addr[0] << 8) | (ndev->dev_addr[1])), in hip04_update_mac_address()
355 writel_relaxed(((ndev->dev_addr[2] << 24) | (ndev->dev_addr[3] << 16) | in hip04_update_mac_address()
356 (ndev->dev_addr[4] << 8) | (ndev->dev_addr[5])), in hip04_update_mac_address()
360 static int hip04_set_mac_address(struct net_device *ndev, void *addr) in hip04_set_mac_address() argument
362 eth_mac_addr(ndev, addr); in hip04_set_mac_address()
363 hip04_update_mac_address(ndev); in hip04_set_mac_address()
367 static int hip04_tx_reclaim(struct net_device *ndev, bool force) in hip04_tx_reclaim() argument
369 struct hip04_priv *priv = netdev_priv(ndev); in hip04_tx_reclaim()
390 dma_unmap_single(&ndev->dev, priv->tx_phys[tx_tail], in hip04_tx_reclaim()
408 netdev_completed_queue(ndev, pkts_compl, bytes_compl); in hip04_tx_reclaim()
410 if (unlikely(netif_queue_stopped(ndev)) && (count < (TX_DESC_NUM - 1))) in hip04_tx_reclaim()
411 netif_wake_queue(ndev); in hip04_tx_reclaim()
425 static int hip04_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev) in hip04_mac_start_xmit() argument
427 struct hip04_priv *priv = netdev_priv(ndev); in hip04_mac_start_xmit()
428 struct net_device_stats *stats = &ndev->stats; in hip04_mac_start_xmit()
436 netif_stop_queue(ndev); in hip04_mac_start_xmit()
440 phys = dma_map_single(&ndev->dev, skb->data, skb->len, DMA_TO_DEVICE); in hip04_mac_start_xmit()
441 if (dma_mapping_error(&ndev->dev, phys)) { in hip04_mac_start_xmit()
458 netdev_sent_queue(ndev, skb->len); in hip04_mac_start_xmit()
487 struct net_device *ndev = priv->ndev; in hip04_rx_poll() local
488 struct net_device_stats *stats = &ndev->stats; in hip04_rx_poll()
506 dma_unmap_single(&ndev->dev, priv->rx_phys[priv->rx_head], in hip04_rx_poll()
524 skb->protocol = eth_type_trans(skb, ndev); in hip04_rx_poll()
534 phys = dma_map_single(&ndev->dev, buf, in hip04_rx_poll()
536 if (dma_mapping_error(&ndev->dev, phys)) in hip04_rx_poll()
558 tx_remaining = hip04_tx_reclaim(ndev, false); in hip04_rx_poll()
567 struct net_device *ndev = (struct net_device *)dev_id; in hip04_mac_interrupt() local
568 struct hip04_priv *priv = netdev_priv(ndev); in hip04_mac_interrupt()
569 struct net_device_stats *stats = &ndev->stats; in hip04_mac_interrupt()
581 netdev_err(ndev, "rx drop\n"); in hip04_mac_interrupt()
585 netdev_err(ndev, "tx drop\n"); in hip04_mac_interrupt()
616 static void hip04_adjust_link(struct net_device *ndev) in hip04_adjust_link() argument
618 struct hip04_priv *priv = netdev_priv(ndev); in hip04_adjust_link()
622 hip04_config_port(ndev, phy->speed, phy->duplex); in hip04_adjust_link()
627 static int hip04_mac_open(struct net_device *ndev) in hip04_mac_open() argument
629 struct hip04_priv *priv = netdev_priv(ndev); in hip04_mac_open()
640 phys = dma_map_single(&ndev->dev, priv->rx_buf[i], in hip04_mac_open()
642 if (dma_mapping_error(&ndev->dev, phys)) in hip04_mac_open()
652 netdev_reset_queue(ndev); in hip04_mac_open()
653 netif_start_queue(ndev); in hip04_mac_open()
654 hip04_mac_enable(ndev); in hip04_mac_open()
660 static int hip04_mac_stop(struct net_device *ndev) in hip04_mac_stop() argument
662 struct hip04_priv *priv = netdev_priv(ndev); in hip04_mac_stop()
666 netif_stop_queue(ndev); in hip04_mac_stop()
667 hip04_mac_disable(ndev); in hip04_mac_stop()
668 hip04_tx_reclaim(ndev, true); in hip04_mac_stop()
676 dma_unmap_single(&ndev->dev, priv->rx_phys[i], in hip04_mac_stop()
685 static void hip04_timeout(struct net_device *ndev) in hip04_timeout() argument
687 struct hip04_priv *priv = netdev_priv(ndev); in hip04_timeout()
697 hip04_mac_stop(priv->ndev); in hip04_tx_timeout_task()
698 hip04_mac_open(priv->ndev); in hip04_tx_timeout_task()
701 static struct net_device_stats *hip04_get_stats(struct net_device *ndev) in hip04_get_stats() argument
703 return &ndev->stats; in hip04_get_stats()
772 static int hip04_alloc_ring(struct net_device *ndev, struct device *d) in hip04_alloc_ring() argument
774 struct hip04_priv *priv = netdev_priv(ndev); in hip04_alloc_ring()
794 static void hip04_free_ring(struct net_device *ndev, struct device *d) in hip04_free_ring() argument
796 struct hip04_priv *priv = netdev_priv(ndev); in hip04_free_ring()
816 struct net_device *ndev; in hip04_mac_probe() local
822 ndev = alloc_etherdev(sizeof(struct hip04_priv)); in hip04_mac_probe()
823 if (!ndev) in hip04_mac_probe()
826 priv = netdev_priv(ndev); in hip04_mac_probe()
827 priv->ndev = ndev; in hip04_mac_probe()
828 platform_set_drvdata(pdev, ndev); in hip04_mac_probe()
879 0, pdev->name, ndev); in hip04_mac_probe()
881 netdev_err(ndev, "devm_request_irq failed\n"); in hip04_mac_probe()
887 priv->phy = of_phy_connect(ndev, priv->phy_node, in hip04_mac_probe()
898 ether_setup(ndev); in hip04_mac_probe()
899 ndev->netdev_ops = &hip04_netdev_ops; in hip04_mac_probe()
900 ndev->ethtool_ops = &hip04_ethtool_ops; in hip04_mac_probe()
901 ndev->watchdog_timeo = TX_TIMEOUT; in hip04_mac_probe()
902 ndev->priv_flags |= IFF_UNICAST_FLT; in hip04_mac_probe()
903 ndev->irq = irq; in hip04_mac_probe()
904 netif_napi_add(ndev, &priv->napi, hip04_rx_poll, NAPI_POLL_WEIGHT); in hip04_mac_probe()
905 SET_NETDEV_DEV(ndev, &pdev->dev); in hip04_mac_probe()
909 hip04_config_port(ndev, SPEED_100, DUPLEX_FULL); in hip04_mac_probe()
912 random_ether_addr(ndev->dev_addr); in hip04_mac_probe()
913 hip04_update_mac_address(ndev); in hip04_mac_probe()
915 ret = hip04_alloc_ring(ndev, d); in hip04_mac_probe()
917 netdev_err(ndev, "alloc ring fail\n"); in hip04_mac_probe()
921 ret = register_netdev(ndev); in hip04_mac_probe()
923 free_netdev(ndev); in hip04_mac_probe()
930 hip04_free_ring(ndev, d); in hip04_mac_probe()
933 free_netdev(ndev); in hip04_mac_probe()
939 struct net_device *ndev = platform_get_drvdata(pdev); in hip04_remove() local
940 struct hip04_priv *priv = netdev_priv(ndev); in hip04_remove()
946 hip04_free_ring(ndev, d); in hip04_remove()
947 unregister_netdev(ndev); in hip04_remove()
948 free_irq(ndev->irq, ndev); in hip04_remove()
951 free_netdev(ndev); in hip04_remove()