Skip to content

Commit a228060

Browse files
ogerlitzSaeed Mahameed
authored andcommitted
net/mlx5e: Add HW vport counters to representor ethtool stats
Currently the representor only report the SW (slow-path) traffic counters. Add packet/bytes reporting of the HW counters, which account for the total amount of traffic that was handled by the vport, both slow and fast (offloaded) paths. The newly exposed counters are named vport_rx/tx_packets/bytes. Signed-off-by: Or Gerlitz <[email protected]> Signed-off-by: Adi Nissim <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 8f8ae89 commit a228060

File tree

1 file changed

+29
-6
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+29
-6
lines changed

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,36 @@ static const struct counter_desc sw_rep_stats_desc[] = {
6666
{ MLX5E_DECLARE_STAT(struct mlx5e_sw_stats, tx_bytes) },
6767
};
6868

69-
#define NUM_VPORT_REP_COUNTERS ARRAY_SIZE(sw_rep_stats_desc)
69+
struct vport_stats {
70+
u64 vport_rx_packets;
71+
u64 vport_tx_packets;
72+
u64 vport_rx_bytes;
73+
u64 vport_tx_bytes;
74+
};
75+
76+
static const struct counter_desc vport_rep_stats_desc[] = {
77+
{ MLX5E_DECLARE_STAT(struct vport_stats, vport_rx_packets) },
78+
{ MLX5E_DECLARE_STAT(struct vport_stats, vport_rx_bytes) },
79+
{ MLX5E_DECLARE_STAT(struct vport_stats, vport_tx_packets) },
80+
{ MLX5E_DECLARE_STAT(struct vport_stats, vport_tx_bytes) },
81+
};
82+
83+
#define NUM_VPORT_REP_SW_COUNTERS ARRAY_SIZE(sw_rep_stats_desc)
84+
#define NUM_VPORT_REP_HW_COUNTERS ARRAY_SIZE(vport_rep_stats_desc)
7085

7186
static void mlx5e_rep_get_strings(struct net_device *dev,
7287
u32 stringset, uint8_t *data)
7388
{
74-
int i;
89+
int i, j;
7590

7691
switch (stringset) {
7792
case ETH_SS_STATS:
78-
for (i = 0; i < NUM_VPORT_REP_COUNTERS; i++)
93+
for (i = 0; i < NUM_VPORT_REP_SW_COUNTERS; i++)
7994
strcpy(data + (i * ETH_GSTRING_LEN),
8095
sw_rep_stats_desc[i].format);
96+
for (j = 0; j < NUM_VPORT_REP_HW_COUNTERS; j++, i++)
97+
strcpy(data + (i * ETH_GSTRING_LEN),
98+
vport_rep_stats_desc[j].format);
8199
break;
82100
}
83101
}
@@ -140,26 +158,31 @@ static void mlx5e_rep_get_ethtool_stats(struct net_device *dev,
140158
struct ethtool_stats *stats, u64 *data)
141159
{
142160
struct mlx5e_priv *priv = netdev_priv(dev);
143-
int i;
161+
int i, j;
144162

145163
if (!data)
146164
return;
147165

148166
mutex_lock(&priv->state_lock);
149167
if (test_bit(MLX5E_STATE_OPENED, &priv->state))
150168
mlx5e_rep_update_sw_counters(priv);
169+
mlx5e_rep_update_hw_counters(priv);
151170
mutex_unlock(&priv->state_lock);
152171

153-
for (i = 0; i < NUM_VPORT_REP_COUNTERS; i++)
172+
for (i = 0; i < NUM_VPORT_REP_SW_COUNTERS; i++)
154173
data[i] = MLX5E_READ_CTR64_CPU(&priv->stats.sw,
155174
sw_rep_stats_desc, i);
175+
176+
for (j = 0; j < NUM_VPORT_REP_HW_COUNTERS; j++, i++)
177+
data[i] = MLX5E_READ_CTR64_CPU(&priv->stats.vf_vport,
178+
vport_rep_stats_desc, j);
156179
}
157180

158181
static int mlx5e_rep_get_sset_count(struct net_device *dev, int sset)
159182
{
160183
switch (sset) {
161184
case ETH_SS_STATS:
162-
return NUM_VPORT_REP_COUNTERS;
185+
return NUM_VPORT_REP_SW_COUNTERS + NUM_VPORT_REP_HW_COUNTERS;
163186
default:
164187
return -EOPNOTSUPP;
165188
}

0 commit comments

Comments
 (0)