All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Saeed Mahameed <saeedm@mellanox.com>
Subject: [net-next 5/8] net/mlx5e: Calc vlan_tag_present only once on xmit
Date: Tue, 31 Jan 2017 22:58:40 +0200	[thread overview]
Message-ID: <20170131205843.23235-6-saeedm@mellanox.com> (raw)
In-Reply-To: <20170131205843.23235-1-saeedm@mellanox.com>

Cache skb_vlan_tag_present(skb) and pass it wherever needed in xmit
routines.

Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_tx.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
index 678c07c8fbb0..ac76fb4f5510 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
@@ -148,15 +148,16 @@ static inline int mlx5e_skb_l3_header_offset(struct sk_buff *skb)
 		return mlx5e_skb_l2_header_offset(skb);
 }
 
-static inline unsigned int mlx5e_calc_min_inline(enum mlx5_inline_modes mode,
-						 struct sk_buff *skb)
+static inline unsigned int
+mlx5e_calc_min_inline(enum mlx5_inline_modes mode, struct sk_buff *skb,
+		      bool vlan_present)
 {
 	int hlen;
 
 	switch (mode) {
 	case MLX5_INLINE_MODE_TCP_UDP:
 		hlen = eth_get_headlen(skb->data, skb_headlen(skb));
-		if (hlen == ETH_HLEN && !skb_vlan_tag_present(skb))
+		if (hlen == ETH_HLEN && !vlan_present)
 			hlen += VLAN_HLEN;
 		return hlen;
 	case MLX5_INLINE_MODE_IP:
@@ -174,7 +175,8 @@ static inline unsigned int mlx5e_calc_min_inline(enum mlx5_inline_modes mode,
 }
 
 static inline u16 mlx5e_get_inline_hdr_size(struct mlx5e_sq *sq,
-					    struct sk_buff *skb, bool bf)
+					    struct sk_buff *skb,
+					    bool vlan_present, bool bf)
 {
 	/* Some NIC TX decisions, e.g loopback, are based on the packet
 	 * headers and occur before the data gather.
@@ -183,13 +185,13 @@ static inline u16 mlx5e_get_inline_hdr_size(struct mlx5e_sq *sq,
 	if (bf) {
 		u16 ihs = skb_headlen(skb);
 
-		if (skb_vlan_tag_present(skb))
+		if (vlan_present)
 			ihs += VLAN_HLEN;
 
 		if (ihs <= sq->max_inline)
 			return skb_headlen(skb);
 	}
-	return mlx5e_calc_min_inline(sq->min_inline_mode, skb);
+	return mlx5e_calc_min_inline(sq->min_inline_mode, skb, vlan_present);
 }
 
 static inline void mlx5e_tx_skb_pull_inline(unsigned char **skb_data,
@@ -228,6 +230,7 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
 	struct mlx5_wqe_eth_seg  *eseg = &wqe->eth;
 	struct mlx5_wqe_data_seg *dseg;
 
+	bool vlan_present = skb_vlan_tag_present(skb);
 	unsigned char *skb_data = skb->data;
 	unsigned int skb_len = skb->len;
 	u8  opcode = MLX5_OPCODE_SEND;
@@ -277,15 +280,14 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
 		bf = sq->bf_budget &&
 		     !skb->xmit_more &&
 		     !skb_shinfo(skb)->nr_frags;
-		ihs = mlx5e_get_inline_hdr_size(sq, skb, bf);
+		ihs = mlx5e_get_inline_hdr_size(sq, skb, vlan_present, bf);
 		num_bytes = max_t(unsigned int, skb->len, ETH_ZLEN);
 	}
 
 	wi->num_bytes = num_bytes;
 
-	if (skb_vlan_tag_present(skb)) {
-		mlx5e_insert_vlan(eseg->inline_hdr.start, skb, ihs, &skb_data,
-				  &skb_len);
+	if (vlan_present) {
+		mlx5e_insert_vlan(eseg->inline_hdr.start, skb, ihs, &skb_data, &skb_len);
 		ihs += VLAN_HLEN;
 	} else {
 		memcpy(eseg->inline_hdr.start, skb_data, ihs);
-- 
2.11.0

  parent reply	other threads:[~2017-01-31 21:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 20:58 [pull request][net-next 0/8] Mellanox mlx5 updates 2017-01-31 Saeed Mahameed
2017-01-31 20:58 ` [net-next 1/8] net/mlx5: Fixed static checker warnings Saeed Mahameed
2017-02-01 11:17   ` David Laight
2017-02-01 16:39     ` Or Gerlitz
2017-02-01 17:02       ` David Laight
2017-02-01 17:22   ` David Miller
2017-02-01 23:48     ` Or Gerlitz
2017-01-31 20:58 ` [net-next 2/8] net/mlx5: Configure cache line size for start and end padding Saeed Mahameed
2017-02-01 11:12   ` David Laight
2017-02-02 14:47     ` Daniel Jurgens
2017-02-05 11:23       ` Saeed Mahameed
2017-02-06 13:50         ` David Laight
2017-02-06 14:26           ` Saeed Mahameed
2017-01-31 20:58 ` [net-next 3/8] net/mlx5e: Lower bound MPWRQ stride by HCA cacheline Saeed Mahameed
2017-01-31 20:58 ` [net-next 4/8] net/mlx5: TX WQE update Saeed Mahameed
2017-01-31 20:58 ` Saeed Mahameed [this message]
2017-02-01 11:20   ` [net-next 5/8] net/mlx5e: Calc vlan_tag_present only once on xmit David Laight
2017-02-05 11:22     ` Saeed Mahameed
2017-01-31 20:58 ` [net-next 6/8] net/mlx5e: Tx, no inline copy on ConnectX-5 Saeed Mahameed
2017-01-31 20:58 ` [net-next 7/8] net/mlx5e: XDP " Saeed Mahameed
2017-01-31 20:58 ` [net-next 8/8] net/mlx5e: Bring back bfreg uar map dedicated pointer 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=20170131205843.23235-6-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=davem@davemloft.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.