From: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>
To: netdev@vger.kernel.org
Cc: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Edward Cree" <ecree.xilinx@gmail.com>,
"Martin Habets" <habetsm.xilinx@gmail.com>,
linux-net-drivers@amd.com, "Saeed Mahameed" <saeedm@nvidia.com>,
"Leon Romanovsky" <leon@kernel.org>,
"Tariq Toukan" <tariqt@nvidia.com>,
linux-rdma@vger.kernel.org,
"Jesse Brandeburg" <jesse.brandeburg@intel.com>,
"Tony Nguyen" <anthony.l.nguyen@intel.com>,
intel-wired-lan@lists.osuosl.org,
"Louis Peens" <louis.peens@corigine.com>,
oss-drivers@corigine.com, linux-kernel@vger.kernel.org,
"Davide Caratti" <dcaratti@redhat.com>,
i.maximets@ovn.org
Subject: [PATCH net-next 1/5] flow_offload: add encapsulation control flag helpers
Date: Sun, 9 Jun 2024 17:33:51 +0000 [thread overview]
Message-ID: <20240609173358.193178-2-ast@fiberby.net> (raw)
In-Reply-To: <20240609173358.193178-1-ast@fiberby.net>
This patch adds two new helper functions:
flow_rule_is_supp_enc_control_flags()
flow_rule_has_enc_control_flags()
They are intended to be used for validating encapsulation control
flags, and compliment the similar helpers without "enc_" in the name.
The only difference is that they have their own error message,
to make it obvious if an unsupported flag error is related to
FLOW_DISSECTOR_KEY_CONTROL or FLOW_DISSECTOR_KEY_ENC_CONTROL.
flow_rule_has_enc_control_flags() is for drivers supporting
FLOW_DISSECTOR_KEY_ENC_CONTROL, but not supporting any
encapsulation control flags.
(Currently all 4 drivers fits this category)
flow_rule_is_supp_enc_control_flags() is currently only used
for the above helper, but should also be used by drivers once
they implement at least one encapsulation control flag.
There is AFAICT currently no need for an "enc_" variant of
flow_rule_match_has_control_flags(), as all drivers currently
supporting FLOW_DISSECTOR_KEY_ENC_CONTROL, are already calling
flow_rule_match_enc_control() directly.
Only compile tested.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
include/net/flow_offload.h | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index ec9f80509f60c..292cd8f4b762a 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -471,6 +471,28 @@ static inline bool flow_rule_is_supp_control_flags(const u32 supp_flags,
return false;
}
+/**
+ * flow_rule_is_supp_enc_control_flags() - check for supported control flags
+ * @supp_enc_flags: encapsulation control flags supported by driver
+ * @enc_ctrl_flags: encapsulation control flags present in rule
+ * @extack: The netlink extended ACK for reporting errors.
+ *
+ * Return: true if only supported control flags are set, false otherwise.
+ */
+static inline bool flow_rule_is_supp_enc_control_flags(const u32 supp_enc_flags,
+ const u32 enc_ctrl_flags,
+ struct netlink_ext_ack *extack)
+{
+ if (likely((enc_ctrl_flags & ~supp_enc_flags) == 0))
+ return true;
+
+ NL_SET_ERR_MSG_FMT_MOD(extack,
+ "Unsupported match on enc_control.flags %#x",
+ enc_ctrl_flags);
+
+ return false;
+}
+
/**
* flow_rule_has_control_flags() - check for presence of any control flags
* @ctrl_flags: control flags present in rule
@@ -484,6 +506,19 @@ static inline bool flow_rule_has_control_flags(const u32 ctrl_flags,
return !flow_rule_is_supp_control_flags(0, ctrl_flags, extack);
}
+/**
+ * flow_rule_has_enc_control_flags() - check for presence of any control flags
+ * @enc_ctrl_flags: encapsulation control flags present in rule
+ * @extack: The netlink extended ACK for reporting errors.
+ *
+ * Return: true if control flags are set, false otherwise.
+ */
+static inline bool flow_rule_has_enc_control_flags(const u32 enc_ctrl_flags,
+ struct netlink_ext_ack *extack)
+{
+ return !flow_rule_is_supp_enc_control_flags(0, enc_ctrl_flags, extack);
+}
+
/**
* flow_rule_match_has_control_flags() - match and check for any control flags
* @rule: The flow_rule under evaluation.
--
2.45.1
next prev parent reply other threads:[~2024-06-09 17:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-09 17:33 [PATCH net-next 0/5] net: flower: validate encapsulation control flags Asbjørn Sloth Tønnesen
2024-06-09 17:33 ` Asbjørn Sloth Tønnesen [this message]
2024-06-09 17:33 ` [PATCH net-next 2/5] sfc: use flow_rule_is_supp_enc_control_flags() Asbjørn Sloth Tønnesen
2024-06-10 19:31 ` Edward Cree
2024-06-09 17:33 ` [PATCH net-next 3/5] net/mlx5e: flower: validate encapsulation control flags Asbjørn Sloth Tønnesen
2024-06-09 17:33 ` [PATCH net-next 4/5] nfp: " Asbjørn Sloth Tønnesen
2024-06-11 7:24 ` Louis Peens
2024-06-09 17:33 ` [PATCH net-next 5/5] ice: " Asbjørn Sloth Tønnesen
2024-06-10 9:06 ` [Intel-wired-lan] " Marcin Szycik
2024-06-11 9:09 ` [PATCH net-next 0/5] net: " Davide Caratti
2024-06-13 1:04 ` Jakub Kicinski
2024-06-13 17:38 ` Asbjørn Sloth Tønnesen
2024-06-13 1:10 ` 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=20240609173358.193178-2-ast@fiberby.net \
--to=ast@fiberby.net \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=habetsm.xilinx@gmail.com \
--cc=i.maximets@ovn.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jesse.brandeburg@intel.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-net-drivers@amd.com \
--cc=linux-rdma@vger.kernel.org \
--cc=louis.peens@corigine.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@corigine.com \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@nvidia.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