DPDK patches and discussions
 help / color / mirror / Atom feed
From: Scott Mitchell <scott.k.mitch1@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: dev@dpdk.org, mb@smartsharesystems.com
Subject: Re: [PATCH v7] net: optimize raw checksum computation
Date: Thu, 8 Jan 2026 16:25:56 -0500	[thread overview]
Message-ID: <CAFn2buC7mCHo8PA3vxhtUvqkCboLCZ9coy-q2HpYCf2vAaeERQ@mail.gmail.com> (raw)
In-Reply-To: <20260108082433.3a70ca07@phoenix.local>

On Thu, Jan 8, 2026 at 11:24 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Thu,  8 Jan 2026 09:59:13 -0500
> scott.k.mitch1@gmail.com wrote:
>
> > diff --git a/lib/net/rte_ip4.h b/lib/net/rte_ip4.h
> > index 822a660cfb..67033875cc 100644
> > --- a/lib/net/rte_ip4.h
> > +++ b/lib/net/rte_ip4.h
> > @@ -223,21 +223,19 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)
> >               uint8_t  zero;     /* zero. */
> >               uint8_t  proto;    /* L4 protocol type. */
> >               uint16_t len;      /* L4 length. */
> > -     } psd_hdr;
> > -
> > -     uint32_t l3_len;
> > -
> > -     psd_hdr.src_addr = ipv4_hdr->src_addr;
> > -     psd_hdr.dst_addr = ipv4_hdr->dst_addr;
> > -     psd_hdr.zero = 0;
> > -     psd_hdr.proto = ipv4_hdr->next_proto_id;
> > -     if (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) {
> > -             psd_hdr.len = 0;
> > -     } else {
> > -             l3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);
> > -             psd_hdr.len = rte_cpu_to_be_16((uint16_t)(l3_len -
> > -                     rte_ipv4_hdr_len(ipv4_hdr)));
> > -     }
> > +     } psd_hdr = {
> > +             .src_addr = ipv4_hdr->src_addr,
> > +             .dst_addr = ipv4_hdr->dst_addr,
> > +             .proto = ipv4_hdr->next_proto_id,
> > +             .len = (ol_flags & (RTE_MBUF_F_TX_TCP_SEG | RTE_MBUF_F_TX_UDP_SEG)) ? 0 :
> > +                     rte_cpu_to_be_16((uint16_t)(rte_be_to_cpu_16(ipv4_hdr->total_length) -
> > +                             rte_ipv4_hdr_len(ipv4_hdr)))
> > +     };
> > +#ifdef RTE_
>
> I find it hard to read complex expressions in initialiazers.
> Much better as original if statement.
> Sometimes you need a union to convince compiler of aliasing
>

I improved the readability of the ternary in the v8 patch (coming soon).
Rational for using an initializer is to lean on the c99 spec which
guarantees the
memory is initialized. Given the ambiguity around "maybe uninitialized
variable use" I made the code in question explicit on initialization.
Let me know
if the approach in v8 patch is not inline with dpdk standards/convention and I
can rework.

      reply	other threads:[~2026-01-08 21:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08 14:59 scott.k.mitch1
2026-01-08 16:24 ` Stephen Hemminger
2026-01-08 21:25   ` Scott Mitchell [this message]

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=CAFn2buC7mCHo8PA3vxhtUvqkCboLCZ9coy-q2HpYCf2vAaeERQ@mail.gmail.com \
    --to=scott.k.mitch1@gmail.com \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.com \
    --cc=stephen@networkplumber.org \
    /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).