From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F3982A034F; Mon, 22 Mar 2021 16:46:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D3958140D60; Mon, 22 Mar 2021 16:46:26 +0100 (CET) Received: from m12-13.163.com (m12-13.163.com [220.181.12.13]) by mails.dpdk.org (Postfix) with ESMTP id 4EB5F4003D for ; Mon, 22 Mar 2021 16:46:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=I2EWjoOUfwml9+sB0g 4+bqR9d6NGr7UVbw7G03YmziE=; b=UPpkErzTaCnOcKGyZCKaObhlftKlglLtTS 47Dk/hRBqFcexNpnIEKw84MHIc4Jn8ZePmxN+fQDXUYB4HON4jocKhlVQF1tW6KU 650HJtLRGzUFgGlYS2Fbl/WMZeLvBQR4hMQrUUfa/qJ21iWH1fPlIicbrzAxEKYG VLpJ7bggQ= Received: from localhost.localdomain.localdomain (unknown [120.234.130.205]) by smtp9 (Coremail) with SMTP id DcCowADnfM3Iu1hgWSjtCQ--.4849S2; Mon, 22 Mar 2021 23:46:18 +0800 (CST) From: Jiawei Zhu <17826875952@163.com> To: dev@dpdk.org Cc: zhujiawei12@huawei.com, matan@nvidia.com, shahafs@nvidia.com, viacheslavo@nvidia.com Date: Mon, 22 Mar 2021 11:46:06 -0400 Message-Id: <1616427966-3481-1-git-send-email-17826875952@163.com> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: DcCowADnfM3Iu1hgWSjtCQ--.4849S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7trW8trWrGF15ur4kGF4UJwb_yoW8Cr4rpF 4akry3XFyUJFW5Ww4Iva1ru3y5G39ayrWj9ry7twn8Wr9rWa4UWryrGayfZryDKFZ7CFyU tF4qywnxGF95XFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j1mhwUUUUU= X-Originating-IP: [120.234.130.205] X-CM-SenderInfo: bprxmjywyxkmivs6il2tof0z/1tbiEQpd9l7+3RFBAQAAsc Subject: [dpdk-dev] [PATCH] net/mlx5: add Rx checksum offload flag return bad X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jiawei Zhu 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 --- drivers/net/mlx5/mlx5_rxtx.c | 17 ++++++++++------- drivers/net/mlx5/mlx5_utils.h | 6 ------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index e3ce9fd..9233af8 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_IP_CKSUM_GOOD; + else + ol_flags |= PKT_RX_IP_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 -- 1.8.3.1