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: <20210803022853.106973-5-saeed@kernel.org>
Date:   Mon,  2 Aug 2021 19:28:41 -0700
From:   Saeed Mahameed <saeed@...nel.org>
To:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>
Cc:     netdev@...r.kernel.org, Maxim Mikityanskiy <maximmi@...dia.com>,
        Tariq Toukan <tariqt@...dia.com>,
        Saeed Mahameed <saeedm@...dia.com>
Subject: [net-next 04/16] net/mlx5e: Allocate the array of channels according to the real max_nch

From: Maxim Mikityanskiy <maximmi@...dia.com>

The channels array in struct mlx5e_rx_res is converted to a dynamic one,
which will use the dynamic value of max_nch instead of
implementation-defined maximum of MLX5E_MAX_NUM_CHANNELS.

Signed-off-by: Maxim Mikityanskiy <maximmi@...dia.com>
Reviewed-by: Tariq Toukan <tariqt@...dia.com>
Signed-off-by: Saeed Mahameed <saeedm@...dia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en.h        |  1 +
 drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c | 12 +++++++++++-
 drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h |  2 --
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 968e6a473cec..594b7971caf9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -140,6 +140,7 @@ struct page_pool;
 #define MLX5E_PARAMS_DEFAULT_MIN_RX_WQES_MPW            0x2
 
 #define MLX5E_MIN_NUM_CHANNELS         0x1
+#define MLX5E_MAX_NUM_CHANNELS         (MLX5E_INDIR_RQT_SIZE / 2)
 #define MLX5E_MAX_NUM_SQS              (MLX5E_MAX_NUM_CHANNELS * MLX5E_MAX_NUM_TC)
 #define MLX5E_TX_CQ_POLL_BUDGET        128
 #define MLX5E_TX_XSK_POLL_BUDGET       64
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
index a6b3a9473405..751b2cdc3ec1 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c
@@ -91,7 +91,7 @@ struct mlx5e_rx_res {
 		struct mlx5e_tir direct_tir;
 		struct mlx5e_rqt xsk_rqt;
 		struct mlx5e_tir xsk_tir;
-	} channels[MLX5E_MAX_NUM_CHANNELS];
+	} *channels;
 
 	struct {
 		struct mlx5e_rqt rqt;
@@ -210,6 +210,12 @@ static int mlx5e_rx_res_channels_init(struct mlx5e_rx_res *res,
 	if (!builder)
 		return -ENOMEM;
 
+	res->channels = kvcalloc(res->max_nch, sizeof(*res->channels), GFP_KERNEL);
+	if (!res->channels) {
+		err = -ENOMEM;
+		goto out;
+	}
+
 	for (ix = 0; ix < res->max_nch; ix++) {
 		err = mlx5e_rqt_init_direct(&res->channels[ix].direct_rqt,
 					    res->mdev, false, res->drop_rqn);
@@ -288,6 +294,8 @@ static int mlx5e_rx_res_channels_init(struct mlx5e_rx_res *res,
 	while (--ix >= 0)
 		mlx5e_rqt_destroy(&res->channels[ix].direct_rqt);
 
+	kvfree(res->channels);
+
 out:
 	mlx5e_tir_builder_free(builder);
 
@@ -355,6 +363,8 @@ static void mlx5e_rx_res_channels_destroy(struct mlx5e_rx_res *res)
 		mlx5e_tir_destroy(&res->channels[ix].xsk_tir);
 		mlx5e_rqt_destroy(&res->channels[ix].xsk_rqt);
 	}
+
+	kvfree(res->channels);
 }
 
 static void mlx5e_rx_res_ptp_destroy(struct mlx5e_rx_res *res)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h
index 0092ee80a2cf..934e41a0761f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h
@@ -9,8 +9,6 @@
 #include "tir.h"
 #include "fs.h"
 
-#define MLX5E_MAX_NUM_CHANNELS (MLX5E_INDIR_RQT_SIZE / 2)
-
 struct mlx5e_rx_res;
 
 struct mlx5e_channels;
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