Skip to content

Commit

Permalink
net: ethernet: Add helper for MACs which support asym pause
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andrew Lunn authored and David S. Miller committed Sep 13, 2018
1 parent 41124fa commit af8d9bb
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 43 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 1 addition & 4 deletions drivers/net/ethernet/broadcom/sb1250-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions drivers/net/ethernet/broadcom/tg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/cortina/gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/dnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/faraday/ftgmac100.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/freescale/gianfar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 1 addition & 5 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions drivers/net/ethernet/microchip/lan743x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/smsc/smsc911x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/ethernet/smsc/smsc9420.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/socionext/sni_ave.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 13 additions & 0 deletions drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions include/linux/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *));
Expand Down

0 comments on commit af8d9bb

Please sign in to comment.