Skip to content

Commit 1a5f3da

Browse files
vidyaravipatidavem330
authored andcommitted
net: ethtool: add support for forward error correction modes
Forward Error Correction (FEC) modes i.e Base-R and Reed-Solomon modes are introduced in 25G/40G/100G standards for providing good BER at high speeds. Various networking devices which support 25G/40G/100G provides ability to manage supported FEC modes and the lack of FEC encoding control and reporting today is a source for interoperability issues for many vendors. FEC capability as well as specific FEC mode i.e. Base-R or RS modes can be requested or advertised through bits D44:47 of base link codeword. This patch set intends to provide option under ethtool to manage and report FEC encoding settings for networking devices as per IEEE 802.3 bj, bm and by specs. set-fec/show-fec option(s) are designed to provide control and report the FEC encoding on the link. SET FEC option: root@tor: ethtool --set-fec swp1 encoding [off | RS | BaseR | auto] Encoding: Types of encoding Off : Turning off any encoding RS : enforcing RS-FEC encoding on supported speeds BaseR : enforcing Base R encoding on supported speeds Auto : IEEE defaults for the speed/medium combination Here are a few examples of what we would expect if encoding=auto: - if autoneg is on, we are expecting FEC to be negotiated as on or off as long as protocol supports it - if the hardware is capable of detecting the FEC encoding on it's receiver it will reconfigure its encoder to match - in absence of the above, the configuration would be set to IEEE defaults. >From our understanding , this is essentially what most hardware/driver combinations are doing today in the absence of a way for users to control the behavior. SHOW FEC option: root@tor: ethtool --show-fec swp1 FEC parameters for swp1: Active FEC encodings: RS Configured FEC encodings: RS | BaseR ETHTOOL DEVNAME output modification: ethtool devname output: root@tor:~# ethtool swp1 Settings for swp1: root@hpe-7712-03:~# ethtool swp18 Settings for swp18: Supported ports: [ FIBRE ] Supported link modes: 40000baseCR4/Full 40000baseSR4/Full 40000baseLR4/Full 100000baseSR4/Full 100000baseCR4/Full 100000baseLR4_ER4/Full Supported pause frame use: No Supports auto-negotiation: Yes Supported FEC modes: [RS | BaseR | None | Not reported] Advertised link modes: Not reported Advertised pause frame use: No Advertised auto-negotiation: No Advertised FEC modes: [RS | BaseR | None | Not reported] <<<< One or more FEC modes Speed: 100000Mb/s Duplex: Full Port: FIBRE PHYAD: 106 Transceiver: internal Auto-negotiation: off Link detected: yes This patch includes following changes a) New ETHTOOL_SFECPARAM/SFECPARAM API, handled by the new get_fecparam/set_fecparam callbacks, provides support for configuration of forward error correction modes. b) Link mode bits for FEC modes i.e. None (No FEC mode), RS, BaseR/FC are defined so that users can configure these fec modes for supported and advertising fields as part of link autonegotiation. Signed-off-by: Vidya Sagar Ravipati <[email protected]> Signed-off-by: Dustin Byford <[email protected]> Signed-off-by: Roopa Prabhu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fe21b26 commit 1a5f3da

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

include/linux/ethtool.h

+4
Original file line numberDiff line numberDiff line change
@@ -374,5 +374,9 @@ struct ethtool_ops {
374374
struct ethtool_link_ksettings *);
375375
int (*set_link_ksettings)(struct net_device *,
376376
const struct ethtool_link_ksettings *);
377+
int (*get_fecparam)(struct net_device *,
378+
struct ethtool_fecparam *);
379+
int (*set_fecparam)(struct net_device *,
380+
struct ethtool_fecparam *);
377381
};
378382
#endif /* _LINUX_ETHTOOL_H */

include/uapi/linux/ethtool.h

+47-1
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,47 @@ struct ethtool_per_queue_op {
12381238
char data[];
12391239
};
12401240

