net: phy: Add helper for advertise to lcl value
Add a helper to convert the local advertising to an LCL capabilities, which is then used to resolve pause flow control settings. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
edc7ccbbcf
commit
5f991f7bdd
|
@ -658,11 +658,7 @@ static void mt7530_adjust_link(struct dsa_switch *ds, int port,
|
||||||
if (phydev->asym_pause)
|
if (phydev->asym_pause)
|
||||||
rmt_adv |= LPA_PAUSE_ASYM;
|
rmt_adv |= LPA_PAUSE_ASYM;
|
||||||
|
|
||||||
if (phydev->advertising & ADVERTISED_Pause)
|
lcl_adv = ethtool_adv_to_lcl_adv_t(phydev->advertising);
|
||||||
lcl_adv |= ADVERTISE_PAUSE_CAP;
|
|
||||||
if (phydev->advertising & ADVERTISED_Asym_Pause)
|
|
||||||
lcl_adv |= ADVERTISE_PAUSE_ASYM;
|
|
||||||
|
|
||||||
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
|
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
|
||||||
|
|
||||||
if (flowctrl & FLOW_CTRL_TX)
|
if (flowctrl & FLOW_CTRL_TX)
|
||||||
|
|
|
@ -1495,10 +1495,7 @@ static void xgbe_phy_phydev_flowctrl(struct xgbe_prv_data *pdata)
|
||||||
if (!phy_data->phydev)
|
if (!phy_data->phydev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (phy_data->phydev->advertising & ADVERTISED_Pause)
|
lcl_adv = ethtool_adv_to_lcl_adv_t(phy_data->phydev->advertising);
|
||||||
lcl_adv |= ADVERTISE_PAUSE_CAP;
|
|
||||||
if (phy_data->phydev->advertising & ADVERTISED_Asym_Pause)
|
|
||||||
lcl_adv |= ADVERTISE_PAUSE_ASYM;
|
|
||||||
|
|
||||||
if (phy_data->phydev->pause) {
|
if (phy_data->phydev->pause) {
|
||||||
XGBE_SET_LP_ADV(lks, Pause);
|
XGBE_SET_LP_ADV(lks, Pause);
|
||||||
|
|
|
@ -393,11 +393,7 @@ void fman_get_pause_cfg(struct mac_device *mac_dev, bool *rx_pause,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* get local capabilities */
|
/* get local capabilities */
|
||||||
lcl_adv = 0;
|
lcl_adv = ethtool_adv_to_lcl_adv_t(phy_dev->advertising);
|
||||||
if (phy_dev->advertising & ADVERTISED_Pause)
|
|
||||||
lcl_adv |= ADVERTISE_PAUSE_CAP;
|
|
||||||
if (phy_dev->advertising & ADVERTISED_Asym_Pause)
|
|
||||||
lcl_adv |= ADVERTISE_PAUSE_ASYM;
|
|
||||||
|
|
||||||
/* get link partner capabilities */
|
/* get link partner capabilities */
|
||||||
rmt_adv = 0;
|
rmt_adv = 0;
|
||||||
|
|
|
@ -3656,12 +3656,7 @@ static u32 gfar_get_flowctrl_cfg(struct gfar_private *priv)
|
||||||
if (phydev->asym_pause)
|
if (phydev->asym_pause)
|
||||||
rmt_adv |= LPA_PAUSE_ASYM;
|
rmt_adv |= LPA_PAUSE_ASYM;
|
||||||
|
|
||||||
lcl_adv = 0;
|
lcl_adv = ethtool_adv_to_lcl_adv_t(phydev->advertising);
|
||||||
if (phydev->advertising & ADVERTISED_Pause)
|
|
||||||
lcl_adv |= ADVERTISE_PAUSE_CAP;
|
|
||||||
if (phydev->advertising & ADVERTISED_Asym_Pause)
|
|
||||||
lcl_adv |= ADVERTISE_PAUSE_ASYM;
|
|
||||||
|
|
||||||
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
|
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
|
||||||
if (flowctrl & FLOW_CTRL_TX)
|
if (flowctrl & FLOW_CTRL_TX)
|
||||||
val |= MACCFG1_TX_FLOW;
|
val |= MACCFG1_TX_FLOW;
|
||||||
|
|
|
@ -5006,11 +5006,7 @@ int hclge_cfg_flowctrl(struct hclge_dev *hdev)
|
||||||
if (!phydev->link || !phydev->autoneg)
|
if (!phydev->link || !phydev->autoneg)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (phydev->advertising & ADVERTISED_Pause)
|
local_advertising = ethtool_adv_to_lcl_adv_t(phydev->advertising);
|
||||||
local_advertising = ADVERTISE_PAUSE_CAP;
|
|
||||||
|
|
||||||
if (phydev->advertising & ADVERTISED_Asym_Pause)
|
|
||||||
local_advertising |= ADVERTISE_PAUSE_ASYM;
|
|
||||||
|
|
||||||
if (phydev->pause)
|
if (phydev->pause)
|
||||||
remote_advertising = LPA_PAUSE_CAP;
|
remote_advertising = LPA_PAUSE_CAP;
|
||||||
|
|
|
@ -243,11 +243,7 @@ static void mtk_phy_link_adjust(struct net_device *dev)
|
||||||
if (dev->phydev->asym_pause)
|
if (dev->phydev->asym_pause)
|
||||||
rmt_adv |= LPA_PAUSE_ASYM;
|
rmt_adv |= LPA_PAUSE_ASYM;
|
||||||
|
|
||||||
if (dev->phydev->advertising & ADVERTISED_Pause)
|
lcl_adv = ethtool_adv_to_lcl_adv_t(dev->phydev->advertising);
|
||||||
lcl_adv |= ADVERTISE_PAUSE_CAP;
|
|
||||||
if (dev->phydev->advertising & ADVERTISED_Asym_Pause)
|
|
||||||
lcl_adv |= ADVERTISE_PAUSE_ASYM;
|
|
||||||
|
|
||||||
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
|
flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
|
||||||
|
|
||||||
if (flowctrl & FLOW_CTRL_TX)
|
if (flowctrl & FLOW_CTRL_TX)
|
||||||
|
|
|
@ -1116,11 +1116,8 @@ static void ave_phy_adjust_link(struct net_device *ndev)
|
||||||
rmt_adv |= LPA_PAUSE_CAP;
|
rmt_adv |= LPA_PAUSE_CAP;
|
||||||
if (phydev->asym_pause)
|
if (phydev->asym_pause)
|
||||||
rmt_adv |= LPA_PAUSE_ASYM;
|
rmt_adv |= LPA_PAUSE_ASYM;
|
||||||
if (phydev->advertising & ADVERTISED_Pause)
|
|
||||||
lcl_adv |= ADVERTISE_PAUSE_CAP;
|
|
||||||
if (phydev->advertising & ADVERTISED_Asym_Pause)
|
|
||||||
lcl_adv |= ADVERTISE_PAUSE_ASYM;
|
|
||||||
|
|
||||||
|
lcl_adv = ethtool_adv_to_lcl_adv_t(phydev->advertising);
|
||||||
cap = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
|
cap = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
|
||||||
if (cap & FLOW_CTRL_TX)
|
if (cap & FLOW_CTRL_TX)
|
||||||
txcr |= AVE_TXCR_FLOCTR;
|
txcr |= AVE_TXCR_FLOCTR;
|
||||||
|
|
|
@ -334,6 +334,25 @@ static inline void mii_adv_to_linkmode_adv_t(unsigned long *advertising,
|
||||||
linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising);
|
linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertising);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ethtool_adv_to_lcl_adv_t
|
||||||
|
* @advertising:pointer to ethtool advertising
|
||||||
|
*
|
||||||
|
* A small helper function that translates ethtool advertising to LVL
|
||||||
|
* pause capabilities.
|
||||||
|
*/
|
||||||
|
static inline u32 ethtool_adv_to_lcl_adv_t(u32 advertising)
|
||||||
|
{
|
||||||
|
u32 lcl_adv = 0;
|
||||||
|
|
||||||
|
if (advertising & ADVERTISED_Pause)
|
||||||
|
lcl_adv |= ADVERTISE_PAUSE_CAP;
|
||||||
|
if (advertising & ADVERTISED_Asym_Pause)
|
||||||
|
lcl_adv |= ADVERTISE_PAUSE_ASYM;
|
||||||
|
|
||||||
|
return lcl_adv;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mii_advertise_flowctrl - get flow control advertisement flags
|
* mii_advertise_flowctrl - get flow control advertisement flags
|
||||||
* @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both)
|
* @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both)
|
||||||
|
|
Loading…
Reference in New Issue