Lines Matching refs:netdev
63 return priv->netdev->dev.parent;
161 static struct sk_buff *owl_emac_alloc_skb(struct net_device *netdev)
166 skb = netdev_alloc_skb(netdev, OWL_EMAC_RX_FRAME_MAX_LEN +
183 struct net_device *netdev = priv->netdev;
190 skb = owl_emac_alloc_skb(netdev);
342 static void owl_emac_set_hw_mac_addr(struct net_device *netdev)
344 struct owl_emac_priv *priv = netdev_priv(netdev);
345 const u8 *mac_addr = netdev->dev_addr;
394 static void owl_emac_adjust_link(struct net_device *netdev)
396 struct owl_emac_priv *priv = netdev_priv(netdev);
397 struct phy_device *phydev = netdev->phydev;
438 struct net_device *netdev = data;
439 struct owl_emac_priv *priv = netdev_priv(netdev);
441 if (netif_running(netdev)) {
465 const u8 *mac_addr = priv->netdev->dev_addr;
493 struct net_device *netdev = priv->netdev;
501 skb = owl_emac_alloc_skb(netdev);
554 netif_stop_queue(netdev);
566 struct net_device *netdev)
568 struct owl_emac_priv *priv = netdev_priv(netdev);
578 dev_err_ratelimited(&netdev->dev, "TX DMA mapping failed\n");
580 netdev->stats.tx_dropped++;
595 netif_stop_queue(netdev);
598 dev_dbg_ratelimited(&netdev->dev, "TX buffer full, status=0x%08x\n",
601 netdev->stats.tx_dropped++;
624 netif_stop_queue(netdev);
634 struct net_device *netdev = priv->netdev;
651 dev_dbg_ratelimited(&netdev->dev,
655 netdev->stats.tx_errors++;
658 netdev->stats.tx_fifo_errors++;
661 netdev->stats.tx_aborted_errors++;
664 netdev->stats.tx_window_errors++;
667 netdev->stats.tx_heartbeat_errors++;
670 netdev->stats.tx_carrier_errors++;
672 netdev->stats.tx_packets++;
673 netdev->stats.tx_bytes += ring->skbs[tx_tail]->len;
678 netdev->stats.collisions++;
689 if (unlikely(netif_queue_stopped(netdev)))
690 netif_wake_queue(netdev);
698 struct net_device *netdev = priv->netdev;
731 netdev_dbg(netdev, "Found uncleared TX desc OWN bit\n");
750 struct net_device *netdev = priv->netdev;
782 dev_dbg_ratelimited(&netdev->dev,
787 netdev->stats.rx_over_errors++;
790 netdev->stats.rx_frame_errors++;
793 netdev->stats.rx_length_errors++;
796 netdev->stats.collisions++;
799 netdev->stats.rx_crc_errors++;
802 netdev->stats.rx_fifo_errors++;
809 netdev->stats.rx_length_errors++;
810 netdev_err(netdev, "invalid RX frame len: %u\n", len);
815 new_skb = owl_emac_alloc_skb(netdev);
822 netdev_err(netdev, "RX DMA mapping failed\n");
830 curr_skb->protocol = eth_type_trans(curr_skb, netdev);
831 curr_skb->dev = netdev;
835 netdev->stats.rx_packets++;
836 netdev->stats.rx_bytes += len;
841 netdev->stats.rx_dropped++;
842 netdev->stats.rx_errors++;
930 netdev_dbg(priv->netdev, "%s error status: 0x%08x\n",
1032 static int owl_emac_enable(struct net_device *netdev, bool start_phy)
1034 struct owl_emac_priv *priv = netdev_priv(netdev);
1048 netdev_err(netdev, "failed to soft reset MAC core: %d\n", ret);
1052 owl_emac_set_hw_mac_addr(netdev);
1055 netdev_reset_queue(netdev);
1062 phy_start(netdev->phydev);
1064 netif_start_queue(netdev);
1075 static void owl_emac_disable(struct net_device *netdev, bool stop_phy)
1077 struct owl_emac_priv *priv = netdev_priv(netdev);
1082 netif_stop_queue(netdev);
1086 phy_stop(netdev->phydev);
1092 static int owl_emac_ndo_open(struct net_device *netdev)
1094 return owl_emac_enable(netdev, true);
1097 static int owl_emac_ndo_stop(struct net_device *netdev)
1099 owl_emac_disable(netdev, true);
1104 static void owl_emac_set_multicast(struct net_device *netdev, int count)
1106 struct owl_emac_priv *priv = netdev_priv(netdev);
1115 netdev_for_each_mc_addr(ha, netdev) {
1128 static void owl_emac_ndo_set_rx_mode(struct net_device *netdev)
1130 struct owl_emac_priv *priv = netdev_priv(netdev);
1134 if (netdev->flags & IFF_PROMISC) {
1136 } else if (netdev->flags & IFF_ALLMULTI) {
1138 } else if (netdev->flags & IFF_MULTICAST) {
1139 mcast_count = netdev_mc_count(netdev);
1163 owl_emac_set_multicast(netdev, mcast_count);
1166 static int owl_emac_ndo_set_mac_addr(struct net_device *netdev, void *addr)
1173 if (netif_running(netdev))
1176 eth_hw_addr_set(netdev, skaddr->sa_data);
1177 owl_emac_set_hw_mac_addr(netdev);
1179 return owl_emac_setup_frame_xmit(netdev_priv(netdev));
1182 static int owl_emac_ndo_eth_ioctl(struct net_device *netdev,
1185 if (!netif_running(netdev))
1188 return phy_mii_ioctl(netdev->phydev, req, cmd);
1191 static void owl_emac_ndo_tx_timeout(struct net_device *netdev,
1194 struct owl_emac_priv *priv = netdev_priv(netdev);
1205 netdev_dbg(priv->netdev, "resetting MAC\n");
1206 owl_emac_disable(priv->netdev, false);
1207 owl_emac_enable(priv->netdev, false);
1211 owl_emac_ndo_get_stats(struct net_device *netdev)
1217 return &netdev->stats;
1238 static u32 owl_emac_ethtool_get_msglevel(struct net_device *netdev)
1240 struct owl_emac_priv *priv = netdev_priv(netdev);
1321 static int owl_emac_mdio_init(struct net_device *netdev)
1323 struct owl_emac_priv *priv = netdev_priv(netdev);
1358 static int owl_emac_phy_init(struct net_device *netdev)
1360 struct owl_emac_priv *priv = netdev_priv(netdev);
1364 phy = of_phy_get_and_connect(netdev, dev->of_node,
1377 static void owl_emac_get_mac_addr(struct net_device *netdev)
1379 struct device *dev = netdev->dev.parent;
1382 ret = platform_get_ethdev_address(dev, netdev);
1383 if (!ret && is_valid_ether_addr(netdev->dev_addr))
1386 eth_hw_addr_random(netdev);
1387 dev_warn(dev, "using random MAC address %pM\n", netdev->dev_addr);
1392 struct net_device *netdev = dev_get_drvdata(dev);
1393 struct owl_emac_priv *priv = netdev_priv(netdev);
1395 disable_irq(netdev->irq);
1397 if (netif_running(netdev)) {
1398 owl_emac_disable(netdev, true);
1399 netif_device_detach(netdev);
1409 struct net_device *netdev = dev_get_drvdata(dev);
1410 struct owl_emac_priv *priv = netdev_priv(netdev);
1417 if (netif_running(netdev)) {
1421 ret = owl_emac_enable(netdev, true);
1427 netif_device_attach(netdev);
1430 enable_irq(netdev->irq);
1473 struct net_device *netdev;
1477 netdev = devm_alloc_etherdev(dev, sizeof(*priv));
1478 if (!netdev)
1481 platform_set_drvdata(pdev, netdev);
1482 SET_NETDEV_DEV(netdev, dev);
1484 priv = netdev_priv(netdev);
1485 priv->netdev = netdev;
1514 netdev->irq = platform_get_irq(pdev, 0);
1515 if (netdev->irq < 0)
1516 return netdev->irq;
1518 ret = devm_request_irq(dev, netdev->irq, owl_emac_handle_irq,
1519 IRQF_SHARED, netdev->name, netdev);
1521 dev_err(dev, "failed to request irq: %d\n", netdev->irq);
1549 owl_emac_get_mac_addr(netdev);
1554 ret = owl_emac_mdio_init(netdev);
1560 ret = owl_emac_phy_init(netdev);
1568 netdev->min_mtu = OWL_EMAC_MTU_MIN;
1569 netdev->max_mtu = OWL_EMAC_MTU_MAX;
1570 netdev->watchdog_timeo = OWL_EMAC_TX_TIMEOUT;
1571 netdev->netdev_ops = &owl_emac_netdev_ops;
1572 netdev->ethtool_ops = &owl_emac_ethtool_ops;
1573 netif_napi_add(netdev, &priv->napi, owl_emac_poll);
1575 ret = devm_register_netdev(dev, netdev);
1578 phy_disconnect(netdev->phydev);
1590 phy_disconnect(priv->netdev->phydev);