ethtool: drop get_settings and set_settings ops
Subsystems (5)
cover ethtool: drop get_settings and set_settings ops
As Andrew Lunn pointed out in recent discussion, there is only one in tree driver left which still defines deprecated callbacks get_settings() and set_settings() in ethtool_ops. First patch converts this driver to get_link_ksettings() and set_link_ksettings(). Second patch then removes the deprecated callbacks from struct ethtool_ops and ethtool code which falls back to them.
This doesn't break old versions of ethtool or any other userspace code using ETHTOOL_{G,S}SET. We still implement both (old) ETHTOOL_{G,S}SET and (new) ETHTOOL_{G,S}LINKSETTINGS ioctl commands but after this series both will be implemented only using {g,s}et_link_ksettings(). The only affected code would be out of tree NIC drivers which have not been converted yet.
Michal Kubecek (2):
8390/etherh: convert to ethtool_{get,set}_link_ksettings
ethtool: drop get_settings and set_settings callbacks
Documentation/ABI/testing/sysfs-class-net | 4 +- drivers/net/ethernet/8390/etherh.c | 35 ++--- include/linux/ethtool.h | 33 ++--- include/uapi/linux/ethtool.h | 15 +- net/core/ethtool.c | 158 +++++----------------- 5 files changed, 69 insertions(+), 176 deletions(-)
Signature · 1 line
2.18.0
PATCH 1/2 8390/etherh: convert to ethtool_{get,set}_link_ksettings
This is the last in-tree driver using the old {get,set}_settings API.
Note: this is only build tested. I don't have the hardware at hand; as it's 10Mb/s half duplex device and driver can be built only for one subplatform of 32-bit ARM (Acorn RiscPC), it may be difficult to find someone who does.
--- drivers/net/ethernet/8390/etherh.c | 35 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/net/ethernet/8390/etherh.c +19 -16
@@ -564,26 +564,29 @@ static void etherh_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i sizeof(info->bus_info)); } -static int etherh_get_settings (struct net_device *dev,struct ethtool_cmd *cmd) +static int etherh_get_link_ksettings (struct net_device *dev, +struct ethtool_link_ksettings *cmd) { - cmd->supported =etherh_priv (dev)->supported; -ethtool_cmd_speed_set (cmd,SPEED_10 ); - cmd->duplex =DUPLEX_HALF ; - cmd->port = dev->if_port ==IF_PORT_10BASET ?PORT_TP :PORT_BNC ; - cmd->autoneg = (dev->flags &IFF_AUTOMEDIA ? -AUTONEG_ENABLE :AUTONEG_DISABLE ); +ethtool_convert_legacy_u32_to_link_mode (cmd->link_modes.supported, +etherh_priv (dev)->supported); + cmd->base.speed =SPEED_10 ; + cmd->base.duplex =DUPLEX_HALF ; + cmd->base.port = dev->if_port ==IF_PORT_10BASET ?PORT_TP :PORT_BNC ; + cmd->base.autoneg = (dev->flags &IFF_AUTOMEDIA ?AUTONEG_ENABLE : +AUTONEG_DISABLE );return 0 ; } -static int etherh_set_settings (struct net_device *dev,struct ethtool_cmd *cmd) +static int etherh_set_link_ksettings (struct net_device *dev, +const struct ethtool_link_ksettings *cmd) { -switch (cmd->autoneg) { +switch (cmd->base.autoneg) {case AUTONEG_ENABLE : dev->flags |=IFF_AUTOMEDIA ;break ;case AUTONEG_DISABLE : -switch (cmd->port) { +switch (cmd->base.port) {case PORT_TP : dev->if_port =IF_PORT_10BASET ;break ;
@@ -622,12 +625,12 @@ static void etherh_set_msglevel(struct net_device *dev, u32 v) }static const struct ethtool_ops etherh_ethtool_ops = { - .get_settings = etherh_get_settings, - .set_settings = etherh_set_settings, - .get_drvinfo = etherh_get_drvinfo, - .get_ts_info = ethtool_op_get_ts_info, - .get_msglevel = etherh_get_msglevel, - .set_msglevel = etherh_set_msglevel, + .get_drvinfo = etherh_get_drvinfo, + .get_ts_info = ethtool_op_get_ts_info, + .get_msglevel = etherh_get_msglevel, + .set_msglevel = etherh_set_msglevel, + .get_link_ksettings = etherh_get_link_ksettings, + .set_link_ksettings = etherh_set_link_ksettings, };static const struct net_device_ops etherh_netdev_ops = {
Signature · 1 line
2.18.0
PATCH 2/2 ethtool: drop get_settings and set_settings callbacks
In reply to Michal KubecekSince [gs]et_settings ethtool_ops callbacks have been deprecated in February 2016, all in tree NIC drivers have been converted to provide [gs]et_link_ksettings() and out of tree drivers have had enough time to do the same.
Drop get_settings() and set_settings() and implement both ETHTOOL_[GS]SET and ETHTOOL_[GS]LINKSETTINGS only using [gs]et_link_ksettings().
--- Documentation/ABI/testing/sysfs-class-net | 4 +- include/linux/ethtool.h | 33 ++--- include/uapi/linux/ethtool.h | 15 +- net/core/ethtool.c | 158 +++++----------------- 4 files changed, 50 insertions(+), 160 deletions(-)
Documentation/ABI/testing/sysfs-class-net +2 -2
@@ -117,7 +117,7 @@ Description: full: full duplex Note: This attribute is only valid for interfaces that implement - the ethtool get_settings method (mostly Ethernet). + the ethtool get_link_ksettings method (mostly Ethernet). What: /sys/class/net/<iface>/flags Date: April 2005
@@ -224,7 +224,7 @@ Description: an integer representing the link speed in Mbits/sec. Note: this attribute is only valid for interfaces that implement - the ethtool get_settings method (mostly Ethernet ). + the ethtool get_link_ksettings method (mostly Ethernet). What: /sys/class/net/<iface>/tx_queue_len Date: April 2005
include/linux/ethtool.h +10 -23
@@ -183,14 +183,6 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,/** * struct ethtool_ops - optional netdev operations -* @get_settings: DEPRECATED, use %get_link_ksettings/%set_link_ksettings -* API. Get various device settings including Ethernet link -* settings. The @cmd parameter is expected to have been cleared -* before get_settings is called. Returns a negative error code -* or zero. -* @set_settings: DEPRECATED, use %get_link_ksettings/%set_link_ksettings -* API. Set various device settings including Ethernet link -* settings. Returns a negative error code or zero. * @get_drvinfo: Report driver/device information. Should only set the * @driver, @version, @fw_version and @bus_info fields. If not * implemented, the @driver and @bus_info fields will be filled in
@@ -297,19 +289,16 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,* a TX queue has this number, return -EINVAL. If only a RX queue or a TX * queue has this number, ignore the inapplicable fields. * Returns a negative error code or zero. -* @get_link_ksettings: When defined, takes precedence over the -* %get_settings method. Get various device settings -* including Ethernet link settings. The %cmd and -* %link_mode_masks_nwords fields should be ignored (use -* %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), any -* change to them will be overwritten by kernel. Returns a -* negative error code or zero. -* @set_link_ksettings: When defined, takes precedence over the -* %set_settings method. Set various device settings including -* Ethernet link settings. The %cmd and %link_mode_masks_nwords -* fields should be ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS -* instead of the latter), any change to them will be overwritten -* by kernel. Returns a negative error code or zero. +* @get_link_ksettings: Get various device settings including Ethernet link +* settings. The %cmd and %link_mode_masks_nwords fields should be +* ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), +* any change to them will be overwritten by kernel. Returns a negative +* error code or zero. +* @set_link_ksettings: Set various device settings including Ethernet link +* settings. The %cmd and %link_mode_masks_nwords fields should be +* ignored (use %__ETHTOOL_LINK_MODE_MASK_NBITS instead of the latter), +* any change to them will be overwritten by kernel. Returns a negative +* error code or zero. * @get_fecparam: Get the network device Forward Error Correction parameters. * @set_fecparam: Set the network device Forward Error Correction parameters. * @get_ethtool_phy_stats: Return extended statistics about the PHY device.
@@ -329,8 +318,6 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,* of the generic netdev features interface. */ struct ethtool_ops { -int (*get_settings)(struct net_device *,struct ethtool_cmd *); -int (*set_settings)(struct net_device *,struct ethtool_cmd *);void (*get_drvinfo)(struct net_device *,struct ethtool_drvinfo *);int (*get_regs_len)(struct net_device *);void (*get_regs)(struct net_device *,struct ethtool_regs *,void *);
include/uapi/linux/ethtool.h +3 -12
@@ -91,10 +91,6 @@* %ETHTOOL_GSET to get the current values before making specific * changes and then applying them with %ETHTOOL_SSET. * -* Drivers that implement set_settings() should validate all fields -* other than @cmd that are not described as read-only or deprecated, -* and must ignore all fields described as read-only. -* * Deprecated fields should be ignored by both users and drivers. */ struct ethtool_cmd {
@@ -1800,14 +1796,9 @@ enum ethtool_reset_flags {* rejected. * * Deprecated %ethtool_cmd fields transceiver, maxtxpkt and maxrxpkt -* are not available in %ethtool_link_settings. Until all drivers are -* converted to ignore them or to the new %ethtool_link_settings API, -* for both queries and changes, users should always try -* %ETHTOOL_GLINKSETTINGS first, and if it fails with -ENOTSUPP stick -* only to %ETHTOOL_GSET and %ETHTOOL_SSET consistently. If it -* succeeds, then users should stick to %ETHTOOL_GLINKSETTINGS and -* %ETHTOOL_SLINKSETTINGS (which would support drivers implementing -* either %ethtool_cmd or %ethtool_link_settings). +* are not available in %ethtool_link_settings. These fields will be +* always set to zero in %ETHTOOL_GSET reply and %ETHTOOL_SSET will +* fail if any of them is set to non-zero value. * * Users should assume that all fields not marked read-only are * writable and subject to validation by the driver. They should use
net/core/ethtool.c +35 -123
220 lines not on this page · raw message
Signature · 1 line
2.18.0
David Miller
maintainerFrom: Michal Kubecek <[email protected]>
Date: Tue, 28 Aug 2018 19:56:48 +0200 (CEST)
Quoted 7 lines
As Andrew Lunn pointed out in recent discussion, there is only one in tree driver left which still defines deprecated callbacks
get_settings()andset_settings()inethtool_ops. First patch converts this driver toget_link_ksettings()andset_link_ksettings(). Second patch then removes the deprecated callbacks from structethtool_opsand ethtool code which falls back to them.
Quoted 5 lines
This doesn't break old versions of ethtool or any other userspace code using ETHTOOL_{G,S}SET. We still implement both (old) ETHTOOL_{G,S}SET and (new) ETHTOOL_{G,S}LINKSETTINGS ioctl commands but after this series both will be implemented only using {g,s}et_link_ksettings(). The only affected code would be out of tree NIC drivers which have not been converted yet.
Nice, thanks for following up on this.
Series applied.