lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200123063827.685230-12-saeedm@mellanox.com>
Date:   Thu, 23 Jan 2020 06:39:56 +0000
From:   Saeed Mahameed <saeedm@...lanox.com>
To:     "David S. Miller" <davem@...emloft.net>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        Saeed Mahameed <saeedm@...lanox.com>,
        Tariq Toukan <tariqt@...lanox.com>
Subject: [net-next 11/15] net/mlx5e: Convert stats groups array to array of
 group pointers

Convert stats groups array to array of "stats group" pointers to allow
sharing and individual selection of groups per profile as illustrated in
the next patches.

Signed-off-by: Saeed Mahameed <saeedm@...lanox.com>
Reviewed-by: Tariq Toukan <tariqt@...lanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h  |  2 +-
 .../net/ethernet/mellanox/mlx5/core/en_main.c |  4 +-
 .../ethernet/mellanox/mlx5/core/en_stats.c    | 69 ++++++++++++-------
 .../ethernet/mellanox/mlx5/core/en_stats.h    | 12 +++-
 4 files changed, 56 insertions(+), 31 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index f85d99d601a6..220ef9f06f84 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -893,7 +893,7 @@ struct mlx5e_profile {
 	void	(*update_stats)(struct mlx5e_priv *priv);
 	void	(*update_carrier)(struct mlx5e_priv *priv);
 	unsigned int (*stats_grps_num)(struct mlx5e_priv *priv);
-	const struct mlx5e_stats_grp *stats_grps;
+	mlx5e_stats_grp_t *stats_grps;
 	struct {
 		mlx5e_fp_handle_rx_cqe handle_rx_cqe;
 		mlx5e_fp_handle_rx_cqe handle_rx_cqe_mpwqe;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index a1bb9eb8e3b5..f3600ae4b0a1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -164,9 +164,9 @@ void mlx5e_update_ndo_stats(struct mlx5e_priv *priv)
 	int i;
 
 	for (i = mlx5e_nic_stats_grps_num(priv) - 1; i >= 0; i--)
-		if (mlx5e_nic_stats_grps[i].update_stats_mask &
+		if (mlx5e_nic_stats_grps[i]->update_stats_mask &
 		    MLX5E_NDO_UPDATE_STATS)
-			mlx5e_nic_stats_grps[i].update_stats(priv);
+			mlx5e_nic_stats_grps[i]->update_stats(priv);
 }
 
 static void mlx5e_update_stats_work(struct work_struct *work)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
index e903a15e7289..85730a8899c1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.c
@@ -43,46 +43,46 @@ static unsigned int stats_grps_num(struct mlx5e_priv *priv)
 
 unsigned int mlx5e_stats_total_num(struct mlx5e_priv *priv)
 {
-	const struct mlx5e_stats_grp *stats_grps = priv->profile->stats_grps;
+	mlx5e_stats_grp_t *stats_grps = priv->profile->stats_grps;
 	const unsigned int num_stats_grps = stats_grps_num(priv);
 	unsigned int total = 0;
 	int i;
 
 	for (i = 0; i < num_stats_grps; i++)
-		total += stats_grps[i].get_num_stats(priv);
+		total += stats_grps[i]->get_num_stats(priv);
 
 	return total;
 }
 
 void mlx5e_stats_update(struct mlx5e_priv *priv)
 {
-	const struct mlx5e_stats_grp *stats_grps = priv->profile->stats_grps;
+	mlx5e_stats_grp_t *stats_grps = priv->profile->stats_grps;
 	const unsigned int num_stats_grps = stats_grps_num(priv);
 	int i;
 
 	for (i = num_stats_grps - 1; i >= 0; i--)
-		if (stats_grps[i].update_stats)
-			stats_grps[i].update_stats(priv);
+		if (stats_grps[i]->update_stats)
+			stats_grps[i]->update_stats(priv);
 }
 
 void mlx5e_stats_fill(struct mlx5e_priv *priv, u64 *data, int idx)
 {
-	const struct mlx5e_stats_grp *stats_grps = priv->profile->stats_grps;
+	mlx5e_stats_grp_t *stats_grps = priv->profile->stats_grps;
 	const unsigned int num_stats_grps = stats_grps_num(priv);
 	int i;
 
 	for (i = 0; i < num_stats_grps; i++)
-		idx = stats_grps[i].fill_stats(priv, data, idx);
+		idx = stats_grps[i]->fill_stats(priv, data, idx);
 }
 
 void mlx5e_stats_fill_strings(struct mlx5e_priv *priv, u8 *data)
 {
-	const struct mlx5e_stats_grp *stats_grps = priv->profile->stats_grps;
+	mlx5e_stats_grp_t *stats_grps = priv->profile->stats_grps;
 	const unsigned int num_stats_grps = stats_grps_num(priv);
 	int i, idx = 0;
 
 	for (i = 0; i < num_stats_grps; i++)
-		idx = stats_grps[i].fill_strings(priv, data, idx);
+		idx = stats_grps[i]->fill_strings(priv, data, idx);
 }
 
 /* Concrete NIC Stats */
@@ -1700,24 +1700,41 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(channels)
 
 static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(channels) { return; }
 
+static MLX5E_DEFINE_STATS_GRP(sw, 0);
+static MLX5E_DEFINE_STATS_GRP(qcnt, MLX5E_NDO_UPDATE_STATS);
+static MLX5E_DEFINE_STATS_GRP(vnic_env, 0);
+static MLX5E_DEFINE_STATS_GRP(vport, MLX5E_NDO_UPDATE_STATS);
+static MLX5E_DEFINE_STATS_GRP(802_3, MLX5E_NDO_UPDATE_STATS);
+static MLX5E_DEFINE_STATS_GRP(2863, 0);
+static MLX5E_DEFINE_STATS_GRP(2819, 0);
+static MLX5E_DEFINE_STATS_GRP(phy, 0);
+static MLX5E_DEFINE_STATS_GRP(pcie, 0);
+static MLX5E_DEFINE_STATS_GRP(per_prio, 0);
+static MLX5E_DEFINE_STATS_GRP(pme, 0);
+static MLX5E_DEFINE_STATS_GRP(channels, 0);
+static MLX5E_DEFINE_STATS_GRP(per_port_buff_congest, 0);
+static MLX5E_DEFINE_STATS_GRP(eth_ext, 0);
+static MLX5E_DEFINE_STATS_GRP(ipsec, 0);
+static MLX5E_DEFINE_STATS_GRP(tls, 0);
+
 /* The stats groups order is opposite to the update_stats() order calls */
-const struct mlx5e_stats_grp mlx5e_nic_stats_grps[] = {
-	MLX5E_DEFINE_STATS_GRP(sw, 0),
-	MLX5E_DEFINE_STATS_GRP(qcnt, MLX5E_NDO_UPDATE_STATS),
-	MLX5E_DEFINE_STATS_GRP(vnic_env, 0),
-	MLX5E_DEFINE_STATS_GRP(vport, MLX5E_NDO_UPDATE_STATS),
-	MLX5E_DEFINE_STATS_GRP(802_3, MLX5E_NDO_UPDATE_STATS),
-	MLX5E_DEFINE_STATS_GRP(2863, 0),
-	MLX5E_DEFINE_STATS_GRP(2819, 0),
-	MLX5E_DEFINE_STATS_GRP(phy, 0),
-	MLX5E_DEFINE_STATS_GRP(eth_ext, 0),
-	MLX5E_DEFINE_STATS_GRP(pcie, 0),
-	MLX5E_DEFINE_STATS_GRP(per_prio, 0),
-	MLX5E_DEFINE_STATS_GRP(pme, 0),
-	MLX5E_DEFINE_STATS_GRP(ipsec, 0),
-	MLX5E_DEFINE_STATS_GRP(tls, 0),
-	MLX5E_DEFINE_STATS_GRP(channels, 0),
-	MLX5E_DEFINE_STATS_GRP(per_port_buff_congest, 0),
+mlx5e_stats_grp_t mlx5e_nic_stats_grps[] = {
+	&MLX5E_STATS_GRP(sw),
+	&MLX5E_STATS_GRP(qcnt),
+	&MLX5E_STATS_GRP(vnic_env),
+	&MLX5E_STATS_GRP(vport),
+	&MLX5E_STATS_GRP(802_3),
+	&MLX5E_STATS_GRP(2863),
+	&MLX5E_STATS_GRP(2819),
+	&MLX5E_STATS_GRP(phy),
+	&MLX5E_STATS_GRP(eth_ext),
+	&MLX5E_STATS_GRP(pcie),
+	&MLX5E_STATS_GRP(per_prio),
+	&MLX5E_STATS_GRP(pme),
+	&MLX5E_STATS_GRP(ipsec),
+	&MLX5E_STATS_GRP(tls),
+	&MLX5E_STATS_GRP(channels),
+	&MLX5E_STATS_GRP(per_port_buff_congest),
 };
 
 unsigned int mlx5e_nic_stats_grps_num(struct mlx5e_priv *priv)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
index bc97964cd721..29ad89f66bf7 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_stats.h
@@ -69,6 +69,8 @@ struct mlx5e_stats_grp {
 	void (*update_stats)(struct mlx5e_priv *priv);
 };
 
+typedef const struct mlx5e_stats_grp *const mlx5e_stats_grp_t;
+
 #define MLX5E_STATS_GRP_OP(grp, name) mlx5e_stats_grp_ ## grp ## _ ## name
 
 #define MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(grp) \
@@ -83,7 +85,13 @@ struct mlx5e_stats_grp {
 #define MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(grp) \
 	int MLX5E_STATS_GRP_OP(grp, fill_stats)(struct mlx5e_priv *priv, u64 *data, int idx)
 
-#define MLX5E_DEFINE_STATS_GRP(grp, mask) { \
+#define MLX5E_STATS_GRP(grp) mlx5e_stats_grp_ ## grp
+
+#define MLX5E_DECLARE_STATS_GRP(grp) \
+	const struct mlx5e_stats_grp MLX5E_STATS_GRP(grp)
+
+#define MLX5E_DEFINE_STATS_GRP(grp, mask) \
+MLX5E_DECLARE_STATS_GRP(grp) = { \
 	.get_num_stats = MLX5E_STATS_GRP_OP(grp, num_stats), \
 	.fill_stats    = MLX5E_STATS_GRP_OP(grp, fill_stats), \
 	.fill_strings  = MLX5E_STATS_GRP_OP(grp, fill_strings), \
@@ -365,7 +373,7 @@ struct mlx5e_stats {
 	struct mlx5e_pcie_stats pcie;
 };
 
-extern const struct mlx5e_stats_grp mlx5e_nic_stats_grps[];
+extern mlx5e_stats_grp_t mlx5e_nic_stats_grps[];
 unsigned int mlx5e_nic_stats_grps_num(struct mlx5e_priv *priv);
 
 MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(802_3);
-- 
2.24.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