netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guillaume Nault <gnault@redhat.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, robh@kernel.org, johannes@sipsolutions.net,
	ecree.xilinx@gmail.com, stephen@networkplumber.org,
	sdf@google.com, f.fainelli@gmail.com, fw@strlen.de,
	linux-doc@vger.kernel.org, razor@blackwall.org,
	nicolas.dichtel@6wind.com
Subject: Re: [PATCH net-next v2 3/7] net: add basic C code generators for Netlink
Date: Thu, 6 Oct 2022 14:51:09 +0200	[thread overview]
Message-ID: <20221006125109.GE3328@localhost.localdomain> (raw)
In-Reply-To: <20220930023418.1346263-4-kuba@kernel.org>

On Thu, Sep 29, 2022 at 07:34:14PM -0700, Jakub Kicinski wrote:
> Code generators to turn Netlink specs into C code.
> I'm definitely not proud of it.
> 
> The main generator is in Python, there's a bash script
> to regen all code-gen'ed files in tree after making
> spec changes.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> --
> v2: - use /* */ comments instead of //

Probably not a very interesting feedback, but there
are still many comments generated in the // style.

For example in this block:

> +    if args.mode == "kernel":
> +        if args.header:
> +            if parsed.kernel_policy == 'global':
> +                cw.p(f"// Global operation policy for {parsed.name}")
> +
> +                struct = Struct(parsed, parsed.global_policy_set, type_list=parsed.global_policy)
> +                print_req_policy_fwd(cw, struct)
> +                cw.nl()
> +
> +            for op_name, op in parsed.ops.items():
> +                if parsed.kernel_policy == 'per-op' and 'do' in op and 'event' not in op:
> +                    cw.p(f"// {op.enum_name} - do")
> +                    ri = RenderInfo(cw, parsed, args.mode, op, op_name, "do")
> +                    print_req_policy_fwd(cw, ri.struct['request'], op=op)
> +                    cw.nl()
> +
> +            print_kernel_op_table_fwd(parsed, cw)
> +        else:
> +            if parsed.kernel_policy == 'global':
> +                cw.p(f"// Global operation policy for {parsed.name}")
> +
> +                struct = Struct(parsed, parsed.global_policy_set, type_list=parsed.global_policy)
> +                print_req_policy(cw, struct)
> +                cw.nl()
> +
> +            for op_name, op in parsed.ops.items():
> +                if parsed.kernel_policy == 'per-op':
> +                    for op_mode in {'do', 'dump'}:
> +                        if op_mode in op and 'request' in op[op_mode]:
> +                            cw.p(f"// {op.enum_name} - {op_mode}")
> +                            ri = RenderInfo(cw, parsed, args.mode, op, op_name, op_mode)
> +                            print_req_policy(cw, ri.struct['request'], op=op)
> +                            cw.nl()
> +
> +            print_kernel_op_table(parsed, cw)


  reply	other threads:[~2022-10-06 12:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-30  2:34 [PATCH net-next v2 0/7] Netlink protocol specs Jakub Kicinski
2022-09-30  2:34 ` [PATCH net-next v2 1/7] docs: add more netlink docs (incl. spec docs) Jakub Kicinski
2022-10-10  9:56   ` Guillaume Nault
2022-09-30  2:34 ` [PATCH net-next v2 2/7] netlink: add schemas for YAML specs Jakub Kicinski
2022-09-30  2:34 ` [PATCH net-next v2 3/7] net: add basic C code generators for Netlink Jakub Kicinski
2022-10-06 12:51   ` Guillaume Nault [this message]
2022-10-06 14:55     ` Jakub Kicinski
2022-10-07  8:54       ` Guillaume Nault
2022-09-30  2:34 ` [PATCH net-next v2 4/7] netlink: add a proto specification for FOU Jakub Kicinski
2022-09-30  2:34 ` [PATCH net-next v2 5/7] net: fou: regenerate the uAPI from the spec Jakub Kicinski
2022-09-30  2:34 ` [PATCH net-next v2 6/7] net: fou: rename the source for linking Jakub Kicinski
2022-09-30  2:34 ` [PATCH net-next v2 7/7] net: fou: use policy and operation tables generated from the spec Jakub Kicinski

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=20221006125109.GE3328@localhost.localdomain \
    --to=gnault@redhat.com \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=fw@strlen.de \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=robh@kernel.org \
    --cc=sdf@google.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).