Commit 84011712 authored by Paolo Abeni's avatar Paolo Abeni
Browse files

Merge branch 'mlx5e-support-recovery-counter-in-reset'

Tariq Toukan says:

====================
mlx5e: Support recovery counter in reset

This series by Yael adds a recovery counter in ethtool, for any recovery
type during port reset cycle.
Series starts with some cleanup and refactoring patches.
New counter is added and exposed to ethtool stats in patch #4.
====================

Link: https://patch.msgid.link/1742112876-2890-1-git-send-email-tariqt@nvidia.com


Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents e2f4ac7b c3b999ca
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1082,6 +1082,11 @@ like flow control, FEC and more.
       need to replace the cable/transceiver.
     - Error

   * - `total_success_recovery_phy`
     - The number of total successful recovery events of any type during
       ports reset cycle.
     - Error

   * - `rx_out_of_buffer`
     - Number of times receive queue had no software buffers allocated for the
       adapter's incoming traffic.
+82 −37
Original line number Diff line number Diff line
@@ -1227,6 +1227,13 @@ void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
	mutex_unlock(&priv->state_lock);
}

#define PPORT_PHY_LAYER_OFF(c) \
	MLX5_BYTE_OFF(ppcnt_reg, \
		      counter_set.phys_layer_cntrs.c)
static const struct counter_desc pport_phy_layer_cntrs_stats_desc[] = {
	{ "link_down_events_phy", PPORT_PHY_LAYER_OFF(link_down_events) }
};

#define PPORT_PHY_STATISTICAL_OFF(c) \
	MLX5_BYTE_OFF(ppcnt_reg, \
		      counter_set.phys_layer_statistical_cntrs.c##_high)
@@ -1243,25 +1250,45 @@ pport_phy_statistical_err_lanes_stats_desc[] = {
	{ "rx_err_lane_3_phy", PPORT_PHY_STATISTICAL_OFF(phy_corrected_bits_lane3) },
};

#define PPORT_PHY_RECOVERY_OFF(c) \
	MLX5_BYTE_OFF(ppcnt_reg, counter_set.phys_layer_recovery_cntrs.c)
static const struct counter_desc
pport_phy_recovery_cntrs_stats_desc[] = {
	{ "total_success_recovery_phy",
	  PPORT_PHY_RECOVERY_OFF(total_successful_recovery_events) }
};

#define NUM_PPORT_PHY_LAYER_COUNTERS \
	ARRAY_SIZE(pport_phy_layer_cntrs_stats_desc)
#define NUM_PPORT_PHY_STATISTICAL_COUNTERS \
	ARRAY_SIZE(pport_phy_statistical_stats_desc)
#define NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS \
	ARRAY_SIZE(pport_phy_statistical_err_lanes_stats_desc)
#define NUM_PPORT_PHY_RECOVERY_COUNTERS \
	ARRAY_SIZE(pport_phy_recovery_cntrs_stats_desc)

#define NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(dev) \
	(MLX5_CAP_PCAM_FEATURE(dev, ppcnt_statistical_group) ? \
	NUM_PPORT_PHY_STATISTICAL_COUNTERS : 0)
#define NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(dev) \
	(MLX5_CAP_PCAM_FEATURE(dev, per_lane_error_counters) ? \
	NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS : 0)
#define NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS(dev) \
	(MLX5_CAP_PCAM_FEATURE(dev, ppcnt_recovery_counters) ? \
	NUM_PPORT_PHY_RECOVERY_COUNTERS : 0)

static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(phy)
{
	struct mlx5_core_dev *mdev = priv->mdev;
	int num_stats;

	/* "1" for link_down_events special counter */
	num_stats = 1;
	num_stats = NUM_PPORT_PHY_LAYER_COUNTERS;

	num_stats += MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group) ?
		     NUM_PPORT_PHY_STATISTICAL_COUNTERS : 0;
	num_stats += NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(mdev);

	num_stats += MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters) ?
		     NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS : 0;
	num_stats += NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);

	num_stats += NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS(mdev);
	return num_stats;
}

