net/mlx5: add Rx checksum offload flag return bad

Message ID 1616430371-3810-1-git-send-email-17826875952@163.com (mailing list archive)
State Rejected, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: add Rx checksum offload flag return bad |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Jiawei Zhu March 22, 2021, 4:26 p.m. UTC
  From: Jiawei Zhu <zhujiawei12@huawei.com>

When open the rx checksum offload and receive the wrong checksum,
add the ol_flags return bad. And it's not best to use multiplication
and division here.

Signed-off-by: Jiawei Zhu <zhujiawei12@huawei.com>
---
 drivers/net/mlx5/mlx5_rxtx.c  | 17 ++++++++++-------
 drivers/net/mlx5/mlx5_utils.h |  6 ------
 2 files changed, 10 insertions(+), 13 deletions(-)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index e3ce9fd..dcc0ebc 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -1325,13 +1325,16 @@  enum mlx5_txcmp_code {
 	uint32_t ol_flags = 0;
 	uint16_t flags = rte_be_to_cpu_16(cqe->hdr_type_etc);
 
-	ol_flags =
-		TRANSPOSE(flags,
-			  MLX5_CQE_RX_L3_HDR_VALID,
-			  PKT_RX_IP_CKSUM_GOOD) |
-		TRANSPOSE(flags,
-			  MLX5_CQE_RX_L4_HDR_VALID,
-			  PKT_RX_L4_CKSUM_GOOD);
+	if (flags & MLX5_CQE_RX_L3_HDR_VALID)
+		ol_flags |= PKT_RX_IP_CKSUM_GOOD;
+	else
+		ol_flags |= PKT_RX_IP_CKSUM_BAD;
+
+	if (flags & MLX5_CQE_RX_L4_HDR_VALID)
+		ol_flags |= PKT_RX_L4_CKSUM_GOOD;
+	else
+		ol_flags |= PKT_RX_L4_CKSUM_BAD;
+
 	return ol_flags;
 }
 
diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h
index 7a62187..2f71a23 100644
--- a/drivers/net/mlx5/mlx5_utils.h
+++ b/drivers/net/mlx5/mlx5_utils.h
@@ -44,12 +44,6 @@ 
 #define NB_SEGS(m) ((m)->nb_segs)
 #define PORT(m) ((m)->port)
 
-/* Transpose flags. Useful to convert IBV to DPDK flags. */
-#define TRANSPOSE(val, from, to) \
-	(((from) >= (to)) ? \
-	 (((val) & (from)) / ((from) / (to))) : \
-	 (((val) & (from)) * ((to) / (from))))
-
 /*
  * For the case which data is linked with sequence increased index, the
  * array table will be more efficiect than hash table once need to serarch