DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
	Fei Qin <fei.qin@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 2/2] net/nfp: add support for VXLAN inner TSO with noudpcsum
Date: Fri,  3 Feb 2023 15:05:55 +0800	[thread overview]
Message-ID: <20230203070555.36199-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230203070555.36199-1-chaoyong.he@corigine.com>

From: Fei Qin <fei.qin@corigine.com>

The device doesn't support outer udp csum offload. Add the support
for VXLAN inner TSO with noudpcsum.

Signed-off-by: Fei Qin <fei.qin@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
---
 drivers/net/nfp/nfp_common.c |  8 ++++++--
 drivers/net/nfp/nfp_ethdev.c |  6 ++++--
 drivers/net/nfp/nfp_rxtx.c   | 13 +++++++++++++
 drivers/net/nfp/nfp_rxtx.h   | 15 +++++++++++++++
 4 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 4f21d9978d..ddf5f131dd 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -440,7 +440,8 @@ nfp_check_offloads(struct rte_eth_dev *dev)
 		ctrl |= NFP_NET_CFG_CTRL_TXCSUM;
 
 	/* LSO offload */
-	if (txmode->offloads & RTE_ETH_TX_OFFLOAD_TCP_TSO) {
+	if (txmode->offloads & RTE_ETH_TX_OFFLOAD_TCP_TSO ||
+	    txmode->offloads & RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO) {
 		if (hw->cap & NFP_NET_CFG_CTRL_LSO)
 			ctrl |= NFP_NET_CFG_CTRL_LSO;
 		else
@@ -881,8 +882,11 @@ nfp_net_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 					     RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
 					     RTE_ETH_TX_OFFLOAD_TCP_CKSUM;
 
-	if (hw->cap & NFP_NET_CFG_CTRL_LSO_ANY)
+	if (hw->cap & NFP_NET_CFG_CTRL_LSO_ANY) {
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_TCP_TSO;
+		if (hw->cap & NFP_NET_CFG_CTRL_VXLAN)
+			dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO;
+	}
 
 	if (hw->cap & NFP_NET_CFG_CTRL_GATHER)
 		dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 31201c0197..a0d12600a3 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -146,8 +146,10 @@ nfp_net_start(struct rte_eth_dev *dev)
 	update |= NFP_NET_CFG_UPDATE_GEN | NFP_NET_CFG_UPDATE_RING;
 
 	/* Enable vxlan */
-	new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
-	update |= NFP_NET_CFG_UPDATE_VXLAN;
+	if (hw->cap & NFP_NET_CFG_CTRL_VXLAN) {
+		new_ctrl |= NFP_NET_CFG_CTRL_VXLAN;
+		update |= NFP_NET_CFG_UPDATE_VXLAN;
+	}
 
 	if (hw->cap & NFP_NET_CFG_CTRL_RINGCFG)
 		new_ctrl |= NFP_NET_CFG_CTRL_RINGCFG;
diff --git a/drivers/net/nfp/nfp_rxtx.c b/drivers/net/nfp/nfp_rxtx.c
index 4a7574fd65..ca146d5cfe 100644
--- a/drivers/net/nfp/nfp_rxtx.c
+++ b/drivers/net/nfp/nfp_rxtx.c
@@ -1368,6 +1368,13 @@ nfp_net_nfdk_tx_cksum(struct nfp_net_txq *txq, struct rte_mbuf *mb,
 
 	ol_flags = mb->ol_flags;
 
+	/* Set TCP csum offload if TSO enabled. */
+	if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
+		flags |= NFDK_DESC_TX_L4_CSUM;
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		flags |= NFDK_DESC_TX_ENCAP;
+
 	/* IPv6 does not need checksum */
 	if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM)
 		flags |= NFDK_DESC_TX_L3_CSUM;
@@ -1400,6 +1407,12 @@ nfp_net_nfdk_tx_tso(struct nfp_net_txq *txq, struct rte_mbuf *mb)
 	txd.lso_hdrlen = mb->l2_len + mb->l3_len + mb->l4_len;
 	txd.lso_totsegs = (mb->pkt_len + mb->tso_segsz) / mb->tso_segsz;
 
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
+		txd.l3_offset += mb->outer_l2_len + mb->outer_l3_len;
+		txd.l4_offset += mb->outer_l2_len + mb->outer_l3_len;
+		txd.lso_hdrlen += mb->outer_l2_len + mb->outer_l3_len;
+	}
+
 	return txd.raw;
 
 clean_txd:
diff --git a/drivers/net/nfp/nfp_rxtx.h b/drivers/net/nfp/nfp_rxtx.h
index f9223b8912..c90bd13267 100644
--- a/drivers/net/nfp/nfp_rxtx.h
+++ b/drivers/net/nfp/nfp_rxtx.h
@@ -122,6 +122,7 @@ struct nfp_meta_parsed {
 #define NFDK_DESC_TX_TYPE_GATHER        1
 #define NFDK_DESC_TX_EOP                BIT(14)
 #define NFDK_DESC_TX_CHAIN_META         BIT(3)
+#define NFDK_DESC_TX_ENCAP              BIT(2)
 #define NFDK_DESC_TX_L4_CSUM            BIT(1)
 #define NFDK_DESC_TX_L3_CSUM            BIT(0)
 
@@ -468,6 +469,13 @@ nfp_net_nfd3_tx_tso(struct nfp_net_txq *txq,
 	txd->l3_offset = mb->l2_len;
 	txd->l4_offset = mb->l2_len + mb->l3_len;
 	txd->lso_hdrlen = mb->l2_len + mb->l3_len + mb->l4_len;
+
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
+		txd->l3_offset += mb->outer_l2_len + mb->outer_l3_len;
+		txd->l4_offset += mb->outer_l2_len + mb->outer_l3_len;
+		txd->lso_hdrlen += mb->outer_l2_len + mb->outer_l3_len;
+	}
+
 	txd->mss = rte_cpu_to_le_16(mb->tso_segsz);
 	txd->flags = PCIE_DESC_TX_LSO;
 	return;
@@ -493,10 +501,17 @@ nfp_net_nfd3_tx_cksum(struct nfp_net_txq *txq, struct nfp_net_nfd3_tx_desc *txd,
 
 	ol_flags = mb->ol_flags;
 
+	/* Set TCP csum offload if TSO enabled. */
+	if (ol_flags & RTE_MBUF_F_TX_TCP_SEG)
+		txd->flags |= PCIE_DESC_TX_TCP_CSUM;
+
 	/* IPv6 does not need checksum */
 	if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM)
 		txd->flags |= PCIE_DESC_TX_IP4_CSUM;
 
+	if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
+		txd->flags |= PCIE_DESC_TX_ENCAP;
+
 	switch (ol_flags & RTE_MBUF_F_TX_L4_MASK) {
 	case RTE_MBUF_F_TX_UDP_CKSUM:
 		txd->flags |= PCIE_DESC_TX_UDP_CSUM;
-- 
2.29.3


  parent reply	other threads:[~2023-02-03  7:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03  7:05 [PATCH 0/2] add VXLAN inner TSO with noudpcsum support for NFP cards Chaoyong He
2023-02-03  7:05 ` [PATCH 1/2] net/nfp: update macro definitions in Tx flag Chaoyong He
2023-02-03  7:05 ` Chaoyong He [this message]
2023-02-14 15:23 ` [PATCH 0/2] add VXLAN inner TSO with noudpcsum support for NFP cards Ferruh Yigit

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=20230203070555.36199-3-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=fei.qin@corigine.com \
    --cc=niklas.soderlund@corigine.com \
    --cc=oss-drivers@corigine.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).