sfc: Use generic MDIO flow control auto-negotiation functions
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
af2a3eac2f
commit
3f926da82f
@@ -711,7 +711,8 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
|
|||||||
mutex_lock(&efx->mac_lock);
|
mutex_lock(&efx->mac_lock);
|
||||||
|
|
||||||
efx->wanted_fc = wanted_fc;
|
efx->wanted_fc = wanted_fc;
|
||||||
efx_mdio_set_pause(efx);
|
if (efx->phy_op->mmds & MDIO_DEVS_AN)
|
||||||
|
mdio45_ethtool_spauseparam_an(&efx->mdio, pause);
|
||||||
__efx_reconfigure_port(efx);
|
__efx_reconfigure_port(efx);
|
||||||
|
|
||||||
mutex_unlock(&efx->mac_lock);
|
mutex_unlock(&efx->mac_lock);
|
||||||
|
@@ -304,7 +304,7 @@ int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
|
|||||||
else if (ecmd->advertising & (ADVERTISED_1000baseT_Half |
|
else if (ecmd->advertising & (ADVERTISED_1000baseT_Half |
|
||||||
ADVERTISED_1000baseT_Full))
|
ADVERTISED_1000baseT_Full))
|
||||||
reg |= ADVERTISE_NPAGE;
|
reg |= ADVERTISE_NPAGE;
|
||||||
reg |= efx_fc_advertise(efx->wanted_fc);
|
reg |= mii_advertise_flowctrl(efx->wanted_fc);
|
||||||
efx_mdio_write(efx, MDIO_MMD_AN, MDIO_AN_ADVERTISE, reg);
|
efx_mdio_write(efx, MDIO_MMD_AN, MDIO_AN_ADVERTISE, reg);
|
||||||
|
|
||||||
/* Set up the (extended) next page if necessary */
|
/* Set up the (extended) next page if necessary */
|
||||||
@@ -340,26 +340,6 @@ int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void efx_mdio_set_pause(struct efx_nic *efx)
|
|
||||||
{
|
|
||||||
int reg;
|
|
||||||
|
|
||||||
if (efx->phy_op->mmds & MDIO_DEVS_AN) {
|
|
||||||
/* Set pause capability advertising */
|
|
||||||
reg = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_AN_ADVERTISE);
|
|
||||||
reg &= ~(ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM);
|
|
||||||
reg |= efx_fc_advertise(efx->wanted_fc);
|
|
||||||
efx_mdio_write(efx, MDIO_MMD_AN, MDIO_AN_ADVERTISE, reg);
|
|
||||||
|
|
||||||
/* Restart auto-negotiation */
|
|
||||||
reg = efx_mdio_read(efx, MDIO_MMD_AN, MDIO_CTRL1);
|
|
||||||
if (reg & MDIO_AN_CTRL1_ENABLE) {
|
|
||||||
reg |= MDIO_AN_CTRL1_RESTART;
|
|
||||||
efx_mdio_write(efx, MDIO_MMD_AN, MDIO_CTRL1, reg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum efx_fc_type efx_mdio_get_pause(struct efx_nic *efx)
|
enum efx_fc_type efx_mdio_get_pause(struct efx_nic *efx)
|
||||||
{
|
{
|
||||||
int lpa;
|
int lpa;
|
||||||
|
@@ -87,9 +87,6 @@ extern void efx_mdio_set_mmds_lpower(struct efx_nic *efx,
|
|||||||
/* Set (some of) the PHY settings over MDIO */
|
/* Set (some of) the PHY settings over MDIO */
|
||||||
extern int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd);
|
extern int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd);
|
||||||
|
|
||||||
/* Set pause parameters to be advertised through AN (if available) */
|
|
||||||
extern void efx_mdio_set_pause(struct efx_nic *efx);
|
|
||||||
|
|
||||||
/* Get pause parameters from AN if available (otherwise return
|
/* Get pause parameters from AN if available (otherwise return
|
||||||
* requested pause parameters)
|
* requested pause parameters)
|
||||||
*/
|
*/
|
||||||
|
@@ -495,8 +495,8 @@ struct efx_nic;
|
|||||||
|
|
||||||
/* Pseudo bit-mask flow control field */
|
/* Pseudo bit-mask flow control field */
|
||||||
enum efx_fc_type {
|
enum efx_fc_type {
|
||||||
EFX_FC_RX = 1,
|
EFX_FC_RX = FLOW_CTRL_RX,
|
||||||
EFX_FC_TX = 2,
|
EFX_FC_TX = FLOW_CTRL_TX,
|
||||||
EFX_FC_AUTO = 4,
|
EFX_FC_AUTO = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -506,33 +506,15 @@ enum efx_mac_type {
|
|||||||
EFX_XMAC = 2,
|
EFX_XMAC = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline unsigned int efx_fc_advertise(enum efx_fc_type wanted_fc)
|
|
||||||
{
|
|
||||||
unsigned int adv = 0;
|
|
||||||
if (wanted_fc & EFX_FC_RX)
|
|
||||||
adv = ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM;
|
|
||||||
if (wanted_fc & EFX_FC_TX)
|
|
||||||
adv ^= ADVERTISE_PAUSE_ASYM;
|
|
||||||
return adv;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum efx_fc_type efx_fc_resolve(enum efx_fc_type wanted_fc,
|
static inline enum efx_fc_type efx_fc_resolve(enum efx_fc_type wanted_fc,
|
||||||
unsigned int lpa)
|
unsigned int lpa)
|
||||||
{
|
{
|
||||||
unsigned int adv = efx_fc_advertise(wanted_fc);
|
BUILD_BUG_ON(EFX_FC_AUTO & (EFX_FC_RX | EFX_FC_TX));
|
||||||
|
|
||||||
if (!(wanted_fc & EFX_FC_AUTO))
|
if (!(wanted_fc & EFX_FC_AUTO))
|
||||||
return wanted_fc;
|
return wanted_fc;
|
||||||
|
|
||||||
if (adv & lpa & ADVERTISE_PAUSE_CAP)
|
return mii_resolve_flowctrl_fdx(mii_advertise_flowctrl(wanted_fc), lpa);
|
||||||
return EFX_FC_RX | EFX_FC_TX;
|
|
||||||
if (adv & lpa & ADVERTISE_PAUSE_ASYM) {
|
|
||||||
if (adv & ADVERTISE_PAUSE_CAP)
|
|
||||||
return EFX_FC_RX;
|
|
||||||
if (lpa & ADVERTISE_PAUSE_CAP)
|
|
||||||
return EFX_FC_TX;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -343,7 +343,6 @@ static int tenxpress_phy_init(struct efx_nic *efx)
|
|||||||
rc = tenxpress_init(efx);
|
rc = tenxpress_init(efx);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
efx_mdio_set_pause(efx);
|
|
||||||
|
|
||||||
if (efx->phy_type == PHY_TYPE_SFT9001B) {
|
if (efx->phy_type == PHY_TYPE_SFT9001B) {
|
||||||
rc = device_create_file(&efx->pci_dev->dev,
|
rc = device_create_file(&efx->pci_dev->dev,
|
||||||
|
Reference in New Issue
Block a user