From patchwork Fri Apr 5 14:45:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139127 X-Patchwork-Delegate: thomas@monjalon.net 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 CF96C43E06; Fri, 5 Apr 2024 16:46:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7FAA40633; Fri, 5 Apr 2024 16:46:24 +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 D13A24029C for ; Fri, 5 Apr 2024 16:46:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712328382; 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=RtC5jXApKY6IYlWOW2A5EQJPQ9UakXkhFCPFE23EBI4=; b=JjN0mLqknko0AHRE6MF4U83V4ShgycM/+PXOOTQ0XyF4ry4NVzlbCB6ZqQmLU9cAT3Ymcp uHqp4GCG9pFqY18STNBfPobkYfKeu2n1Or9kPLbPp9fABSXjjUsvSE4fxnkSpif+KCMPIv n8m4Qk/jMGhM/+ptkcAz7bY6tnLVZrM= 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-237-B0wIKmh0OTSp67vb7GW5lQ-1; Fri, 05 Apr 2024 10:46:19 -0400 X-MC-Unique: B0wIKmh0OTSp67vb7GW5lQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 91C47101A521; Fri, 5 Apr 2024 14:46:18 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C8B9492BCB; Fri, 5 Apr 2024 14:46:17 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, Qi Zhang , Murphy Yang Subject: [PATCH v2 1/8] net/ice: fix check for outer UDP checksum offload Date: Fri, 5 Apr 2024 16:45:55 +0200 Message-ID: <20240405144604.906695-2-david.marchand@redhat.com> In-Reply-To: <20240405144604.906695-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240405144604.906695-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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 --- 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 Fri Apr 5 14:45:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139128 X-Patchwork-Delegate: thomas@monjalon.net 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 48CAB43E06; Fri, 5 Apr 2024 16:46:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB5864068E; Fri, 5 Apr 2024 16:46:28 +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 BEAC340689 for ; Fri, 5 Apr 2024 16:46:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712328387; 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=Ygup4MIWR3cOAla0vzg8zMHbr/SPgXKVLvmN29pqqW0=; b=hxtvPUbtIGO+j0hM517ZC7b4GzVQqz1rOskW0HiNL62JqAhC3qGpCHT7Y2bm97NGWcH9d/ PIJdGqDqpp7C7Il5gjaBpLOGq7KMvp5eoSzYK1WD3Kvnl1YGVk+sWy6YmGLkn3dzWENAcl W+Op0NgfZ4pX27xGRgQn8iJUB3s/p3U= 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-350-IcBLWYG-Oby3aI8jLktslw-1; Fri, 05 Apr 2024 10:46:26 -0400 X-MC-Unique: IcBLWYG-Oby3aI8jLktslw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 6088E85A58B; Fri, 5 Apr 2024 14:46:25 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1C20202451F; Fri, 5 Apr 2024 14:46:24 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com Subject: [PATCH v2 2/8] net/ice: enhance debug when HW fails to transmit Date: Fri, 5 Apr 2024 16:45:56 +0200 Message-ID: <20240405144604.906695-3-david.marchand@redhat.com> In-Reply-To: <20240405144604.906695-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240405144604.906695-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 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 and the VF index in all logs. Signed-off-by: David Marchand --- drivers/net/ice/ice_ethdev.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 87385d2649..fd494e6b3b 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -1389,6 +1389,7 @@ ice_interrupt_handler(void *param) uint32_t oicr; uint32_t reg; uint8_t pf_num; + uint16_t vf_num; uint8_t event; uint16_t queue; int ret; @@ -1432,28 +1433,48 @@ ice_interrupt_handler(void *param) if (reg & GL_MDET_TX_PQM_VALID_M) { pf_num = (reg & GL_MDET_TX_PQM_PF_NUM_M) >> GL_MDET_TX_PQM_PF_NUM_S; + vf_num = (reg & GL_MDET_TX_PQM_VF_NUM_M) >> + GL_MDET_TX_PQM_VF_NUM_S; event = (reg & GL_MDET_TX_PQM_MAL_TYPE_M) >> GL_MDET_TX_PQM_MAL_TYPE_S; queue = (reg & GL_MDET_TX_PQM_QNUM_M) >> GL_MDET_TX_PQM_QNUM_S; PMD_DRV_LOG(WARNING, "Malicious Driver Detection event " - "%d by PQM on TX queue %d PF# %d", - event, queue, pf_num); + "%d by PQM on TX queue %d PF# %d VF# %d", + event, queue, pf_num, vf_num); } reg = ICE_READ_REG(hw, GL_MDET_TX_TCLAN); if (reg & GL_MDET_TX_TCLAN_VALID_M) { pf_num = (reg & GL_MDET_TX_TCLAN_PF_NUM_M) >> GL_MDET_TX_TCLAN_PF_NUM_S; + vf_num = (reg & GL_MDET_TX_TCLAN_VF_NUM_M) >> + GL_MDET_TX_TCLAN_VF_NUM_S; event = (reg & GL_MDET_TX_TCLAN_MAL_TYPE_M) >> GL_MDET_TX_TCLAN_MAL_TYPE_S; queue = (reg & GL_MDET_TX_TCLAN_QNUM_M) >> GL_MDET_TX_TCLAN_QNUM_S; PMD_DRV_LOG(WARNING, "Malicious Driver Detection event " - "%d by TCLAN on TX queue %d PF# %d", - event, queue, pf_num); + "%d by TCLAN on TX queue %d PF# %d VF# %d", + event, queue, pf_num, vf_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; + vf_num = (reg & GL_MDET_TX_TDPU_VF_NUM_M) >> + GL_MDET_TX_TDPU_VF_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 VF# %d", + event, queue, pf_num, vf_num); } } done: From patchwork Fri Apr 5 14:45:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139129 X-Patchwork-Delegate: thomas@monjalon.net 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 28A5B43E06; Fri, 5 Apr 2024 16:46:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 76754406A2; Fri, 5 Apr 2024 16:46:37 +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 DEFD040697 for ; Fri, 5 Apr 2024 16:46:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712328396; 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=v9Xq8FQK1hfn9g+vFXPNjevKVPrRQdO54XU4Uu1gDH0=; b=REBFzQAC7/NjyH/rT1TMQpAfP+l63csuL+ixPiIZbAlo0xouSn/25OOGeq1lsjHDFMy2Uc sV9DWeWyijLcsDQL61PFcc+oITuSWvs6vpLj2JMBgXsDTarSescRt1bcz5PirA6BtO/wUz bN12QEVX5dPMscIDoczx3H8IK8xB5s4= 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-651-Gk_Q3cP2OAWirFfVRfotRA-1; Fri, 05 Apr 2024 10:46:32 -0400 X-MC-Unique: Gk_Q3cP2OAWirFfVRfotRA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 B755238000AE; Fri, 5 Apr 2024 14:46:31 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75EECC04221; Fri, 5 Apr 2024 14:46:30 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, stable@dpdk.org, Olivier Matz , Jijiang Liu Subject: [PATCH v2 3/8] mbuf: fix Tx checksum offload examples Date: Fri, 5 Apr 2024 16:45:57 +0200 Message-ID: <20240405144604.906695-4-david.marchand@redhat.com> In-Reply-To: <20240405144604.906695-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240405144604.906695-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 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 Mandate use of rte_eth_tx_prepare() in the mbuf Tx checksum offload examples. Remove unneeded resetting of checksums to align with the mbuf API doxygen. Clarify the case when requesting "inner" checksum offload with lack of outer L4 checksum offload. Fixes: f00dcb7b0a74 ("mbuf: fix Tx checksum offload API doc") Fixes: 609dd68ef14f ("mbuf: enhance the API documentation of offload flags") Cc: stable@dpdk.org Signed-off-by: David Marchand --- doc/guides/prog_guide/mbuf_lib.rst | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/doc/guides/prog_guide/mbuf_lib.rst b/doc/guides/prog_guide/mbuf_lib.rst index 049357c755..4e285c0aab 100644 --- a/doc/guides/prog_guide/mbuf_lib.rst +++ b/doc/guides/prog_guide/mbuf_lib.rst @@ -126,6 +126,9 @@ processing to the hardware if it supports it. For instance, the RTE_MBUF_F_TX_IP_CKSUM flag allows to offload the computation of the IPv4 checksum. +Support for such processing by the hardware is advertised through RTE_ETH_TX_OFFLOAD_* capabilities. +Please note that a call to ``rte_eth_tx_prepare`` is needed to handle driver specific requirements such as resetting some checksum fields. + The following examples explain how to configure different TX offloads on a vxlan-encapsulated tcp packet: ``out_eth/out_ip/out_udp/vxlan/in_eth/in_ip/in_tcp/payload`` @@ -135,7 +138,6 @@ a vxlan-encapsulated tcp packet: mb->l2_len = len(out_eth) mb->l3_len = len(out_ip) mb->ol_flags |= RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CSUM - set out_ip checksum to 0 in the packet This is supported on hardware advertising RTE_ETH_TX_OFFLOAD_IPV4_CKSUM. @@ -144,8 +146,6 @@ a vxlan-encapsulated tcp packet: mb->l2_len = len(out_eth) mb->l3_len = len(out_ip) mb->ol_flags |= RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CSUM | RTE_MBUF_F_TX_UDP_CKSUM - set out_ip checksum to 0 in the packet - set out_udp checksum to pseudo header using rte_ipv4_phdr_cksum() This is supported on hardware advertising RTE_ETH_TX_OFFLOAD_IPV4_CKSUM and RTE_ETH_TX_OFFLOAD_UDP_CKSUM. @@ -155,7 +155,6 @@ a vxlan-encapsulated tcp packet: mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth) mb->l3_len = len(in_ip) mb->ol_flags |= RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CSUM - set in_ip checksum to 0 in the packet This is similar to case 1), but l2_len is different. It is supported on hardware advertising RTE_ETH_TX_OFFLOAD_IPV4_CKSUM. @@ -166,8 +165,6 @@ a vxlan-encapsulated tcp packet: mb->l2_len = len(out_eth + out_ip + out_udp + vxlan + in_eth) mb->l3_len = len(in_ip) mb->ol_flags |= RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CSUM | RTE_MBUF_F_TX_TCP_CKSUM - set in_ip checksum to 0 in the packet - set in_tcp checksum to pseudo header using rte_ipv4_phdr_cksum() This is similar to case 2), but l2_len is different. It is supported on hardware advertising RTE_ETH_TX_OFFLOAD_IPV4_CKSUM and @@ -181,9 +178,6 @@ a vxlan-encapsulated tcp packet: mb->l4_len = len(in_tcp) mb->ol_flags |= RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_TCP_CKSUM | RTE_MBUF_F_TX_TCP_SEG; - set in_ip checksum to 0 in the packet - set in_tcp checksum to pseudo header without including the IP - payload length using rte_ipv4_phdr_cksum() This is supported on hardware advertising RTE_ETH_TX_OFFLOAD_TCP_TSO. Note that it can only work if outer L4 checksum is 0. @@ -196,12 +190,10 @@ a vxlan-encapsulated tcp packet: mb->l3_len = len(in_ip) mb->ol_flags |= RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IP_CKSUM | \ RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_TCP_CKSUM; - set out_ip checksum to 0 in the packet - set in_ip checksum to 0 in the packet - set in_tcp checksum to pseudo header using rte_ipv4_phdr_cksum() This is supported on hardware advertising RTE_ETH_TX_OFFLOAD_IPV4_CKSUM, RTE_ETH_TX_OFFLOAD_UDP_CKSUM and RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM. + Note that it can only work if outer L4 checksum is 0. The list of flags and their precise meaning is described in the mbuf API documentation (rte_mbuf.h). Also refer to the testpmd source code From patchwork Fri Apr 5 14:45:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139130 X-Patchwork-Delegate: thomas@monjalon.net 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 C900243E06; Fri, 5 Apr 2024 16:46:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C43CA4069D; Fri, 5 Apr 2024 16:46: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 AC35A40695 for ; Fri, 5 Apr 2024 16:46:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712328403; 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=AfVtwNLFeFl8EUfAF5rblnLUymqhE4XPPxjmN3ZUxcYUuyjeNcKXX5fx3jYMczP+CEfPpC DMDr7NaR++6FrE8ejKk3luCsgrAB4DaNxCupvoWFPre30BEt2nGd8/9E4AD+aomh9EXi96 FaG92bBmJYWP9KJv9NMCzECAbILC4Tw= 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-205-gjQtld68MwWa8y37YZSqqQ-1; Fri, 05 Apr 2024 10:46:40 -0400 X-MC-Unique: gjQtld68MwWa8y37YZSqqQ-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 86FC6868901; Fri, 5 Apr 2024 14:46:39 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6F1D17A91; Fri, 5 Apr 2024 14:46:37 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, stable@dpdk.org, Aman Singh , Yuying Zhang , Tomasz Kulasek , Konstantin Ananyev , Olivier Matz Subject: [PATCH v2 4/8] app/testpmd: fix outer IP checksum offload Date: Fri, 5 Apr 2024 16:45:58 +0200 Message-ID: <20240405144604.906695-5-david.marchand@redhat.com> In-Reply-To: <20240405144604.906695-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240405144604.906695-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 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 Fri Apr 5 14:45:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139131 X-Patchwork-Delegate: thomas@monjalon.net 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 A0F2843E06; Fri, 5 Apr 2024 16:47:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8D0254029C; Fri, 5 Apr 2024 16:47:07 +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 3CC064029C for ; Fri, 5 Apr 2024 16:47:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712328424; 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=AGE5CWwawI56gJHV5iiCVFqnY/4kXauwrzbao5BYMNdQwPO+KBqQqA9ZbmhRlQnC6onSLf wwa/aIiEocFASrbWKDPipLvwrlh/VBndLMFYJXTCqIgXKolWsqyHt7qw8l1d25IqD8rllL m6wbua0vwa6BT4a5qYM15kAFIalWx1A= 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-694-imPPjYmYPly_FiAi5zKQfg-1; Fri, 05 Apr 2024 10:47:03 -0400 X-MC-Unique: imPPjYmYPly_FiAi5zKQfg-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 79DE5848A64; Fri, 5 Apr 2024 14:47:02 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 675D53C21; Fri, 5 Apr 2024 14:47:00 +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 , Ting Xu Subject: [PATCH v2 5/8] net: fix outer UDP checksum in Intel prepare helper Date: Fri, 5 Apr 2024 16:45:59 +0200 Message-ID: <20240405144604.906695-6-david.marchand@redhat.com> In-Reply-To: <20240405144604.906695-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240405144604.906695-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 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 Fri Apr 5 14:46:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139132 X-Patchwork-Delegate: thomas@monjalon.net 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 D51D143E06; Fri, 5 Apr 2024 16:47:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B4F884068E; Fri, 5 Apr 2024 16:47:22 +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 F3ADA4064A for ; Fri, 5 Apr 2024 16:47:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712328440; 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=eSQuHNw2En0c8+hzRtNIJQSBtmtxDFp6My8TMehkygusfd2ZoNet0ik1WsXwkvTpFRSiBd OOd/VCbiXxWPJA0ht/yNxLz7IsZTAk1RjFSPXJ997Lp2pScXoVskdCovxOgIdPsyOO7lR0 5LSAXLFwMF12jmtoYF0ildWVVuDShKc= 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-674-gTof9SkUPRWSKMtE6r6Ltg-1; Fri, 05 Apr 2024 10:47:17 -0400 X-MC-Unique: gTof9SkUPRWSKMtE6r6Ltg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 1088029AA3BA; Fri, 5 Apr 2024 14:47:09 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B6FD492BCD; Fri, 5 Apr 2024 14:47:07 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, stable@dpdk.org, Jun Wang , Yuying Zhang , Beilei Xing , Jie Wang Subject: [PATCH v2 6/8] net/i40e: fix outer UDP checksum offload for X710 Date: Fri, 5 Apr 2024 16:46:00 +0200 Message-ID: <20240405144604.906695-7-david.marchand@redhat.com> In-Reply-To: <20240405144604.906695-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240405144604.906695-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 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 Fri Apr 5 14:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139133 X-Patchwork-Delegate: thomas@monjalon.net 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 1E17043E06; Fri, 5 Apr 2024 16:47:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EF8FA40697; Fri, 5 Apr 2024 16:47:23 +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 BDEBD402CE for ; Fri, 5 Apr 2024 16:47:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712328441; 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=iC3T4vNgvPvII2AiSdtvqvNUX0frTS/kwvtSCuG9jKwJcIGzf7MR/wjvgFKwixtZnEnftt 0kuyHMY1dQzmSRA/EWF+EV7ISVlzhDJ0OHmoMUyzFHUw/xVA4yEMhps6WAO+geVR0lZuQO RwxGlFn4jzOI6Fah9fBUQyXdsejz1V0= 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-468-VSqEEEt5PPm3kyoaHnE_Zg-1; Fri, 05 Apr 2024 10:47:17 -0400 X-MC-Unique: VSqEEEt5PPm3kyoaHnE_Zg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 969063813F32; Fri, 5 Apr 2024 14:47:16 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24C5D200A386; Fri, 5 Apr 2024 14:47:15 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, stable@dpdk.org, Jingjing Wu , Zhichao Zeng , Peng Zhang , Qi Zhang Subject: [PATCH v2 7/8] net/iavf: remove outer UDP checksum offload for X710 VF Date: Fri, 5 Apr 2024 16:46:01 +0200 Message-ID: <20240405144604.906695-8-david.marchand@redhat.com> In-Reply-To: <20240405144604.906695-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240405144604.906695-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 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 Fri Apr 5 14:46:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 139134 X-Patchwork-Delegate: thomas@monjalon.net 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 AFCFF43E06; Fri, 5 Apr 2024 16:47:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 641F14069D; Fri, 5 Apr 2024 16:47:30 +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 EABB140633 for ; Fri, 5 Apr 2024 16:47:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712328448; 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=HexOe9efAcg94Cfh+kb/JlltZ/Z3WEk7QUM13Nh1WIM=; b=RdBPG36xqGiRmqP64EBFVIks0g07YBfntmQRdMdMlBvqA8cbDni1EUw/k3lP7iGymAPaT9 yFqE1zQ+9k6I8Fs1a6wOFEVq3Jw6b/SsvSKCuZIP9ZIVtJzbEY9t+oKAMTtHF2giIrFdPm VlmRcnVvDOrjjQQuMNY5aTNvdZRxOwc= 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-504-O9E8e2pzP-eK0sHJaiSjuw-1; Fri, 05 Apr 2024 10:47:25 -0400 X-MC-Unique: O9E8e2pzP-eK0sHJaiSjuw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 04D2B85A5B7; Fri, 5 Apr 2024 14:47:24 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id A968E1121337; Fri, 5 Apr 2024 14:47:22 +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 v2 8/8] net: clear outer UDP checksum in Intel prepare helper Date: Fri, 5 Apr 2024 16:46:02 +0200 Message-ID: <20240405144604.906695-9-david.marchand@redhat.com> In-Reply-To: <20240405144604.906695-1-david.marchand@redhat.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240405144604.906695-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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 --- app/test-pmd/csumonly.c | 10 ++----- doc/guides/prog_guide/mbuf_lib.rst | 8 +++--- drivers/net/hns3/hns3_rxtx.c | 44 ------------------------------ lib/net/rte_net.h | 22 +++++++++++---- 4 files changed, 22 insertions(+), 62 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/doc/guides/prog_guide/mbuf_lib.rst b/doc/guides/prog_guide/mbuf_lib.rst index 4e285c0aab..35f7fffbc7 100644 --- a/doc/guides/prog_guide/mbuf_lib.rst +++ b/doc/guides/prog_guide/mbuf_lib.rst @@ -158,7 +158,7 @@ a vxlan-encapsulated tcp packet: This is similar to case 1), but l2_len is different. It is supported on hardware advertising RTE_ETH_TX_OFFLOAD_IPV4_CKSUM. - Note that it can only work if outer L4 checksum is 0. + Note that some driver may set outer L4 checksum to 0. - calculate checksum of in_ip and in_tcp:: @@ -169,7 +169,7 @@ a vxlan-encapsulated tcp packet: This is similar to case 2), but l2_len is different. It is supported on hardware advertising RTE_ETH_TX_OFFLOAD_IPV4_CKSUM and RTE_ETH_TX_OFFLOAD_TCP_CKSUM. - Note that it can only work if outer L4 checksum is 0. + Note that some driver may set outer L4 checksum to 0. - segment inner TCP:: @@ -180,7 +180,7 @@ a vxlan-encapsulated tcp packet: RTE_MBUF_F_TX_TCP_SEG; This is supported on hardware advertising RTE_ETH_TX_OFFLOAD_TCP_TSO. - Note that it can only work if outer L4 checksum is 0. + Note that some driver may set outer L4 checksum to 0. - calculate checksum of out_ip, in_ip, in_tcp:: @@ -193,7 +193,7 @@ a vxlan-encapsulated tcp packet: This is supported on hardware advertising RTE_ETH_TX_OFFLOAD_IPV4_CKSUM, RTE_ETH_TX_OFFLOAD_UDP_CKSUM and RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM. - Note that it can only work if outer L4 checksum is 0. + Note that some driver may set outer L4 checksum to 0. The list of flags and their precise meaning is described in the mbuf API documentation (rte_mbuf.h). Also refer to the testpmd source code 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..79e969464b 100644 --- a/lib/net/rte_net.h +++ b/lib/net/rte_net.h @@ -109,6 +109,10 @@ static inline int rte_net_intel_cksum_flags_prepare(struct rte_mbuf *m, uint64_t ol_flags) { /* Initialise ipv4_hdr to avoid false positive compiler warnings. */ + 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; struct rte_ipv4_hdr *ipv4_hdr = NULL; struct rte_ipv6_hdr *ipv6_hdr; struct rte_tcp_hdr *tcp_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 + 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 + udp_hdr->dgram_cksum = 0; } } }