DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tal Shnaiderman <talshn@nvidia.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <matan@nvidia.com>, <rasland@nvidia.com>,
	<asafp@nvidia.com>, <viacheslavo@nvidia.com>, <eilong@nvidia.com>,
	<kcollins@nvidia.com>, <idanhac@nvidia.com>, <stable@dpdk.org>
Subject: [dpdk-dev] [RFC PATCH 01/12] net/mlx5: fix software parsing support query
Date: Wed, 15 Sep 2021 13:43:37 +0300	[thread overview]
Message-ID: <20210915104348.12920-2-talshn@nvidia.com> (raw)
In-Reply-To: <20210915104348.12920-1-talshn@nvidia.com>

Currently, the PMD decides if the software parsing
offload can enable outer IPv4 checksum and tunneled
TSO support by checking config->hw_csum and config->tso
respectively.

This is incorrect, the right way is to check the following
flags returned by the mlx5dv_query_device function:

MLX5DV_SW_PARSING - check general swp support.
MLX5DV_SW_PARSING_CSUM - check swp checksum support.
MLX5DV_SW_PARSING_LSO - check swp LSO/TSO support.

The fix enables the offloads according to the correct
flags returned by the kernel.

Fixes: e46821e9fcdc60 ("net/mlx5: separate generic tunnel TSO from the standard one")
Cc: stable@dpdk.org

Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_os.c |  3 ++-
 drivers/net/mlx5/linux/mlx5_os.h | 12 ++++++++++++
 drivers/net/mlx5/mlx5.h          |  2 +-
 drivers/net/mlx5/mlx5_txq.c      | 15 +++++++++------
 4 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 470b16cb9a..536b39ba9c 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -1112,7 +1112,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 		swp = dv_attr.sw_parsing_caps.sw_parsing_offloads;
 	DRV_LOG(DEBUG, "SWP support: %u", swp);
 #endif
-	config->swp = !!swp;
+	config->swp = swp & (MLX5_SW_PARSING_CAP | MLX5_SW_PARSING_CSUM_CAP |
+		MLX5_SW_PARSING_TSO_CAP);
 #ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
 	if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) {
 		struct mlx5dv_striding_rq_caps mprq_caps =
diff --git a/drivers/net/mlx5/linux/mlx5_os.h b/drivers/net/mlx5/linux/mlx5_os.h
index 2991d37df2..da036edb72 100644
--- a/drivers/net/mlx5/linux/mlx5_os.h
+++ b/drivers/net/mlx5/linux/mlx5_os.h
@@ -21,4 +21,16 @@ enum {
 
 int mlx5_auxiliary_get_ifindex(const char *sf_name);
 
+
+enum mlx5_sw_parsing_offloads {
+#ifdef HAVE_IBV_MLX5_MOD_SWP
+	MLX5_SW_PARSING_CAP      = MLX5DV_SW_PARSING,
+	MLX5_SW_PARSING_CSUM_CAP = MLX5DV_SW_PARSING_CSUM,
+	MLX5_SW_PARSING_TSO_CAP  = MLX5DV_SW_PARSING_LSO,
+#else
+	MLX5_SW_PARSING_CAP      = 0,
+	MLX5_SW_PARSING_CSUM_CAP = 0,
+	MLX5_SW_PARSING_TSO_CAP  = 0,
+#endif
+};
 #endif /* RTE_PMD_MLX5_OS_H_ */
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index e02714e231..a56f39cd5f 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -260,7 +260,7 @@ struct mlx5_dev_config {
 	unsigned int dv_xmeta_en:2; /* Enable extensive flow metadata. */
 	unsigned int lacp_by_user:1;
 	/* Enable user to manage LACP traffic. */
-	unsigned int swp:1; /* Tx generic tunnel checksum and TSO offload. */
+	unsigned int swp:3; /* Tx generic tunnel checksum and TSO offload. */
 	unsigned int devx:1; /* Whether devx interface is available or not. */
 	unsigned int dest_tir:1; /* Whether advanced DR API is available. */
 	unsigned int reclaim_mode:2; /* Memory reclaim mode. */
diff --git a/drivers/net/mlx5/mlx5_txq.c b/drivers/net/mlx5/mlx5_txq.c
index eb4d34ca55..8dca2b7f79 100644
--- a/drivers/net/mlx5/mlx5_txq.c
+++ b/drivers/net/mlx5/mlx5_txq.c
@@ -111,9 +111,9 @@ mlx5_get_tx_port_offloads(struct rte_eth_dev *dev)
 	if (config->tx_pp)
 		offloads |= DEV_TX_OFFLOAD_SEND_ON_TIMESTAMP;
 	if (config->swp) {
-		if (config->hw_csum)
+		if (config->swp & MLX5_SW_PARSING_CSUM_CAP)
 			offloads |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
-		if (config->tso)
+		if (config->swp & MLX5_SW_PARSING_TSO_CAP)
 			offloads |= (DEV_TX_OFFLOAD_IP_TNL_TSO |
 				     DEV_TX_OFFLOAD_UDP_TNL_TSO);
 	}
@@ -979,10 +979,13 @@ txq_set_params(struct mlx5_txq_ctrl *txq_ctrl)
 		txq_ctrl->txq.tso_en = 1;
 	}
 	txq_ctrl->txq.tunnel_en = config->tunnel_en | config->swp;
-	txq_ctrl->txq.swp_en = ((DEV_TX_OFFLOAD_IP_TNL_TSO |
-				 DEV_TX_OFFLOAD_UDP_TNL_TSO |
-				 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) &
-				txq_ctrl->txq.offloads) && config->swp;
+	txq_ctrl->txq.swp_en = (((DEV_TX_OFFLOAD_IP_TNL_TSO |
+				  DEV_TX_OFFLOAD_UDP_TNL_TSO) &
+				  txq_ctrl->txq.offloads) && (config->swp &
+				  MLX5_SW_PARSING_TSO_CAP)) |
+				((DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM &
+				 txq_ctrl->txq.offloads) && (config->swp &
+				 MLX5_SW_PARSING_CSUM_CAP));
 }
 
 /**
-- 
2.16.1.windows.4


  reply	other threads:[~2021-09-15 10:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 10:43 [dpdk-dev] [RFC PATCH 00/12] Expand NIC offloads support on Windows Tal Shnaiderman
2021-09-15 10:43 ` Tal Shnaiderman [this message]
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 02/12] common/mlx5: read software parsing capabilities from DevX Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 03/12] net/mlx5: query software parsing support on Windows Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 04/12] net/mlx5: fix tunneling support query Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 05/12] common/mlx5: read tunneling capabilities from DevX Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 06/12] net/mlx5: query tunneling support on Windows Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 07/12] common/mlx5: read TSO capability from DevX Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 08/12] net/mlx5: support TSO offload on Windows Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 09/12] common/mlx5: read VLAN capability from DevX Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 10/12] net/mlx5: support VLAN stripping offload on Windows Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 11/12] common/mlx5: read FCS scattering capability from DevX Tal Shnaiderman
2021-09-15 10:43 ` [dpdk-dev] [RFC PATCH 12/12] net/mlx5: support keep-CRC offload on Windows Tal Shnaiderman

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=20210915104348.12920-2-talshn@nvidia.com \
    --to=talshn@nvidia.com \
    --cc=asafp@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=eilong@nvidia.com \
    --cc=idanhac@nvidia.com \
    --cc=kcollins@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=rasland@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@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;
as well as URLs for NNTP newsgroup(s).