From: Joe Damato <jdamato@fastly.com>
To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: nalramli@fastly.com, Joe Damato <jdamato@fastly.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Tariq Toukan <tariqt@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-rdma@vger.kernel.org (open list:MELLANOX MLX5 core VPI
driver)
Subject: [RFC net-next v3 1/2] net/mlx5e: Add helpers to calculate txq and ch idx
Date: Wed, 29 May 2024 03:16:26 +0000 [thread overview]
Message-ID: <20240529031628.324117-2-jdamato@fastly.com> (raw)
In-Reply-To: <20240529031628.324117-1-jdamato@fastly.com>
Add two helpers to:
1. Compute the txq_ix given a channel and a tc offset (tc_to_txq_ix).
2. Compute the channel index and tc offset given a txq_ix
(txq_ix_to_chtc_ix).
The first helper, tc_to_txq_ix, is used in place of the mathematical
expressionin mlx5e_open_sqs when txq_ix values are computed.
The second helper, txq_ix_to_chtc_ix, will be used in a following patch.
Signed-off-by: Joe Damato <jdamato@fastly.com>
---
.../net/ethernet/mellanox/mlx5/core/en_main.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index b758bc72ac36..ce15805ad55a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2312,6 +2312,22 @@ static int mlx5e_txq_get_qos_node_hw_id(struct mlx5e_params *params, int txq_ix,
return 0;
}
+static inline int tc_to_txq_ix(struct mlx5e_channel *c,
+ struct mlx5e_params *params,
+ int tc)
+{
+ return c->ix + tc * params->num_channels;
+}
+
+static inline void txq_ix_to_chtc_ix(struct mlx5e_params *params, int txq_ix,
+ int *ch_ix, int *tc_ix)
+{
+ if (params->num_channels) {
+ *ch_ix = txq_ix % params->num_channels;
+ *tc_ix = txq_ix / params->num_channels;
+ }
+}
+
static int mlx5e_open_sqs(struct mlx5e_channel *c,
struct mlx5e_params *params,
struct mlx5e_channel_param *cparam)
@@ -2319,7 +2335,7 @@ static int mlx5e_open_sqs(struct mlx5e_channel *c,
int err, tc;
for (tc = 0; tc < mlx5e_get_dcb_num_tc(params); tc++) {
- int txq_ix = c->ix + tc * params->num_channels;
+ int txq_ix = tc_to_txq_ix(c, params, tc);
u32 qos_queue_group_id;
u32 tisn;
--
2.25.1
next prev parent reply other threads:[~2024-05-29 3:20 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 3:16 [RFC net-next v3 0/2] mlx5: Add netdev-genl queue stats Joe Damato
2024-05-29 3:16 ` Joe Damato [this message]
2024-05-30 21:15 ` [RFC net-next v3 1/2] net/mlx5e: Add helpers to calculate txq and ch idx Jacob Keller
2024-06-01 11:35 ` Simon Horman
2024-06-01 11:39 ` Simon Horman
2024-06-02 19:23 ` Joe Damato
2024-05-29 3:16 ` [RFC net-next v3 2/2] net/mlx5e: Add per queue netdev-genl stats Joe Damato
2024-05-30 21:16 ` Jacob Keller
2024-06-02 9:14 ` Tariq Toukan
2024-06-02 19:22 ` Joe Damato
2024-06-03 11:11 ` Tariq Toukan
2024-06-03 18:11 ` Joe Damato
2024-06-03 19:22 ` Joe Damato
2024-06-03 21:36 ` Tariq Toukan
2024-06-03 21:50 ` Joe Damato
2024-05-31 0:11 ` [RFC net-next v3 0/2] mlx5: Add netdev-genl queue stats Jakub Kicinski
2024-05-31 0:15 ` Joe Damato
2024-05-31 0:39 ` Jakub Kicinski
2024-05-31 0:56 ` Joe Damato
2024-05-31 1:07 ` Joe Damato
2024-05-31 1:26 ` Jakub Kicinski
2024-05-31 18:30 ` Joe Damato
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=20240529031628.324117-2-jdamato@fastly.com \
--to=jdamato@fastly.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=nalramli@fastly.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.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