Skip to content

Commit c3b999c

Browse files
Yael ChemlaPaolo Abeni
Yael Chemla
authored and
Paolo Abeni
committed
net/mlx5e: Expose port reset cycle recovery counter via ethtool
Display recovery event of PPCNT recovery counters group. Counts (per link) the number of total successful recovery events of any recovery types during port reset cycle. Signed-off-by: Yael Chemla <[email protected]> Reviewed-by: Cosmin Ratiu <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 4c737ce commit c3b999c

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

Documentation/networking/device_drivers/ethernet/mellanox/mlx5/counters.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,11 @@ like flow control, FEC and more.
10821082
need to replace the cable/transceiver.
10831083
- Error
10841084

1085+
* - `total_success_recovery_phy`
1086+
- The number of total successful recovery events of any type during
1087+
ports reset cycle.
1088+
- Error
1089+
10851090
* - `rx_out_of_buffer`
10861091
- Number of times receive queue had no software buffers allocated for the
10871092
adapter's incoming traffic.

drivers/net/ethernet/mellanox/mlx5/core/en_stats.c

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,19 +1250,32 @@ pport_phy_statistical_err_lanes_stats_desc[] = {
12501250
{ "rx_err_lane_3_phy", PPORT_PHY_STATISTICAL_OFF(phy_corrected_bits_lane3) },
12511251
};
12521252

1253+
#define PPORT_PHY_RECOVERY_OFF(c) \
1254+
MLX5_BYTE_OFF(ppcnt_reg, counter_set.phys_layer_recovery_cntrs.c)
1255+
static const struct counter_desc
1256+
pport_phy_recovery_cntrs_stats_desc[] = {
1257+
{ "total_success_recovery_phy",
1258+
PPORT_PHY_RECOVERY_OFF(total_successful_recovery_events) }
1259+
};
1260+
12531261
#define NUM_PPORT_PHY_LAYER_COUNTERS \
12541262
ARRAY_SIZE(pport_phy_layer_cntrs_stats_desc)
12551263
#define NUM_PPORT_PHY_STATISTICAL_COUNTERS \
12561264
ARRAY_SIZE(pport_phy_statistical_stats_desc)
12571265
#define NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS \
12581266
ARRAY_SIZE(pport_phy_statistical_err_lanes_stats_desc)
1267+
#define NUM_PPORT_PHY_RECOVERY_COUNTERS \
1268+
ARRAY_SIZE(pport_phy_recovery_cntrs_stats_desc)
12591269

12601270
#define NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(dev) \
12611271
(MLX5_CAP_PCAM_FEATURE(dev, ppcnt_statistical_group) ? \
12621272
NUM_PPORT_PHY_STATISTICAL_COUNTERS : 0)
12631273
#define NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(dev) \
12641274
(MLX5_CAP_PCAM_FEATURE(dev, per_lane_error_counters) ? \
12651275
NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS : 0)
1276+
#define NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS(dev) \
1277+
(MLX5_CAP_PCAM_FEATURE(dev, ppcnt_recovery_counters) ? \
1278+
NUM_PPORT_PHY_RECOVERY_COUNTERS : 0)
12661279

12671280
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(phy)
12681281
{
@@ -1275,6 +1288,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(phy)
12751288

12761289
num_stats += NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);
12771290

1291+
num_stats += NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS(mdev);
12781292
return num_stats;
12791293
}
12801294

@@ -1295,6 +1309,10 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(phy)
12951309
ethtool_puts(data,
12961310
pport_phy_statistical_err_lanes_stats_desc[i]
12971311
.format);
1312+
1313+
for (i = 0; i < NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS(mdev); i++)
1314+
ethtool_puts(data,
1315+
pport_phy_recovery_cntrs_stats_desc[i].format);
12981316
}
12991317

13001318
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(phy)
@@ -1324,6 +1342,13 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(phy)
13241342
MLX5E_READ_CTR64_BE(
13251343
&priv->stats.pport.phy_statistical_counters,
13261344
pport_phy_statistical_err_lanes_stats_desc, i));
1345+
1346+
for (i = 0; i < NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS(mdev); i++)
1347+
mlx5e_ethtool_put_stat(
1348+
data,
1349+
MLX5E_READ_CTR32_BE(
1350+
&priv->stats.pport.phy_recovery_counters,
1351+
pport_phy_recovery_cntrs_stats_desc, i));
13271352
}
13281353

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

1342-
if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
1343-
return;
1367+
if (MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group)) {
1368+
out = pstats->phy_statistical_counters;
1369+
MLX5_SET(ppcnt_reg, in, grp,
1370+
MLX5_PHYSICAL_LAYER_STATISTICAL_GROUP);
1371+
mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0,
1372+
0);
1373+
}
13441374

1345-
out = pstats->phy_statistical_counters;
1346-
MLX5_SET(ppcnt_reg, in, grp, MLX5_PHYSICAL_LAYER_STATISTICAL_GROUP);
1347-
mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0, 0);
1375+
if (MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_recovery_counters)) {
1376+
out = pstats->phy_recovery_counters;
1377+
MLX5_SET(ppcnt_reg, in, grp,
1378+
MLX5_PHYSICAL_LAYER_RECOVERY_GROUP);
1379+
mlx5_core_access_reg(mdev, in, sz, out, sz, MLX5_REG_PPCNT, 0,
1380+
0);
1381+
}
13481382
}
13491383

13501384
void mlx5e_get_link_ext_stats(struct net_device *dev,

drivers/net/ethernet/mellanox/mlx5/core/en_stats.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ struct mlx5e_vport_stats {
309309
#define PPORT_PHY_STATISTICAL_GET(pstats, c) \
310310
MLX5_GET64(ppcnt_reg, (pstats)->phy_statistical_counters, \
311311
counter_set.phys_layer_statistical_cntrs.c##_high)
312+
#define PPORT_PHY_RECOVERY_GET(pstats, c) \
313+
MLX5_GET64(ppcnt_reg, (pstats)->phy_recovery_counters, \
314+
counter_set.phys_layer_recovery_cntrs.c)
312315
#define PPORT_PER_PRIO_GET(pstats, prio, c) \
313316
MLX5_GET64(ppcnt_reg, pstats->per_prio_counters[prio], \
314317
counter_set.eth_per_prio_grp_data_layout.c##_high)
@@ -324,6 +327,7 @@ struct mlx5e_pport_stats {
324327
__be64 per_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];
325328
__be64 phy_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
326329
__be64 phy_statistical_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
330+
__be64 phy_recovery_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
327331
__be64 eth_ext_counters[MLX5_ST_SZ_QW(ppcnt_reg)];
328332
__be64 per_tc_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];
329333
__be64 per_tc_congest_prio_counters[NUM_PPORT_PRIO][MLX5_ST_SZ_QW(ppcnt_reg)];

0 commit comments

Comments
 (0)