From: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org,
Louis Peens <louis.peens@corigine.com>,
Yanguo Li <yanguo.li@corigine.com>,
oss-drivers@corigine.com,
Taras Chornyi <taras.chornyi@plvision.eu>,
Woojung Huh <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
Edward Cree <ecree.xilinx@gmail.com>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>
Subject: Re: [PATCH net-next v2 1/4] flow_offload: add control flag checking helpers
Date: Wed, 10 Apr 2024 11:27:59 +0000 [thread overview]
Message-ID: <628da266-fe6a-4e4d-8fc0-9d416dc39eaa@fiberby.net> (raw)
In-Reply-To: <20240410093235.5334-2-ast@fiberby.net>
On 4/10/24 9:32 AM, Asbjørn Sloth Tønnesen wrote:
> These helpers aim to help drivers, with checking
> for the presence of unsupported control flags.
>
> For drivers supporting at least one control flag:
> flow_rule_is_supp_control_flags()
>
> For drivers using flow_rule_match_control(), but not using flags:
> flow_rule_has_control_flags()
>
> For drivers not using flow_rule_match_control():
> flow_rule_match_has_control_flags()
>
> While primarily aimed at FLOW_DISSECTOR_KEY_CONTROL
> and flow_rule_match_control(), then the first two
> can also be used with FLOW_DISSECTOR_KEY_ENC_CONTROL
> and flow_rule_match_enc_control().
>
> These helpers mirrors the existing check done in sfc:
> drivers/net/ethernet/sfc/tc.c +276
>
> Only compile-tested.
>
> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
> ---
> include/net/flow_offload.h | 55 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 55 insertions(+)
>
> diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
> index 314087a5e1818..9ee3ad4a308a8 100644
> --- a/include/net/flow_offload.h
> +++ b/include/net/flow_offload.h
> @@ -449,6 +449,61 @@ static inline bool flow_rule_match_key(const struct flow_rule *rule,
> return dissector_uses_key(rule->match.dissector, key);
> }
>
> +/**
> + * flow_rule_is_supp_control_flags() - check for supported control flags
> + * @supp_flags: control flags supported by driver
> + * @ctrl_flags: control flags present in rule
> + * @extack: The netlink extended ACK for reporting errors.
> + *
> + * @returns true if only supported control flags are set, false otherwise.
> + */
The kdoc test failed:
> include/net/flow_offload.h:463: warning: No description found for return value of 'flow_rule_is_supp_control_flags'
For some reason I didn't find kernel-doc.rst, because I searched for autodoc sphinx stuff.
Will do proper "Return:" in v3.
I wasn't able to reproduce the kdoc failure[1] locally:
$ ./scripts/kernel-doc -none include/net/flow_offload.h
$ ./scripts/kernel-doc -none -v include/net/flow_offload.h
include/net/flow_offload.h:345: info: Scanning doc for function flow_offload_has_one_action
include/net/flow_offload.h:453: info: Scanning doc for function flow_rule_is_supp_control_flags
include/net/flow_offload.h:475: info: Scanning doc for function flow_rule_has_control_flags
include/net/flow_offload.h:488: info: Scanning doc for function flow_rule_match_has_control_flags
[1] https://netdev.bots.linux.dev/static/nipa/843159/13623977/kdoc/
pw-bot: changes-requested
> +static inline bool flow_rule_is_supp_control_flags(const u32 supp_flags,
> + const u32 ctrl_flags,
> + struct netlink_ext_ack *extack)
> +{
> + if (likely((ctrl_flags & ~supp_flags) == 0))
> + return true;
> +
> + NL_SET_ERR_MSG_FMT_MOD(extack,
> + "Unsupported match on control.flags %#x",
> + ctrl_flags);
> +
> + return false;
> +}
> +
> +/**
> + * flow_rule_has_control_flags() - check for presence of any control flags
> + * @ctrl_flags: control flags present in rule
> + * @extack: The netlink extended ACK for reporting errors.
> + *
> + * @returns true if control flags are set, false otherwise.
> + */
> +static inline bool flow_rule_has_control_flags(const u32 ctrl_flags,
> + struct netlink_ext_ack *extack)
> +{
> + return !flow_rule_is_supp_control_flags(0, ctrl_flags, extack);
> +}
> +
> +/**
> + * flow_rule_match_has_control_flags() - match and check for any control flags
> + * @rule: The flow_rule under evaluation.
> + * @extack: The netlink extended ACK for reporting errors.
> + *
> + * @returns true if control flags are set, false otherwise.
> + */
> +static inline bool flow_rule_match_has_control_flags(struct flow_rule *rule,
> + struct netlink_ext_ack *extack)
> +{
> + struct flow_match_control match;
> +
> + if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL))
> + return false;
> +
> + flow_rule_match_control(rule, &match);
> +
> + return flow_rule_has_control_flags(match.mask->flags, extack);
> +}
> +
> struct flow_stats {
> u64 pkts;
> u64 bytes;
--
Best regards
Asbjørn Sloth Tønnesen
Network Engineer
Fiberby - AS42541
next prev parent reply other threads:[~2024-04-10 11:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 9:32 [PATCH net-next v2 0/4] flower: validate control flags Asbjørn Sloth Tønnesen
2024-04-10 9:32 ` [PATCH net-next v2 1/4] flow_offload: add control flag checking helpers Asbjørn Sloth Tønnesen
2024-04-10 11:27 ` Asbjørn Sloth Tønnesen [this message]
2024-04-11 6:24 ` Louis Peens
2024-04-10 9:32 ` [PATCH net-next v2 2/4] nfp: flower: fix check for unsupported control flags Asbjørn Sloth Tønnesen
2024-04-11 6:59 ` Louis Peens
2024-04-10 9:32 ` [PATCH net-next v2 3/4] net: prestera: flower: validate " Asbjørn Sloth Tønnesen
2024-04-10 9:32 ` [PATCH net-next v2 4/4] net: dsa: microchip: ksz9477: " Asbjørn Sloth Tønnesen
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=628da266-fe6a-4e4d-8fc0-9d416dc39eaa@fiberby.net \
--to=ast@fiberby.net \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=louis.peens@corigine.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=oss-drivers@corigine.com \
--cc=pabeni@redhat.com \
--cc=taras.chornyi@plvision.eu \
--cc=woojung.huh@microchip.com \
--cc=xiyou.wangcong@gmail.com \
--cc=yanguo.li@corigine.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
all inboxes | Powered by JetHome®