net: mdio: add mdio45_ethtool_ksettings_get
Subsystems (4)
PATCH 1/2 net: mdio: add mdio45_ethtool_ksettings_get
There is a function in mdio for the old ethtool api gset. We add a new function mdio45_ethtool_ksettings_get for the new ethtool api glinksettings.
--- drivers/net/mdio.c | 178 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mdio.h | 21 ++++++ 2 files changed, 199 insertions(+), 0 deletions(-)
drivers/net/mdio.c +178 -0
@@ -342,6 +342,184 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,EXPORT_SYMBOL (mdio45_ethtool_gset_npage);/** +* mdio45_ethtool_ksettings_get_npage - get settings for ETHTOOL_GLINKSETTINGS +* @mdio: MDIO interface +* @cmd: Ethtool request structure +* @npage_adv: Modes currently advertised on next pages +* @npage_lpa: Modes advertised by link partner on next pages +* +* The @cmd parameter is expected to have been cleared before calling +* mdio45_ethtool_ksettings_get_npage(). +* +* Since the CSRs for auto-negotiation using next pages are not fully +* standardised, this function does not attempt to decode them. The +* caller must pass them in. +*/ +void mdio45_ethtool_ksettings_get_npage (const struct mdio_if_info *mdio, +struct ethtool_link_ksettings *cmd, +u32 npage_adv,u32 npage_lpa) +{ +int reg; +u32 speed, supported =0 , advertising =0 , lp_advertising =0 ; + +BUILD_BUG_ON (MDIO_SUPPORTS_C22 !=ETH_MDIO_SUPPORTS_C22 ); +BUILD_BUG_ON (MDIO_SUPPORTS_C45 !=ETH_MDIO_SUPPORTS_C45 ); + + cmd->base.phy_address = mdio->prtad; + cmd->base.mdio_support = + mdio->mode_support & (MDIO_SUPPORTS_C45 |MDIO_SUPPORTS_C22 ); + + reg = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_PMAPMD , +MDIO_CTRL2 ); +switch (reg &MDIO_PMA_CTRL2_TYPE ) { +case MDIO_PMA_CTRL2_10GBT : +case MDIO_PMA_CTRL2_1000BT : +case MDIO_PMA_CTRL2_100BTX : +case MDIO_PMA_CTRL2_10BT : + cmd->base.port =PORT_TP ; + supported =SUPPORTED_TP ; + reg = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_PMAPMD , +MDIO_SPEED ); +if (reg &MDIO_SPEED_10G ) + supported |= SUPPORTED_10000baseT_Full; +if (reg &MDIO_PMA_SPEED_1000 ) + supported |= (SUPPORTED_1000baseT_Full | + SUPPORTED_1000baseT_Half); +if (reg &MDIO_PMA_SPEED_100 ) + supported |= (SUPPORTED_100baseT_Full | + SUPPORTED_100baseT_Half); +if (reg &MDIO_PMA_SPEED_10 ) + supported |= (SUPPORTED_10baseT_Full | + SUPPORTED_10baseT_Half); + advertising =ADVERTISED_TP ; +break ; + +case MDIO_PMA_CTRL2_10GBCX4 : + cmd->base.port =PORT_OTHER ; + supported =0 ; + advertising =0 ; +break ; + +case MDIO_PMA_CTRL2_10GBKX4 : +case MDIO_PMA_CTRL2_10GBKR : +case MDIO_PMA_CTRL2_1000BKX : + cmd->base.port =PORT_OTHER ; + supported = SUPPORTED_Backplane; + reg = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_PMAPMD , +MDIO_PMA_EXTABLE ); +if (reg &MDIO_PMA_EXTABLE_10GBKX4 ) + supported |= SUPPORTED_10000baseKX4_Full; +if (reg &MDIO_PMA_EXTABLE_10GBKR ) + supported |= SUPPORTED_10000baseKR_Full; +if (reg &MDIO_PMA_EXTABLE_1000BKX ) + supported |= SUPPORTED_1000baseKX_Full; + reg = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_PMAPMD , +MDIO_PMA_10GBR_FECABLE ); +if (reg &MDIO_PMA_10GBR_FECABLE_ABLE ) + supported |= SUPPORTED_10000baseR_FEC; + advertising = ADVERTISED_Backplane; +break ; + +/* All the other defined modes are flavours of optical */ +default : + cmd->base.port =PORT_FIBRE ; + supported =SUPPORTED_FIBRE ; + advertising =ADVERTISED_FIBRE ; +break ; + } + +if (mdio->mmds &MDIO_DEVS_AN ) { + supported |= SUPPORTED_Autoneg; + reg = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_AN , +MDIO_CTRL1 ); +if (reg &MDIO_AN_CTRL1_ENABLE ) { + cmd->base.autoneg =AUTONEG_ENABLE ; + advertising |= + ADVERTISED_Autoneg | +mdio45_get_an (mdio,MDIO_AN_ADVERTISE ) | + npage_adv; + }else { + cmd->base.autoneg =AUTONEG_DISABLE ; + } + }else { + cmd->base.autoneg =AUTONEG_DISABLE ; + } + +if (cmd->base.autoneg) { +u32 modes =0 ; +int an_stat = mdio->mdio_read (mdio->dev, mdio->prtad, +MDIO_MMD_AN ,MDIO_STAT1 ); + +/* If AN is complete and successful, report best common +* mode, otherwise report best advertised mode. +*/ +if (an_stat &MDIO_AN_STAT1_COMPLETE ) { + lp_advertising = +mdio45_get_an (mdio,MDIO_AN_LPA ) | npage_lpa; +if (an_stat &MDIO_AN_STAT1_LPABLE ) + lp_advertising |= ADVERTISED_Autoneg; + modes = advertising & lp_advertising; + } +if ((modes & ~ADVERTISED_Autoneg) ==0 ) + modes = advertising; + +if (modes & (ADVERTISED_10000baseT_Full | + ADVERTISED_10000baseKX4_Full | + ADVERTISED_10000baseKR_Full)) { + speed =SPEED_10000 ; + cmd->base.duplex =DUPLEX_FULL ; + }else if (modes & (ADVERTISED_1000baseT_Full | + ADVERTISED_1000baseT_Half | + ADVERTISED_1000baseKX_Full)) { + speed =SPEED_1000 ; + cmd->base.duplex = !(modes & ADVERTISED_1000baseT_Half); + }else if (modes & (ADVERTISED_100baseT_Full | + ADVERTISED_100baseT_Half)) { + speed =SPEED_100 ; + cmd->base.duplex = !!(modes & ADVERTISED_100baseT_Full); + }else { + speed =SPEED_10 ; + cmd->base.duplex = !!(modes & ADVERTISED_10baseT_Full); + } + }else { +/* Report forced settings */ + reg = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_PMAPMD , +MDIO_CTRL1 ); + speed = (((reg &MDIO_PMA_CTRL1_SPEED1000 ) ?100 :1 ) + * ((reg &MDIO_PMA_CTRL1_SPEED100 ) ?100 :10 )); + cmd->base.duplex = (reg &MDIO_CTRL1_FULLDPLX || + speed ==SPEED_10000 ); + } + + cmd->base.speed = speed; + +ethtool_convert_legacy_u32_to_link_mode (cmd->link_modes.supported, + supported); +ethtool_convert_legacy_u32_to_link_mode (cmd->link_modes.advertising, + advertising); +ethtool_convert_legacy_u32_to_link_mode (cmd->link_modes.lp_advertising, + lp_advertising); + +/* 10GBASE-T MDI/MDI-X */ +if (cmd->base.port ==PORT_TP && (cmd->base.speed ==SPEED_10000 )) { +switch (mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_PMAPMD , +MDIO_PMA_10GBT_SWAPPOL )) { +case MDIO_PMA_10GBT_SWAPPOL_ABNX |MDIO_PMA_10GBT_SWAPPOL_CDNX : + cmd->base.eth_tp_mdix =ETH_TP_MDI ; +break ; +case 0 : + cmd->base.eth_tp_mdix =ETH_TP_MDI_X ; +break ; +default : +/* It's complicated... */ + cmd->base.eth_tp_mdix =ETH_TP_MDI_INVALID ; +break ; + } + } +} +EXPORT_SYMBOL (mdio45_ethtool_ksettings_get_npage); + +/** * mdio_mii_ioctl - MII ioctl interface for MDIO (clause 22 or 45) PHYs * @mdio: MDIO interface * @mii_data: MII ioctl data structure
include/linux/mdio.h +21 -0
@@ -130,6 +130,10 @@ extern int mdio_set_flag(const struct mdio_if_info *mdio,extern void mdio45_ethtool_gset_npage (const struct mdio_if_info *mdio,struct ethtool_cmd *ecmd,u32 npage_adv,u32 npage_lpa); +extern void +mdio45_ethtool_ksettings_get_npage (const struct mdio_if_info *mdio, +struct ethtool_link_ksettings *cmd, +u32 npage_adv,u32 npage_lpa);/** * mdio45_ethtool_gset - get settings for ETHTOOL_GSET
@@ -147,6 +151,23 @@ static inline void mdio45_ethtool_gset(const struct mdio_if_info *mdio,mdio45_ethtool_gset_npage (mdio, ecmd,0 ,0 ); } +/** +* mdio45_ethtool_ksettings_get - get settings for ETHTOOL_GLINKSETTINGS +* @mdio: MDIO interface +* @cmd: Ethtool request structure +* +* Since the CSRs for auto-negotiation using next pages are not fully +* standardised, this function does not attempt to decode them. Use +* mdio45_ethtool_ksettings_get_npage() to specify advertisement bits +* from next pages. +*/ +static inline void +mdio45_ethtool_ksettings_get (const struct mdio_if_info *mdio, +struct ethtool_link_ksettings *cmd) +{ +mdio45_ethtool_ksettings_get_npage (mdio, cmd,0 ,0 ); +} +extern int mdio_mii_ioctl (const struct mdio_if_info *mdio,struct mii_ioctl_data *mii_data,int cmd);
Signature · 1 line
1.7.4.4
PATCH 2/2 net: sfc: falcon: use new api ethtool_{get|set}_link_ksettings
The ethtool api {get|set}_settings is deprecated. We move this driver to new api {get|set}_link_ksettings.
--- drivers/net/ethernet/sfc/falcon/efx.c | 2 +- drivers/net/ethernet/sfc/falcon/ethtool.c | 35 ++++++++++++------- drivers/net/ethernet/sfc/falcon/mdio_10g.c | 44 +++++++++++++++--------- drivers/net/ethernet/sfc/falcon/mdio_10g.h | 3 +- drivers/net/ethernet/sfc/falcon/net_driver.h | 12 +++--- drivers/net/ethernet/sfc/falcon/qt202x_phy.c | 9 +++-- drivers/net/ethernet/sfc/falcon/tenxpress.c | 22 ++++++------ drivers/net/ethernet/sfc/falcon/txc43128_phy.c | 9 +++-- 8 files changed, 80 insertions(+), 56 deletions(-)
drivers/net/ethernet/sfc/falcon/efx.c +1 -1
@@ -986,7 +986,7 @@ void ef4_mac_reconfigure(struct ef4_nic *efx)/* Push loopback/power/transmit disable settings to the PHY, and reconfigure * the MAC appropriately. All other PHY configuration changes are pushed -* through phy_op->set_settings(), and pushed asynchronously to the MAC +* through phy_op->set_link_ksettings(), and pushed asynchronously to the MAC * through ef4_monitor(). * * Callers must hold the mac_lock
drivers/net/ethernet/sfc/falcon/ethtool.c +22 -13
@@ -115,44 +115,53 @@ static int ef4_ethtool_phys_id(struct net_device *net_dev, }/* This must be called with rtnl_lock held. */ -static int ef4_ethtool_get_settings (struct net_device *net_dev, -struct ethtool_cmd *ecmd) +static int +ef4_ethtool_get_link_ksettings (struct net_device *net_dev, +struct ethtool_link_ksettings *cmd) {struct ef4_nic *efx =netdev_priv (net_dev);struct ef4_link_state *link_state = &efx->link_state; +u32 supported; + +ethtool_convert_link_mode_to_legacy_u32 (&supported, + cmd->link_modes.supported);mutex_lock (&efx->mac_lock); - efx->phy_op->get_settings (efx, ecmd); + efx->phy_op->get_link_ksettings (efx, cmd);mutex_unlock (&efx->mac_lock);/* Both MACs support pause frames (bidirectional and respond-only) */ - ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; + supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;if (LOOPBACK_INTERNAL (efx)) { -ethtool_cmd_speed_set (ecmd, link_state->speed); - ecmd->duplex = link_state->fd ?DUPLEX_FULL :DUPLEX_HALF ; + cmd->base.speed = link_state->speed; + cmd->base.duplex = link_state->fd ?DUPLEX_FULL :DUPLEX_HALF ; } +ethtool_convert_legacy_u32_to_link_mode (cmd->link_modes.supported, + supported); +return 0 ; }/* This must be called with rtnl_lock held. */ -static int ef4_ethtool_set_settings (struct net_device *net_dev, -struct ethtool_cmd *ecmd) +static int +ef4_ethtool_set_link_ksettings (struct net_device *net_dev, +const struct ethtool_link_ksettings *cmd) {struct ef4_nic *efx =netdev_priv (net_dev);int rc;/* GMAC does not support 1000Mbps HD */ -if ((ethtool_cmd_speed (ecmd) ==SPEED_1000 ) && - (ecmd->duplex !=DUPLEX_FULL )) { +if ((cmd->base.speed ==SPEED_1000 ) && + (cmd->base.duplex !=DUPLEX_FULL )) {netif_dbg (efx, drv, efx->net_dev,"rejecting unsupported 1000Mbps HD setting\n" );return -EINVAL ; }mutex_lock (&efx->mac_lock); - rc = efx->phy_op->set_settings (efx, ecmd); + rc = efx->phy_op->set_link_ksettings (efx, cmd);mutex_unlock (&efx->mac_lock);return rc; }
@@ -1310,8 +1319,6 @@ static int ef4_ethtool_get_module_info(struct net_device *net_dev, }const struct ethtool_ops ef4_ethtool_ops = { - .get_settings = ef4_ethtool_get_settings, - .set_settings = ef4_ethtool_set_settings, .get_drvinfo = ef4_ethtool_get_drvinfo, .get_regs_len = ef4_ethtool_get_regs_len, .get_regs = ef4_ethtool_get_regs,
@@ -1340,4 +1347,6 @@ static int ef4_ethtool_get_module_info(struct net_device *net_dev, .set_rxfh = ef4_ethtool_set_rxfh, .get_module_info = ef4_ethtool_get_module_info, .get_module_eeprom = ef4_ethtool_get_module_eeprom, + .get_link_ksettings = ef4_ethtool_get_link_ksettings, + .set_link_ksettings = ef4_ethtool_set_link_ksettings, };
drivers/net/ethernet/sfc/falcon/mdio_10g.c +28 -16
61 lines not on this page · raw message
drivers/net/ethernet/sfc/falcon/mdio_10g.h +2 -1
@@ -83,7 +83,8 @@ void ef4_mdio_set_mmds_lpower(struct ef4_nic *efx, int low_power, unsigned int mmd_mask);/* Set (some of) the PHY settings over MDIO */ -int ef4_mdio_set_settings (struct ef4_nic *efx,struct ethtool_cmd *ecmd); +int ef4_mdio_set_link_ksettings (struct ef4_nic *efx, +const struct ethtool_link_ksettings *cmd);/* Push advertising flags and restart autonegotiation */ void ef4_mdio_an_reconfigure (struct ef4_nic *efx);
drivers/net/ethernet/sfc/falcon/net_driver.h +6 -6
@@ -684,8 +684,8 @@ static inline bool ef4_link_state_equal(const struct ef4_link_state *left,* @reconfigure: Reconfigure PHY (e.g. for new link parameters) * @poll: Update @link_state and report whether it changed. * Serialised by the mac_lock. -* @get_settings: Get ethtool settings. Serialised by the mac_lock. -* @set_settings: Set ethtool settings. Serialised by the mac_lock. +* @get_link_ksettings: Get ethtool settings. Serialised by the mac_lock. +* @set_link_ksettings: Set ethtool settings. Serialised by the mac_lock. * @set_npage_adv: Set abilities advertised in (Extended) Next Page * (only needed where AN bit is set in mmds) * @test_alive: Test that PHY is 'alive' (online)
@@ -700,10 +700,10 @@ struct ef4_phy_operations {void (*remove) (struct ef4_nic *efx);int (*reconfigure) (struct ef4_nic *efx);bool (*poll) (struct ef4_nic *efx); -void (*get_settings) (struct ef4_nic *efx, -struct ethtool_cmd *ecmd); -int (*set_settings) (struct ef4_nic *efx, -struct ethtool_cmd *ecmd); +void (*get_link_ksettings)(struct ef4_nic *efx, +struct ethtool_link_ksettings *cmd); +int (*set_link_ksettings)(struct ef4_nic *efx, +const struct ethtool_link_ksettings *cmd);void (*set_npage_adv) (struct ef4_nic *efx,u32 );int (*test_alive) (struct ef4_nic *efx);const char *(*test_name) (struct ef4_nic *efx,unsigned int index);
drivers/net/ethernet/sfc/falcon/qt202x_phy.c +5 -4
@@ -437,9 +437,10 @@ static int qt202x_phy_reconfigure(struct ef4_nic *efx)return 0 ; } -static void qt202x_phy_get_settings (struct ef4_nic *efx,struct ethtool_cmd *ecmd) +static void qt202x_phy_get_link_ksettings (struct ef4_nic *efx, +struct ethtool_link_ksettings *cmd) { -mdio45_ethtool_gset (&efx->mdio, ecmd); +mdio45_ethtool_ksettings_get (&efx->mdio, cmd); }static void qt202x_phy_remove (struct ef4_nic *efx)
@@ -487,8 +488,8 @@ static int qt202x_phy_get_module_eeprom(struct ef4_nic *efx, .poll = qt202x_phy_poll, .fini = ef4_port_dummy_op_void, .remove = qt202x_phy_remove, - .get_settings = qt202x_phy_get_settings, - .set_settings = ef4_mdio_set_settings, + .get_link_ksettings = qt202x_phy_get_link_ksettings, + .set_link_ksettings = ef4_mdio_set_link_ksettings, .test_alive = ef4_mdio_test_alive, .get_module_eeprom = qt202x_phy_get_module_eeprom, .get_module_info = qt202x_phy_get_module_info,
drivers/net/ethernet/sfc/falcon/tenxpress.c +11 -11
@@ -351,9 +351,6 @@ static int tenxpress_phy_reconfigure(struct ef4_nic *efx)return 0 ; } -static void -tenxpress_get_settings (struct ef4_nic *efx,struct ethtool_cmd *ecmd); -/* Poll for link state changes */ static bool tenxpress_phy_poll (struct ef4_nic *efx) {
@@ -443,7 +440,8 @@ void tenxpress_set_id_led(struct ef4_nic *efx, enum ef4_led_mode mode) }static void -tenxpress_get_settings (struct ef4_nic *efx,struct ethtool_cmd *ecmd) +tenxpress_get_link_ksettings (struct ef4_nic *efx, +struct ethtool_link_ksettings *cmd) {u32 adv =0 , lpa =0 ;int reg;
@@ -455,20 +453,22 @@ void tenxpress_set_id_led(struct ef4_nic *efx, enum ef4_led_mode mode)if (reg &MDIO_AN_10GBT_STAT_LP10G ) lpa |= ADVERTISED_10000baseT_Full; -mdio45_ethtool_gset_npage (&efx->mdio, ecmd, adv, lpa); +mdio45_ethtool_ksettings_get_npage (&efx->mdio, cmd, adv, lpa);/* In loopback, the PHY automatically brings up the correct interface, * but doesn't advertise the correct speed. So override it */ if (LOOPBACK_EXTERNAL (efx)) -ethtool_cmd_speed_set (ecmd,SPEED_10000 ); + cmd->base.speed =SPEED_10000 ; } -static int tenxpress_set_settings (struct ef4_nic *efx,struct ethtool_cmd *ecmd) +static int +tenxpress_set_link_ksettings (struct ef4_nic *efx, +const struct ethtool_link_ksettings *cmd) { -if (!ecmd->autoneg) +if (!cmd->base.autoneg)return -EINVAL ; -return ef4_mdio_set_settings (efx, ecmd); +return ef4_mdio_set_link_ksettings (efx, cmd); }static void sfx7101_set_npage_adv (struct ef4_nic *efx,u32 advertising)
@@ -485,8 +485,8 @@ static void sfx7101_set_npage_adv(struct ef4_nic *efx, u32 advertising) .poll = tenxpress_phy_poll, .fini = sfx7101_phy_fini, .remove = tenxpress_phy_remove, - .get_settings = tenxpress_get_settings, - .set_settings = tenxpress_set_settings, + .get_link_ksettings = tenxpress_get_link_ksettings, + .set_link_ksettings = tenxpress_set_link_ksettings, .set_npage_adv = sfx7101_set_npage_adv, .test_alive = ef4_mdio_test_alive, .test_name = sfx7101_test_name,
drivers/net/ethernet/sfc/falcon/txc43128_phy.c +5 -4
@@ -540,9 +540,10 @@ static int txc43128_run_tests(struct ef4_nic *efx, int *results, unsigned flags)return rc; } -static void txc43128_get_settings (struct ef4_nic *efx,struct ethtool_cmd *ecmd) +static void txc43128_get_link_ksettings (struct ef4_nic *efx, +struct ethtool_link_ksettings *cmd) { -mdio45_ethtool_gset (&efx->mdio, ecmd); +mdio45_ethtool_ksettings_get (&efx->mdio, cmd); }const struct ef4_phy_operations falcon_txc_phy_ops = {
@@ -552,8 +553,8 @@ static void txc43128_get_settings(struct ef4_nic *efx, struct ethtool_cmd *ecmd) .poll = txc43128_phy_poll, .fini = txc43128_phy_fini, .remove = txc43128_phy_remove, - .get_settings = txc43128_get_settings, - .set_settings = ef4_mdio_set_settings, + .get_link_ksettings = txc43128_get_link_ksettings, + .set_link_ksettings = ef4_mdio_set_link_ksettings, .test_alive = ef4_mdio_test_alive, .run_tests = txc43128_run_tests, .test_name = txc43128_test_name,
Signature · 1 line
1.7.4.4
Re: [PATCH 2/2] net: sfc: falcon: use new api ethtool_{get|set}_link_ksettings
Quoted 60 lines · Philippe Reynes
The ethtool api {get|set}_settings is deprecated. We move this driver to new api {get|set}_link_ksettings.
Signed-off-by Philippe Reynes <[email protected]>--- drivers/net/ethernet/sfc/falcon/efx.c | 2 +- drivers/net/ethernet/sfc/falcon/ethtool.c | 35 ++++++++++++------- drivers/net/ethernet/sfc/falcon/mdio_10g.c | 44 +++++++++++++++--------- drivers/net/ethernet/sfc/falcon/mdio_10g.h | 3 +- drivers/net/ethernet/sfc/falcon/net_driver.h | 12 +++--- drivers/net/ethernet/sfc/falcon/qt202x_phy.c | 9 +++-- drivers/net/ethernet/sfc/falcon/tenxpress.c | 22 ++++++------ drivers/net/ethernet/sfc/falcon/txc43128_phy.c | 9 +++-- 8 files changed, 80 insertions(+), 56 deletions(-)drivers/net/ethernet/sfc/falcon/efx.c +1
-1@@ -986,7 +986,7 @@ void ef4_mac_reconfigure(struct ef4_nic *efx)/* Push loopback/power/transmit disable settings to the PHY, and reconfigure * the MAC appropriately. All other PHY configuration changes are pushed -* through phy_op->set_settings(), and pushed asynchronously to the MAC +* through phy_op->set_link_ksettings(), and pushed asynchronously to the MAC * through ef4_monitor(). * * Callers must hold the mac_lock drivers/net/ethernet/sfc/falcon/ethtool.c +9
-5@@ -115,44 +115,53 @@ static int ef4_ethtool_phys_id(struct net_device *net_dev, }/* This must be called with rtnl_lock held. */ -static int ef4_ethtool_get_settings (struct net_device *net_dev, -struct ethtool_cmd *ecmd) +static int +ef4_ethtool_get_link_ksettings (struct net_device *net_dev, +struct ethtool_link_ksettings *cmd) {struct ef4_nic *efx =netdev_priv (net_dev);struct ef4_link_state *link_state = &efx->link_state; +u32 supported; + +ethtool_convert_link_mode_to_legacy_u32 (&supported, + cmd->link_modes.supported);mutex_lock (&efx->mac_lock); - efx->phy_op->get_settings (efx, ecmd); + efx->phy_op->get_link_ksettings (efx, cmd);mutex_unlock (&efx->mac_lock);/* Both MACs support pause frames (bidirectional and respond-only) */ - ecmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause; + supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;if (LOOPBACK_INTERNAL (efx)) { -ethtool_cmd_speed_set (ecmd, link_state->speed);
drivers/net/ethernet/sfc/falcon/ethtool.c static int ef4_ethtool_phys_id(struct net_device *net_dev, · line 145
Quoted 10 lines
drivers/net/ethernet/sfc/falcon/ethtool.c +5
-1- ecmd->duplex = link_state->fd ?DUPLEX_FULL :DUPLEX_HALF ; + cmd->base.speed = link_state->speed; + cmd->base.duplex = link_state->fd ?DUPLEX_FULL :DUPLEX_HALF ; } +ethtool_convert_legacy_u32_to_link_mode (cmd->link_modes.supported, + supported); +return 0 ; }
This translates cmd->link_modes.supported in to the legacy supported bitmap before we've actually read the values from the phy. Given we're only using the legacy bitmap so we can add the pause frame settings, I suggest something like:
ef4_ethtool_get_link_ksettings(struct net_device *net_dev,
struct ethtool_link_ksettings *cmd)
{
struct ef4_nic *efx = netdev_priv(net_dev);
struct ef4_link_state *link_state = &efx->link_state;
mutex_lock(&efx->mac_lock);
efx->phy_op->get_link_ksettings(efx, cmd);
mutex_unlock(&efx->mac_lock);
/* Both MACs support pause frames (bidirectional and respond-only) */
ethtool_link_ksettings_add_link_mode(cmd, supported, Pause);
ethtool_link_ksettings_add_link_mode(cmd, supported, Asym_Pause);
if (LOOPBACK_INTERNAL(efx)) {
cmd->base.speed = link_state->speed;
cmd->base.duplex = link_state->fd ? DUPLEX_FULL : DUPLEX_HALF;
}
return 0;
}Thanks,
Bert.
David Miller
maintainerPlease resubmit this patch series when net-next opens back up, thanks.