DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: <dev@dpdk.org>, Jerin Jacob <jerinj@marvell.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>
Subject: Re: [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases
Date: Thu, 17 Oct 2024 20:03:13 +0100	[thread overview]
Message-ID: <ZxFfcRh9pgkTYVfH@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F7F3@smartserver.smartshare.dk>

On Thu, Oct 17, 2024 at 07:15:10PM +0200, Morten Brørup wrote:
> > +/**
> > + * 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 = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl;
> > +	ip_cksum = 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 = (ip_cksum & 0xffff) + (ip_cksum >> 16);
> > +	ip_cksum = (ip_cksum & 0xffff) + (ip_cksum >> 16);
> > +	ip_cksum = (~ip_cksum) & 0x0000FFFF;
> > +	return (ip_cksum == 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.
> 

I was wondering about that, because I didn't see it mentioned anywhere in
the RFCs I consulted, but on the other hand all the implementations in the
code seemed to have the check for zero.

> > +}
> 
> Besides that, for the series,

So, just to confirm, the zero check at the end of the new ip_cksum_simple
function should be removed and we always return the computed value
directly?

> Acked-by: Morten Brørup <mb@smartsharesystems.com>
> 

  reply	other threads:[~2024-10-17 19:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17 14:22 [PATCH 0/6] Reduce scope address-of-packed-member warning Bruce Richardson
2024-10-17 14:22 ` [PATCH 1/6] ip_frag: remove use of unaligned variable Bruce Richardson
2024-10-17 16:26   ` Stephen Hemminger
2024-10-17 16:42   ` Konstantin Ananyev
2024-10-17 14:22 ` [PATCH 2/6] efd: remove unnecessary packed attributes Bruce Richardson
2024-10-17 16:22   ` Stephen Hemminger
2024-10-17 14:22 ` [PATCH 3/6] bus/ifpga: remove packed attribute Bruce Richardson
2024-10-17 14:52   ` Xu, Rosen
2024-10-17 16:25   ` Stephen Hemminger
2024-10-17 14:22 ` [PATCH 4/6] pipeline: " Bruce Richardson
2024-10-17 14:24   ` Bruce Richardson
2024-10-17 16:25   ` Stephen Hemminger
2024-10-17 14:22 ` [PATCH 5/6] net: add smaller IPv4 cksum function for simple cases Bruce Richardson
2024-10-17 16:24   ` Stephen Hemminger
2024-10-17 17:01     ` Bruce Richardson
2024-10-17 17:15   ` Morten Brørup
2024-10-17 19:03     ` Bruce Richardson [this message]
2024-10-17 19:34       ` Stephen Hemminger
2024-10-18  0:32         ` Morten Brørup
2024-10-17 14:22 ` [PATCH 6/6] build: limit scope of packed member warning disabling Bruce Richardson
2024-10-17 16:21 ` [PATCH 0/6] Reduce scope address-of-packed-member warning Stephen Hemminger
2024-10-17 17:02   ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZxFfcRh9pgkTYVfH@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=mb@smartsharesystems.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).