Skip to content

Commit b2a62e5

Browse files
ohartoovSaeed Mahameed
authored andcommitted
net/mlx5e: Add local loopback counter to vport rep stats
Add counter for number of unicast, multicast and broadcast packets/ octets that were loopback. Signed-off-by: Or Har-Toov <ohartoov@nvidia.com> Reviewed-by: Patrisious Haddad <phaddad@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 4aea6a6 commit b2a62e5

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,18 @@ static const struct counter_desc vport_rep_stats_desc[] = {
108108
tx_vport_rdma_multicast_bytes) },
109109
};
110110

111+
static const struct counter_desc vport_rep_loopback_stats_desc[] = {
112+
{ MLX5E_DECLARE_STAT(struct mlx5e_rep_stats,
113+
vport_loopback_packets) },
114+
{ MLX5E_DECLARE_STAT(struct mlx5e_rep_stats,
115+
vport_loopback_bytes) },
116+
};
117+
111118
#define NUM_VPORT_REP_SW_COUNTERS ARRAY_SIZE(sw_rep_stats_desc)
112119
#define NUM_VPORT_REP_HW_COUNTERS ARRAY_SIZE(vport_rep_stats_desc)
120+
#define NUM_VPORT_REP_LOOPBACK_COUNTERS(dev) \
121+
(MLX5_CAP_GEN(dev, vport_counter_local_loopback) ? \
122+
ARRAY_SIZE(vport_rep_loopback_stats_desc) : 0)
113123

114124
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(sw_rep)
115125
{
@@ -153,7 +163,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw_rep)
153163

154164
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(vport_rep)
155165
{
156-
return NUM_VPORT_REP_HW_COUNTERS;
166+
return NUM_VPORT_REP_HW_COUNTERS +
167+
NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev);
157168
}
158169

159170
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep)
@@ -162,6 +173,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep)
162173

163174
for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++)
164175
strcpy(data + (idx++) * ETH_GSTRING_LEN, vport_rep_stats_desc[i].format);
176+
for (i = 0; i < NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev); i++)
177+
strcpy(data + (idx++) * ETH_GSTRING_LEN,
178+
vport_rep_loopback_stats_desc[i].format);
165179
return idx;
166180
}
167181

@@ -172,6 +186,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vport_rep)
172186
for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++)
173187
data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.rep_stats,
174188
vport_rep_stats_desc, i);
189+
for (i = 0; i < NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev); i++)
190+
data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.rep_stats,
191+
vport_rep_loopback_stats_desc, i);
175192
return idx;
176193
}
177194

@@ -243,6 +260,13 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(vport_rep)
243260
rep_stats->tx_vport_rdma_multicast_bytes =
244261
MLX5_GET_CTR(out, received_ib_multicast.octets);
245262

263+
if (MLX5_CAP_GEN(priv->mdev, vport_counter_local_loopback)) {
264+
rep_stats->vport_loopback_packets =
265+
MLX5_GET_CTR(out, local_loopback.packets);
266+
rep_stats->vport_loopback_bytes =
267+
MLX5_GET_CTR(out, local_loopback.octets);
268+
}
269+
246270
out:
247271
kvfree(out);
248272
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ struct mlx5e_rep_stats {
476476
u64 tx_vport_rdma_multicast_packets;
477477
u64 rx_vport_rdma_multicast_bytes;
478478
u64 tx_vport_rdma_multicast_bytes;
479+
u64 vport_loopback_packets;
480+
u64 vport_loopback_bytes;
479481
};
480482

481483
struct mlx5e_stats {

0 commit comments

Comments
 (0)