From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 09EFE430E4;
	Wed, 23 Aug 2023 18:01:59 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 6E85D43036;
	Wed, 23 Aug 2023 18:01:54 +0200 (CEST)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.133.124])
 by mails.dpdk.org (Postfix) with ESMTP id B05854161A
 for <dev@dpdk.org>; Wed, 23 Aug 2023 18:01:52 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1692806512;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=GsZ5wYmN/N7qUwp7+/SA9quw0Wbx/4/jVZEKUZm9xxQ=;
 b=IBJOhJ506LDClyo/UOpMeMG4ykVos3xi6HeQAdyV4Z8r4ZoaGxK+ayhgvM75nIKkfV/nwC
 Tthr91g96PE/v5fDgYxPJVCmkM+MHWbThS7UF7c2LDv20oaGrvlTRNeuQxDHdL+Nyec5LW
 b3tAQdt+wfXkuSgiJwt63SHHw3AErQs=
Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by
 relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 us-mta-120-SlChiIDJOPyKOyBgf7suWg-1; Wed, 23 Aug 2023 12:01:48 -0400
X-MC-Unique: SlChiIDJOPyKOyBgf7suWg-1
Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com
 [10.11.54.8])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C649A1C09A55;
 Wed, 23 Aug 2023 16:01:47 +0000 (UTC)
Received: from dmarchan.redhat.com (unknown [10.45.225.147])
 by smtp.corp.redhat.com (Postfix) with ESMTP id 37E10C15BAE;
 Wed, 23 Aug 2023 16:01:47 +0000 (UTC)
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: olivier.matz@6wind.com
Subject: [PATCH v2 2/3] net/tap: fix IPv4 checksum offloading
Date: Wed, 23 Aug 2023 18:01:37 +0200
Message-ID: <20230823160138.291980-2-david.marchand@redhat.com>
In-Reply-To: <20230823160138.291980-1-david.marchand@redhat.com>
References: <20230822073244.3751885-1-david.marchand@redhat.com>
 <20230823160138.291980-1-david.marchand@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="US-ASCII"; x-default=true
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Checking that one of RTE_MBUF_F_TX_IPV4 or RTE_MBUF_F_TX_IP_CKSUM is
present is not compliant with the offloading API which specifies that IP
checksum requires RTE_MBUF_F_TX_IP_CKSUM.
On the other hand, RTE_MBUF_F_TX_IP_CKSUM is invalid for IPv6 packets,
so we can simply check for RTE_MBUF_F_TX_IP_CKSUM and assume this is an
IPv4 packet.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/tap/rte_eth_tap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 0ab214847a..30b45ddc67 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -559,7 +559,7 @@ tap_tx_l3_cksum(char *packet, uint64_t ol_flags, unsigned int l2_len,
 {
 	void *l3_hdr = packet + l2_len;
 
-	if (ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4)) {
+	if (ol_flags & RTE_MBUF_F_TX_IP_CKSUM) {
 		struct rte_ipv4_hdr *iph = l3_hdr;
 		uint16_t cksum;
 
@@ -642,7 +642,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
 
 		nb_segs = mbuf->nb_segs;
 		if (txq->csum &&
-		    ((mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4) ||
+		    ((mbuf->ol_flags & RTE_MBUF_F_TX_IP_CKSUM ||
 		      (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM ||
 		      (mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM))) {
 			unsigned int l4_len = 0;
-- 
2.41.0