netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@nvidia.com>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: <netdev@vger.kernel.org>,
	Maxim Mikityanskiy <maximmi@mellanox.com>,
	"Saeed Mahameed" <saeedm@nvidia.com>
Subject: [net-next 01/10] net/mlx5e: Refactor inline header size calculation in the TX path
Date: Thu, 3 Sep 2020 14:00:13 -0700	[thread overview]
Message-ID: <20200903210022.22774-2-saeedm@nvidia.com> (raw)
In-Reply-To: <20200903210022.22774-1-saeedm@nvidia.com>

From: Maxim Mikityanskiy <maximmi@mellanox.com>

As preparation for the next patch, don't increase ihs to calculate
ds_cnt and then decrease it, but rather calculate the intermediate value
temporarily. This code has the same amount of arithmetic operations, but
now allows to split out ds_cnt calculation, which will be performed in
the next patch.

Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index da596de3abba..e15aa53ff83e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -307,9 +307,9 @@ void mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
 	ds_cnt += skb_shinfo(skb)->nr_frags;
 
 	if (ihs) {
-		ihs += !!skb_vlan_tag_present(skb) * VLAN_HLEN;
+		u16 inl = ihs + !!skb_vlan_tag_present(skb) * VLAN_HLEN - INL_HDR_START_SZ;
 
-		ds_cnt_inl = DIV_ROUND_UP(ihs - INL_HDR_START_SZ, MLX5_SEND_WQE_DS);
+		ds_cnt_inl = DIV_ROUND_UP(inl, MLX5_SEND_WQE_DS);
 		ds_cnt += ds_cnt_inl;
 	}
 
@@ -348,12 +348,12 @@ void mlx5e_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb,
 	eseg->mss = mss;
 
 	if (ihs) {
-		eseg->inline_hdr.sz = cpu_to_be16(ihs);
 		if (skb_vlan_tag_present(skb)) {
-			ihs -= VLAN_HLEN;
+			eseg->inline_hdr.sz = cpu_to_be16(ihs + VLAN_HLEN);
 			mlx5e_insert_vlan(eseg->inline_hdr.start, skb, ihs);
 			stats->added_vlan_packets++;
 		} else {
+			eseg->inline_hdr.sz = cpu_to_be16(ihs);
 			memcpy(eseg->inline_hdr.start, skb->data, ihs);
 		}
 		dseg += ds_cnt_inl;
-- 
2.26.2


  reply	other threads:[~2020-09-03 21:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 21:00 [pull request][net-next 00/10] mlx5 Multi packet tx descriptors for SKBs Saeed Mahameed
2020-09-03 21:00 ` Saeed Mahameed [this message]
2020-09-03 21:00 ` [net-next 02/10] net/mlx5e: Refactor xmit functions Saeed Mahameed
2020-09-04 15:27   ` Willem de Bruijn
2020-09-08  8:58     ` Maxim Mikityanskiy
2020-09-08  9:08       ` Willem de Bruijn
2020-09-03 21:00 ` [net-next 03/10] net/mlx5e: Small improvements for XDP TX MPWQE logic Saeed Mahameed
2020-09-03 21:00 ` [net-next 04/10] net/mlx5e: Unify constants for WQE_EMPTY_DS_COUNT Saeed Mahameed
2020-09-04 15:05   ` Willem de Bruijn
2020-09-08  8:59     ` Maxim Mikityanskiy
2020-09-08  9:06       ` Willem de Bruijn
2020-09-03 21:00 ` [net-next 05/10] net/mlx5e: Move the TLS resync check out of the function Saeed Mahameed
2020-09-03 21:00 ` [net-next 06/10] net/mlx5e: Support multiple SKBs in a TX WQE Saeed Mahameed
2020-09-03 22:46   ` Jakub Kicinski
2020-09-08  8:59     ` Maxim Mikityanskiy
2020-09-08 18:07       ` Jakub Kicinski
2020-09-03 21:00 ` [net-next 07/10] net/mlx5e: Generalize TX MPWQE checks for full session Saeed Mahameed
2020-09-03 21:00 ` [net-next 08/10] net/mlx5e: Rename xmit-related structs to generalize them Saeed Mahameed
2020-09-03 21:00 ` [net-next 09/10] net/mlx5e: Move TX code into functions to be used by MPWQE Saeed Mahameed
2020-09-04 15:06   ` Willem de Bruijn
2020-09-08  8:59     ` Maxim Mikityanskiy
2020-09-08  9:04       ` Willem de Bruijn
2020-09-03 21:00 ` [net-next 10/10] net/mlx5e: Enhanced TX MPWQE for SKBs Saeed Mahameed

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=20200903210022.22774-2-saeedm@nvidia.com \
    --to=saeedm@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=maximmi@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /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).