Commit 50dad399 authored by David S. Miller's avatar David S. Miller

Merge branch 'ethtool-FEC'

Jakub Kicinski says:

====================
ethtool: clarify the ethtool FEC interface

Our FEC configuration interface is one of the more confusing.
It also lacks any error checking in the core. This certainly
shows in the varying implementations across the drivers.

Improve the documentation and add most basic checks. Sadly, it's
probably too late now to try to enforce much more uniformity.

Any thoughts & suggestions welcome. Next step is to add netlink
for FEC, then stats.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 241949e4 6dbf94b2
...@@ -1376,15 +1376,29 @@ struct ethtool_per_queue_op { ...@@ -1376,15 +1376,29 @@ struct ethtool_per_queue_op {
}; };
/** /**
* struct ethtool_fecparam - Ethernet forward error correction(fec) parameters * struct ethtool_fecparam - Ethernet Forward Error Correction parameters
* @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM * @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM
* @active_fec: FEC mode which is active on porte * @active_fec: FEC mode which is active on the port, single bit set, GET only.
* @fec: Bitmask of supported/configured FEC modes * @fec: Bitmask of configured FEC modes.
* @rsvd: Reserved for future extensions. i.e FEC bypass feature. * @reserved: Reserved for future extensions, ignore on GET, write 0 for SET.
* *
* Drivers should reject a non-zero setting of @autoneg when * FEC modes supported by the device can be read via %ETHTOOL_GLINKSETTINGS.
* autoneogotiation is disabled (or not supported) for the link. * FEC settings are configured by link autonegotiation whenever it's enabled.
* With autoneg on %ETHTOOL_GFECPARAM can be used to read the current mode.
*
* When autoneg is disabled %ETHTOOL_SFECPARAM controls the FEC settings.
* It is recommended that drivers only accept a single bit set in @fec.
* When multiple bits are set in @fec drivers may pick mode in an implementation
* dependent way. Drivers should reject mixing %ETHTOOL_FEC_AUTO_BIT with other
* FEC modes, because it's unclear whether in this case other modes constrain
* AUTO or are independent choices.
* Drivers must reject SET requests if they support none of the requested modes.
*
* If device does not support FEC drivers may use %ETHTOOL_FEC_NONE instead
* of returning %EOPNOTSUPP from %ETHTOOL_GFECPARAM.
* *
* See enum ethtool_fec_config_bits for definition of valid bits for both
* @fec and @active_fec.
*/ */
struct ethtool_fecparam { struct ethtool_fecparam {
__u32 cmd; __u32 cmd;
...@@ -1396,11 +1410,16 @@ struct ethtool_fecparam { ...@@ -1396,11 +1410,16 @@ struct ethtool_fecparam {
/** /**
* enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration * enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration
* @ETHTOOL_FEC_NONE: FEC mode configuration is not supported * @ETHTOOL_FEC_NONE: FEC mode configuration is not supported. Should not
* @ETHTOOL_FEC_AUTO: Default/Best FEC mode provided by driver * be used together with other bits. GET only.
* @ETHTOOL_FEC_AUTO: Select default/best FEC mode automatically, usually based
* link mode and SFP parameters read from module's EEPROM.
* This bit does _not_ mean autonegotiation.
* @ETHTOOL_FEC_OFF: No FEC Mode * @ETHTOOL_FEC_OFF: No FEC Mode
* @ETHTOOL_FEC_RS: Reed-Solomon Forward Error Detection mode * @ETHTOOL_FEC_RS: Reed-Solomon FEC Mode
* @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon Forward Error Detection mode * @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon FEC Mode
* @ETHTOOL_FEC_LLRS: Low Latency Reed Solomon FEC Mode (25G/50G Ethernet
* Consortium)
*/ */
enum ethtool_fec_config_bits { enum ethtool_fec_config_bits {
ETHTOOL_FEC_NONE_BIT, ETHTOOL_FEC_NONE_BIT,
......
...@@ -2568,6 +2568,9 @@ static int ethtool_get_fecparam(struct net_device *dev, void __user *useraddr) ...@@ -2568,6 +2568,9 @@ static int ethtool_get_fecparam(struct net_device *dev, void __user *useraddr)
if (rc) if (rc)
return rc; return rc;
if (WARN_ON_ONCE(fecparam.reserved))
fecparam.reserved = 0;
if (copy_to_user(useraddr, &fecparam, sizeof(fecparam))) if (copy_to_user(useraddr, &fecparam, sizeof(fecparam)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -2583,6 +2586,12 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr) ...@@ -2583,6 +2586,12 @@ static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr)
if (copy_from_user(&fecparam, useraddr, sizeof(fecparam))) if (copy_from_user(&fecparam, useraddr, sizeof(fecparam)))
return -EFAULT; return -EFAULT;
if (!fecparam.fec || fecparam.fec & ETHTOOL_FEC_NONE_BIT)
return -EINVAL;
fecparam.active_fec = 0;
fecparam.reserved = 0;
return dev->ethtool_ops->set_fecparam(dev, &fecparam); return dev->ethtool_ops->set_fecparam(dev, &fecparam);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment