From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 306C645C15; Wed, 30 Oct 2024 15:08:23 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BAC83402EE; Wed, 30 Oct 2024 15:08:22 +0100 (CET) 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 2D2CA4028E for ; Wed, 30 Oct 2024 15:08:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730297300; 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=W+74V21mnthT1TXQwTm7FA2jjmzZWdP1IbIncLEiotM=; b=Xy/+Nmem/XZMMAMFOcYoyMh46Er1GQShXyByYKZMyJSNtjgi1QSKXjfv5Q1S8p8McLkb8u 0JBuEXs3qrqRVNN70WRpfGpcdaaPYBsDMsGt1zpo23m3mPHL0iccQ5zzsMIM9PoBcatN7x f5aZA8Q4+VN63+ZN0WqdDlUn9G7J/Ro= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-144-9T4yEWDUMVegP2rYcrFGmQ-1; Wed, 30 Oct 2024 10:08:19 -0400 X-MC-Unique: 9T4yEWDUMVegP2rYcrFGmQ-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2fb58d1da8eso39375861fa.0 for ; Wed, 30 Oct 2024 07:08:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730297298; x=1730902098; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W+74V21mnthT1TXQwTm7FA2jjmzZWdP1IbIncLEiotM=; b=uo6RkfIZ1Jqmu5mvviEAxFhHWP5f9qxmkF/+T7wqu7NaGjN6jjSuCyhM8OB2L6rWta dbwjwNqPuzJPuCiDEj/l+G1haSjzCG9kC5WJuRXqUru/IR3MuKdVPivhcvK1obIGxZ9k YkRXwd6Ih0WDt5EoGIkHpXhTTmqP9VRCO1sDFy1wv5TjPBklAU7EFInzWbseHGa0YCvR neYGHDXatXbbW1jlgmVPRFfKXgwriCunBeSskskdYLAWh0LC2mwrpkgLYpkk/TEpV1ik 85VmEkvFtrESTsx9v9TN5VfnntYlV8yO6Jv7040J9zK/wPkH0mNlRD81Ixv5qINAE7OJ e0Lw== X-Gm-Message-State: AOJu0Yy2/ENZ6QxJMjKQfSf+9yPR1x0nSggKWjxAX7QncxrkB4Squldt jFwVPZ9m6hGZU4P8Y51CUSOvrxjnmUu4X4wo3710US0fw9sFoSzgw275Nq9k5tYX5rW+vRtSD/b jzuYBPr3hrf2YWE4KLuFU+zkJ6UpEn4zICOOaLq5Rt7DceChl9oIADsOpk9bqtYn6bIw5oQYubj baJMa8TN3dKp5qXD0= X-Received: by 2002:a05:651c:1504:b0:2fb:5014:c998 with SMTP id 38308e7fff4ca-2fcbe08cf24mr72029061fa.28.1730297297711; Wed, 30 Oct 2024 07:08:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPBVMFgjH+LUkGzqzaXLGmywtRM7sxYrreRhIrBASHHWH7RjwOiCiXu5PRoeSwcMr7IkZhE+usaObJ+6GAZZE= X-Received: by 2002:a05:651c:1504:b0:2fb:5014:c998 with SMTP id 38308e7fff4ca-2fcbe08cf24mr72028821fa.28.1730297297265; Wed, 30 Oct 2024 07:08:17 -0700 (PDT) MIME-Version: 1.0 References: <20241017142214.1669370-1-bruce.richardson@intel.com> <20241025165020.1856733-1-bruce.richardson@intel.com> <20241025165020.1856733-6-bruce.richardson@intel.com> <98CBD80474FA8B44BF855DF32C47DC35E9F84E@smartserver.smartshare.dk> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F84E@smartserver.smartshare.dk> From: David Marchand Date: Wed, 30 Oct 2024 15:08:06 +0100 Message-ID: Subject: Re: [PATCH v2 5/6] net: add smaller IPv4 cksum function for simple cases To: =?UTF-8?Q?Morten_Br=C3=B8rup?= , Bruce Richardson Cc: dev@dpdk.org, Stephen Hemminger , Jerin Jacob , Aman Singh , Konstantin Ananyev X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Wed, Oct 30, 2024 at 12:32=E2=80=AFPM Morten Br=C3=B8rup wrote: > > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > Sent: Wednesday, 30 October 2024 12.28 > > > > On Wed, Oct 30, 2024 at 12:21:00PM +0100, David Marchand wrote: > > > Hello Bruce, > > > > > > On Fri, Oct 25, 2024 at 6:51=E2=80=AFPM Bruce Richardson > > > wrote: > > > > > > > > There are multiple instances in the DPDK app folder where we set up > > an > > > > IP header and then compute the checksum field by direct addition of > > > > nine uint16_t values in the header (20 bytes less the cksum field). > > > > The existing rte_ip.h checksum function is more general than > > necessary > > > > here and requires that the checksum field is already set to zero - > > > > rather than having it skipped. > > > > > > > > Fix the code duplication present in the apps by creating a new > > > > rte_ipv4_cksum_simple function - taking the code from the existing > > > > testpmd icmpecho.c file - and using that in app/test, testpmd and > > > > testeventdev. > > > > > > > > Within that new function, we can adjust slightly how the > > typecasting to > > > > uint16_t is done, and thereby ensure that the app can all be > > compiled > > > > without -Wno-address-of-packed-member compiler flag. > > > > > > > > Signed-off-by: Bruce Richardson > > > > Acked-by: Stephen Hemminger > > > > Acked-by: Morten Br=C3=B8rup > > > > > > This added function triggers a build error with OVS because of - > > Wcast-align: > > > https://github.com/david- > > marchand/ovs/actions/runs/11401635820/job/32273090691#step:12:514 > > > > > > libtool: compile: env REAL_CC=3Dgcc "CHECK=3Dsparse -Wsparse-error -I > > > ./include/sparse -I ./include -m64 -I /usr/local/include -I > > > /usr/include/x86_64-linux-gnu " cgcc -target=3Dx86_64 > > > -target=3Dhost_os_specs -D__MMX__=3D1 -D__MMX_WITH_SSE__=3D1 > > > -D__SSE2_MATH__=3D1 -D__SSE_MATH__=3D1 -D__SSE__=3D1 -D__SSE2__=3D1 > > > -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib > > > -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith > > > -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter > > > -Wbad-function-cast -Wcast-align -Wstrict-prototypes > > > -Wold-style-definition -Wmissing-prototypes > > > -Wmissing-field-initializers -fno-strict-aliasing -Wswitch-bool > > > -Wlogical-not-parentheses -Wsizeof-array-argument -Wbool-compare > > > -Wshift-negative-value -Wduplicated-cond -Wshadow > > > -Wmultistatement-macros -Wcast-align=3Dstrict -mssse3 > > > -I/home/runner/work/ovs/ovs/dpdk-dir/include -include rte_config.h > > > -mrtm -Werror -D_FILE_OFFSET_BITS=3D64 -g -O2 -MT lib/ofp-protocol.lo > > > -MD -MP -MF lib/.deps/ofp-protocol.Tpo -c lib/ofp-protocol.c -o > > > lib/ofp-protocol.o > > > In file included from /home/runner/work/ovs/ovs/dpdk- > > dir/include/rte_ip.h:9, > > > from /home/runner/work/ovs/ovs/dpdk-dir/include/rte_flow.h:25, > > > from lib/netdev-dpdk.h:30, > > > from lib/dp-packet.h:30, > > > from lib/ofp-print.c:34: > > > /home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h: In function > > > =E2=80=98rte_ipv4_cksum_simple=E2=80=99: > > > /home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h:191:17: error: > > > cast increases required alignment of target type [-Werror=3Dcast-alig= n] > > > 191 | v16_h =3D (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; > > > | ^ > > Ok, I'll see if I can rework it to avoid issues. > > Would be easier if IP(v4/v6) headers were 2-byte aligned, like the Ethern= et header. > Just saying. ;-) Aligning rte_ipv4_hdr is not enough. Pointing at a uint8_t triggers a warning (with clang at least). I guess we need something like: diff --git a/lib/net/rte_ip4.h b/lib/net/rte_ip4.h index 4dd0058cc5..f9b8333332 100644 --- a/lib/net/rte_ip4.h +++ b/lib/net/rte_ip4.h @@ -39,7 +39,7 @@ extern "C" { /** * IPv4 Header */ -struct rte_ipv4_hdr { +struct __rte_aligned(2) rte_ipv4_hdr { __extension__ union { uint8_t version_ihl; /**< version and header length */ @@ -188,7 +188,7 @@ rte_ipv4_cksum_simple(const struct rte_ipv4_hdr *ipv4_h= dr) * Compute the sum of successive 16-bit words of the IPv4 header, * skipping the checksum field of the header. */ - v16_h =3D (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + v16_h =3D (const uint16_t *)ipv4_hdr; ip_cksum =3D v16_h[0] + v16_h[1] + v16_h[2] + v16_h[3] + v16_h[4] + v16_h[6] + v16_h[7] + v16_h[8] + v16_h[9]; --=20 David Marchand