.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Driver for Marvell Discovery (MV643XX) and Marvell Orion ethernet ports |
---|
3 | 4 | * Copyright (C) 2002 Matthew Dharm <mdharm@momenco.com> |
---|
.. | .. |
---|
21 | 22 | * Lennert Buytenhek <buytenh@marvell.com> |
---|
22 | 23 | * |
---|
23 | 24 | * Copyright (C) 2013 Michael Stapelberg <michael@stapelberg.de> |
---|
24 | | - * |
---|
25 | | - * This program is free software; you can redistribute it and/or |
---|
26 | | - * modify it under the terms of the GNU General Public License |
---|
27 | | - * as published by the Free Software Foundation; either version 2 |
---|
28 | | - * of the License, or (at your option) any later version. |
---|
29 | | - * |
---|
30 | | - * This program is distributed in the hope that it will be useful, |
---|
31 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
32 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
33 | | - * GNU General Public License for more details. |
---|
34 | | - * |
---|
35 | | - * You should have received a copy of the GNU General Public License |
---|
36 | | - * along with this program; if not, see <http://www.gnu.org/licenses/>. |
---|
37 | 25 | */ |
---|
38 | 26 | |
---|
39 | 27 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
.. | .. |
---|
671 | 659 | for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { |
---|
672 | 660 | const skb_frag_t *fragp = &skb_shinfo(skb)->frags[frag]; |
---|
673 | 661 | |
---|
674 | | - if (skb_frag_size(fragp) <= 8 && fragp->page_offset & 7) |
---|
| 662 | + if (skb_frag_size(fragp) <= 8 && skb_frag_off(fragp) & 7) |
---|
675 | 663 | return 1; |
---|
676 | 664 | } |
---|
677 | 665 | |
---|
678 | 666 | return 0; |
---|
679 | | -} |
---|
680 | | - |
---|
681 | | -static inline __be16 sum16_as_be(__sum16 sum) |
---|
682 | | -{ |
---|
683 | | - return (__force __be16)sum; |
---|
684 | 667 | } |
---|
685 | 668 | |
---|
686 | 669 | static int skb_tx_csum(struct mv643xx_eth_private *mp, struct sk_buff *skb, |
---|
.. | .. |
---|
833 | 816 | struct net_device *dev) |
---|
834 | 817 | { |
---|
835 | 818 | struct mv643xx_eth_private *mp = txq_to_mp(txq); |
---|
836 | | - int total_len, data_left, ret; |
---|
| 819 | + int hdr_len, total_len, data_left, ret; |
---|
837 | 820 | int desc_count = 0; |
---|
838 | 821 | struct tso_t tso; |
---|
839 | | - int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); |
---|
840 | 822 | struct tx_desc *first_tx_desc; |
---|
841 | 823 | u32 first_cmd_sts = 0; |
---|
842 | 824 | |
---|
.. | .. |
---|
849 | 831 | first_tx_desc = &txq->tx_desc_area[txq->tx_curr_desc]; |
---|
850 | 832 | |
---|
851 | 833 | /* Initialize the TSO handler, and prepare the first payload */ |
---|
852 | | - tso_start(skb, &tso); |
---|
| 834 | + hdr_len = tso_start(skb, &tso); |
---|
853 | 835 | |
---|
854 | 836 | total_len = skb->len - hdr_len; |
---|
855 | 837 | while (total_len > 0) { |
---|
.. | .. |
---|
1444 | 1426 | }; |
---|
1445 | 1427 | |
---|
1446 | 1428 | #define SSTAT(m) \ |
---|
1447 | | - { #m, FIELD_SIZEOF(struct net_device_stats, m), \ |
---|
| 1429 | + { #m, sizeof_field(struct net_device_stats, m), \ |
---|
1448 | 1430 | offsetof(struct net_device, stats.m), -1 } |
---|
1449 | 1431 | |
---|
1450 | 1432 | #define MIBSTAT(m) \ |
---|
1451 | | - { #m, FIELD_SIZEOF(struct mib_counters, m), \ |
---|
| 1433 | + { #m, sizeof_field(struct mib_counters, m), \ |
---|
1452 | 1434 | -1, offsetof(struct mv643xx_eth_private, mib_counters.m) } |
---|
1453 | 1435 | |
---|
1454 | 1436 | static const struct mv643xx_eth_stats mv643xx_eth_stats[] = { |
---|
.. | .. |
---|
1499 | 1481 | struct ethtool_link_ksettings *cmd) |
---|
1500 | 1482 | { |
---|
1501 | 1483 | struct net_device *dev = mp->dev; |
---|
1502 | | - u32 supported, advertising; |
---|
1503 | 1484 | |
---|
1504 | 1485 | phy_ethtool_ksettings_get(dev->phydev, cmd); |
---|
1505 | 1486 | |
---|
1506 | 1487 | /* |
---|
1507 | 1488 | * The MAC does not support 1000baseT_Half. |
---|
1508 | 1489 | */ |
---|
1509 | | - ethtool_convert_link_mode_to_legacy_u32(&supported, |
---|
1510 | | - cmd->link_modes.supported); |
---|
1511 | | - ethtool_convert_link_mode_to_legacy_u32(&advertising, |
---|
1512 | | - cmd->link_modes.advertising); |
---|
1513 | | - supported &= ~SUPPORTED_1000baseT_Half; |
---|
1514 | | - advertising &= ~ADVERTISED_1000baseT_Half; |
---|
1515 | | - ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, |
---|
1516 | | - supported); |
---|
1517 | | - ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, |
---|
1518 | | - advertising); |
---|
| 1490 | + linkmode_clear_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, |
---|
| 1491 | + cmd->link_modes.supported); |
---|
| 1492 | + linkmode_clear_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, |
---|
| 1493 | + cmd->link_modes.advertising); |
---|
1519 | 1494 | |
---|
1520 | 1495 | return 0; |
---|
1521 | 1496 | } |
---|
.. | .. |
---|
1756 | 1731 | } |
---|
1757 | 1732 | |
---|
1758 | 1733 | static const struct ethtool_ops mv643xx_eth_ethtool_ops = { |
---|
| 1734 | + .supported_coalesce_params = ETHTOOL_COALESCE_USECS, |
---|
1759 | 1735 | .get_drvinfo = mv643xx_eth_get_drvinfo, |
---|
1760 | 1736 | .nway_reset = phy_ethtool_nway_reset, |
---|
1761 | 1737 | .get_link = ethtool_op_get_link, |
---|
.. | .. |
---|
2495 | 2471 | for (i = 0; i < mp->rxq_count; i++) |
---|
2496 | 2472 | rxq_deinit(mp->rxq + i); |
---|
2497 | 2473 | out: |
---|
| 2474 | + napi_disable(&mp->napi); |
---|
2498 | 2475 | free_irq(dev->irq, dev); |
---|
2499 | 2476 | |
---|
2500 | 2477 | return err; |
---|
.. | .. |
---|
2609 | 2586 | } |
---|
2610 | 2587 | } |
---|
2611 | 2588 | |
---|
2612 | | -static void mv643xx_eth_tx_timeout(struct net_device *dev) |
---|
| 2589 | +static void mv643xx_eth_tx_timeout(struct net_device *dev, unsigned int txqueue) |
---|
2613 | 2590 | { |
---|
2614 | 2591 | struct mv643xx_eth_private *mp = netdev_priv(dev); |
---|
2615 | 2592 | |
---|
.. | .. |
---|
2733 | 2710 | |
---|
2734 | 2711 | memset(&res, 0, sizeof(res)); |
---|
2735 | 2712 | if (of_irq_to_resource(pnp, 0, &res) <= 0) { |
---|
2736 | | - dev_err(&pdev->dev, "missing interrupt on %s\n", pnp->name); |
---|
| 2713 | + dev_err(&pdev->dev, "missing interrupt on %pOFn\n", pnp); |
---|
2737 | 2714 | return -EINVAL; |
---|
2738 | 2715 | } |
---|
2739 | 2716 | |
---|
2740 | 2717 | if (of_property_read_u32(pnp, "reg", &ppd.port_number)) { |
---|
2741 | | - dev_err(&pdev->dev, "missing reg property on %s\n", pnp->name); |
---|
| 2718 | + dev_err(&pdev->dev, "missing reg property on %pOFn\n", pnp); |
---|
2742 | 2719 | return -EINVAL; |
---|
2743 | 2720 | } |
---|
2744 | 2721 | |
---|
2745 | 2722 | if (ppd.port_number >= 3) { |
---|
2746 | | - dev_err(&pdev->dev, "invalid reg property on %s\n", pnp->name); |
---|
| 2723 | + dev_err(&pdev->dev, "invalid reg property on %pOFn\n", pnp); |
---|
2747 | 2724 | return -EINVAL; |
---|
2748 | 2725 | } |
---|
2749 | 2726 | |
---|
.. | .. |
---|
2756 | 2733 | } |
---|
2757 | 2734 | |
---|
2758 | 2735 | mac_addr = of_get_mac_address(pnp); |
---|
2759 | | - if (mac_addr) |
---|
2760 | | - memcpy(ppd.mac_addr, mac_addr, ETH_ALEN); |
---|
| 2736 | + if (!IS_ERR(mac_addr)) |
---|
| 2737 | + ether_addr_copy(ppd.mac_addr, mac_addr); |
---|
2761 | 2738 | |
---|
2762 | 2739 | mv643xx_eth_property(pnp, "tx-queue-size", ppd.tx_queue_size); |
---|
2763 | 2740 | mv643xx_eth_property(pnp, "tx-sram-addr", ppd.tx_sram_addr); |
---|
.. | .. |
---|
2978 | 2955 | static int get_phy_mode(struct mv643xx_eth_private *mp) |
---|
2979 | 2956 | { |
---|
2980 | 2957 | struct device *dev = mp->dev->dev.parent; |
---|
2981 | | - int iface = -1; |
---|
| 2958 | + phy_interface_t iface; |
---|
| 2959 | + int err; |
---|
2982 | 2960 | |
---|
2983 | 2961 | if (dev->of_node) |
---|
2984 | | - iface = of_get_phy_mode(dev->of_node); |
---|
| 2962 | + err = of_get_phy_mode(dev->of_node, &iface); |
---|
2985 | 2963 | |
---|
2986 | 2964 | /* Historical default if unspecified. We could also read/write |
---|
2987 | 2965 | * the interface state in the PSC1 |
---|
2988 | 2966 | */ |
---|
2989 | | - if (iface < 0) |
---|
| 2967 | + if (!dev->of_node || err) |
---|
2990 | 2968 | iface = PHY_INTERFACE_MODE_GMII; |
---|
2991 | 2969 | return iface; |
---|
2992 | 2970 | } |
---|
.. | .. |
---|
3036 | 3014 | phy->autoneg = AUTONEG_ENABLE; |
---|
3037 | 3015 | phy->speed = 0; |
---|
3038 | 3016 | phy->duplex = 0; |
---|
3039 | | - phy->advertising = phy->supported | ADVERTISED_Autoneg; |
---|
| 3017 | + linkmode_copy(phy->advertising, phy->supported); |
---|
| 3018 | + linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, |
---|
| 3019 | + phy->advertising); |
---|
3040 | 3020 | } else { |
---|
3041 | 3021 | phy->autoneg = AUTONEG_DISABLE; |
---|
3042 | | - phy->advertising = 0; |
---|
| 3022 | + linkmode_zero(phy->advertising); |
---|
3043 | 3023 | phy->speed = speed; |
---|
3044 | 3024 | phy->duplex = duplex; |
---|
3045 | 3025 | } |
---|