From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Bruce Richardson" <bruce.richardson@intel.com>, <dev@dpdk.org>
Cc: "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 19:15:10 +0200 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F7F3@smartserver.smartshare.dk> (raw)
In-Reply-To: <20241017142214.1669370-6-bruce.richardson@intel.com>
> +/**
> + * 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.
> +}
Besides that, for the series,
Acked-by: Morten Brørup <mb@smartsharesystems.com>
next prev parent reply other threads:[~2024-10-17 17:15 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 [this message]
2024-10-17 19:03 ` Bruce Richardson
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=98CBD80474FA8B44BF855DF32C47DC35E9F7F3@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=aman.deep.singh@intel.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=jerinj@marvell.com \
--cc=konstantin.v.ananyev@yandex.ru \
/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).