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 7DDBC45B60; Thu, 17 Oct 2024 19:15:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E8434060F; Thu, 17 Oct 2024 19:15:14 +0200 (CEST) Received: from dkmailrelay1.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 3EE9A4025F for ; Thu, 17 Oct 2024 19:15:13 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesys.local [192.168.4.10]) by dkmailrelay1.smartsharesystems.com (Postfix) with ESMTP id 4674E206EF; Thu, 17 Oct 2024 19:15:12 +0200 (CEST) Content-class: urn:content-classes:message Subject: RE: [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Thu, 17 Oct 2024 19:15:10 +0200 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F7F3@smartserver.smartshare.dk> In-Reply-To: <20241017142214.1669370-6-bruce.richardson@intel.com> X-MS-Has-Attach: X-MimeOLE: Produced By Microsoft Exchange V6.5 X-MS-TNEF-Correlator: Thread-Topic: [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases Thread-Index: AdsgoBZPBHhPKTrpRh6w3S6MAQfKxwAF2vlA References: <20241017142214.1669370-1-bruce.richardson@intel.com> <20241017142214.1669370-6-bruce.richardson@intel.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Bruce Richardson" , Cc: "Jerin Jacob" , "Aman Singh" , "Konstantin Ananyev" 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 > +/** > + * Process the IPv4 checksum of an IPv4 header without any = extensions. > + * > + * The checksum field does NOT have to be set by the caller, the = field > + * is skipped by the calculation. > + * > + * @param ipv4_hdr > + * The pointer to the contiguous IPv4 header. > + * @return > + * The complemented checksum to set in the IP packet. > + */ > +__rte_experimental > +static inline uint16_t > +rte_ipv4_cksum_simple(const struct rte_ipv4_hdr *ipv4_hdr) > +{ > + const uint16_t *v16_h; > + uint32_t ip_cksum; > + > + /* > + * 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; > + 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]; > + > + /* reduce 32 bit checksum to 16 bits and complement it */ > + ip_cksum =3D (ip_cksum & 0xffff) + (ip_cksum >> 16); > + ip_cksum =3D (ip_cksum & 0xffff) + (ip_cksum >> 16); > + ip_cksum =3D (~ip_cksum) & 0x0000FFFF; > + return (ip_cksum =3D=3D 0) ? 0xFFFF : (uint16_t) ip_cksum; The zero exception does not apply to the checksum stored in the IP = header, only to the checksum in the UDP header. > +} Besides that, for the series, Acked-by: Morten Br=F8rup