From: "Nabil S. Alramli" <dev@nalramli.com>
To: netdev@vger.kernel.org, saeedm@nvidia.com, saeed@kernel.org,
kuba@kernel.org, davem@davemloft.net, tariqt@nvidia.com,
linux-kernel@vger.kernel.org, leon@kernel.org
Cc: jdamato@fastly.com, sbhogavilli@fastly.com, nalramli@fastly.com,
"Nabil S. Alramli" <dev@nalramli.com>
Subject: [net-next RFC v2 1/4] mlx5: Add mlx5e_param to individual mlx5e_channel and preserve them through mlx5e_open_channels()
Date: Mon, 18 Sep 2023 18:29:52 -0400 [thread overview]
Message-ID: <20230918222955.2066-2-dev@nalramli.com> (raw)
In-Reply-To: <20230918222955.2066-1-dev@nalramli.com>
The mlx-5 driver currently has one global `struct mlx5e_param` for storing
settings including coalescing ones which means that individual channels
cannot have their own independent settings. This patch adds a
`struct mlx5e_param` to each `struct mlx5e_channel`. The global settings
have been preserved as well to continue to support global commands.
Signed-off-by: Nabil S. Alramli <dev@nalramli.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en.h | 3 +-
.../net/ethernet/mellanox/mlx5/core/en_main.c | 34 ++++++++++++++-----
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 86f2690c5e01..3657839b88f8 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -783,6 +783,7 @@ struct mlx5e_channel {
DECLARE_BITMAP(state, MLX5E_CHANNEL_NUM_STATES);
int ix;
int cpu;
+ struct mlx5e_params params; /* channel specific params */
/* Sync between icosq recovery and XSK enable/disable. */
struct mutex icosq_recovery_lock;
};
@@ -793,7 +794,7 @@ struct mlx5e_channels {
struct mlx5e_channel **c;
struct mlx5e_ptp *ptp;
unsigned int num;
- struct mlx5e_params params;
+ struct mlx5e_params params; /* global params */
};
struct mlx5e_channel_stats {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index a2ae791538ed..a1578219187b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2471,6 +2471,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
c->tstamp = &priv->tstamp;
c->ix = ix;
c->cpu = cpu;
+ c->params = *params;
c->pdev = mlx5_core_dma_dev(priv->mdev);
c->netdev = priv->netdev;
c->mkey_be = cpu_to_be32(priv->mdev->mlx5e_res.hw_objs.mkey);
@@ -2558,27 +2559,42 @@ int mlx5e_open_channels(struct mlx5e_priv *priv,
struct mlx5e_channels *chs)
{
struct mlx5e_channel_param *cparam;
+ bool use_global_params = true;
int err = -ENOMEM;
int i;
chs->num = chs->params.num_channels;
+ /* This check is necessary here in case chs == priv->channels because the allocation of
+ * chs->c will invalidate it
+ */
+ if (priv->channels.c)
+ use_global_params = false;
+
chs->c = kcalloc(chs->num, sizeof(struct mlx5e_channel *), GFP_KERNEL);
- cparam = kvzalloc(sizeof(struct mlx5e_channel_param), GFP_KERNEL);
+ cparam = kvmalloc(sizeof(*cparam), GFP_KERNEL);
if (!chs->c || !cparam)
goto err_free;
- err = mlx5e_build_channel_param(priv->mdev, &chs->params, priv->q_counter, cparam);
- if (err)
- goto err_free;
-
for (i = 0; i < chs->num; i++) {
struct xsk_buff_pool *xsk_pool = NULL;
+ struct mlx5e_params *params = NULL;
+
+ /* If priv->channels.c is not NULL, then retain the original params */
+ if (use_global_params)
+ params = &chs->params;
+ else
+ params = &priv->channels.c[i]->params;
+
+ memset(cparam, 0, sizeof(*cparam));
+ err = mlx5e_build_channel_param(priv->mdev, params, priv->q_counter, cparam);
+ if (err)
+ goto err_free;
- if (chs->params.xdp_prog)
- xsk_pool = mlx5e_xsk_get_pool(&chs->params, chs->params.xsk, i);
+ if (params->xdp_prog)
+ xsk_pool = mlx5e_xsk_get_pool(params, params->xsk, i);
- err = mlx5e_open_channel(priv, i, &chs->params, cparam, xsk_pool, &chs->c[i]);
+ err = mlx5e_open_channel(priv, i, params, cparam, xsk_pool, &chs->c[i]);
if (err)
goto err_close_channels;
}
@@ -3115,6 +3131,7 @@ int mlx5e_open_locked(struct net_device *netdev)
set_bit(MLX5E_STATE_OPENED, &priv->state);
+ priv->channels.c = NULL;
err = mlx5e_open_channels(priv, &priv->channels);
if (err)
goto err_clear_state_opened_flag;
@@ -5611,6 +5628,7 @@ int mlx5e_priv_init(struct mlx5e_priv *priv,
priv->netdev = netdev;
priv->max_nch = nch;
priv->max_opened_tc = 1;
+ priv->channels.c = NULL;
if (!alloc_cpumask_var(&priv->scratchpad.cpumask, GFP_KERNEL))
return -ENOMEM;
--
2.35.1
next prev parent reply other threads:[~2023-09-18 22:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 22:31 [net-next RFC 0/1] mlx5: support per queue coalesce settings Nabil S. Alramli
2023-08-23 22:31 ` [net-next RFC 1/1] mlx5: Add {get,set}_per_queue_coalesce() Nabil S. Alramli
2023-08-24 18:51 ` [net-next RFC 0/1] mlx5: support per queue coalesce settings Saeed Mahameed
2023-08-25 0:26 ` Nabil S. Alramli
2023-09-18 22:29 ` [net-next RFC v2 0/4] " Nabil S. Alramli
2023-09-18 22:29 ` Nabil S. Alramli [this message]
2023-09-18 22:29 ` [net-next RFC v2 2/4] mlx5: Add queue number parameter to mlx5e_safe_switch_params() Nabil S. Alramli
2023-09-18 22:29 ` [net-next RFC v2 3/4] mlx5: Implement mlx5e_ethtool_{get,set}_per_queue_coalesce() to support per-queue operations Nabil S. Alramli
2023-09-18 22:29 ` [net-next RFC v2 4/4] mlx5: Add {get,set}_per_queue_coalesce() Nabil S. Alramli
2023-09-19 18:55 ` [net-next RFC v2 0/4] mlx5: support per queue coalesce settings Rahul Rameshbabu
2023-09-19 20:42 ` Nabil S. Alramli
2023-10-06 21:46 ` Rahul Rameshbabu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230918222955.2066-2-dev@nalramli.com \
--to=dev@nalramli.com \
--cc=davem@davemloft.net \
--cc=jdamato@fastly.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nalramli@fastly.com \
--cc=netdev@vger.kernel.org \
--cc=saeed@kernel.org \
--cc=saeedm@nvidia.com \
--cc=sbhogavilli@fastly.com \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).