From patchwork Thu Apr 18 08:20:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139481 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 108D543E9E; Thu, 18 Apr 2024 10:20:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E51B040DFB; Thu, 18 Apr 2024 10:20:39 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id AD63A40042 for ; Thu, 18 Apr 2024 10:20:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713428436; 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=PveGbfTQvSdTa19gSv82rN7kKCv/TyQ07sdgxpt+Q9s=; b=J86AkXdXLicnjomiRA3DPEwSzT1mvTqhbkZYNuz635e26kYWtAGVVIAtlHsgXR7Lt5dHC1 8DdAjaWe8PE29adAn5X75q1Pp4NyBW5otxFRSAFMHa2NW66jnNgOrkLmluaR6imWOZtVtM B1Ox4qdr2vthT+Lo3biNACTZzcztQME= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-KwxhF2r1OieuRwfw6MrHLw-1; Thu, 18 Apr 2024 04:20:34 -0400 X-MC-Unique: KwxhF2r1OieuRwfw6MrHLw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE9343C10161; Thu, 18 Apr 2024 08:20:33 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8590635430; Thu, 18 Apr 2024 08:20:32 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, Bruce Richardson , Qi Zhang , Murphy Yang Subject: [PATCH v3 1/7] net/ice: fix check for outer UDP checksum offload Date: Thu, 18 Apr 2024 10:20:15 +0200 Message-ID: <20240418082023.1767998-2-david.marchand@redhat.com> In-Reply-To: <20240418082023.1767998-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240418082023.1767998-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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 ICE_TX_CTX_EIPT_NONE == 0. There is a good chance that !(anything & 0) is true :-). While removing this noop check is doable, let's check that the descriptor does contain a outer ip type. Fixes: 2ed011776334 ("net/ice: fix outer UDP Tx checksum offload") Signed-off-by: David Marchand Reviewed-by: Bruce Richardson Acked-by: Morten Brørup --- Changes since v1: - fix inverted check, --- drivers/net/ice/ice_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index 13aabe97a5..40471306b4 100644 --- a/drivers/net/ice/ice_rxtx.c +++ b/drivers/net/ice/ice_rxtx.c @@ -2751,9 +2751,9 @@ ice_parse_tunneling_params(uint64_t ol_flags, * Calculate the tunneling UDP checksum. * Shall be set only if L4TUNT = 01b and EIPT is not zero */ - if (!(*cd_tunneling & ICE_TX_CTX_EIPT_NONE) && - (*cd_tunneling & ICE_TXD_CTX_UDP_TUNNELING) && - (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM)) + if ((*cd_tunneling & ICE_TXD_CTX_QW0_EIPT_M) && + (*cd_tunneling & ICE_TXD_CTX_UDP_TUNNELING) && + (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM)) *cd_tunneling |= ICE_TXD_CTX_QW0_L4T_CS_M; } From patchwork Thu Apr 18 08:20:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139482 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 D4C1243E9E; Thu, 18 Apr 2024 10:20:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4BF8F40E09; Thu, 18 Apr 2024 10:20:44 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id DF5C940E09 for ; Thu, 18 Apr 2024 10:20:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713428440; 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=tHSFOhY5PNwK4dm6qcVwa8bbDyveDuGNuRO+JJFO9p0=; b=FbuYtfyGo+IeZMJZBrhTo7gcJMQF97z7DdIOquZfTXtPiSpoLLccknG6TdMd84UuFD3XhT B0jCQ4N0ZTLAHoyXLHRlOWyjxCJ734tfPjciK9gsQhabrRop8hBFc3FXrqfviIOiTsKd/s MHYWjTGYlKHYn0cKYEPEp3Ooq7HaPd0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-n5I9iRnePlef1wqVCHstow-1; Thu, 18 Apr 2024 04:20:36 -0400 X-MC-Unique: n5I9iRnePlef1wqVCHstow-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E14080253A; Thu, 18 Apr 2024 08:20:36 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6290490EB; Thu, 18 Apr 2024 08:20:35 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com Subject: [PATCH v3 2/7] net/ice: enhance debug when HW fails to transmit Date: Thu, 18 Apr 2024 10:20:16 +0200 Message-ID: <20240418082023.1767998-3-david.marchand@redhat.com> In-Reply-To: <20240418082023.1767998-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240418082023.1767998-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.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 At the moment, if the driver sets an incorrect Tx descriptor, the HW will raise a MDD event reported as: ice_interrupt_handler(): OICR: MDD event Add some debug info for this case. Signed-off-by: David Marchand --- Changes since v2: - dropped VF index from logs, --- drivers/net/ice/ice_ethdev.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 87385d2649..16a6caf555 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -1455,6 +1455,20 @@ ice_interrupt_handler(void *param) "%d by TCLAN on TX queue %d PF# %d", event, queue, pf_num); } + + reg = ICE_READ_REG(hw, GL_MDET_TX_TDPU); + if (reg & GL_MDET_TX_TDPU_VALID_M) { + pf_num = (reg & GL_MDET_TX_TDPU_PF_NUM_M) >> + GL_MDET_TX_TDPU_PF_NUM_S; + event = (reg & GL_MDET_TX_TDPU_MAL_TYPE_M) >> + GL_MDET_TX_TDPU_MAL_TYPE_S; + queue = (reg & GL_MDET_TX_TDPU_QNUM_M) >> + GL_MDET_TX_TDPU_QNUM_S; + + PMD_DRV_LOG(WARNING, "Malicious Driver Detection event " + "%d by TDPU on TX queue %d PF# %d", + event, queue, pf_num); + } } done: /* Enable interrupt */ From patchwork Thu Apr 18 08:20:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139483 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 1F66D43E9E; Thu, 18 Apr 2024 10:21:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D8B640E4A; Thu, 18 Apr 2024 10:20:50 +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 C2DB740E4A for ; Thu, 18 Apr 2024 10:20:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713428446; 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=c3GedpwcYQJZk2gAzze9YP4qRF038eYSTIN6ghJ5eZ4=; b=NK7eu5rNzrMiy1A4hfR3T3Cj6PuZiyylSo91+AflaWaAaXuGgpaJ4W5iX1JzE5RUMPqPh4 /biWoN82hkfyht71+GMxOhdGu3C3iVE4x5dyldexYfwtOfy0uyeypmiJeFI0iyC/EcjD6u q/hqyJw9ohOw6PCAJ+Cr8aMFWGMJTPU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-160-lAWfAnbeMp2B7rZyhSg2Fg-1; Thu, 18 Apr 2024 04:20:42 -0400 X-MC-Unique: lAWfAnbeMp2B7rZyhSg2Fg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 941B3801855; Thu, 18 Apr 2024 08:20:40 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9482C40357A7; Thu, 18 Apr 2024 08:20:38 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, stable@dpdk.org, Aman Singh , Yuying Zhang , Olivier Matz , Konstantin Ananyev , Tomasz Kulasek Subject: [PATCH v3 3/7] app/testpmd: fix outer IP checksum offload Date: Thu, 18 Apr 2024 10:20:17 +0200 Message-ID: <20240418082023.1767998-4-david.marchand@redhat.com> In-Reply-To: <20240418082023.1767998-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240418082023.1767998-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.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 Resetting the outer IP checksum to 0 is not something mandated by the mbuf API and is done by rte_eth_tx_prepare(), or per driver if needed. Fixes: 4fb7e803eb1a ("ethdev: add Tx preparation") Cc: stable@dpdk.org Signed-off-by: David Marchand --- app/test-pmd/csumonly.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 6711dda42e..f5125c2788 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -583,15 +583,17 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, uint64_t ol_flags = 0; if (info->outer_ethertype == _htons(RTE_ETHER_TYPE_IPV4)) { - ipv4_hdr->hdr_checksum = 0; ol_flags |= RTE_MBUF_F_TX_OUTER_IPV4; - if (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) + if (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) { ol_flags |= RTE_MBUF_F_TX_OUTER_IP_CKSUM; - else + } else { + ipv4_hdr->hdr_checksum = 0; ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); - } else + } + } else { ol_flags |= RTE_MBUF_F_TX_OUTER_IPV6; + } if (info->outer_l4_proto != IPPROTO_UDP) return ol_flags; From patchwork Thu Apr 18 08:20:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139484 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 5B6E443E9E; Thu, 18 Apr 2024 10:21:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CBCBE40E96; Thu, 18 Apr 2024 10:20:52 +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 ABEBF40E54 for ; Thu, 18 Apr 2024 10:20:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713428450; 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=S4fn+TJKt47mpCqj01ODr31WxeLfKeRTOq4xZRua4Eo=; b=FKi7CnxW+zhrnc8vW2Oa8ncB3UC2TFDF/D1mTqSZEwnS31+r82WJ5buEIXw1IBqkg6L+qf uddiMmcAPHV9zBLdNxugvMLuXBoosdmZjYBmI85OlZNskx94Tw6H2Zh9pWcITH1ftTvDIm nY56H7hh/CPr5MBNYMMDkffsCbZFajE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-6-MyQjeZsWPc2mJxmBpSzulA-1; Thu, 18 Apr 2024 04:20:46 -0400 X-MC-Unique: MyQjeZsWPc2mJxmBpSzulA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CEAA18065B3; Thu, 18 Apr 2024 08:20:45 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADFCA3543A; Thu, 18 Apr 2024 08:20:42 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, stable@dpdk.org, Aman Singh , Yuying Zhang , Jie Hai , Yisen Zhuang , Ferruh Yigit , Ting Xu Subject: [PATCH v3 4/7] net: fix outer UDP checksum in Intel prepare helper Date: Thu, 18 Apr 2024 10:20:18 +0200 Message-ID: <20240418082023.1767998-5-david.marchand@redhat.com> In-Reply-To: <20240418082023.1767998-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240418082023.1767998-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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 Setting a pseudo header checksum in the outer UDP checksum is a Intel (and some other vendors) requirement. Applications (like OVS) requesting outer UDP checksum without doing this extra setup have broken outer UDP checksums. Move this specific setup from testpmd to the "common" helper rte_net_intel_cksum_flags_prepare(). net/hns3 can then be adjusted. Bugzilla ID: 1406 Fixes: d8e5e69f3a9b ("app/testpmd: add GTP parsing and Tx checksum offload") Cc: stable@dpdk.org Signed-off-by: David Marchand --- app/test-pmd/csumonly.c | 11 +---- drivers/net/hns3/hns3_rxtx.c | 93 ++++++++++-------------------------- lib/net/rte_net.h | 18 ++++++- 3 files changed, 44 insertions(+), 78 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index f5125c2788..71add6ca47 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -577,8 +577,6 @@ static uint64_t process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, uint64_t tx_offloads, int tso_enabled, struct rte_mbuf *m) { - struct rte_ipv4_hdr *ipv4_hdr = outer_l3_hdr; - struct rte_ipv6_hdr *ipv6_hdr = outer_l3_hdr; struct rte_udp_hdr *udp_hdr; uint64_t ol_flags = 0; @@ -588,6 +586,8 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, if (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM) { ol_flags |= RTE_MBUF_F_TX_OUTER_IP_CKSUM; } else { + struct rte_ipv4_hdr *ipv4_hdr = outer_l3_hdr; + ipv4_hdr->hdr_checksum = 0; ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); } @@ -608,13 +608,6 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, /* Skip SW outer UDP checksum generation if HW supports it */ if (tx_offloads & RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM) { - if (info->outer_ethertype == _htons(RTE_ETHER_TYPE_IPV4)) - udp_hdr->dgram_cksum - = rte_ipv4_phdr_cksum(ipv4_hdr, ol_flags); - else - udp_hdr->dgram_cksum - = rte_ipv6_phdr_cksum(ipv6_hdr, ol_flags); - ol_flags |= RTE_MBUF_F_TX_OUTER_UDP_CKSUM; return ol_flags; } diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 7e636a0a2e..03fc919fd7 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -3616,58 +3616,6 @@ hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num, return false; } -static bool -hns3_outer_ipv4_cksum_prepared(struct rte_mbuf *m, uint64_t ol_flags, - uint32_t *l4_proto) -{ - struct rte_ipv4_hdr *ipv4_hdr; - ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, - m->outer_l2_len); - if (ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM) - ipv4_hdr->hdr_checksum = 0; - if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) { - struct rte_udp_hdr *udp_hdr; - /* - * If OUTER_UDP_CKSUM is support, HW can calculate the pseudo - * header for TSO packets - */ - if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) - return true; - udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, - m->outer_l2_len + m->outer_l3_len); - udp_hdr->dgram_cksum = rte_ipv4_phdr_cksum(ipv4_hdr, ol_flags); - - return true; - } - *l4_proto = ipv4_hdr->next_proto_id; - return false; -} - -static bool -hns3_outer_ipv6_cksum_prepared(struct rte_mbuf *m, uint64_t ol_flags, - uint32_t *l4_proto) -{ - struct rte_ipv6_hdr *ipv6_hdr; - ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, - m->outer_l2_len); - if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) { - struct rte_udp_hdr *udp_hdr; - /* - * If OUTER_UDP_CKSUM is support, HW can calculate the pseudo - * header for TSO packets - */ - if (ol_flags & RTE_MBUF_F_TX_TCP_SEG) - return true; - udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, - m->outer_l2_len + m->outer_l3_len); - udp_hdr->dgram_cksum = rte_ipv6_phdr_cksum(ipv6_hdr, ol_flags); - - return true; - } - *l4_proto = ipv6_hdr->proto; - return false; -} - static void hns3_outer_header_cksum_prepare(struct rte_mbuf *m) { @@ -3675,29 +3623,38 @@ hns3_outer_header_cksum_prepare(struct rte_mbuf *m) uint32_t paylen, hdr_len, l4_proto; struct rte_udp_hdr *udp_hdr; - if (!(ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IPV6))) + if (!(ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IPV6)) && + ((ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) || + !(ol_flags & RTE_MBUF_F_TX_TCP_SEG))) return; if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4) { - if (hns3_outer_ipv4_cksum_prepared(m, ol_flags, &l4_proto)) - return; + struct rte_ipv4_hdr *ipv4_hdr; + + ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, + m->outer_l2_len); + l4_proto = ipv4_hdr->next_proto_id; } else { - if (hns3_outer_ipv6_cksum_prepared(m, ol_flags, &l4_proto)) - return; + struct rte_ipv6_hdr *ipv6_hdr; + + ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, + m->outer_l2_len); + l4_proto = ipv6_hdr->proto; } + if (l4_proto != IPPROTO_UDP) + return; + /* driver should ensure the outer udp cksum is 0 for TUNNEL TSO */ - if (l4_proto == IPPROTO_UDP && (ol_flags & RTE_MBUF_F_TX_TCP_SEG)) { - hdr_len = m->l2_len + m->l3_len + m->l4_len; - hdr_len += m->outer_l2_len + m->outer_l3_len; - paylen = m->pkt_len - hdr_len; - if (paylen <= m->tso_segsz) - return; - udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, - m->outer_l2_len + - m->outer_l3_len); - udp_hdr->dgram_cksum = 0; - } + hdr_len = m->l2_len + m->l3_len + m->l4_len; + hdr_len += m->outer_l2_len + m->outer_l3_len; + paylen = m->pkt_len - hdr_len; + if (paylen <= m->tso_segsz) + return; + udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, + m->outer_l2_len + + m->outer_l3_len); + udp_hdr->dgram_cksum = 0; } static int diff --git a/lib/net/rte_net.h b/lib/net/rte_net.h index ef3ff4c6fd..efd9d5f5ee 100644 --- a/lib/net/rte_net.h +++ b/lib/net/rte_net.h @@ -121,7 +121,8 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) * no offloads are requested. */ if (!(ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK | RTE_MBUF_F_TX_TCP_SEG | - RTE_MBUF_F_TX_UDP_SEG | RTE_MBUF_F_TX_OUTER_IP_CKSUM))) + RTE_MBUF_F_TX_UDP_SEG | RTE_MBUF_F_TX_OUTER_IP_CKSUM | + RTE_MBUF_F_TX_OUTER_UDP_CKSUM))) return 0; if (ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IPV6)) { @@ -135,6 +136,21 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) struct rte_ipv4_hdr *, m->outer_l2_len); ipv4_hdr->hdr_checksum = 0; } + if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) { + if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4) { + ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, + m->outer_l2_len); + udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr + + m->outer_l3_len); + udp_hdr->dgram_cksum = rte_ipv4_phdr_cksum(ipv4_hdr, m->ol_flags); + } else { + ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, + m->outer_l2_len); + udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, + m->outer_l2_len + m->outer_l3_len); + udp_hdr->dgram_cksum = rte_ipv6_phdr_cksum(ipv6_hdr, m->ol_flags); + } + } } /* From patchwork Thu Apr 18 08:20:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139485 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 185C243E9E; Thu, 18 Apr 2024 10:21:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2086240ED2; Thu, 18 Apr 2024 10:20:55 +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 9F37140ECF for ; Thu, 18 Apr 2024 10:20:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713428453; 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=AbY1bjB/FNwTyGqJGT/MAqOZTsm6Hg/hwgrAb+x1vcM=; b=BTL7Da/q0W9makn7SyBe4Ypyz1pXNpDNu9LT2UKNf777vA+KPjvyFuz4yePI5HNU7NJhFd vtyFi5AARG3v+3+K8/81vbC5ZxFgCTuavovvsQg7LAho7nAUQishHTvLdaSCyd3HVlYcKW i6wbAYMW6WxM6fvTQBceZK/5zaoQoCI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-448-m0NgL3DIPja7W0gUM487qw-1; Thu, 18 Apr 2024 04:20:49 -0400 X-MC-Unique: m0NgL3DIPja7W0gUM487qw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 797E83C1015E; Thu, 18 Apr 2024 08:20:49 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65E4D35430; Thu, 18 Apr 2024 08:20:47 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, stable@dpdk.org, Jun Wang , Yuying Zhang , Jie Wang , Beilei Xing Subject: [PATCH v3 5/7] net/i40e: fix outer UDP checksum offload for X710 Date: Thu, 18 Apr 2024 10:20:19 +0200 Message-ID: <20240418082023.1767998-6-david.marchand@redhat.com> In-Reply-To: <20240418082023.1767998-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240418082023.1767998-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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 According to the X710 datasheet (and confirmed on the field..), X710 devices do not support outer checksum offload. """ 8.4.4.2 Transmit L3 and L4 Integrity Offload Tunneling UDP headers and GRE header are not offloaded while the X710/XXV710/XL710 leaves their checksum field as is. If a checksum is required, software should provide it as well as the inner checksum value(s) that are required for the outer checksum. """ Fix Tx offload capabilities according to the hardware. X722 may support such offload by setting I40E_TXD_CTX_QW0_L4T_CS_MASK. Bugzilla ID: 1406 Fixes: 8cc79a1636cd ("net/i40e: fix forward outer IPv6 VXLAN") Cc: stable@dpdk.org Reported-by: Jun Wang Signed-off-by: David Marchand --- Note: I do not have X722 nic. Please Intel devs, check for both X710 and X722 series. Changes since v1: - fix inverted check, --- .mailmap | 1 + drivers/net/i40e/i40e_ethdev.c | 6 +++++- drivers/net/i40e/i40e_rxtx.c | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index 3843868716..091766eca7 100644 --- a/.mailmap +++ b/.mailmap @@ -719,6 +719,7 @@ Junjie Wan Jun Qiu Jun W Zhou Junxiao Shi +Jun Wang Jun Yang Junyu Jiang Juraj Linkeš diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 380ce1a720..6535c7c178 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -3862,8 +3862,12 @@ i40e_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO | RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | RTE_ETH_TX_OFFLOAD_MULTI_SEGS | - RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM | dev_info->tx_queue_offload_capa; + if (hw->mac.type == I40E_MAC_X722) { + dev_info->tx_offload_capa |= + RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM; + } + dev_info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 5d25ab4d3a..b4f7599cfc 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -295,6 +295,15 @@ i40e_parse_tunneling_params(uint64_t ol_flags, */ *cd_tunneling |= (tx_offload.l2_len >> 1) << I40E_TXD_CTX_QW0_NATLEN_SHIFT; + + /** + * Calculate the tunneling UDP checksum (only supported with X722). + * Shall be set only if L4TUNT = 01b and EIPT is not zero + */ + if ((*cd_tunneling & I40E_TXD_CTX_QW0_EXT_IP_MASK) && + (*cd_tunneling & I40E_TXD_CTX_UDP_TUNNELING) && + (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM)) + *cd_tunneling |= I40E_TXD_CTX_QW0_L4T_CS_MASK; } static inline void From patchwork Thu Apr 18 08:20:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139486 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 AF06243E9E; Thu, 18 Apr 2024 10:21:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E833C40EDF; Thu, 18 Apr 2024 10:21:00 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 67F8540ECF for ; Thu, 18 Apr 2024 10:20:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713428459; 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=T0j+RXnvnrBijTzpEfl40NF9XnoNTHANM9UtjQ7I2nc=; b=LBl8VBmToXIt8Q0Mk6QtUKzX91pIqi0787/v1av4LX2AiOnQ2iwRbZ5acUYmQlD/g+97eJ xwaNegzOZEvPToTKFZ4uEfK3pNd5GzHp7R6QjFQJItVubPgWFNGU5qmsqZfR7zOpv5cagA s+fL2/g9moWXWri+qzmwNj3dRiMKKvo= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-4vBOwanVPMSp-mS8z602JA-1; Thu, 18 Apr 2024 04:20:53 -0400 X-MC-Unique: 4vBOwanVPMSp-mS8z602JA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27A671C4C394; Thu, 18 Apr 2024 08:20:53 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92A741C060D0; Thu, 18 Apr 2024 08:20:51 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, stable@dpdk.org, Jingjing Wu , Qi Zhang , Peng Zhang , Zhichao Zeng Subject: [PATCH v3 6/7] net/iavf: remove outer UDP checksum offload for X710 VF Date: Thu, 18 Apr 2024 10:20:20 +0200 Message-ID: <20240418082023.1767998-7-david.marchand@redhat.com> In-Reply-To: <20240418082023.1767998-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240418082023.1767998-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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 According to the X710 datasheet, X710 devices do not support outer checksum offload. """ 8.4.4.2 Transmit L3 and L4 Integrity Offload Tunneling UDP headers and GRE header are not offloaded while the X710/XXV710/XL710 leaves their checksum field as is. If a checksum is required, software should provide it as well as the inner checksum value(s) that are required for the outer checksum. """ Fix Tx offload capabilities depending on the VF type. Bugzilla ID: 1406 Fixes: f7c8c36fdeb7 ("net/iavf: enable inner and outer Tx checksum offload") Cc: stable@dpdk.org Signed-off-by: David Marchand --- doc/guides/nics/features/iavf.ini | 2 +- drivers/net/iavf/iavf_ethdev.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/features/iavf.ini b/doc/guides/nics/features/iavf.ini index c59115ae15..ce9860e963 100644 --- a/doc/guides/nics/features/iavf.ini +++ b/doc/guides/nics/features/iavf.ini @@ -33,7 +33,7 @@ L3 checksum offload = Y L4 checksum offload = Y Timestamp offload = Y Inner L3 checksum = Y -Inner L4 checksum = Y +Inner L4 checksum = P Packet type parsing = Y Rx descriptor status = Y Tx descriptor status = Y diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 245b3cd854..bbf915097e 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -1174,7 +1174,6 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) RTE_ETH_TX_OFFLOAD_TCP_CKSUM | RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | - RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_TSO | RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | @@ -1183,6 +1182,10 @@ iavf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) RTE_ETH_TX_OFFLOAD_MULTI_SEGS | RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE; + /* X710 does not support outer udp checksum */ + if (adapter->hw.mac.type != IAVF_MAC_XL710) + dev_info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM; + if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_CRC) dev_info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_KEEP_CRC; From patchwork Thu Apr 18 08:20:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139487 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 61DE843E9E; Thu, 18 Apr 2024 10:21:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AAACA40ECF; Thu, 18 Apr 2024 10:21:03 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id CA20B40ECF for ; Thu, 18 Apr 2024 10:21:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713428460; 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=IyzzhgjfPik4Bwo/KDaW56NPfzd2PTxAr+DHPeCNhXA=; b=NiS3pY+YzagPY0af+VY2IyAoZxe0UtDHQBP+GtRwaRqGbal1pV0KKHcMZr17H9kdhDtS97 CZDGddiTKpvJqgc99eik3LtgM35gKSaQO7GiZduT9A1FtueUQsckhRUm/Oizsn5NRlblAj EywgDIHxoRoKvSI5tjqJqhPPlRIp52c= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-45-X15BMsHgM9GqP9jj4uGHgw-1; Thu, 18 Apr 2024 04:20:57 -0400 X-MC-Unique: X15BMsHgM9GqP9jj4uGHgw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8319918065B3; Thu, 18 Apr 2024 08:20:56 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 221FC40357A7; Thu, 18 Apr 2024 08:20:54 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, Aman Singh , Yuying Zhang , Jie Hai , Yisen Zhuang Subject: [PATCH v3 7/7] net: clear outer UDP checksum in Intel prepare helper Date: Thu, 18 Apr 2024 10:20:21 +0200 Message-ID: <20240418082023.1767998-8-david.marchand@redhat.com> In-Reply-To: <20240418082023.1767998-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240418082023.1767998-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.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 If requesting an inner (L3/L4 checksum or L4 segmentation) offload, when the hardware does not support recomputing outer UDP checksum, automatically disable it in the common helper. Signed-off-by: David Marchand --- Changes since v2: - fixed GRE tunneling, - dropped documentation update, --- app/test-pmd/csumonly.c | 10 ++------ drivers/net/hns3/hns3_rxtx.c | 44 ------------------------------------ lib/net/rte_net.h | 22 +++++++++++++----- 3 files changed, 18 insertions(+), 58 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 71add6ca47..2246c22e8e 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -612,19 +612,13 @@ process_outer_cksums(void *outer_l3_hdr, struct testpmd_offload_info *info, return ol_flags; } - /* outer UDP checksum is done in software. In the other side, for - * UDP tunneling, like VXLAN or Geneve, outer UDP checksum can be - * set to zero. + /* Outer UDP checksum is done in software. * * If a packet will be TSOed into small packets by NIC, we cannot * set/calculate a non-zero checksum, because it will be a wrong * value after the packet be split into several small packets. */ - if (tso_enabled) - udp_hdr->dgram_cksum = 0; - - /* do not recalculate udp cksum if it was 0 */ - if (udp_hdr->dgram_cksum != 0) { + if (!tso_enabled && udp_hdr->dgram_cksum != 0) { udp_hdr->dgram_cksum = 0; udp_hdr->dgram_cksum = get_udptcp_checksum(m, outer_l3_hdr, info->outer_l2_len + info->outer_l3_len, diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 03fc919fd7..b5436c51e7 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -3616,47 +3616,6 @@ hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num, return false; } -static void -hns3_outer_header_cksum_prepare(struct rte_mbuf *m) -{ - uint64_t ol_flags = m->ol_flags; - uint32_t paylen, hdr_len, l4_proto; - struct rte_udp_hdr *udp_hdr; - - if (!(ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IPV6)) && - ((ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) || - !(ol_flags & RTE_MBUF_F_TX_TCP_SEG))) - return; - - if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4) { - struct rte_ipv4_hdr *ipv4_hdr; - - ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, - m->outer_l2_len); - l4_proto = ipv4_hdr->next_proto_id; - } else { - struct rte_ipv6_hdr *ipv6_hdr; - - ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, - m->outer_l2_len); - l4_proto = ipv6_hdr->proto; - } - - if (l4_proto != IPPROTO_UDP) - return; - - /* driver should ensure the outer udp cksum is 0 for TUNNEL TSO */ - hdr_len = m->l2_len + m->l3_len + m->l4_len; - hdr_len += m->outer_l2_len + m->outer_l3_len; - paylen = m->pkt_len - hdr_len; - if (paylen <= m->tso_segsz) - return; - udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, - m->outer_l2_len + - m->outer_l3_len); - udp_hdr->dgram_cksum = 0; -} - static int hns3_check_tso_pkt_valid(struct rte_mbuf *m) { @@ -3834,7 +3793,6 @@ hns3_prep_pkt_proc(struct hns3_tx_queue *tx_queue, struct rte_mbuf *m) * checksum of packets that need TSO, so network driver * software not need to recalculate it. */ - hns3_outer_header_cksum_prepare(m); return 0; } } @@ -3848,8 +3806,6 @@ hns3_prep_pkt_proc(struct hns3_tx_queue *tx_queue, struct rte_mbuf *m) if (!hns3_validate_tunnel_cksum(tx_queue, m)) return 0; - hns3_outer_header_cksum_prepare(m); - return 0; } diff --git a/lib/net/rte_net.h b/lib/net/rte_net.h index efd9d5f5ee..cdc6cf956d 100644 --- a/lib/net/rte_net.h +++ b/lib/net/rte_net.h @@ -108,6 +108,10 @@ uint32_t rte_net_get_ptype(const struct rte_mbuf *m, static inline int rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) { + const uint64_t inner_requests = RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK | + RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG; + const uint64_t outer_requests = RTE_MBUF_F_TX_OUTER_IP_CKSUM | + RTE_MBUF_F_TX_OUTER_UDP_CKSUM; /* Initialise ipv4_hdr to avoid false positive compiler warnings. */ struct rte_ipv4_hdr *ipv4_hdr = NULL; struct rte_ipv6_hdr *ipv6_hdr; @@ -120,9 +124,7 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) * Mainly it is required to avoid fragmented headers check if * no offloads are requested. */ - if (!(ol_flags & (RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_L4_MASK | RTE_MBUF_F_TX_TCP_SEG | - RTE_MBUF_F_TX_UDP_SEG | RTE_MBUF_F_TX_OUTER_IP_CKSUM | - RTE_MBUF_F_TX_OUTER_UDP_CKSUM))) + if (!(ol_flags & (inner_requests | outer_requests))) return 0; if (ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IPV6)) { @@ -136,19 +138,27 @@ rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) struct rte_ipv4_hdr *, m->outer_l2_len); ipv4_hdr->hdr_checksum = 0; } - if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) { + if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM || ol_flags & inner_requests) { if (ol_flags & RTE_MBUF_F_TX_OUTER_IPV4) { ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, m->outer_l2_len); udp_hdr = (struct rte_udp_hdr *)((char *)ipv4_hdr + m->outer_l3_len); - udp_hdr->dgram_cksum = rte_ipv4_phdr_cksum(ipv4_hdr, m->ol_flags); + if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) + udp_hdr->dgram_cksum = rte_ipv4_phdr_cksum(ipv4_hdr, + m->ol_flags); + else if (ipv4_hdr->next_proto_id == IPPROTO_UDP) + udp_hdr->dgram_cksum = 0; } else { ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, m->outer_l2_len); udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, m->outer_l2_len + m->outer_l3_len); - udp_hdr->dgram_cksum = rte_ipv6_phdr_cksum(ipv6_hdr, m->ol_flags); + if (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM) + udp_hdr->dgram_cksum = rte_ipv6_phdr_cksum(ipv6_hdr, + m->ol_flags); + else if (ipv6_hdr->proto == IPPROTO_UDP) + udp_hdr->dgram_cksum = 0; } } }