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
Unified · Split
| @@ -1641,6 +1641,46 @@ static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter) · 1640 unmodified lines | |||
| 1641 | *stat = counter->value; | 1641 | *stat = counter->value; |
| 1642 | } | 1642 | } |
| 1643 | 1643 | ||
| 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 | |||
| 1644 | static void | 1684 | static void |
| 1645 | fbnic_get_eth_mac_stats(struct net_device *netdev, | 1685 | fbnic_get_eth_mac_stats(struct net_device *netdev, |
| 1646 | struct ethtool_eth_mac_stats *eth_mac_stats) | 1686 | struct ethtool_eth_mac_stats *eth_mac_stats) |
| @@ -1782,7 +1822,9 @@ static const struct ethtool_ops fbnic_ethtool_ops = { · 135 unmodified lines | |||
| 1782 | .get_ts_info = fbnic_get_ts_info, | 1822 | .get_ts_info = fbnic_get_ts_info, |
| 1783 | .get_ts_stats = fbnic_get_ts_stats, | 1823 | .get_ts_stats = fbnic_get_ts_stats, |
| 1784 | .get_link_ksettings = fbnic_phylink_ethtool_ksettings_get, | 1824 | .get_link_ksettings = fbnic_phylink_ethtool_ksettings_get, |
| 1825 | .get_fec_stats = fbnic_get_fec_stats, | ||
| 1785 | .get_fecparam = fbnic_phylink_get_fecparam, | 1826 | .get_fecparam = fbnic_phylink_get_fecparam, |
| 1827 | .get_eth_phy_stats = fbnic_get_eth_phy_stats, | ||
| 1786 | .get_eth_mac_stats = fbnic_get_eth_mac_stats, | 1828 | .get_eth_mac_stats = fbnic_get_eth_mac_stats, |
| 1787 | .get_eth_ctrl_stats = fbnic_get_eth_ctrl_stats, | 1829 | .get_eth_ctrl_stats = fbnic_get_eth_ctrl_stats, |
| 1788 | .get_rmon_stats = fbnic_get_rmon_stats, | 1830 | .get_rmon_stats = fbnic_get_rmon_stats, |