]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bnxt_en: Add support for FEC bin histograms
authorMichael Chan <michael.chan@broadcom.com>
Thu, 8 Jan 2026 18:35:18 +0000 (10:35 -0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 10 Jan 2026 23:19:50 +0000 (15:19 -0800)
Fill in the struct ethtool_fec_hist passed to the bnxt_get_fec_stats()
callback if the FW supports the feature.  Bins 0 to 15 inclusive are
available when the feature is supported.

Reviewed-by: Hongguang Gao <hongguang.gao@broadcom.com>
Reviewed-by: Damodharam Ammepalli <damodharam.ammepalli@broadcom.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20260108183521.215610-4-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

index 67e59e61b83c2ea737a49120c742bc95e0027fba..b8f1c78b92e8da9b4aa45631f98ee3c20718983f 100644 (file)
@@ -2702,6 +2702,7 @@ struct bnxt {
 #define BNXT_PHY_FL_NO_PFC             (PORT_PHY_QCAPS_RESP_FLAGS2_PFC_UNSUPPORTED << 8)
 #define BNXT_PHY_FL_BANK_SEL           (PORT_PHY_QCAPS_RESP_FLAGS2_BANK_ADDR_SUPPORTED << 8)
 #define BNXT_PHY_FL_SPEEDS2            (PORT_PHY_QCAPS_RESP_FLAGS2_SPEEDS2_SUPPORTED << 8)
+#define BNXT_PHY_FL_FDRSTATS           (PORT_PHY_QCAPS_RESP_FLAGS2_FDRSTAT_CMD_SUPPORTED << 8)
 
        /* copied from flags in hwrm_port_mac_qcaps_output */
        u8                      mac_flags;
index 068e191ede19e63c3e172ff24f19ace6cde3f94d..af4ceb6d2158ce154bd42a4be9395074c71688ac 100644 (file)
@@ -3216,6 +3216,56 @@ static int bnxt_get_fecparam(struct net_device *dev,
        return 0;
 }
 
+static const struct ethtool_fec_hist_range bnxt_fec_ranges[] = {
+       { 0, 0},
+       { 1, 1},
+       { 2, 2},
+       { 3, 3},
+       { 4, 4},
+       { 5, 5},
+       { 6, 6},
+       { 7, 7},
+       { 8, 8},
+       { 9, 9},
+       { 10, 10},
+       { 11, 11},
+       { 12, 12},
+       { 13, 13},
+       { 14, 14},
+       { 15, 15},
+       { 0, 0},
+};
+
+static void bnxt_hwrm_port_phy_fdrstat(struct bnxt *bp,
+                                      struct ethtool_fec_hist *hist)
+{
+       struct ethtool_fec_hist_value *values = hist->values;
+       struct hwrm_port_phy_fdrstat_output *resp;
+       struct hwrm_port_phy_fdrstat_input *req;
+       int rc, i;
+
+       if (!(bp->phy_flags & BNXT_PHY_FL_FDRSTATS))
+               return;
+
+       rc = hwrm_req_init(bp, req, HWRM_PORT_PHY_FDRSTAT);
+       if (rc)
+               return;
+
+       req->port_id = cpu_to_le16(bp->pf.port_id);
+       req->ops = cpu_to_le16(PORT_PHY_FDRSTAT_REQ_OPS_COUNTER);
+       resp = hwrm_req_hold(bp, req);
+       rc = hwrm_req_send(bp, req);
+       if (!rc) {
+               hist->ranges = bnxt_fec_ranges;
+               for (i = 0; i <= 15; i++) {
+                       __le64 sum = resp->accumulated_codewords_err_s[i];
+
+                       values[i].sum = le64_to_cpu(sum);
+               }
+       }
+       hwrm_req_drop(bp, req);
+}
+
 static void bnxt_get_fec_stats(struct net_device *dev,
                               struct ethtool_fec_stats *fec_stats,
                               struct ethtool_fec_hist *hist)
@@ -3237,6 +3287,7 @@ static void bnxt_get_fec_stats(struct net_device *dev,
                *(rx + BNXT_RX_STATS_EXT_OFFSET(rx_fec_corrected_blocks));
        fec_stats->uncorrectable_blocks.total =
                *(rx + BNXT_RX_STATS_EXT_OFFSET(rx_fec_uncorrectable_blocks));
+       bnxt_hwrm_port_phy_fdrstat(bp, hist);
 }
 
 static u32 bnxt_ethtool_forced_fec_to_fw(struct bnxt_link_info *link_info,