net: ethernet: Add helper for MACs which support asym pause
Rather than have the MAC drivers manipulate phydev members to indicate they support Asym Pause, add a helper function. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
41124fa64d
commit
af8d9bb2f2
@ -879,8 +879,8 @@ static bool xgbe_phy_finisar_phy_quirks(struct xgbe_prv_data *pdata)
|
||||
phy_write(phy_data->phydev, 0x00, 0x9140);
|
||||
|
||||
phy_data->phydev->supported = PHY_GBIT_FEATURES;
|
||||
phy_data->phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
|
||||
phy_data->phydev->advertising = phy_data->phydev->supported;
|
||||
phy_support_asym_pause(phy_data->phydev);
|
||||
|
||||
netif_dbg(pdata, drv, pdata->netdev,
|
||||
"Finisar PHY quirk in place\n");
|
||||
@ -951,8 +951,8 @@ static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata)
|
||||
phy_write(phy_data->phydev, 0x00, reg & ~0x00800);
|
||||
|
||||
phy_data->phydev->supported = PHY_GBIT_FEATURES;
|
||||
phy_data->phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
|
||||
phy_data->phydev->advertising = phy_data->phydev->supported;
|
||||
phy_support_asym_pause(phy_data->phydev);
|
||||
|
||||
netif_dbg(pdata, drv, pdata->netdev,
|
||||
"BelFuse PHY quirk in place\n");
|
||||
|
@ -898,9 +898,7 @@ int xgene_enet_phy_connect(struct net_device *ndev)
|
||||
phy_remove_link_mode(phy_dev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
|
||||
phy_remove_link_mode(phy_dev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
|
||||
phy_remove_link_mode(phy_dev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
|
||||
phy_dev->supported |= SUPPORTED_Pause |
|
||||
SUPPORTED_Asym_Pause;
|
||||
phy_dev->advertising = phy_dev->supported;
|
||||
phy_support_asym_pause(phy_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2358,13 +2358,10 @@ static int sbmac_mii_probe(struct net_device *dev)
|
||||
|
||||
/* Remove any features not supported by the controller */
|
||||
phy_set_max_speed(phy_dev, SPEED_1000);
|
||||
phy_dev->supported |= SUPPORTED_Pause |
|
||||
SUPPORTED_Asym_Pause;
|
||||
phy_support_asym_pause(phy_dev);
|
||||
|
||||
phy_attached_info(phy_dev);
|
||||
|
||||
phy_dev->advertising = phy_dev->supported;
|
||||
|
||||
sc->phy_dev = phy_dev;
|
||||
|
||||
return 0;
|
||||
|
@ -2123,15 +2123,13 @@ static int tg3_phy_init(struct tg3 *tp)
|
||||
case PHY_INTERFACE_MODE_RGMII:
|
||||
if (!(tp->phy_flags & TG3_PHYFLG_10_100_ONLY)) {
|
||||
phy_set_max_speed(phydev, SPEED_1000);
|
||||
phydev->supported |= (SUPPORTED_Pause |
|
||||
SUPPORTED_Asym_Pause);
|
||||
phy_support_asym_pause(phydev);
|
||||
break;
|
||||
}
|
||||
/* fallthru */
|
||||
case PHY_INTERFACE_MODE_MII:
|
||||
phy_set_max_speed(phydev, SPEED_100);
|
||||
phydev->supported |= (SUPPORTED_Pause |
|
||||
SUPPORTED_Asym_Pause);
|
||||
phy_support_asym_pause(phydev);
|
||||
break;
|
||||
default:
|
||||
phy_disconnect(mdiobus_get_phy(tp->mdio_bus, tp->phy_addr));
|
||||
@ -2140,8 +2138,6 @@ static int tg3_phy_init(struct tg3 *tp)
|
||||
|
||||
tp->phy_flags |= TG3_PHYFLG_IS_CONNECTED;
|
||||
|
||||
phydev->advertising = phydev->supported;
|
||||
|
||||
phy_attached_info(phydev);
|
||||
|
||||
return 0;
|
||||
|
@ -373,8 +373,7 @@ static int gmac_setup_phy(struct net_device *netdev)
|
||||
netdev->phydev = phy;
|
||||
|
||||
phy_set_max_speed(phy, SPEED_1000);
|
||||
phy->supported |= SUPPORTED_Asym_Pause | SUPPORTED_Pause;
|
||||
phy->advertising = phy->supported;
|
||||
phy_support_asym_pause(phy);
|
||||
|
||||
/* set PHY interface type */
|
||||
switch (phy->interface) {
|
||||
|
@ -288,9 +288,7 @@ static int dnet_mii_probe(struct net_device *dev)
|
||||
else
|
||||
phy_set_max_speed(phydev, SPEED_100);
|
||||
|
||||
phydev->supported |= SUPPORTED_Asym_Pause | SUPPORTED_Pause;
|
||||
|
||||
phydev->advertising = phydev->supported;
|
||||
phy_support_asym_pause(phydev);
|
||||
|
||||
bp->link = 0;
|
||||
bp->speed = 0;
|
||||
|
@ -1079,8 +1079,7 @@ static int ftgmac100_mii_probe(struct ftgmac100 *priv, phy_interface_t intf)
|
||||
/* Indicate that we support PAUSE frames (see comment in
|
||||
* Documentation/networking/phy.txt)
|
||||
*/
|
||||
phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
|
||||
phydev->advertising = phydev->supported;
|
||||
phy_support_asym_pause(phydev);
|
||||
|
||||
/* Display what we found */
|
||||
phy_attached_info(phydev);
|
||||
|
@ -2491,8 +2491,7 @@ static int dpaa_phy_init(struct net_device *net_dev)
|
||||
|
||||
/* Remove any features not supported by the controller */
|
||||
phy_dev->supported &= mac_dev->if_support;
|
||||
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;
|
||||
net_dev->phydev = phy_dev;
|
||||
|
@ -1814,8 +1814,8 @@ static int init_phy(struct net_device *dev)
|
||||
phydev->supported &= (GFAR_SUPPORTED | gigabit_support);
|
||||
phydev->advertising = phydev->supported;
|
||||
|
||||
/* Add support for flow control, but don't advertise it by default */
|
||||
phydev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause);
|
||||
/* Add support for flow control */
|
||||
phy_support_asym_pause(phydev);
|
||||
|
||||
/* disable EEE autoneg, EEE not supported by eTSEC */
|
||||
memset(&edata, 0, sizeof(struct ethtool_eee));
|
||||
|
@ -211,9 +211,7 @@ int hclge_mac_connect_phy(struct hclge_dev *hdev)
|
||||
}
|
||||
|
||||
phydev->supported &= HCLGE_PHY_SUPPORTED_FEATURES;
|
||||
phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
|
||||
|
||||
phydev->advertising = phydev->supported;
|
||||
phy_support_asym_pause(phydev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -355,12 +355,8 @@ static int mtk_phy_connect(struct net_device *dev)
|
||||
dev->phydev->speed = 0;
|
||||
dev->phydev->duplex = 0;
|
||||
|
||||
if (of_phy_is_fixed_link(mac->of_node))
|
||||
dev->phydev->supported |=
|
||||
SUPPORTED_Pause | SUPPORTED_Asym_Pause;
|
||||
|
||||
phy_set_max_speed(dev->phydev, SPEED_1000);
|
||||
dev->phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
|
||||
phy_support_asym_pause(dev->phydev);
|
||||
dev->phydev->advertising = dev->phydev->supported |
|
||||
ADVERTISED_Autoneg;
|
||||
phy_start_aneg(dev->phydev);
|
||||
|
@ -999,7 +999,6 @@ static int lan743x_phy_open(struct lan743x_adapter *adapter)
|
||||
struct phy_device *phydev;
|
||||
struct net_device *netdev;
|
||||
int ret = -EIO;
|
||||
u32 mii_adv;
|
||||
|
||||
netdev = adapter->netdev;
|
||||
phydev = phy_find_first(adapter->mdiobus);
|
||||
@ -1016,10 +1015,8 @@ static int lan743x_phy_open(struct lan743x_adapter *adapter)
|
||||
phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
|
||||
|
||||
/* support both flow controls */
|
||||
phy_support_asym_pause(phydev);
|
||||
phy->fc_request_control = (FLOW_CTRL_RX | FLOW_CTRL_TX);
|
||||
phydev->advertising &= ~(ADVERTISED_Pause | ADVERTISED_Asym_Pause);
|
||||
mii_adv = (u32)mii_advertise_flowctrl(phy->fc_request_control);
|
||||
phydev->advertising |= mii_adv_to_ethtool_adv_t(mii_adv);
|
||||
phy->fc_autoneg = phydev->autoneg;
|
||||
|
||||
phy_start(phydev);
|
||||
|
@ -1051,8 +1051,7 @@ static int smsc911x_mii_probe(struct net_device *dev)
|
||||
phy_set_max_speed(phydev, SPEED_100);
|
||||
|
||||
/* mask with MAC supported features */
|
||||
phydev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause);
|
||||
phydev->advertising = phydev->supported;
|
||||
phy_support_asym_pause(phydev);
|
||||
|
||||
pdata->last_duplex = -1;
|
||||
pdata->last_carrier = -1;
|
||||
|
@ -1138,8 +1138,7 @@ static int smsc9420_mii_probe(struct net_device *dev)
|
||||
phy_set_max_speed(phydev, SPEED_100);
|
||||
|
||||
/* mask with MAC supported features */
|
||||
phydev->supported |= (SUPPORTED_Pause | SUPPORTED_Asym_Pause);
|
||||
phydev->advertising = phydev->supported;
|
||||
phy_support_asym_pause(phydev);
|
||||
|
||||
phy_attached_info(phydev);
|
||||
|
||||
|
@ -1225,7 +1225,8 @@ static int ave_init(struct net_device *ndev)
|
||||
|
||||
if (!phy_interface_is_rgmii(phydev))
|
||||
phy_set_max_speed(phydev, SPEED_100);
|
||||
phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
|
||||
|
||||
phy_support_asym_pause(phydev);
|
||||
|
||||
phy_attached_info(phydev);
|
||||
|
||||
|
@ -1783,6 +1783,19 @@ void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode)
|
||||
}
|
||||
EXPORT_SYMBOL(phy_remove_link_mode);
|
||||
|
||||
/**
|
||||
* phy_support_asym_pause - Enable support of asym pause
|
||||
* @phydev: target phy_device struct
|
||||
*
|
||||
* Description: Called by the MAC to indicate is supports Asym Pause.
|
||||
*/
|
||||
void phy_support_asym_pause(struct phy_device *phydev)
|
||||
{
|
||||
phydev->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
|
||||
phydev->advertising = phydev->supported;
|
||||
}
|
||||
EXPORT_SYMBOL(phy_support_asym_pause);
|
||||
|
||||
static void of_set_phy_supported(struct phy_device *phydev)
|
||||
{
|
||||
struct device_node *node = phydev->mdio.dev.of_node;
|
||||
|
@ -1050,6 +1050,7 @@ int phy_start_interrupts(struct phy_device *phydev);
|
||||
void phy_print_status(struct phy_device *phydev);
|
||||
int phy_set_max_speed(struct phy_device *phydev, u32 max_speed);
|
||||
void phy_remove_link_mode(struct phy_device *phydev, u32 link_mode);
|
||||
void phy_support_asym_pause(struct phy_device *phydev);
|
||||
|
||||
int phy_register_fixup(const char *bus_id, u32 phy_uid, u32 phy_uid_mask,
|
||||
int (*run)(struct phy_device *));
|
||||
|
Loading…
Reference in New Issue
Block a user