From patchwork Tue Aug 22 07:32:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 130627 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EEEE1430CC; Tue, 22 Aug 2023 09:32:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D8F8410F1; Tue, 22 Aug 2023 09:32:51 +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 52D444021D for ; Tue, 22 Aug 2023 09:32:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692689569; 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; bh=OdNVvjyCE+i5Hx9NZqIMx0Yh+JvmeqaMY8f5SK/1Xno=; b=gpLpnJuX819+0jrXBKYK8EbMH+EUrIvJx6hSnOdip39qn3NyD1mDjX4zm4TL2eSaDBGlX1 TnoFC6fItHGclpwb3xmZTBuNayOKc4CYRx/W49xccJ0JB8quJ+aNSPg4dWNMN5SeGmiAqj 0W0TNXnZalnM7vFyBvg90afhM+g0KpY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-56-VxOX01I2Mmeu118egaY0Kw-1; Tue, 22 Aug 2023 03:32:48 -0400 X-MC-Unique: VxOX01I2Mmeu118egaY0Kw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0B56857A84; Tue, 22 Aug 2023 07:32:47 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D26E40C206F; Tue, 22 Aug 2023 07:32:46 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: stable@dpdk.org, Ales Musil , Thomas Monjalon , Ophir Munk , Keith Wiles , Raslan Darawsheh Subject: [PATCH] net/tap: fix L4 checksum Date: Tue, 22 Aug 2023 09:32:44 +0200 Message-ID: <20230822073244.3751885-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 The L4 checksum offloading API does not require l4_len to be set. Make the driver discover the L4 headers size by itself. Fixes: 6546e76056e3 ("net/tap: calculate checksums of multi segs packets") Cc: stable@dpdk.org Signed-off-by: David Marchand Tested-by: Ales Musil --- .mailmap | 1 + drivers/net/tap/rte_eth_tap.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index 864d33ee46..b6a21b35cb 100644 --- a/.mailmap +++ b/.mailmap @@ -40,6 +40,7 @@ Aleksandr Loktionov Aleksandr Miloshenko Aleksey Baulin Aleksey Katargin +Ales Musil Alexander Bechikov Alexander Belyakov Alexander Chernavin diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index bf98f75559..0ab214847a 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -645,13 +645,22 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs, ((mbuf->ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_IPV4) || (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; + is_cksum = 1; + if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == + RTE_MBUF_F_TX_UDP_CKSUM) + l4_len = sizeof(struct rte_udp_hdr); + else if ((mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK) == + RTE_MBUF_F_TX_TCP_CKSUM) + l4_len = sizeof(struct rte_tcp_hdr); + /* Support only packets with at least layer 4 * header included in the first segment */ seg_len = rte_pktmbuf_data_len(mbuf); - l234_hlen = mbuf->l2_len + mbuf->l3_len + mbuf->l4_len; + l234_hlen = mbuf->l2_len + mbuf->l3_len + l4_len; if (seg_len < l234_hlen) return -1; @@ -661,7 +670,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs, rte_memcpy(m_copy, rte_pktmbuf_mtod(mbuf, void *), l234_hlen); tap_tx_l3_cksum(m_copy, mbuf->ol_flags, - mbuf->l2_len, mbuf->l3_len, mbuf->l4_len, + mbuf->l2_len, mbuf->l3_len, l4_len, &l4_cksum, &l4_phdr_cksum, &l4_raw_cksum); iovecs[k].iov_base = m_copy; From patchwork Thu Aug 24 07:18:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 130692 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0F34A430EC; Thu, 24 Aug 2023 09:18:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D773041148; Thu, 24 Aug 2023 09:18:31 +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 E593641148 for ; Thu, 24 Aug 2023 09:18:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692861510; 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=K9hizu206DeR1Np461fbp2+qHctj2kUtjg+L2FuuACdmldIFhetTPTtsX5kAE2xbqC+RZb IYtzYaczWgW5B+y4G+lzn4f6vcfTVx6bInZqKaOnqGYSuRjD5LZFpnouSHzZGvAn2ImNKc 8b361pdTNVHSNlafdn0BQ7GmXjWI55g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-144-XCTYEALYNs6ibI8tMjljZQ-1; Thu, 24 Aug 2023 03:18:28 -0400 X-MC-Unique: XCTYEALYNs6ibI8tMjljZQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 676A885D060; Thu, 24 Aug 2023 07:18:28 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD74F40C6F4C; Thu, 24 Aug 2023 07:18:27 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: olivier.matz@6wind.com Subject: [PATCH v3 2/3] net/tap: fix IPv4 checksum offloading Date: Thu, 24 Aug 2023 09:18:21 +0200 Message-ID: <20230824071822.337670-2-david.marchand@redhat.com> In-Reply-To: <20230824071822.337670-1-david.marchand@redhat.com> References: <20230822073244.3751885-1-david.marchand@redhat.com> <20230824071822.337670-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 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 --- 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;