Commit e1c9c892 authored by Michael Chan's avatar Michael Chan Committed by Jakub Kicinski
Browse files

bnxt_en: Add support for FEC bin histograms



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: default avatarHongguang Gao <hongguang.gao@broadcom.com>
Reviewed-by: default avatarDamodharam Ammepalli <damodharam.ammepalli@broadcom.com>
Reviewed-by: default avatarVadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Link: https://patch.msgid.link/20260108183521.215610-4-michael.chan@broadcom.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent c470195b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
+51 −0
Original line number Diff line number Diff line
@@ -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,