Commit b2a62e56 authored by Or Har-Toov's avatar Or Har-Toov Committed by Saeed Mahameed

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: default avatarOr Har-Toov <ohartoov@nvidia.com>
Reviewed-by: default avatarPatrisious Haddad <phaddad@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
parent 4aea6a6d
...@@ -108,8 +108,18 @@ static const struct counter_desc vport_rep_stats_desc[] = { ...@@ -108,8 +108,18 @@ static const struct counter_desc vport_rep_stats_desc[] = {
tx_vport_rdma_multicast_bytes) }, tx_vport_rdma_multicast_bytes) },
}; };
static const struct counter_desc vport_rep_loopback_stats_desc[] = {
{ MLX5E_DECLARE_STAT(struct mlx5e_rep_stats,
vport_loopback_packets) },
{ MLX5E_DECLARE_STAT(struct mlx5e_rep_stats,
vport_loopback_bytes) },
};
#define NUM_VPORT_REP_SW_COUNTERS ARRAY_SIZE(sw_rep_stats_desc) #define NUM_VPORT_REP_SW_COUNTERS ARRAY_SIZE(sw_rep_stats_desc)
#define NUM_VPORT_REP_HW_COUNTERS ARRAY_SIZE(vport_rep_stats_desc) #define NUM_VPORT_REP_HW_COUNTERS ARRAY_SIZE(vport_rep_stats_desc)
#define NUM_VPORT_REP_LOOPBACK_COUNTERS(dev) \
(MLX5_CAP_GEN(dev, vport_counter_local_loopback) ? \
ARRAY_SIZE(vport_rep_loopback_stats_desc) : 0)
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(sw_rep) static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(sw_rep)
{ {
...@@ -153,7 +163,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw_rep) ...@@ -153,7 +163,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw_rep)
static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(vport_rep) static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(vport_rep)
{ {
return NUM_VPORT_REP_HW_COUNTERS; return NUM_VPORT_REP_HW_COUNTERS +
NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev);
} }
static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep) static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep)
...@@ -162,6 +173,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep) ...@@ -162,6 +173,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vport_rep)
for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++) for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN, vport_rep_stats_desc[i].format); strcpy(data + (idx++) * ETH_GSTRING_LEN, vport_rep_stats_desc[i].format);
for (i = 0; i < NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev); i++)
strcpy(data + (idx++) * ETH_GSTRING_LEN,
vport_rep_loopback_stats_desc[i].format);
return idx; return idx;
} }
...@@ -172,6 +186,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vport_rep) ...@@ -172,6 +186,9 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vport_rep)
for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++) for (i = 0; i < NUM_VPORT_REP_HW_COUNTERS; i++)
data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.rep_stats, data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.rep_stats,
vport_rep_stats_desc, i); vport_rep_stats_desc, i);
for (i = 0; i < NUM_VPORT_REP_LOOPBACK_COUNTERS(priv->mdev); i++)
data[idx++] = MLX5E_READ_CTR64_CPU(&priv->stats.rep_stats,
vport_rep_loopback_stats_desc, i);
return idx; return idx;
} }
...@@ -243,6 +260,13 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(vport_rep) ...@@ -243,6 +260,13 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(vport_rep)
rep_stats->tx_vport_rdma_multicast_bytes = rep_stats->tx_vport_rdma_multicast_bytes =
MLX5_GET_CTR(out, received_ib_multicast.octets); MLX5_GET_CTR(out, received_ib_multicast.octets);
if (MLX5_CAP_GEN(priv->mdev, vport_counter_local_loopback)) {
rep_stats->vport_loopback_packets =
MLX5_GET_CTR(out, local_loopback.packets);
rep_stats->vport_loopback_bytes =
MLX5_GET_CTR(out, local_loopback.octets);
}
out: out:
kvfree(out); kvfree(out);
} }
......
...@@ -476,6 +476,8 @@ struct mlx5e_rep_stats { ...@@ -476,6 +476,8 @@ struct mlx5e_rep_stats {
u64 tx_vport_rdma_multicast_packets; u64 tx_vport_rdma_multicast_packets;
u64 rx_vport_rdma_multicast_bytes; u64 rx_vport_rdma_multicast_bytes;
u64 tx_vport_rdma_multicast_bytes; u64 tx_vport_rdma_multicast_bytes;
u64 vport_loopback_packets;
u64 vport_loopback_bytes;
}; };
struct mlx5e_stats { struct mlx5e_stats {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment