net/mlx5e: Expose rx_oversize_pkts_buffer counter
authorGal Pressman <gal@nvidia.com>
Sun, 2 Oct 2022 04:56:27 +0000 (21:56 -0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 3 Oct 2022 23:55:29 +0000 (16:55 -0700)
Add the rx_oversize_pkts_buffer counter to ethtool statistics.
This counter exposes the number of dropped received packets due to
length which arrived to RQ and exceed software buffer size allocated by
the device for incoming traffic. It might imply that the device MTU is
larger than the software buffers size.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
include/linux/mlx5/mlx5_ifc.h

index d4f03ff7b0e12256c76e050872396a3e67d2ec37..364f04309149225b3a8795d315cd619fb838b62b 100644 (file)
@@ -3699,7 +3699,8 @@ mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
        stats->rx_length_errors =
                PPORT_802_3_GET(pstats, a_in_range_length_errors) +
                PPORT_802_3_GET(pstats, a_out_of_range_length_field) +
-               PPORT_802_3_GET(pstats, a_frame_too_long_errors);
+               PPORT_802_3_GET(pstats, a_frame_too_long_errors) +
+               VNIC_ENV_GET(&priv->stats.vnic, eth_wqe_too_small);
        stats->rx_crc_errors =
                PPORT_802_3_GET(pstats, a_frame_check_sequence_errors);
        stats->rx_frame_errors = PPORT_802_3_GET(pstats, a_alignment_errors);
index 575717186912f75fd735f8ab8fc2cee3f79786cb..03c1841970f14b053cd2f3b1711d8df79bf9cc37 100644 (file)
@@ -641,17 +641,26 @@ static const struct counter_desc vnic_env_stats_dev_oob_desc[] = {
                VNIC_ENV_OFF(vport_env.internal_rq_out_of_buffer) },
 };
 
+static const struct counter_desc vnic_env_stats_drop_desc[] = {
+       { "rx_oversize_pkts_buffer",
+               VNIC_ENV_OFF(vport_env.eth_wqe_too_small) },
+};
+
 #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)
+#define NUM_VNIC_ENV_DROP_COUNTERS(dev) \
+       (MLX5_CAP_GEN(dev, eth_wqe_too_small) ? \
+        ARRAY_SIZE(vnic_env_stats_drop_desc) : 0)
 
 static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(vnic_env)
 {
        return NUM_VNIC_ENV_STEER_COUNTERS(priv->mdev) +
-               NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev);
+              NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev) +
+              NUM_VNIC_ENV_DROP_COUNTERS(priv->mdev);
 }
 
 static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vnic_env)
@@ -665,6 +674,11 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(vnic_env)
        for (i = 0; i < NUM_VNIC_ENV_DEV_OOB_COUNTERS(priv->mdev); i++)
                strcpy(data + (idx++) * ETH_GSTRING_LEN,
                       vnic_env_stats_dev_oob_desc[i].format);
+
+       for (i = 0; i < NUM_VNIC_ENV_DROP_COUNTERS(priv->mdev); i++)
+               strcpy(data + (idx++) * ETH_GSTRING_LEN,
+                      vnic_env_stats_drop_desc[i].format);
+
        return idx;
 }
 
@@ -679,6 +693,11 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(vnic_env)
        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);
+
+       for (i = 0; i < NUM_VNIC_ENV_DROP_COUNTERS(priv->mdev); i++)
+               data[idx++] = MLX5E_READ_CTR32_BE(priv->stats.vnic.query_vnic_env_out,
+                                                 vnic_env_stats_drop_desc, i);
+
        return idx;
 }
 
index 99e321bfb744509b18dc1ef573760e67e4ce9bd4..9f781085be4711336fa03c8092b234f80d272651 100644 (file)
@@ -273,6 +273,10 @@ struct mlx5e_qcounter_stats {
        u32 rx_if_down_packets;
 };
 
+#define VNIC_ENV_GET(vnic_env_stats, c) \
+       MLX5_GET(query_vnic_env_out, (vnic_env_stats)->query_vnic_env_out, \
+                vport_env.c)
+
 struct mlx5e_vnic_env_stats {
        __be64 query_vnic_env_out[MLX5_ST_SZ_QW(query_vnic_env_out)];
 };
index 1ad762e22d86d6719136b402408a261fe3e18076..06574d430ff51930460c70509ea423232c315580 100644 (file)
@@ -1491,7 +1491,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
 
        u8         reserved_at_120[0xa];
        u8         log_max_ra_req_dc[0x6];
-       u8         reserved_at_130[0x9];
+       u8         reserved_at_130[0x2];
+       u8         eth_wqe_too_small[0x1];
+       u8         reserved_at_133[0x6];
        u8         vnic_env_cq_overrun[0x1];
        u8         log_max_ra_res_dc[0x6];
 
@@ -3537,7 +3539,9 @@ struct mlx5_ifc_vnic_diagnostic_statistics_bits {
 
        u8         cq_overrun[0x20];
 
-       u8         reserved_at_220[0xde0];
+       u8         eth_wqe_too_small[0x20];
+
+       u8         reserved_at_220[0xdc0];
 };
 
 struct mlx5_ifc_traffic_counter_bits {