]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net/mlx5e: Add device out of buffer counter
authorMoshe Shemesh <moshe@mellanox.com>
Sun, 4 Aug 2019 14:53:09 +0000 (17:53 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Wed, 28 Aug 2019 18:49:04 +0000 (11:49 -0700)
Added the following packets drop counter:
Device out of buffer - counts packets which were dropped due to full
device internal receive queue.
This counter will be shown on ethtool as a new counter called
dev_out_of_buffer.
The counter is read from FW by command QUERY_VNIC_ENV.

Signed-off-by: Moshe Shemesh <moshe@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c

index 18e4c162256a27bffb9d1a4c9a446dfd57a45977..f1065e78086af5b4916a9de2ef0afe3f6910497d 100644 (file)
@@ -369,17 +369,27 @@ static void mlx5e_grp_q_update_stats(struct mlx5e_priv *priv)
 }
 
 #define VNIC_ENV_OFF(c) MLX5_BYTE_OFF(query_vnic_env_out, c)
-static const struct counter_desc vnic_env_stats_desc[] = {
+static const struct counter_desc vnic_env_stats_steer_desc[] = {
        { "rx_steer_missed_packets",
                VNIC_ENV_OFF(vport_env.nic_receive_steering_discard) },
 };
 
-#define NUM_VNIC_ENV_COUNTERS          ARRAY_SIZE(vnic_env_stats_desc)
+static const struct counter_desc vnic_env_stats_dev_oob_desc[] = {
+       { "dev_internal_queue_oob",
+               VNIC_ENV_OFF(vport_env.internal_rq_out_of_buffer) },
+};
+
+#define NUM_VNIC_ENV_STEER_COUNTERS(dev) \
+       (MLX5_CAP_GEN(dev, nic_receive_steering_discard) ? \
+        ARRAY_SIZE(vnic_env_stats_steer_desc) : 0)
+#define NUM_VNIC_ENV_DEV_OOB_COUNTERS(dev) \
+       (MLX5_CAP_GEN(dev, vnic_env_int_rq_oob) ? \
+        ARRAY_SIZE(vnic_env_stats_dev_oob_desc) : 0)
 
 static int mlx5e_grp_vnic_env_get_num_stats(struct mlx5e_priv *priv)
 {
-       return MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard) ?
-               NUM_VNIC_ENV_COUNTERS : 0;
+       return NUM_VNIC_ENV_STEER_COUNTERS(priv->mdev) +
+               NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev);
 }
 
 static int mlx5e_grp_vnic_env_fill_strings(struct mlx5e_priv *priv, u8 *data,
@@ -387,12 +397,13 @@ static int mlx5e_grp_vnic_env_fill_strings(struct mlx5e_priv *priv, u8 *data,
 {
        int i;
 
-       if (!MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard))
-               return idx;
+       for (i = 0; i < NUM_VNIC_ENV_STEER_COUNTERS(priv->mdev); i++)
+               strcpy(data + (idx++) * ETH_GSTRING_LEN,
+                      vnic_env_stats_steer_desc[i].format);
 
-       for (i = 0; i < NUM_VNIC_ENV_COUNTERS; i++)
+       for (i = 0; i < NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev); i++)
                strcpy(data + (idx++) * ETH_GSTRING_LEN,
-                      vnic_env_stats_desc[i].format);
+                      vnic_env_stats_dev_oob_desc[i].format);
        return idx;
 }
 
@@ -401,12 +412,13 @@ static int mlx5e_grp_vnic_env_fill_stats(struct mlx5e_priv *priv, u64 *data,
 {
        int i;
 
-       if (!MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard))
-               return idx;
-
-       for (i = 0; i < NUM_VNIC_ENV_COUNTERS; i++)
+       for (i = 0; i < NUM_VNIC_ENV_STEER_COUNTERS(priv->mdev); i++)
                data[idx++] = MLX5E_READ_CTR64_BE(priv->stats.vnic.query_vnic_env_out,
-                                                 vnic_env_stats_desc, i);
+                                                 vnic_env_stats_steer_desc, i);
+
+       for (i = 0; i < NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev); i++)
+               data[idx++] = MLX5E_READ_CTR32_BE(priv->stats.vnic.query_vnic_env_out,
+                                                 vnic_env_stats_dev_oob_desc, i);
        return idx;
 }