History

eth: fbnic: Read PHY stats via the ethtool API

Provide support to read PHY stats (FEC and PCS) via the ethtool API. ]# ethtool -I --show-fec eth0 FEC parameters for eth0: Supported/Configured FEC encodings: RS Active FEC encoding: RS Statistics: corrected_blocks: 0 uncorrectable_blocks: 0 ]# ethtool -S eth0 --groups eth-phy Standard stats for eth0: eth-phy-SymbolErrorDuringCarrier: 0

Mohsin Bashir committed 1 year ago

Commit 33c49371 parent df4c5d91 file · +42 −0Browse files

Unified · Split

drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c+42−0
@@ -1641,6 +1641,46 @@ static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter) · 1640 unmodified lines
16411641 *stat = counter->value;
16421642 }
16431643
1644+static void
1645+fbnic_get_fec_stats(struct net_device *netdev,
1646+ struct ethtool_fec_stats *fec_stats)
1647+{
1648+ struct fbnic_net *fbn = netdev_priv(netdev);
1649+ struct fbnic_phy_stats *phy_stats;
1650+ struct fbnic_dev *fbd = fbn->fbd;
1651+
1652+ fbnic_get_hw_stats32(fbd);
1653+ phy_stats = &fbd->hw_stats.phy;
1654+
1655+ spin_lock(&fbd->hw_stats.lock);
1656+ fec_stats->corrected_blocks.total =
1657+ phy_stats->fec.corrected_blocks.value;
1658+ fec_stats->uncorrectable_blocks.total =
1659+ phy_stats->fec.uncorrectable_blocks.value;
1660+ spin_unlock(&fbd->hw_stats.lock);
1661+}
1662+
1663+static void
1664+fbnic_get_eth_phy_stats(struct net_device *netdev,
1665+ struct ethtool_eth_phy_stats *eth_phy_stats)
1666+{
1667+ struct fbnic_net *fbn = netdev_priv(netdev);
1668+ struct fbnic_phy_stats *phy_stats;
1669+ struct fbnic_dev *fbd = fbn->fbd;
1670+ u64 total = 0;
1671+ int i;
1672+
1673+ fbnic_get_hw_stats32(fbd);
1674+ phy_stats = &fbd->hw_stats.phy;
1675+
1676+ spin_lock(&fbd->hw_stats.lock);
1677+ for (i = 0; i < FBNIC_PCS_MAX_LANES; i++)
1678+ total += phy_stats->pcs.SymbolErrorDuringCarrier.lanes[i].value;
1679+
1680+ eth_phy_stats->SymbolErrorDuringCarrier = total;
1681+ spin_unlock(&fbd->hw_stats.lock);
1682+}
1683+
16441684 static void
16451685 fbnic_get_eth_mac_stats(struct net_device *netdev,
16461686 struct ethtool_eth_mac_stats *eth_mac_stats)
@@ -1782,7 +1822,9 @@ static const struct ethtool_ops fbnic_ethtool_ops = { · 135 unmodified lines
17821822 .get_ts_info = fbnic_get_ts_info,
17831823 .get_ts_stats = fbnic_get_ts_stats,
17841824 .get_link_ksettings = fbnic_phylink_ethtool_ksettings_get,
1825+ .get_fec_stats = fbnic_get_fec_stats,
17851826 .get_fecparam = fbnic_phylink_get_fecparam,
1827+ .get_eth_phy_stats = fbnic_get_eth_phy_stats,
17861828 .get_eth_mac_stats = fbnic_get_eth_mac_stats,
17871829 .get_eth_ctrl_stats = fbnic_get_eth_ctrl_stats,
17881830 .get_rmon_stats = fbnic_get_rmon_stats,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t