net/mlx5e: Add vnic steering drop statistics
authorMoshe Shemesh <moshe@mellanox.com>
Tue, 26 Dec 2017 14:46:29 +0000 (16:46 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Mon, 26 Mar 2018 20:47:10 +0000 (13:47 -0700)
Added the following packets drop counter:
Rx steering missed dropped packets - counts packets which were dropped
due to miss on NIC rx steering rules.
This counter will be shown on ethtool as a new counter called
rx_steer_missed_packets.

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
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
include/linux/mlx5/mlx5_ifc.h

index 2553c58dcf1ce24c027d93234affff17680a282a..552510c03ef2b79f5099ddbeb8a161f786633cfa 100644 (file)
@@ -211,6 +211,65 @@ static void mlx5e_grp_q_update_stats(struct mlx5e_priv *priv)
        qcnt->rx_out_of_buffer = MLX5_GET(query_q_counter_out, out, out_of_buffer);
 }
 
+#define VNIC_ENV_OFF(c) MLX5_BYTE_OFF(query_vnic_env_out, c)
+static const struct counter_desc vnic_env_stats_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 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;
+}
+
+static int mlx5e_grp_vnic_env_fill_strings(struct mlx5e_priv *priv, u8 *data,
+                                          int idx)
+{
+       int i;
+
+       if (!MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard))
+               return idx;
+
+       for (i = 0; i < NUM_VNIC_ENV_COUNTERS; i++)
+               strcpy(data + (idx++) * ETH_GSTRING_LEN,
+                      vnic_env_stats_desc[i].format);
+       return idx;
+}
+
+static int mlx5e_grp_vnic_env_fill_stats(struct mlx5e_priv *priv, u64 *data,
+                                        int idx)
+{
+       int i;
+
+       if (!MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard))
+               return idx;
+
+       for (i = 0; i < NUM_VNIC_ENV_COUNTERS; i++)
+               data[idx++] = MLX5E_READ_CTR64_BE(priv->stats.vnic.query_vnic_env_out,
+                                                 vnic_env_stats_desc, i);
+       return idx;
+}
+
+static void mlx5e_grp_vnic_env_update_stats(struct mlx5e_priv *priv)
+{
+       u32 *out = (u32 *)priv->stats.vnic.query_vnic_env_out;
+       int outlen = MLX5_ST_SZ_BYTES(query_vnic_env_out);
+       u32 in[MLX5_ST_SZ_DW(query_vnic_env_in)] = {0};
+       struct mlx5_core_dev *mdev = priv->mdev;
+
+       if (!MLX5_CAP_GEN(priv->mdev, nic_receive_steering_discard))
+               return;
+
+       MLX5_SET(query_vnic_env_in, in, opcode,
+                MLX5_CMD_OP_QUERY_VNIC_ENV);
+       MLX5_SET(query_vnic_env_in, in, op_mod, 0);
+       MLX5_SET(query_vnic_env_in, in, other_vport, 0);
+       mlx5_cmd_exec(mdev, in, sizeof(in), out, outlen);
+}
+
 #define VPORT_COUNTER_OFF(c) MLX5_BYTE_OFF(query_vport_counter_out, c)
 static const struct counter_desc vport_stats_desc[] = {
        { "rx_vport_unicast_packets",
@@ -1111,6 +1170,12 @@ const struct mlx5e_stats_grp mlx5e_stats_grps[] = {
                .update_stats_mask = MLX5E_NDO_UPDATE_STATS,
                .update_stats = mlx5e_grp_q_update_stats,
        },
+       {
+               .get_num_stats = mlx5e_grp_vnic_env_get_num_stats,
+               .fill_strings = mlx5e_grp_vnic_env_fill_strings,
+               .fill_stats = mlx5e_grp_vnic_env_fill_stats,
+               .update_stats = mlx5e_grp_vnic_env_update_stats,
+       },
        {
                .get_num_stats = mlx5e_grp_vport_get_num_stats,
                .fill_strings = mlx5e_grp_vport_fill_strings,
index 0b3320a2b0726586fd7cb0455715900f79fd0fe9..847388ff8ca842cbe17f60b653c75fedad91c1db 100644 (file)
@@ -99,6 +99,10 @@ struct mlx5e_qcounter_stats {
        u32 rx_out_of_buffer;
 };
 
+struct mlx5e_vnic_env_stats {
+       __be64 query_vnic_env_out[MLX5_ST_SZ_QW(query_vnic_env_out)];
+};
+
 #define VPORT_COUNTER_GET(vstats, c) MLX5_GET64(query_vport_counter_out, \
                                                vstats->query_vport_out, c)
 
@@ -201,6 +205,7 @@ struct mlx5e_ch_stats {
 struct mlx5e_stats {
        struct mlx5e_sw_stats sw;
        struct mlx5e_qcounter_stats qcnt;
+       struct mlx5e_vnic_env_stats vnic;
        struct mlx5e_vport_stats vport;
        struct mlx5e_pport_stats pport;
        struct rtnl_link_stats64 vf_vport;
index 52e373dd2679eeb1d32ac3ca551951b58ddb4fda..9202113f552c438237683cc7575642c054725121 100644 (file)
@@ -1008,7 +1008,8 @@ struct mlx5_ifc_cmd_hca_cap_bits {
        u8         reserved_at_330[0xb];
        u8         log_max_xrcd[0x5];
 
-       u8         reserved_at_340[0x8];
+       u8         nic_receive_steering_discard[0x1];
+       u8         reserved_at_341[0x7];
        u8         log_max_flow_counter_bulk[0x8];
        u8         max_flow_counter_15_0[0x10];