]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
net/mlx5e: Switch vport counters to use the stats group API
authorKamal Heib <kamalh@mellanox.com>
Wed, 23 Aug 2017 11:47:58 +0000 (14:47 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Tue, 31 Oct 2017 21:20:46 +0000 (14:20 -0700)
Switch the vport counters to use the new stats group API.

Signed-off-by: Kamal Heib <kamalh@mellanox.com>
Reviewed-by: Gal Pressman <galp@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h

index 35ba40af2a735510fd7393ca85432cd2c047ce28..08089f1d2c4c9d629ee80f54fe0dd01b5ef63884 100644 (file)
@@ -182,7 +182,7 @@ int mlx5e_ethtool_get_sset_count(struct mlx5e_priv *priv, int sset)
                for (i = 0; i < mlx5e_num_stats_grps; i++)
                        num_stats += mlx5e_stats_grps[i].get_num_stats(priv);
                return num_stats +
-                      NUM_VPORT_COUNTERS + NUM_PPORT_COUNTERS(priv) +
+                      NUM_PPORT_COUNTERS(priv) +
                       NUM_PCIE_COUNTERS(priv) +
                       MLX5E_NUM_RQ_STATS(priv) +
                       MLX5E_NUM_SQ_STATS(priv) +
@@ -216,11 +216,6 @@ static void mlx5e_fill_stats_strings(struct mlx5e_priv *priv, u8 *data)
        for (i = 0; i < mlx5e_num_stats_grps; i++)
                idx = mlx5e_stats_grps[i].fill_strings(priv, data, idx);
 
-       /* VPORT counters */
-       for (i = 0; i < NUM_VPORT_COUNTERS; i++)
-               strcpy(data + (idx++) * ETH_GSTRING_LEN,
-                      vport_stats_desc[i].format);
-
        /* PPORT counters */
        for (i = 0; i < NUM_PPORT_802_3_COUNTERS; i++)
                strcpy(data + (idx++) * ETH_GSTRING_LEN,
@@ -354,10 +349,6 @@ void mlx5e_ethtool_get_ethtool_stats(struct mlx5e_priv *priv,
        for (i = 0; i < mlx5e_num_stats_grps; i++)
                idx = mlx5e_stats_grps[i].fill_stats(priv, data, idx);
 
-       for (i = 0; i < NUM_VPORT_COUNTERS; i++)
-               data[idx++] = MLX5E_READ_CTR64_BE(priv->stats.vport.query_vport_out,
-                                                 vport_stats_desc, i);
-
        for (i = 0; i < NUM_PPORT_802_3_COUNTERS; i++)
                data[idx++] = MLX5E_READ_CTR64_BE(&priv->stats.pport.IEEE_802_3_counters,
                                                  pport_802_3_stats_desc, i);
index 64b344720a3103a13cb3d0ea864916b44214f8eb..199e34f204a67ff5bd8e2b78264e4ed79863161c 100644 (file)
@@ -125,6 +125,78 @@ static int mlx5e_grp_q_fill_stats(struct mlx5e_priv *priv, u64 *data, int idx)
        return idx;
 }
 
+#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",
+               VPORT_COUNTER_OFF(received_eth_unicast.packets) },
+       { "rx_vport_unicast_bytes",
+               VPORT_COUNTER_OFF(received_eth_unicast.octets) },
+       { "tx_vport_unicast_packets",
+               VPORT_COUNTER_OFF(transmitted_eth_unicast.packets) },
+       { "tx_vport_unicast_bytes",
+               VPORT_COUNTER_OFF(transmitted_eth_unicast.octets) },
+       { "rx_vport_multicast_packets",
+               VPORT_COUNTER_OFF(received_eth_multicast.packets) },
+       { "rx_vport_multicast_bytes",
+               VPORT_COUNTER_OFF(received_eth_multicast.octets) },
+       { "tx_vport_multicast_packets",
+               VPORT_COUNTER_OFF(transmitted_eth_multicast.packets) },
+       { "tx_vport_multicast_bytes",
+               VPORT_COUNTER_OFF(transmitted_eth_multicast.octets) },
+       { "rx_vport_broadcast_packets",
+               VPORT_COUNTER_OFF(received_eth_broadcast.packets) },
+       { "rx_vport_broadcast_bytes",
+               VPORT_COUNTER_OFF(received_eth_broadcast.octets) },
+       { "tx_vport_broadcast_packets",
+               VPORT_COUNTER_OFF(transmitted_eth_broadcast.packets) },
+       { "tx_vport_broadcast_bytes",
+               VPORT_COUNTER_OFF(transmitted_eth_broadcast.octets) },
+       { "rx_vport_rdma_unicast_packets",
+               VPORT_COUNTER_OFF(received_ib_unicast.packets) },
+       { "rx_vport_rdma_unicast_bytes",
+               VPORT_COUNTER_OFF(received_ib_unicast.octets) },
+       { "tx_vport_rdma_unicast_packets",
+               VPORT_COUNTER_OFF(transmitted_ib_unicast.packets) },
+       { "tx_vport_rdma_unicast_bytes",
+               VPORT_COUNTER_OFF(transmitted_ib_unicast.octets) },
+       { "rx_vport_rdma_multicast_packets",
+               VPORT_COUNTER_OFF(received_ib_multicast.packets) },
+       { "rx_vport_rdma_multicast_bytes",
+               VPORT_COUNTER_OFF(received_ib_multicast.octets) },
+       { "tx_vport_rdma_multicast_packets",
+               VPORT_COUNTER_OFF(transmitted_ib_multicast.packets) },
+       { "tx_vport_rdma_multicast_bytes",
+               VPORT_COUNTER_OFF(transmitted_ib_multicast.octets) },
+};
+
+#define NUM_VPORT_COUNTERS             ARRAY_SIZE(vport_stats_desc)
+
+static int mlx5e_grp_vport_get_num_stats(struct mlx5e_priv *priv)
+{
+       return NUM_VPORT_COUNTERS;
+}
+
+static int mlx5e_grp_vport_fill_strings(struct mlx5e_priv *priv, u8 *data,
+                                       int idx)
+{
+       int i;
+
+       for (i = 0; i < NUM_VPORT_COUNTERS; i++)
+               strcpy(data + (idx++) * ETH_GSTRING_LEN, vport_stats_desc[i].format);
+       return idx;
+}
+
+static int mlx5e_grp_vport_fill_stats(struct mlx5e_priv *priv, u64 *data,
+                                     int idx)
+{
+       int i;
+
+       for (i = 0; i < NUM_VPORT_COUNTERS; i++)
+               data[idx++] = MLX5E_READ_CTR64_BE(priv->stats.vport.query_vport_out,
+                                                 vport_stats_desc, i);
+       return idx;
+}
+
 const struct mlx5e_stats_grp mlx5e_stats_grps[] = {
        {
                .get_num_stats = mlx5e_grp_sw_get_num_stats,
@@ -136,6 +208,11 @@ const struct mlx5e_stats_grp mlx5e_stats_grps[] = {
                .fill_strings = mlx5e_grp_q_fill_strings,
                .fill_stats = mlx5e_grp_q_fill_stats,
        },
+       {
+               .get_num_stats = mlx5e_grp_vport_get_num_stats,
+               .fill_strings = mlx5e_grp_vport_fill_strings,
+               .fill_stats = mlx5e_grp_vport_fill_stats,
+       },
 };
 
 const int mlx5e_num_stats_grps = ARRAY_SIZE(mlx5e_stats_grps);
index b82ecb1fa353704850913a13ff93904d9a95202d..610208aed76776716e37b9fcb644a569c15de853 100644 (file)
@@ -95,7 +95,6 @@ struct mlx5e_qcounter_stats {
        u32 rx_out_of_buffer;
 };
 
-#define VPORT_COUNTER_OFF(c) MLX5_BYTE_OFF(query_vport_counter_out, c)
 #define VPORT_COUNTER_GET(vstats, c) MLX5_GET64(query_vport_counter_out, \
                                                vstats->query_vport_out, c)
 
