Skip to content

Commit 6e90c3d

Browse files
ahduyckNipaLocal
authored andcommitted
fbnic: Add support for reporting link config
This change adds some basic support for reporting the current link config to the user via ethtool. Currently the main components reported are the carrier status, link speed, and FEC. For now we are handling the FEC directly as phylink doesn't have support for it. The plan is to work on incorporating FEC support into phylink and eventually adding the ability for us to set the FEC configuration through phylink itself. In addition as we don't yet have SFP or PHY support the listed modes supported are including ones not supported by the media we are attached to. That will hopefully be addressed once we can get the QSFP modules supported. Signed-off-by: Alexander Duyck <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 9eaa403 commit 6e90c3d

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,7 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
16831683
.get_drvinfo = fbnic_get_drvinfo,
16841684
.get_regs_len = fbnic_get_regs_len,
16851685
.get_regs = fbnic_get_regs,
1686+
.get_link = ethtool_op_get_link,
16861687
.get_coalesce = fbnic_get_coalesce,
16871688
.set_coalesce = fbnic_set_coalesce,
16881689
.get_ringparam = fbnic_get_ringparam,
@@ -1705,6 +1706,8 @@ static const struct ethtool_ops fbnic_ethtool_ops = {
17051706
.set_channels = fbnic_set_channels,
17061707
.get_ts_info = fbnic_get_ts_info,
17071708
.get_ts_stats = fbnic_get_ts_stats,
1709+
.get_link_ksettings = fbnic_phylink_ethtool_ksettings_get,
1710+
.get_fecparam = fbnic_phylink_get_fecparam,
17081711
.get_eth_mac_stats = fbnic_get_eth_mac_stats,
17091712
.get_eth_ctrl_stats = fbnic_get_eth_ctrl_stats,
17101713
.get_rmon_stats = fbnic_get_rmon_stats,

drivers/net/ethernet/meta/fbnic/fbnic_netdev.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,9 @@ void fbnic_time_stop(struct fbnic_net *fbn);
9292
void __fbnic_set_rx_mode(struct net_device *netdev);
9393
void fbnic_clear_rx_mode(struct net_device *netdev);
9494

95+
int fbnic_phylink_ethtool_ksettings_get(struct net_device *netdev,
96+
struct ethtool_link_ksettings *cmd);
97+
int fbnic_phylink_get_fecparam(struct net_device *netdev,
98+
struct ethtool_fecparam *fecparam);
9599
int fbnic_phylink_init(struct net_device *netdev);
96100
#endif /* _FBNIC_NETDEV_H_ */

drivers/net/ethernet/meta/fbnic/fbnic_phylink.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,67 @@ static phy_interface_t fbnic_phylink_select_interface(u8 aui)
2424
return PHY_INTERFACE_MODE_NA;
2525
}
2626

27+
static void
28+
fbnic_phylink_get_supported_fec_modes(unsigned long *supported)
29+
{
30+
/* The NIC can support up to 8 possible combinations.
31+
* Either 50G-CR, or 100G-CR2
32+
* This is with RS FEC mode only
33+
* Either 25G-CR, or 50G-CR2
34+
* This is with No FEC, RS, or Base-R
35+
*/
36+
if (phylink_test(supported, 100000baseCR2_Full) ||
37+
phylink_test(supported, 50000baseCR_Full))
38+
phylink_set(supported, FEC_RS);
39+
if (phylink_test(supported, 50000baseCR2_Full) ||
40+
phylink_test(supported, 25000baseCR_Full)) {
41+
phylink_set(supported, FEC_BASER);
42+
phylink_set(supported, FEC_NONE);
43+
phylink_set(supported, FEC_RS);
44+
}
45+
}
46+
47+
int fbnic_phylink_ethtool_ksettings_get(struct net_device *netdev,
48+
struct ethtool_link_ksettings *cmd)
49+
{
50+
struct fbnic_net *fbn = netdev_priv(netdev);
51+
int err;
52+
53+
err = phylink_ethtool_ksettings_get(fbn->phylink, cmd);
54+
if (!err) {
55+
unsigned long *supp = cmd->link_modes.supported;
56+
57+
cmd->base.port = PORT_DA;
58+
cmd->lanes = (fbn->aui & FBNIC_AUI_MODE_R2) ? 2 : 1;
59+
60+
fbnic_phylink_get_supported_fec_modes(supp);
61+
}
62+
63+
return err;
64+
}
65+
66+
int fbnic_phylink_get_fecparam(struct net_device *netdev,
67+
struct ethtool_fecparam *fecparam)
68+
{
69+
struct fbnic_net *fbn = netdev_priv(netdev);
70+
71+
if (fbn->fec & FBNIC_FEC_RS) {
72+
fecparam->active_fec = ETHTOOL_FEC_RS;
73+
fecparam->fec = ETHTOOL_FEC_RS;
74+
} else if (fbn->fec & FBNIC_FEC_BASER) {
75+
fecparam->active_fec = ETHTOOL_FEC_BASER;
76+
fecparam->fec = ETHTOOL_FEC_BASER;
77+
} else {
78+
fecparam->active_fec = ETHTOOL_FEC_OFF;
79+
fecparam->fec = ETHTOOL_FEC_OFF;
80+
}
81+
82+
if (fbn->aui & FBNIC_AUI_MODE_PAM4)
83+
fecparam->fec |= ETHTOOL_FEC_AUTO;
84+
85+
return 0;
86+
}
87+
2788
static struct fbnic_net *
2889
fbnic_pcs_to_net(struct phylink_pcs *pcs)
2990
{

0 commit comments

Comments
 (0)