@@ -1227,6 +1227,13 @@ void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
1227
1227
mutex_unlock (& priv -> state_lock );
1228
1228
}
1229
1229
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
+
1230
1237
#define PPORT_PHY_STATISTICAL_OFF (c ) \
1231
1238
MLX5_BYTE_OFF(ppcnt_reg, \
1232
1239
counter_set.phys_layer_statistical_cntrs.c##_high)
@@ -1243,25 +1250,45 @@ pport_phy_statistical_err_lanes_stats_desc[] = {
1243
1250
{ "rx_err_lane_3_phy" , PPORT_PHY_STATISTICAL_OFF (phy_corrected_bits_lane3 ) },
1244
1251
};
1245
1252
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)
1246
1263
#define NUM_PPORT_PHY_STATISTICAL_COUNTERS \
1247
1264
ARRAY_SIZE(pport_phy_statistical_stats_desc)
1248
1265
#define NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS \
1249
1266
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)
1250
1279
1251
1280
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS (phy )
1252
1281
{
1253
1282
struct mlx5_core_dev * mdev = priv -> mdev ;
1254
1283
int num_stats ;
1255
1284
1256
- /* "1" for link_down_events special counter */
1257
- num_stats = 1 ;
1285
+ num_stats = NUM_PPORT_PHY_LAYER_COUNTERS ;
1258
1286
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 );
1261
1288
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 );
1264
1290
1291
+ num_stats += NUM_PPORT_PHY_RECOVERY_LOOPBACK_COUNTERS (mdev );
1265
1292
return num_stats ;
1266
1293
}
1267
1294
@@ -1270,49 +1297,58 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(phy)
1270
1297
struct mlx5_core_dev * mdev = priv -> mdev ;
1271
1298
int i ;
1272
1299
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 );
1277
1302
1278
- for (i = 0 ; i < NUM_PPORT_PHY_STATISTICAL_COUNTERS ; i ++ )
1303
+ for (i = 0 ; i < NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS ( mdev ) ; i ++ )
1279
1304
ethtool_puts (data , pport_phy_statistical_stats_desc [i ].format );
1280
1305
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 );
1285
1316
}
1286
1317
1287
1318
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS (phy )
1288
1319
{
1289
1320
struct mlx5_core_dev * mdev = priv -> mdev ;
1290
1321
int i ;
1291
1322
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 ));
1299
1329
1300
- for (i = 0 ; i < NUM_PPORT_PHY_STATISTICAL_COUNTERS ; i ++ )
1330
+ for (i = 0 ; i < NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS ( mdev ) ; i ++ )
1301
1331
mlx5e_ethtool_put_stat (
1302
1332
data ,
1303
1333
MLX5E_READ_CTR64_BE (
1304
1334
& priv -> stats .pport .phy_statistical_counters ,
1305
1335
pport_phy_statistical_stats_desc , i ));
1306
1336
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 ));
1316
1352
}
1317
1353
1318
1354
static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS (phy )
@@ -1328,12 +1364,21 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(phy)
1328
1364
MLX5_SET (ppcnt_reg , in , grp , MLX5_PHYSICAL_LAYER_COUNTERS_GROUP );
1329
1365
mlx5_core_access_reg (mdev , in , sz , out , sz , MLX5_REG_PPCNT , 0 , 0 );
1330
1366
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
+ }
1333
1374
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
+ }
1337
1382
}
1338
1383
1339
1384
void mlx5e_get_link_ext_stats (struct net_device * dev ,
0 commit comments