Skip to content

Commit 4c737ce

Browse files
Yael ChemlaPaolo Abeni
authored andcommitted
net/mlx5e: Get counter group size by FW capability
Retrieve the number of fields supported by each PPCNT counter group based on the FW capability for this group. Signed-off-by: Yael Chemla <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Reviewed-by: Kalesh AP <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent da4fa5d commit 4c737ce

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

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

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,18 +1257,23 @@ pport_phy_statistical_err_lanes_stats_desc[] = {
12571257
#define NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS \
12581258
ARRAY_SIZE(pport_phy_statistical_err_lanes_stats_desc)
12591259

1260+
#define NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(dev) \
1261+
(MLX5_CAP_PCAM_FEATURE(dev, ppcnt_statistical_group) ? \
1262+
NUM_PPORT_PHY_STATISTICAL_COUNTERS : 0)
1263+
#define NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(dev) \
1264+
(MLX5_CAP_PCAM_FEATURE(dev, per_lane_error_counters) ? \
1265+
NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS : 0)
1266+
12601267
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(phy)
12611268
{
12621269
struct mlx5_core_dev *mdev = priv->mdev;
12631270
int num_stats;
12641271

12651272
num_stats = NUM_PPORT_PHY_LAYER_COUNTERS;
12661273

1267-
num_stats += MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group) ?
1268-
NUM_PPORT_PHY_STATISTICAL_COUNTERS : 0;
1274+
num_stats += NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(mdev);
12691275

1270-
num_stats += MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters) ?
1271-
NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS : 0;
1276+
num_stats += NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);
12721277

12731278
return num_stats;
12741279
}
@@ -1281,14 +1286,15 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(phy)
12811286
for (i = 0; i < NUM_PPORT_PHY_LAYER_COUNTERS; i++)
12821287
ethtool_puts(data, pport_phy_layer_cntrs_stats_desc[i].format);
12831288

1284-
if (MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
1285-
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_COUNTERS; i++)
1286-
ethtool_puts(data, pport_phy_statistical_stats_desc[i].format);
1289+
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(mdev); i++)
1290+
ethtool_puts(data, pport_phy_statistical_stats_desc[i].format);
12871291

1288-
if (MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters))
1289-
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS; i++)
1290-
ethtool_puts(data,
1291-
pport_phy_statistical_err_lanes_stats_desc[i].format);
1292+
for (i = 0;
1293+
i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);
1294+
i++)
1295+
ethtool_puts(data,
1296+
pport_phy_statistical_err_lanes_stats_desc[i]
1297+
.format);
12921298
}
12931299

12941300
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(phy)
@@ -1303,23 +1309,21 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(phy)
13031309
.phy_counters,
13041310
pport_phy_layer_cntrs_stats_desc, i));
13051311

1306-
if (MLX5_CAP_PCAM_FEATURE(mdev, ppcnt_statistical_group))
1307-
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_COUNTERS; i++)
1308-
mlx5e_ethtool_put_stat(
1309-
data,
1310-
MLX5E_READ_CTR64_BE(
1311-
&priv->stats.pport.phy_statistical_counters,
1312-
pport_phy_statistical_stats_desc, i));
1312+
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_LOOPBACK_COUNTERS(mdev); i++)
1313+
mlx5e_ethtool_put_stat(
1314+
data,
1315+
MLX5E_READ_CTR64_BE(
1316+
&priv->stats.pport.phy_statistical_counters,
1317+
pport_phy_statistical_stats_desc, i));
13131318

1314-
if (MLX5_CAP_PCAM_FEATURE(mdev, per_lane_error_counters))
1315-
for (i = 0; i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_COUNTERS; i++)
1316-
mlx5e_ethtool_put_stat(
1317-
data,
1318-
MLX5E_READ_CTR64_BE(
1319-
&priv->stats.pport
1320-
.phy_statistical_counters,
1321-
pport_phy_statistical_err_lanes_stats_desc,
1322-
i));
1319+
for (i = 0;
1320+
i < NUM_PPORT_PHY_STATISTICAL_PER_LANE_LOOPBACK_COUNTERS(mdev);
1321+
i++)
1322+
mlx5e_ethtool_put_stat(
1323+
data,
1324+
MLX5E_READ_CTR64_BE(
1325+
&priv->stats.pport.phy_statistical_counters,
1326+
pport_phy_statistical_err_lanes_stats_desc, i));
13231327
}
13241328

13251329
static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(phy)

0 commit comments

Comments
 (0)