From 68b77d267414d790e5cbd76f46a77501559e5748 Mon Sep 17 00:00:00 2001 From: Camelia Groza Date: Tue, 26 Mar 2019 18:27:11 +0200 Subject: [PATCH] sdk_dpaa: adapt to kernel 5.1.0 rc1 Apply fixes corresponding to the following upstream patches: 3c1bcc8 net: ethernet: Convert phydev advertize and supported from u32 to link mode 1e562c8 ptp_qoriq: make structure/function names more consistent 70814e8 net: ethernet: Add helper for set_pauseparam for Asym Pause 22b7d29 net: ethernet: Add helper to determine if pause configuration is supported Signed-off-by: Camelia Groza --- .../net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c | 31 +++------------------- drivers/net/ethernet/freescale/sdk_dpaa/mac-api.c | 27 +++++++++---------- 2 files changed, 16 insertions(+), 42 deletions(-) --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_ethtool.c @@ -225,7 +225,6 @@ static int __cold dpa_set_pauseparam(str struct mac_device *mac_dev; struct phy_device *phy_dev; int _errno; - u32 newadv, oldadv; bool rx_pause, tx_pause; priv = netdev_priv(net_dev); @@ -242,9 +241,7 @@ static int __cold dpa_set_pauseparam(str return -ENODEV; } - if (!(phy_dev->supported & SUPPORTED_Pause) || - (!(phy_dev->supported & SUPPORTED_Asym_Pause) && - (epause->rx_pause != epause->tx_pause))) + if (!phy_validate_pause(phy_dev, epause)) return -EINVAL; /* The MAC should know how to handle PAUSE frame autonegotiation before @@ -258,29 +255,7 @@ static int __cold dpa_set_pauseparam(str /* Determine the sym/asym advertised PAUSE capabilities from the desired * rx/tx pause settings. */ - newadv = 0; - if (epause->rx_pause) - newadv = ADVERTISED_Pause | ADVERTISED_Asym_Pause; - if (epause->tx_pause) - newadv |= ADVERTISED_Asym_Pause; - - oldadv = phy_dev->advertising & - (ADVERTISED_Pause | ADVERTISED_Asym_Pause); - - /* If there are differences between the old and the new advertised - * values, restart PHY autonegotiation and advertise the new values. - */ - if (oldadv != newadv) { - phy_dev->advertising &= ~(ADVERTISED_Pause - | ADVERTISED_Asym_Pause); - phy_dev->advertising |= newadv; - if (phy_dev->autoneg) { - _errno = phy_start_aneg(phy_dev); - if (unlikely(_errno < 0)) - netdev_err(net_dev, "phy_start_aneg() = %d\n", - _errno); - } - } + phy_set_asym_pause(phy_dev, epause->rx_pause, epause->tx_pause); get_pause_cfg(mac_dev, &rx_pause, &tx_pause); _errno = set_mac_active_pause(mac_dev, rx_pause, tx_pause); @@ -530,7 +505,7 @@ static int dpaa_get_ts_info(struct net_d struct device_node *mac_node = dev->of_node; struct device_node *fman_node = NULL, *ptp_node = NULL; struct platform_device *ptp_dev = NULL; - struct qoriq_ptp *ptp = NULL; + struct ptp_qoriq *ptp = NULL; info->phc_index = -1; --- a/drivers/net/ethernet/freescale/sdk_dpaa/mac-api.c +++ b/drivers/net/ethernet/freescale/sdk_dpaa/mac-api.c @@ -385,11 +385,7 @@ void get_pause_cfg(struct mac_device *ma */ /* get local capabilities */ - lcl_adv = 0; - if (phy_dev->advertising & ADVERTISED_Pause) - lcl_adv |= ADVERTISE_PAUSE_CAP; - if (phy_dev->advertising & ADVERTISED_Asym_Pause) - lcl_adv |= ADVERTISE_PAUSE_ASYM; + lcl_adv = linkmode_adv_to_lcl_adv_t(phy_dev->advertising); /* get link partner capabilities */ rmt_adv = 0; @@ -439,6 +435,7 @@ static int dtsec_init_phy(struct net_dev struct mac_device *mac_dev) { struct phy_device *phy_dev; + __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; if (of_phy_is_fixed_link(mac_dev->phy_node)) phy_dev = of_phy_attach(net_dev, mac_dev->phy_node, @@ -455,12 +452,12 @@ static int dtsec_init_phy(struct net_dev } /* Remove any features not supported by the controller */ - phy_dev->supported &= mac_dev->if_support; + ethtool_convert_legacy_u32_to_link_mode(mask, mac_dev->if_support); + linkmode_and(phy_dev->supported, phy_dev->supported, mask); /* Enable the symmetric and asymmetric PAUSE frame advertisements, * as most of the PHY drivers do not enable them by default. */ - phy_dev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause); - phy_dev->advertising = phy_dev->supported; + phy_support_asym_pause(phy_dev); mac_dev->phy_dev = phy_dev; @@ -471,6 +468,7 @@ static int xgmac_init_phy(struct net_dev struct mac_device *mac_dev) { struct phy_device *phy_dev; + __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; if (of_phy_is_fixed_link(mac_dev->phy_node)) phy_dev = of_phy_attach(net_dev, mac_dev->phy_node, @@ -486,12 +484,12 @@ static int xgmac_init_phy(struct net_dev return phy_dev == NULL ? -ENODEV : PTR_ERR(phy_dev); } - phy_dev->supported &= mac_dev->if_support; + ethtool_convert_legacy_u32_to_link_mode(mask, mac_dev->if_support); + linkmode_and(phy_dev->supported, phy_dev->supported, mask); /* Enable the symmetric and asymmetric PAUSE frame advertisements, * as most of the PHY drivers do not enable them by default. */ - phy_dev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause); - phy_dev->advertising = phy_dev->supported; + phy_support_asym_pause(phy_dev); mac_dev->phy_dev = phy_dev; @@ -502,6 +500,7 @@ static int memac_init_phy(struct net_dev struct mac_device *mac_dev) { struct phy_device *phy_dev; + __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; void (*adjust_link_handler)(struct net_device *); if ((macdev2enetinterface(mac_dev) == e_ENET_MODE_XGMII_10000) || @@ -547,12 +546,12 @@ static int memac_init_phy(struct net_dev } /* Remove any features not supported by the controller */ - phy_dev->supported &= mac_dev->if_support; + ethtool_convert_legacy_u32_to_link_mode(mask, mac_dev->if_support); + linkmode_and(phy_dev->supported, phy_dev->supported, mask); /* Enable the symmetric and asymmetric PAUSE frame advertisements, * as most of the PHY drivers do not enable them by default. */ - phy_dev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause); - phy_dev->advertising = phy_dev->supported; + phy_support_asym_pause(phy_dev); mac_dev->phy_dev = phy_dev;