1241+
/**
1242+
* struct ethtool_fecparam - Ethernet forward error correction(fec) parameters
1243+
* @cmd: Command number = %ETHTOOL_GFECPARAM or %ETHTOOL_SFECPARAM
1244+
* @active_fec: FEC mode which is active on porte
1245+
* @fec: Bitmask of supported/configured FEC modes
1246+
* @rsvd: Reserved for future extensions. i.e FEC bypass feature.
1247+
*
1248+
* Drivers should reject a non-zero setting of @autoneg when
1249+
* autoneogotiation is disabled (or not supported) for the link.
1250+
*
1251+
*/
1252+
struct ethtool_fecparam {
1253+
__u32 cmd;
1254+
/* bitmask of FEC modes */
1255+
__u32 active_fec;
1256+
__u32 fec;
1257+
__u32 reserved;
1258+
};
1259+
1260+
/**
1261+
* enum ethtool_fec_config_bits - flags definition of ethtool_fec_configuration
1262+
* @ETHTOOL_FEC_NONE: FEC mode configuration is not supported
1263+
* @ETHTOOL_FEC_AUTO: Default/Best FEC mode provided by driver
1264+
* @ETHTOOL_FEC_OFF: No FEC Mode
1265+
* @ETHTOOL_FEC_RS: Reed-Solomon Forward Error Detection mode
1266+
* @ETHTOOL_FEC_BASER: Base-R/Reed-Solomon Forward Error Detection mode
1267+
*/
1268+
enum ethtool_fec_config_bits {
1269+
ETHTOOL_FEC_NONE_BIT,
1270+
ETHTOOL_FEC_AUTO_BIT,
1271+
ETHTOOL_FEC_OFF_BIT,
1272+
ETHTOOL_FEC_RS_BIT,
1273+
ETHTOOL_FEC_BASER_BIT,
1274+
};
1275+
1276+
#define ETHTOOL_FEC_NONE (1 << ETHTOOL_FEC_NONE_BIT)
1277+
#define ETHTOOL_FEC_AUTO (1 << ETHTOOL_FEC_AUTO_BIT)
1278+
#define ETHTOOL_FEC_OFF (1 << ETHTOOL_FEC_OFF_BIT)
1279+
#define ETHTOOL_FEC_RS (1 << ETHTOOL_FEC_RS_BIT)
1280+
#define ETHTOOL_FEC_BASER (1 << ETHTOOL_FEC_BASER_BIT)
1281+
12411282
/* CMDs currently supported */
12421283
#define ETHTOOL_GSET 0x00000001 /* DEPRECATED, Get settings.
12431284
* Please use ETHTOOL_GLINKSETTINGS
@@ -1330,6 +1371,8 @@ struct ethtool_per_queue_op {
13301371
#define ETHTOOL_SLINKSETTINGS 0x0000004d /* Set ethtool_link_settings */
13311372
#define ETHTOOL_PHY_GTUNABLE 0x0000004e /* Get PHY tunable configuration */
13321373
#define ETHTOOL_PHY_STUNABLE 0x0000004f /* Set PHY tunable configuration */
1374+
#define ETHTOOL_GFECPARAM 0x00000050 /* Get FEC settings */
1375+
#define ETHTOOL_SFECPARAM 0x00000051 /* Set FEC settings */
13331376

13341377
/* compatibility with older code */
13351378
#define SPARC_ETH_GSET ETHTOOL_GSET
@@ -1387,6 +1430,9 @@ enum ethtool_link_mode_bit_indices {
13871430
ETHTOOL_LINK_MODE_2500baseT_Full_BIT = 47,
13881431
ETHTOOL_LINK_MODE_5000baseT_Full_BIT = 48,
13891432

1433+
ETHTOOL_LINK_MODE_FEC_NONE_BIT = 49,
1434+
ETHTOOL_LINK_MODE_FEC_RS_BIT = 50,
1435+
ETHTOOL_LINK_MODE_FEC_BASER_BIT = 51,
13901436

13911437
/* Last allowed bit for __ETHTOOL_LINK_MODE_LEGACY_MASK is bit
13921438
* 31. Please do NOT define any SUPPORTED_* or ADVERTISED_*
@@ -1395,7 +1441,7 @@ enum ethtool_link_mode_bit_indices {
13951441
*/
13961442

13971443
__ETHTOOL_LINK_MODE_LAST
1398-
= ETHTOOL_LINK_MODE_5000baseT_Full_BIT,
1444+
= ETHTOOL_LINK_MODE_FEC_BASER_BIT,
13991445
};
14001446

14011447
#define __ETHTOOL_LINK_MODE_LEGACY_MASK(base_name) \

net/core/ethtool.c

+34
Original file line numberDiff line numberDiff line change
@@ -2512,6 +2512,33 @@ static int set_phy_tunable(struct net_device *dev, void __user *useraddr)
25122512
return ret;
25132513
}
25142514

2515+
static int ethtool_get_fecparam(struct net_device *dev, void __user *useraddr)
2516+
{
2517+
struct ethtool_fecparam fecparam = { ETHTOOL_GFECPARAM };
2518+
2519+
if (!dev->ethtool_ops->get_fecparam)
2520+
return -EOPNOTSUPP;
2521+
2522+
dev->ethtool_ops->get_fecparam(dev, &fecparam);
2523+
2524+
if (copy_to_user(useraddr, &fecparam, sizeof(fecparam)))
2525+
return -EFAULT;
2526+
return 0;
2527+
}
2528+
2529+
static int ethtool_set_fecparam(struct net_device *dev, void __user *useraddr)
2530+
{
2531+
struct ethtool_fecparam fecparam;
2532+
2533+
if (!dev->ethtool_ops->set_fecparam)
2534+
return -EOPNOTSUPP;
2535+
2536+
if (copy_from_user(&fecparam, useraddr, sizeof(fecparam)))
2537+
return -EFAULT;
2538+
2539+
return dev->ethtool_ops->set_fecparam(dev, &fecparam);
2540+
}
2541+
25152542
/* The main entry point in this file. Called from net/core/dev_ioctl.c */
25162543

25172544
int dev_ethtool(struct net *net, struct ifreq *ifr)
@@ -2570,6 +2597,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
25702597
case ETHTOOL_GTUNABLE:
25712598
case ETHTOOL_PHY_GTUNABLE:
25722599
case ETHTOOL_GLINKSETTINGS:
2600+
case ETHTOOL_GFECPARAM:
25732601
break;
25742602
default:
25752603
if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
@@ -2779,6 +2807,12 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
27792807
case ETHTOOL_PHY_STUNABLE:
27802808
rc = set_phy_tunable(dev, useraddr);
27812809
break;
2810+
case ETHTOOL_GFECPARAM:
2811+
rc = ethtool_get_fecparam(dev, useraddr);
2812+
break;
2813+
case ETHTOOL_SFECPARAM:
2814+
rc = ethtool_set_fecparam(dev, useraddr);
2815+
break;
27822816
default:
27832817
rc = -EOPNOTSUPP;
27842818
}

0 commit comments

Comments
 (0)