Skip to content

Commit 8401171

Browse files
author
Paolo Abeni
committed
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/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents e2f4ac7 + c3b999c commit 8401171

File tree

3 files changed

+91
-37
lines changed

3 files changed

+91
-37
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: 82 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,13 @@ void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
12271227
mutex_unlock(&priv->state_lock);
12281228
}
12291229

1230+
#define PPORT_PHY_LAYER_OFF(c) \
1231+
MLX5_BYTE_OFF(ppcnt_reg, \
1232+
counter_set.phys_layer_cntrs.c)
1233+
static const struct counter_desc pport_phy_layer_cntrs_stats_desc[] = {
1234+
{ "link_down_events_phy", PPORT_PHY_LAYER_OFF(link_down_events) }
1235+
};
1236+
12301237
#define PPORT_PHY_STATISTICAL_OFF(c) \
12311238
MLX5_BYTE_OFF(ppcnt_reg, \
12321239
counter_set.phys_layer_statistical_cntrs.c##_high)
@@ -1243,25 +1250,45 @@ pport_phy_statistical_err_lanes_stats_desc[] = {
12431250
{ "rx_err_lane_3_phy", PPORT_PHY_STATISTICAL_OFF(phy_corrected_bits_lane3) },
12441251
};
12451252

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+
1261+
#define NUM_PPORT_PHY_LAYER_COUNTERS \
1262+
ARRAY_SIZE(pport_phy_layer_cntrs_stats_desc)
12461263
#define NUM_PPORT_PHY_STATISTICAL_COUNTERS \
12471264
ARRAY_SIZE(pport_phy_statistical_stats_desc)
12481265
#define NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS \
12491266
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)
1269+
1270+
#define NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(dev) \
1271+
(MLX5_CAP_PCAM_FEATURE(dev, ppcnt_statistical_group) ? \
1272+
NUM_PPORT_PHY_STATISTICAL_COUNTERS : 0)
1273+
#define NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(dev) \
1274+
(MLX5_CAP_PCAM_FEATURE(dev, per_lane_error_counters) ? \
1275+
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)
12501279

12511280
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(phy)
12521281
{
12531282
struct mlx5_core_dev *mdev = priv->mdev;
12541283
int num_stats;
12551284

1256-
/* "1" for link_down_events special counter */
1257-
num_stats = 1;
1285+
num_stats = NUM_PPORT_PHY_LAYER_COUNTERS;
12581286

1259-
num_stats += MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group) ?
1260-
NUM_PPORT_PHY_STATISTICAL_COUNTERS : 0;
1287+
num_stats += NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(mdev);
12611288

1262-
num_stats += MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters) ?
1263-
NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS : 0;
1289+
num_stats += NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);
12641290

1291+
num_stats += NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS(mdev);
12651292
return num_stats;
12661293
}
12671294

@@ -1270,49 +1297,58 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(phy)
12701297
struct mlx5_core_dev *mdev = priv->mdev;
12711298
int i;
12721299

1273-
ethtool_puts(data, "link_down_events_phy");
1274-
1275-
if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
1276-
return;
1300+
for (i = 0; i < NUM_PPORT_PHY_LAYER_COUNTERS; i++)
1301+
ethtool_puts(data, pport_phy_layer_cntrs_stats_desc[i].format);
12771302

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

1281-
if (MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters))
1282-
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS; i++)
1283-
ethtool_puts(data,
1284-
pport_phy_statistical_err_lanes_stats_desc[i].format);
1306+
for (i = 0;
1307+
i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);
1308+
i++)
1309+
ethtool_puts(data,
1310+
pport_phy_statistical_err_lanes_stats_desc[i]
1311+
.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);
12851316
}
12861317

12871318
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(phy)
12881319
{
12891320
struct mlx5_core_dev *mdev = priv->mdev;
12901321
int i;
12911322

1292-
/* link_down_events_phy has special handling since it is not stored in __be64 format */
1293-
mlx5e_ethtool_put_stat(
1294-
data, MLX5_GET(ppcnt_reg, priv->stats.pport.phy_counters,
1295-
counter_set.phys_layer_cntrs.link_down_events));
1296-
1297-
if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
1298-
return;
1323+
for (i = 0; i < NUM_PPORT_PHY_LAYER_COUNTERS; i++)
1324+
mlx5e_ethtool_put_stat(
1325+
data,
1326+
MLX5E_READ_CTR32_BE(&priv->stats.pport
1327+
.phy_counters,
1328+
pport_phy_layer_cntrs_stats_desc, i));
12991329

1300-
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_COUNTERS; i++)
1330+
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(mdev); i++)
13011331
mlx5e_ethtool_put_stat(
13021332
data,
13031333
MLX5E_READ_CTR64_BE(
13041334
&priv->stats.pport.phy_statistical_counters,
13051335
pport_phy_statistical_stats_desc, i));
13061336

1307-
if (MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters))
1308-
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS; i++)
1309-
mlx5e_ethtool_put_stat(
1310-
data,
1311-
MLX5E_READ_CTR64_BE(
1312-
&priv->stats.pport
1313-
.phy_statistical_counters,
1314-
pport_phy_statistical_err_lanes_stats_desc,
1315-
i));
1337+
for (i = 0;
1338+
i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);
1339+
i++)
1340+
mlx5e_ethtool_put_stat(
1341+
data,
1342+
MLX5E_READ_CTR64_BE(
1343+
&priv->stats.pport.phy_statistical_counters,
1344+
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));
13161352
}
13171353

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

1331-
if (!MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
1332-
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+
}
13331374

1334-
out = pstats->phy_statistical_counters;
1335-
MLX5_SET(ppcnt_reg, in, grp, MLX5_PHYSICAL_LAYER_STATISTICAL_GROUP);
1336-
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+
}
13371382
}
13381383

13391384
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)