@@ -1270,18 +1297,22 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(phy)
	struct mlx5_core_dev *mdev = priv->mdev;
	int i;

	ethtool_puts(data, "link_down_events_phy");

	if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
		return;
	for (i = 0; i < NUM_PPORT_PHY_LAYER_COUNTERS; i++)
		ethtool_puts(data, pport_phy_layer_cntrs_stats_desc[i].format);

	for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_COUNTERS; i++)
	for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(mdev); i++)
		ethtool_puts(data, pport_phy_statistical_stats_desc[i].format);

	if (MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters))
		for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS; i++)
	for (i = 0;
	     i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);
	     i++)
		ethtool_puts(data,
			     pport_phy_statistical_err_lanes_stats_desc[i]
			     .format);

	for (i = 0; i < NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS(mdev); i++)
		ethtool_puts(data,
				     pport_phy_statistical_err_lanes_stats_desc[i].format);
			     pport_phy_recovery_cntrs_stats_desc[i].format);
}

static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(phy)
@@ -1289,30 +1320,35 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(phy)
	struct mlx5_core_dev *mdev = priv->mdev;
	int i;

	/* link_down_events_phy has special handling since it is not stored in __be64 format */
	for (i = 0; i < NUM_PPORT_PHY_LAYER_COUNTERS; i++)
		mlx5e_ethtool_put_stat(
		data, MLX5_GET(ppcnt_reg, priv->stats.pport.phy_counters,
			       counter_set.phys_layer_cntrs.link_down_events));

	if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
		return;
				data,
				MLX5E_READ_CTR32_BE(&priv->stats.pport
					.phy_counters,
					pport_phy_layer_cntrs_stats_desc, i));

	for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_COUNTERS; i++)
	for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(mdev); i++)
		mlx5e_ethtool_put_stat(
			data,
			MLX5E_READ_CTR64_BE(
				&priv->stats.pport.phy_statistical_counters,
				pport_phy_statistical_stats_desc, i));

	if (MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters))
		for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS; i++)
	for (i = 0;
	     i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);
	     i++)
		mlx5e_ethtool_put_stat(
			data,
			MLX5E_READ_CTR64_BE(
					&priv->stats.pport
						 .phy_statistical_counters,
					pport_phy_statistical_err_lanes_stats_desc,
					i));
				&priv->stats.pport.phy_statistical_counters,
				pport_phy_statistical_err_lanes_stats_desc, i));

	for (i = 0; i < NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS(mdev); i++)
		mlx5e_ethtool_put_stat(
			data,
			MLX5E_READ_CTR32_BE(
				&priv->stats.pport.phy_recovery_counters,
				pport_phy_recovery_cntrs_stats_desc, i));
}

static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(phy)
@@ -1328,12 +1364,21 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(phy)
	MLX5_SET(ppcnt_reg, in, grp, MLX5_PHYSICAL_LAYER_COUNTERS_GROUP);
	mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0);

	if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
		return;

	if (MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group)) {
		out = pstats->phy_statistical_counters;
	MLX5_SET(ppcnt_reg, in, grp, MLX5_PHYSICAL_LAYER_STATISTICAL_GROUP);
	mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0);
		MLX5_SET(ppcnt_reg, in, grp,
			 MLX5_PHYSICAL_LAYER_STATISTICAL_GROUP);
		mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0,
				     0);
	}

	if (MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_recovery_counters)) {
		out = pstats->phy_recovery_counters;
		MLX5_SET(ppcnt_reg, in, grp,
			 MLX5_PHYSICAL_LAYER_RECOVERY_GROUP);
		mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0,
				     0);
	}
}

void mlx5e_get_link_ext_stats(struct net_device *dev,
+4 −0
Original line number Diff line number Diff line
@@ -309,6 +309,9 @@ struct mlx5e_vport_stats {
#define PPORT_PHY_STATISTICAL_GET(pstats, c) \
	MLX5_GET64(ppcnt_reg, (pstats)->phy_statistical_counters, \
		   counter_set.phys_layer_statistical_cntrs.c##_high)
#define PPORT_PHY_RECOVERY_GET(pstats, c) \
	MLX5_GET64(ppcnt_reg, (pstats)->phy_recovery_counters, \
		   counter_set.phys_layer_recovery_cntrs.c)
#define PPORT_PER_PRIO_GET(pstats, prio, c) \
	MLX5_GET64(ppcnt_reg, pstats->per_prio_counters[prio], \
		   counter_set.eth_per_prio_grp_data_layout.c##_high)
@@ -324,6 +327,7 @@ struct mlx5e_pport_stats {
	__be64 per_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];
	__be64 phy_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
	__be64 phy_statistical_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
	__be64 phy_recovery_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
	__be64 eth_ext_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
	__be64 per_tc_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];
	__be64 per_tc_congest_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];