Lines Matching refs:ndev
26 static void arc_emac_restart(struct net_device *ndev);
46 static void arc_emac_adjust_link(struct net_device *ndev) in arc_emac_adjust_link() argument
48 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_adjust_link()
49 struct phy_device *phy_dev = ndev->phydev; in arc_emac_adjust_link()
89 static void arc_emac_get_drvinfo(struct net_device *ndev, in arc_emac_get_drvinfo() argument
92 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_get_drvinfo()
110 static void arc_emac_tx_clean(struct net_device *ndev) in arc_emac_tx_clean() argument
112 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_tx_clean()
113 struct net_device_stats *stats = &ndev->stats; in arc_emac_tx_clean()
143 dma_unmap_single(&ndev->dev, dma_unmap_addr(tx_buff, addr), in arc_emac_tx_clean()
161 if (netif_queue_stopped(ndev) && arc_emac_tx_avail(priv)) in arc_emac_tx_clean()
162 netif_wake_queue(ndev); in arc_emac_tx_clean()
174 static int arc_emac_rx(struct net_device *ndev, int budget) in arc_emac_rx() argument
176 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_rx()
181 struct net_device_stats *stats = &ndev->stats; in arc_emac_rx()
202 netdev_err(ndev, "incomplete packet received\n"); in arc_emac_rx()
215 skb = netdev_alloc_skb_ip_align(ndev, EMAC_BUFFER_SIZE); in arc_emac_rx()
218 netdev_err(ndev, "cannot allocate skb\n"); in arc_emac_rx()
226 addr = dma_map_single(&ndev->dev, (void *)skb->data, in arc_emac_rx()
228 if (dma_mapping_error(&ndev->dev, addr)) { in arc_emac_rx()
230 netdev_err(ndev, "cannot map dma buffer\n"); in arc_emac_rx()
240 dma_unmap_single(&ndev->dev, dma_unmap_addr(rx_buff, addr), in arc_emac_rx()
247 rx_buff->skb->dev = ndev; in arc_emac_rx()
248 rx_buff->skb->protocol = eth_type_trans(rx_buff->skb, ndev); in arc_emac_rx()
272 static void arc_emac_rx_miss_handle(struct net_device *ndev) in arc_emac_rx_miss_handle() argument
274 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_rx_miss_handle()
275 struct net_device_stats *stats = &ndev->stats; in arc_emac_rx_miss_handle()
297 static void arc_emac_rx_stall_check(struct net_device *ndev, in arc_emac_rx_stall_check() argument
300 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_rx_stall_check()
309 arc_emac_restart(ndev); in arc_emac_rx_stall_check()
324 struct net_device *ndev = napi->dev; in arc_emac_poll() local
325 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_poll()
328 arc_emac_tx_clean(ndev); in arc_emac_poll()
329 arc_emac_rx_miss_handle(ndev); in arc_emac_poll()
331 work_done = arc_emac_rx(ndev, budget); in arc_emac_poll()
337 arc_emac_rx_stall_check(ndev, budget, work_done); in arc_emac_poll()
354 struct net_device *ndev = dev_instance; in arc_emac_intr() local
355 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_intr()
356 struct net_device_stats *stats = &ndev->stats; in arc_emac_intr()
422 static int arc_emac_open(struct net_device *ndev) in arc_emac_open() argument
424 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_open()
425 struct phy_device *phy_dev = ndev->phydev; in arc_emac_open()
443 rx_buff->skb = netdev_alloc_skb_ip_align(ndev, in arc_emac_open()
448 addr = dma_map_single(&ndev->dev, (void *)rx_buff->skb->data, in arc_emac_open()
450 if (dma_mapping_error(&ndev->dev, addr)) { in arc_emac_open()
451 netdev_err(ndev, "cannot dma map\n"); in arc_emac_open()
497 phy_start(ndev->phydev); in arc_emac_open()
499 netif_start_queue(ndev); in arc_emac_open()
511 static void arc_emac_set_rx_mode(struct net_device *ndev) in arc_emac_set_rx_mode() argument
513 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_set_rx_mode()
515 if (ndev->flags & IFF_PROMISC) { in arc_emac_set_rx_mode()
520 if (ndev->flags & IFF_ALLMULTI) { in arc_emac_set_rx_mode()
523 } else if (ndev->flags & IFF_MULTICAST) { in arc_emac_set_rx_mode()
528 netdev_for_each_mc_addr(ha, ndev) { in arc_emac_set_rx_mode()
548 static void arc_free_tx_queue(struct net_device *ndev) in arc_free_tx_queue() argument
550 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_free_tx_queue()
558 dma_unmap_single(&ndev->dev, in arc_free_tx_queue()
579 static void arc_free_rx_queue(struct net_device *ndev) in arc_free_rx_queue() argument
581 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_free_rx_queue()
589 dma_unmap_single(&ndev->dev, in arc_free_rx_queue()
612 static int arc_emac_stop(struct net_device *ndev) in arc_emac_stop() argument
614 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_stop()
617 netif_stop_queue(ndev); in arc_emac_stop()
619 phy_stop(ndev->phydev); in arc_emac_stop()
628 arc_free_tx_queue(ndev); in arc_emac_stop()
629 arc_free_rx_queue(ndev); in arc_emac_stop()
641 static struct net_device_stats *arc_emac_stats(struct net_device *ndev) in arc_emac_stats() argument
643 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_stats()
644 struct net_device_stats *stats = &ndev->stats; in arc_emac_stats()
676 static netdev_tx_t arc_emac_tx(struct sk_buff *skb, struct net_device *ndev) in arc_emac_tx() argument
678 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_tx()
680 struct net_device_stats *stats = &ndev->stats; in arc_emac_tx()
690 netif_stop_queue(ndev); in arc_emac_tx()
691 netdev_err(ndev, "BUG! Tx Ring full when queue awake!\n"); in arc_emac_tx()
695 addr = dma_map_single(&ndev->dev, (void *)skb->data, len, in arc_emac_tx()
698 if (unlikely(dma_mapping_error(&ndev->dev, addr))) { in arc_emac_tx()
731 netif_stop_queue(ndev); in arc_emac_tx()
735 netif_start_queue(ndev); in arc_emac_tx()
743 static void arc_emac_set_address_internal(struct net_device *ndev) in arc_emac_set_address_internal() argument
745 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_set_address_internal()
748 addr_low = le32_to_cpu(*(__le32 *)&ndev->dev_addr[0]); in arc_emac_set_address_internal()
749 addr_hi = le16_to_cpu(*(__le16 *)&ndev->dev_addr[4]); in arc_emac_set_address_internal()
766 static int arc_emac_set_address(struct net_device *ndev, void *p) in arc_emac_set_address() argument
770 if (netif_running(ndev)) in arc_emac_set_address()
776 memcpy(ndev->dev_addr, addr->sa_data, ndev->addr_len); in arc_emac_set_address()
778 arc_emac_set_address_internal(ndev); in arc_emac_set_address()
790 static void arc_emac_restart(struct net_device *ndev) in arc_emac_restart() argument
792 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_restart()
793 struct net_device_stats *stats = &ndev->stats; in arc_emac_restart()
797 netdev_warn(ndev, "restarting stalled EMAC\n"); in arc_emac_restart()
799 netif_stop_queue(ndev); in arc_emac_restart()
808 arc_free_tx_queue(ndev); in arc_emac_restart()
837 netif_start_queue(ndev); in arc_emac_restart()
853 int arc_emac_probe(struct net_device *ndev, int interface) in arc_emac_probe() argument
855 struct device *dev = ndev->dev.parent; in arc_emac_probe()
887 ndev->netdev_ops = &arc_emac_netdev_ops; in arc_emac_probe()
888 ndev->ethtool_ops = &arc_emac_ethtool_ops; in arc_emac_probe()
889 ndev->watchdog_timeo = TX_TIMEOUT; in arc_emac_probe()
891 priv = netdev_priv(ndev); in arc_emac_probe()
933 ndev->irq = irq; in arc_emac_probe()
934 dev_info(dev, "IRQ is %d\n", ndev->irq); in arc_emac_probe()
937 err = devm_request_irq(dev, ndev->irq, arc_emac_intr, 0, in arc_emac_probe()
938 ndev->name, ndev); in arc_emac_probe()
948 ether_addr_copy(ndev->dev_addr, mac_addr); in arc_emac_probe()
950 eth_hw_addr_random(ndev); in arc_emac_probe()
952 arc_emac_set_address_internal(ndev); in arc_emac_probe()
953 dev_info(dev, "MAC address is now %pM\n", ndev->dev_addr); in arc_emac_probe()
977 phydev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0, in arc_emac_probe()
988 netif_napi_add(ndev, &priv->napi, arc_emac_poll, ARC_EMAC_NAPI_WEIGHT); in arc_emac_probe()
990 err = register_netdev(ndev); in arc_emac_probe()
1014 int arc_emac_remove(struct net_device *ndev) in arc_emac_remove() argument
1016 struct arc_emac_priv *priv = netdev_priv(ndev); in arc_emac_remove()
1018 phy_disconnect(ndev->phydev); in arc_emac_remove()
1020 unregister_netdev(ndev); in arc_emac_remove()