@@ -103,49 +102,6 @@ struct mlx5e_vport_stats {
        __be64 query_vport_out[MLX5_ST_SZ_QW(query_vport_counter_out)];
 };
 
-static const struct counter_desc vport_stats_desc[] = {
-       { "rx_vport_unicast_packets",
-               VPORT_COUNTER_OFF(received_eth_unicast.packets) },
-       { "rx_vport_unicast_bytes",
-               VPORT_COUNTER_OFF(received_eth_unicast.octets) },
-       { "tx_vport_unicast_packets",
-               VPORT_COUNTER_OFF(transmitted_eth_unicast.packets) },
-       { "tx_vport_unicast_bytes",
-               VPORT_COUNTER_OFF(transmitted_eth_unicast.octets) },
-       { "rx_vport_multicast_packets",
-               VPORT_COUNTER_OFF(received_eth_multicast.packets) },
-       { "rx_vport_multicast_bytes",
-               VPORT_COUNTER_OFF(received_eth_multicast.octets) },
-       { "tx_vport_multicast_packets",
-               VPORT_COUNTER_OFF(transmitted_eth_multicast.packets) },
-       { "tx_vport_multicast_bytes",
-               VPORT_COUNTER_OFF(transmitted_eth_multicast.octets) },
-       { "rx_vport_broadcast_packets",
-               VPORT_COUNTER_OFF(received_eth_broadcast.packets) },
-       { "rx_vport_broadcast_bytes",
-               VPORT_COUNTER_OFF(received_eth_broadcast.octets) },
-       { "tx_vport_broadcast_packets",
-               VPORT_COUNTER_OFF(transmitted_eth_broadcast.packets) },
-       { "tx_vport_broadcast_bytes",
-               VPORT_COUNTER_OFF(transmitted_eth_broadcast.octets) },
-       { "rx_vport_rdma_unicast_packets",
-               VPORT_COUNTER_OFF(received_ib_unicast.packets) },
-       { "rx_vport_rdma_unicast_bytes",
-               VPORT_COUNTER_OFF(received_ib_unicast.octets) },
-       { "tx_vport_rdma_unicast_packets",
-               VPORT_COUNTER_OFF(transmitted_ib_unicast.packets) },
-       { "tx_vport_rdma_unicast_bytes",
-               VPORT_COUNTER_OFF(transmitted_ib_unicast.octets) },
-       { "rx_vport_rdma_multicast_packets",
-               VPORT_COUNTER_OFF(received_ib_multicast.packets) },
-       { "rx_vport_rdma_multicast_bytes",
-               VPORT_COUNTER_OFF(received_ib_multicast.octets) },
-       { "tx_vport_rdma_multicast_packets",
-               VPORT_COUNTER_OFF(transmitted_ib_multicast.packets) },
-       { "tx_vport_rdma_multicast_bytes",
-               VPORT_COUNTER_OFF(transmitted_ib_multicast.octets) },
-};
-
 #define PPORT_802_3_OFF(c) \
        MLX5_BYTE_OFF(ppcnt_reg, \
                      counter_set.eth_802_3_cntrs_grp_data_layout.c##_high)
@@ -380,7 +336,6 @@ static const struct counter_desc sq_stats_desc[] = {
        { MLX5E_DECLARE_TX_STAT(struct mlx5e_sq_stats, xmit_more) },
 };
 
-#define NUM_VPORT_COUNTERS             ARRAY_SIZE(vport_stats_desc)
 #define NUM_PPORT_802_3_COUNTERS       ARRAY_SIZE(pport_802_3_stats_desc)
 #define NUM_PPORT_2863_COUNTERS                ARRAY_SIZE(pport_2863_stats_desc)
 #define NUM_PPORT_2819_COUNTERS                ARRAY_SIZE(pport_2819_stats_desc)