DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yongseok Koh <yskoh@mellanox.com>
To: shahafs@mellanox.com, adrien.mazarguil@6wind.com,
	nelio.laranjeiro@6wind.com
Cc: dev@dpdk.org, Yongseok Koh <yskoh@mellanox.com>
Subject: [dpdk-dev] [PATCH v3 1/2] net/mlx5: fix setting offsets for SW parser
Date: Tue, 22 May 2018 01:59:42 -0700	[thread overview]
Message-ID: <20180522085943.15574-1-yskoh@mellanox.com> (raw)

Since ConnectX-5, SW parser just complements HW parser. SW parser starts to
engage only if HW parser can't reach a header. For the older devices, HW
parser will not kick in if any of SWP offsets is set. Therefore, all of the
L3 offsets should be set regardless of HW offload. As IPv6 doesn't have
header checksum, the mbuf can't have PKT_TX_[OUTER_]IP_CKSUM if outer or
inner L3 is IPv6.

And if inner packet isn't IP, the inner offsets shouldn't be set.

Fixes: 5f8ba81c4228 ("net/mlx5: support generic tunnel offloading")

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Acked-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxtx.h | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_rxtx.h b/drivers/net/mlx5/mlx5_rxtx.h
index a6017f0dd..1e4b2fdb9 100644
--- a/drivers/net/mlx5/mlx5_rxtx.h
+++ b/drivers/net/mlx5/mlx5_rxtx.h
@@ -655,10 +655,13 @@ txq_mbuf_to_swp(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
 		 uint8_t *offsets, uint8_t *swp_types)
 {
 	uint64_t tunnel = buf->ol_flags & PKT_TX_TUNNEL_MASK;
-	uint16_t idx;
-	uint16_t off;
+	const uint64_t csum_flags = buf->ol_flags & PKT_TX_L4_MASK;
+	const uint64_t inner_ip =
+		buf->ol_flags & (PKT_TX_IPV4 | PKT_TX_IPV6);
 	const uint64_t ol_flags_mask = PKT_TX_L4_MASK | PKT_TX_IPV6 |
 				       PKT_TX_OUTER_IPV6;
+	uint16_t idx;
+	uint16_t off;
 
 	if (likely(!tunnel || !txq->swp_en ||
 		   (tunnel != PKT_TX_TUNNEL_UDP && tunnel != PKT_TX_TUNNEL_IP)))
@@ -674,20 +677,28 @@ txq_mbuf_to_swp(struct mlx5_txq_data *txq, struct rte_mbuf *buf,
 	if (tunnel == PKT_TX_TUNNEL_UDP)
 		idx |= 1 << 9;
 	*swp_types = mlx5_swp_types_table[idx];
-	/* swp offsets. */
-	off = buf->outer_l2_len + (vlan ? 4 : 0); /* Outer L3 offset. */
-	if (tso || (buf->ol_flags & PKT_TX_OUTER_IP_CKSUM))
-		offsets[1] = off >> 1;
-	off += buf->outer_l3_len; /* Outer L4 offset. */
-	if (tunnel == PKT_TX_TUNNEL_UDP)
-		offsets[0] = off >> 1;
-	off += buf->l2_len; /* Inner L3 offset. */
-	if (tso || (buf->ol_flags & PKT_TX_IP_CKSUM))
-		offsets[3] = off >> 1;
-	off += buf->l3_len; /* Inner L4 offset. */
-	if (tso || ((buf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM) ||
-	    ((buf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM))
-		offsets[2] = off >> 1;
+	/*
+	 * Set offsets for SW parser. Since ConnectX-5, SW parser just
+	 * complements HW parser. SW parser starts to engage only if HW parser
+	 * can't reach a header. For the older devices, HW parser will not kick
+	 * in if any of SWP offsets is set. Therefore, all of the L3 offsets
+	 * should be set regardless of HW offload.
+	 */
+	off = buf->outer_l2_len + (vlan ? 4 : 0);
+	offsets[1] = off >> 1; /* Outer L3 offset. */
+	if (tunnel == PKT_TX_TUNNEL_UDP) {
+		off += buf->outer_l3_len;
+		offsets[0] = off >> 1; /* Outer L4 offset. */
+	}
+	if (inner_ip) {
+		off += buf->l2_len;
+		offsets[3] = off >> 1; /* Inner L3 offset. */
+		if (csum_flags == PKT_TX_TCP_CKSUM || tso ||
+		    csum_flags == PKT_TX_UDP_CKSUM) {
+			off += buf->l3_len;
+			offsets[2] = off >> 1; /* Inner L4 offset. */
+		}
+	}
 }
 
 /**
-- 
2.11.0

             reply	other threads:[~2018-05-22  8:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22  8:59 Yongseok Koh [this message]
2018-05-22  8:59 ` [dpdk-dev] [PATCH v3 2/2] net/mlx5: remove redundant checks Yongseok Koh
2018-05-22 14:16 ` [dpdk-dev] [PATCH v3 1/2] net/mlx5: fix setting offsets for SW parser Shahaf Shuler

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=20180522085943.15574-1-yskoh@mellanox.com \
    --to=yskoh@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=nelio.laranjeiro@6wind.com \
    --cc=shahafs@mellanox.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).