netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: David Wei <dw@davidwei.uk>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
	donald.hunter@gmail.com, jacob.e.keller@intel.com,
	sdf@fomichev.me
Subject: Re: [PATCH net-next 2/3] tools: ynl-gen: split presence metadata
Date: Mon, 5 May 2025 17:27:50 -0700	[thread overview]
Message-ID: <20250505172750.2c0a8f2b@kernel.org> (raw)
In-Reply-To: <a6842c5f-032c-4003-9e7c-2705fecc2835@davidwei.uk>

On Mon, 5 May 2025 14:06:29 -0700 David Wei wrote:
> > @@ -282,6 +281,7 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
> >               # Every layer below last is a nest, so we know it uses bit presence
> >               # last layer is "self" and may be a complex type
> >               if i == len(ref) - 1 and self.presence_type() != 'present':
> > +                presence = f"{var}->{'.'.join(ref[:i] + [''])}_{self.presence_type()}.{ref[i]}"  
> 
> Can this go a few lines higher and replace:
> 
>              presence = f"{var}->{'.'.join(ref[:i] + [''])}_present.{ref[i]}"
> 
> Since self.presence_type() would always return the correct string,
> including "_present"?

Hm, I don't think so. This is some of the gnarliest code the codegen
has, but it tries to generate something like:

	req->_present.options = 1;
	req->options._present.cgroup = 1;
	req->options.cgroup._count.act = n_act;

We have a nested member called "act". It's two nesting layers deep
inside the requests. We need to mark the "act" as present, but also
all parent nests as present. The nests always have presence type
of "present" (that's why its hardcoded at the start of the loop).
Last layer is the "real" presence type of the attribute, so we use
self.presence_type().

  reply	other threads:[~2025-05-06  0:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-05 16:52 [PATCH net-next 0/3] tools: ynl-gen: split presence metadata Jakub Kicinski
2025-05-05 16:52 ` [PATCH net-next 1/3] tools: ynl-gen: rename basic presence from 'bit' to 'present' Jakub Kicinski
2025-05-05 20:52   ` David Wei
2025-05-05 16:52 ` [PATCH net-next 2/3] tools: ynl-gen: split presence metadata Jakub Kicinski
2025-05-05 21:06   ` David Wei
2025-05-06  0:27     ` Jakub Kicinski [this message]
2025-05-05 16:52 ` [PATCH net-next 3/3] tools: ynl-gen: move the count into a presence struct too Jakub Kicinski
2025-05-08  1:40 ` [PATCH net-next 0/3] tools: ynl-gen: split presence metadata patchwork-bot+netdevbpf

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=20250505172750.2c0a8f2b@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=dw@davidwei.uk \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    /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).