Skip to content

Commit b441c4a

Browse files
Hariprasad KelamPaolo Abeni
authored andcommitted
octeontx2-pf: ethtool: Implement get_fec_stats
This patch registers a callback for get_fec_stats such that FEC stats can be queried from the below command "ethtool -I --show-fec eth0" Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent b9d0fed commit b441c4a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,39 @@ static int otx2_set_link_ksettings(struct net_device *netdev,
12681268
return err;
12691269
}
12701270

1271+
static void otx2_get_fec_stats(struct net_device *netdev,
1272+
struct ethtool_fec_stats *fec_stats)
1273+
{
1274+
struct otx2_nic *pfvf = netdev_priv(netdev);
1275+
struct cgx_fw_data *rsp;
1276+
1277+
otx2_update_lmac_fec_stats(pfvf);
1278+
1279+
/* Report MAC FEC stats */
1280+
fec_stats->corrected_blocks.total = pfvf->hw.cgx_fec_corr_blks;
1281+
fec_stats->uncorrectable_blocks.total = pfvf->hw.cgx_fec_uncorr_blks;
1282+
1283+
rsp = otx2_get_fwdata(pfvf);
1284+
if (!IS_ERR(rsp) && rsp->fwdata.phy.misc.has_fec_stats &&
1285+
!otx2_get_phy_fec_stats(pfvf)) {
1286+
/* Fetch fwdata again because it's been recently populated with
1287+
* latest PHY FEC stats.
1288+
*/
1289+
rsp = otx2_get_fwdata(pfvf);
1290+
if (!IS_ERR(rsp)) {
1291+
struct fec_stats_s *p = &rsp->fwdata.phy.fec_stats;
1292+
1293+
if (pfvf->linfo.fec == OTX2_FEC_BASER) {
1294+
fec_stats->corrected_blocks.total = p->brfec_corr_blks;
1295+
fec_stats->uncorrectable_blocks.total = p->brfec_uncorr_blks;
1296+
} else {
1297+
fec_stats->corrected_blocks.total = p->rsfec_corr_cws;
1298+
fec_stats->uncorrectable_blocks.total = p->rsfec_uncorr_cws;
1299+
}
1300+
}
1301+
}
1302+
}
1303+
12711304
static const struct ethtool_ops otx2_ethtool_ops = {
12721305
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
12731306
ETHTOOL_COALESCE_MAX_FRAMES |
@@ -1298,6 +1331,7 @@ static const struct ethtool_ops otx2_ethtool_ops = {
12981331
.get_pauseparam = otx2_get_pauseparam,
12991332
.set_pauseparam = otx2_set_pauseparam,
13001333
.get_ts_info = otx2_get_ts_info,
1334+
.get_fec_stats = otx2_get_fec_stats,
13011335
.get_fecparam = otx2_get_fecparam,
13021336
.set_fecparam = otx2_set_fecparam,
13031337
.get_link_ksettings = otx2_get_link_ksettings,

0 commit comments

Comments
 (0)