OSDN Git Service

net/mlx5e: Reuse fold sw stats in representors
authorSaeed Mahameed <saeedm@mellanox.com>
Wed, 12 Dec 2018 09:42:30 +0000 (01:42 -0800)
committerSaeed Mahameed <saeedm@mellanox.com>
Fri, 25 Jan 2019 20:16:15 +0000 (12:16 -0800)
Representors software stats are basic, this patch is reusing the
mlx5e_fold_sw_stats in representors, which sums up the basic stats64 for a
mlx5e netdevice.

Fixes: 8bfaf07f7806 ("net/mlx5e: Present SW stats when state is not opened")
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

index 3e35a90..6dd74ef 100644 (file)
@@ -804,6 +804,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
 
 void mlx5e_update_stats(struct mlx5e_priv *priv);
 void mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
+void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s);
 
 void mlx5e_init_l2_addr(struct mlx5e_priv *priv);
 int mlx5e_self_test_num(struct mlx5e_priv *priv);
index 01d0895..17b6bab 100644 (file)
@@ -3521,7 +3521,7 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
        }
 }
 
-static void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s)
+void mlx5e_fold_sw_stats64(struct mlx5e_priv *priv, struct rtnl_link_stats64 *s)
 {
        int i;
 
index 22f686b..edb34b3 100644 (file)
@@ -162,25 +162,16 @@ static void mlx5e_rep_update_hw_counters(struct mlx5e_priv *priv)
 static void mlx5e_rep_update_sw_counters(struct mlx5e_priv *priv)
 {
        struct mlx5e_sw_stats *s = &priv->stats.sw;
-       int i, j;
+       struct rtnl_link_stats64 stats64 = {};
 
        memset(s, 0, sizeof(*s));
-       for (i = 0; i < mlx5e_get_netdev_max_channels(priv->netdev); i++) {
-               struct mlx5e_channel_stats *channel_stats =
-                       &priv->channel_stats[i];
-               struct mlx5e_rq_stats *rq_stats = &channel_stats->rq;
-
-               s->rx_packets   += rq_stats->packets;
-               s->rx_bytes     += rq_stats->bytes;
-
-               for (j = 0; j < priv->max_opened_tc; j++) {
-                       struct mlx5e_sq_stats *sq_stats = &channel_stats->sq[j];
+       mlx5e_fold_sw_stats64(priv, &stats64);
 
-                       s->tx_packets           += sq_stats->packets;
-                       s->tx_bytes             += sq_stats->bytes;
-                       s->tx_queue_dropped     += sq_stats->dropped;
-               }
-       }
+       s->rx_packets = stats64.rx_packets;
+       s->rx_bytes   = stats64.rx_bytes;
+       s->tx_packets = stats64.tx_packets;
+       s->tx_bytes   = stats64.tx_bytes;
+       s->tx_queue_dropped = stats64.tx_dropped;
 }
 
 static void mlx5e_rep_get_ethtool_stats(struct net_device *dev,
@@ -1226,17 +1217,8 @@ mlx5e_get_sw_stats64(const struct net_device *dev,
                     struct rtnl_link_stats64 *stats)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
-       struct mlx5e_sw_stats *sstats = &priv->stats.sw;
-
-       mlx5e_rep_update_sw_counters(priv);
-
-       stats->rx_packets = sstats->rx_packets;
-       stats->rx_bytes   = sstats->rx_bytes;
-       stats->tx_packets = sstats->tx_packets;
-       stats->tx_bytes   = sstats->tx_bytes;
-
-       stats->tx_dropped = sstats->tx_queue_dropped;
 
+       mlx5e_fold_sw_stats64(priv, stats);
        return 0;
 }