Lines Matching defs:ndev

26 static void arc_emac_restart(struct net_device *ndev);
41 * @ndev: Pointer to the net_device structure.
46 static void arc_emac_adjust_link(struct net_device *ndev)
48 struct arc_emac_priv *priv = netdev_priv(ndev);
49 struct phy_device *phy_dev = ndev->phydev;
83 * @ndev: Pointer to net_device structure.
89 static void arc_emac_get_drvinfo(struct net_device *ndev,
92 struct arc_emac_priv *priv = netdev_priv(ndev);
108 * @ndev: Pointer to the network device.
110 static void arc_emac_tx_clean(struct net_device *ndev)
112 struct arc_emac_priv *priv = netdev_priv(ndev);
113 struct net_device_stats *stats = &ndev->stats;
143 dma_unmap_single(&ndev->dev, dma_unmap_addr(tx_buff, addr),
161 if (netif_queue_stopped(ndev) && arc_emac_tx_avail(priv))
162 netif_wake_queue(ndev);
167 * @ndev: Pointer to the network device.
174 static int arc_emac_rx(struct net_device *ndev, int budget)
176 struct arc_emac_priv *priv = netdev_priv(ndev);
181 struct net_device_stats *stats = &ndev->stats;
202 netdev_err(ndev, "incomplete packet received\n");
215 skb = netdev_alloc_skb_ip_align(ndev, EMAC_BUFFER_SIZE);
218 netdev_err(ndev, "cannot allocate skb\n");
226 addr = dma_map_single(&ndev->dev, (void *)skb->data,
228 if (dma_mapping_error(&ndev->dev, addr)) {
230 netdev_err(ndev, "cannot map dma buffer\n");
240 dma_unmap_single(&ndev->dev, dma_unmap_addr(rx_buff, addr),
247 rx_buff->skb->dev = ndev;
248 rx_buff->skb->protocol = eth_type_trans(rx_buff->skb, ndev);
270 * @ndev: Pointer to the net_device structure.
272 static void arc_emac_rx_miss_handle(struct net_device *ndev)
274 struct arc_emac_priv *priv = netdev_priv(ndev);
275 struct net_device_stats *stats = &ndev->stats;
288 * @ndev: Pointer to the net_device structure.
297 static void arc_emac_rx_stall_check(struct net_device *ndev,
300 struct arc_emac_priv *priv = netdev_priv(ndev);
309 arc_emac_restart(ndev);
324 struct net_device *ndev = napi->dev;
325 struct arc_emac_priv *priv = netdev_priv(ndev);
328 arc_emac_tx_clean(ndev);
329 arc_emac_rx_miss_handle(ndev);
331 work_done = arc_emac_rx(ndev, budget);
337 arc_emac_rx_stall_check(ndev, budget, work_done);
354 struct net_device *ndev = dev_instance;
355 struct arc_emac_priv *priv = netdev_priv(ndev);
356 struct net_device_stats *stats = &ndev->stats;
414 * @ndev: Pointer to the network device.
422 static int arc_emac_open(struct net_device *ndev)
424 struct arc_emac_priv *priv = netdev_priv(ndev);
425 struct phy_device *phy_dev = ndev->phydev;
443 rx_buff->skb = netdev_alloc_skb_ip_align(ndev,
448 addr = dma_map_single(&ndev->dev, (void *)rx_buff->skb->data,
450 if (dma_mapping_error(&ndev->dev, addr)) {
451 netdev_err(ndev, "cannot dma map\n");
497 phy_start(ndev->phydev);
499 netif_start_queue(ndev);
506 * @ndev: Pointer to the network device.
511 static void arc_emac_set_rx_mode(struct net_device *ndev)
513 struct arc_emac_priv *priv = netdev_priv(ndev);
515 if (ndev->flags & IFF_PROMISC) {
520 if (ndev->flags & IFF_ALLMULTI) {
523 } else if (ndev->flags & IFF_MULTICAST) {
528 netdev_for_each_mc_addr(ha, ndev) {
544 * @ndev: Pointer to the network device.
548 static void arc_free_tx_queue(struct net_device *ndev)
550 struct arc_emac_priv *priv = netdev_priv(ndev);
558 dma_unmap_single(&ndev->dev,
575 * @ndev: Pointer to the network device.
579 static void arc_free_rx_queue(struct net_device *ndev)
581 struct arc_emac_priv *priv = netdev_priv(ndev);
589 dma_unmap_single(&ndev->dev,
606 * @ndev: Pointer to the network device.
612 static int arc_emac_stop(struct net_device *ndev)
614 struct arc_emac_priv *priv = netdev_priv(ndev);
617 netif_stop_queue(ndev);
619 phy_stop(ndev->phydev);
628 arc_free_tx_queue(ndev);
629 arc_free_rx_queue(ndev);
636 * @ndev: Pointer to net_device structure.
641 static struct net_device_stats *arc_emac_stats(struct net_device *ndev)
643 struct arc_emac_priv *priv = netdev_priv(ndev);
644 struct net_device_stats *stats = &ndev->stats;
669 * @ndev: Pointer to net_device structure.
676 static netdev_tx_t arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
678 struct arc_emac_priv *priv = netdev_priv(ndev);
680 struct net_device_stats *stats = &ndev->stats;
690 netif_stop_queue(ndev);
691 netdev_err(ndev, "BUG! Tx Ring full when queue awake!\n");
695 addr = dma_map_single(&ndev->dev, (void *)skb->data, len,
698 if (unlikely(dma_mapping_error(&ndev->dev, addr))) {
731 netif_stop_queue(ndev);
735 netif_start_queue(ndev);
743 static void arc_emac_set_address_internal(struct net_device *ndev)
745 struct arc_emac_priv *priv = netdev_priv(ndev);
748 addr_low = le32_to_cpu(*(__le32 *)&ndev->dev_addr[0]);
749 addr_hi = le16_to_cpu(*(__le16 *)&ndev->dev_addr[4]);
757 * @ndev: Pointer to net_device structure.
766 static int arc_emac_set_address(struct net_device *ndev, void *p)
770 if (netif_running(ndev))
776 eth_hw_addr_set(ndev, addr->sa_data);
778 arc_emac_set_address_internal(ndev);
785 * @ndev: Pointer to net_device structure.
790 static void arc_emac_restart(struct net_device *ndev)
792 struct arc_emac_priv *priv = netdev_priv(ndev);
793 struct net_device_stats *stats = &ndev->stats;
797 netdev_warn(ndev, "restarting stalled EMAC\n");
799 netif_stop_queue(ndev);
808 arc_free_tx_queue(ndev);
837 netif_start_queue(ndev);
853 int arc_emac_probe(struct net_device *ndev, int interface)
855 struct device *dev = ndev->dev.parent;
886 ndev->netdev_ops = &arc_emac_netdev_ops;
887 ndev->ethtool_ops = &arc_emac_ethtool_ops;
888 ndev->watchdog_timeo = TX_TIMEOUT;
890 priv = netdev_priv(ndev);
932 ndev->irq = irq;
933 dev_info(dev, "IRQ is %d\n", ndev->irq);
936 err = devm_request_irq(dev, ndev->irq, arc_emac_intr, 0,
937 ndev->name, ndev);
944 err = of_get_ethdev_address(dev->of_node, ndev);
946 eth_hw_addr_random(ndev);
948 arc_emac_set_address_internal(ndev);
949 dev_info(dev, "MAC address is now %pM\n", ndev->dev_addr);
973 phydev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0,
984 netif_napi_add_weight(ndev, &priv->napi, arc_emac_poll,
987 err = register_netdev(ndev);
1011 void arc_emac_remove(struct net_device *ndev)
1013 struct arc_emac_priv *priv = netdev_priv(ndev);
1015 phy_disconnect(ndev->phydev);
1017 unregister_netdev(ndev);