| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Hisilicon Fast Ethernet MAC Driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2016 HiSilicon Technologies Co., Ltd. |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | | - * |
|---|
| 11 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | | - * GNU General Public License for more details. |
|---|
| 15 | | - * |
|---|
| 16 | | - * You should have received a copy of the GNU General Public License |
|---|
| 17 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 18 | 6 | */ |
|---|
| 19 | 7 | |
|---|
| 20 | 8 | #include <linux/circ_buf.h> |
|---|
| .. | .. |
|---|
| 295 | 283 | skb->protocol = eth_type_trans(skb, dev); |
|---|
| 296 | 284 | napi_gro_receive(&priv->napi, skb); |
|---|
| 297 | 285 | dev->stats.rx_packets++; |
|---|
| 298 | | - dev->stats.rx_bytes += skb->len; |
|---|
| 286 | + dev->stats.rx_bytes += len; |
|---|
| 299 | 287 | next: |
|---|
| 300 | 288 | pos = (pos + 1) % rxq->num; |
|---|
| 301 | 289 | if (rx_pkts_num >= limit) |
|---|
| .. | .. |
|---|
| 687 | 675 | } |
|---|
| 688 | 676 | } |
|---|
| 689 | 677 | |
|---|
| 690 | | -static int hisi_femac_net_ioctl(struct net_device *dev, |
|---|
| 691 | | - struct ifreq *ifreq, int cmd) |
|---|
| 692 | | -{ |
|---|
| 693 | | - if (!netif_running(dev)) |
|---|
| 694 | | - return -EINVAL; |
|---|
| 695 | | - |
|---|
| 696 | | - if (!dev->phydev) |
|---|
| 697 | | - return -EINVAL; |
|---|
| 698 | | - |
|---|
| 699 | | - return phy_mii_ioctl(dev->phydev, ifreq, cmd); |
|---|
| 700 | | -} |
|---|
| 701 | | - |
|---|
| 702 | 678 | static const struct ethtool_ops hisi_femac_ethtools_ops = { |
|---|
| 703 | 679 | .get_link = ethtool_op_get_link, |
|---|
| 704 | 680 | .get_link_ksettings = phy_ethtool_get_link_ksettings, |
|---|
| .. | .. |
|---|
| 709 | 685 | .ndo_open = hisi_femac_net_open, |
|---|
| 710 | 686 | .ndo_stop = hisi_femac_net_close, |
|---|
| 711 | 687 | .ndo_start_xmit = hisi_femac_net_xmit, |
|---|
| 712 | | - .ndo_do_ioctl = hisi_femac_net_ioctl, |
|---|
| 688 | + .ndo_do_ioctl = phy_do_ioctl_running, |
|---|
| 713 | 689 | .ndo_set_mac_address = hisi_femac_set_mac_address, |
|---|
| 714 | 690 | .ndo_set_rx_mode = hisi_femac_net_set_rx_mode, |
|---|
| 715 | 691 | }; |
|---|
| .. | .. |
|---|
| 793 | 769 | { |
|---|
| 794 | 770 | struct device *dev = &pdev->dev; |
|---|
| 795 | 771 | struct device_node *node = dev->of_node; |
|---|
| 796 | | - struct resource *res; |
|---|
| 797 | 772 | struct net_device *ndev; |
|---|
| 798 | 773 | struct hisi_femac_priv *priv; |
|---|
| 799 | 774 | struct phy_device *phy; |
|---|
| .. | .. |
|---|
| 811 | 786 | priv->dev = dev; |
|---|
| 812 | 787 | priv->ndev = ndev; |
|---|
| 813 | 788 | |
|---|
| 814 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 815 | | - priv->port_base = devm_ioremap_resource(dev, res); |
|---|
| 789 | + priv->port_base = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 816 | 790 | if (IS_ERR(priv->port_base)) { |
|---|
| 817 | 791 | ret = PTR_ERR(priv->port_base); |
|---|
| 818 | 792 | goto out_free_netdev; |
|---|
| 819 | 793 | } |
|---|
| 820 | 794 | |
|---|
| 821 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
|---|
| 822 | | - priv->glb_base = devm_ioremap_resource(dev, res); |
|---|
| 795 | + priv->glb_base = devm_platform_ioremap_resource(pdev, 1); |
|---|
| 823 | 796 | if (IS_ERR(priv->glb_base)) { |
|---|
| 824 | 797 | ret = PTR_ERR(priv->glb_base); |
|---|
| 825 | 798 | goto out_free_netdev; |
|---|
| .. | .. |
|---|
| 870 | 843 | phy_modes(phy->interface)); |
|---|
| 871 | 844 | |
|---|
| 872 | 845 | mac_addr = of_get_mac_address(node); |
|---|
| 873 | | - if (mac_addr) |
|---|
| 846 | + if (!IS_ERR(mac_addr)) |
|---|
| 874 | 847 | ether_addr_copy(ndev->dev_addr, mac_addr); |
|---|
| 875 | 848 | if (!is_valid_ether_addr(ndev->dev_addr)) { |
|---|
| 876 | 849 | eth_hw_addr_random(ndev); |
|---|
| .. | .. |
|---|
| 892 | 865 | |
|---|
| 893 | 866 | ndev->irq = platform_get_irq(pdev, 0); |
|---|
| 894 | 867 | if (ndev->irq <= 0) { |
|---|
| 895 | | - dev_err(dev, "No irq resource\n"); |
|---|
| 896 | 868 | ret = -ENODEV; |
|---|
| 897 | 869 | goto out_disconnect_phy; |
|---|
| 898 | 870 | } |
|---|