diff mbox series

[net-next,v2,12/14] net: qede: use faked extack in qede_flow_spec_to_rule()

Message ID 20240508143404.95901-13-ast@fiberby.net (mailing list archive)
State Accepted
Commit eb705d7345255316f3a25ba60c4c7ee215c92c1a
Delegated to: Netdev Maintainers
Headers show
Series net: qede: convert filter code to use extack | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 926 this patch: 926
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 937 this patch: 937
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 937 this patch: 937
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-10--18-00 (tests: 1014)

Commit Message

Asbjørn Sloth Tønnesen May 8, 2024, 2:34 p.m. UTC
Since qede_parse_flow_attr() now does error reporting
through extack, then give it a fake extack and extract the
error message afterwards if one was set.

The extracted error message is then passed on through
DP_NOTICE(), including messages that was earlier issued
with DP_INFO().

This fake extack approach is already used by
mlxsw_env_linecard_modules_power_mode_apply() in
drivers/net/ethernet/mellanox/mlxsw/core_env.c

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>

---
Note:
Even through _msg is marked in include/linux/netlink.h as
"don't access directly, use NL_SET_ERR_MSG", then the comment
above NL_SET_ERR_MSG, seams to indicate that it should be fine
to access it directly if for reading, as is done other places.
I could also add a NL_GET_ERR_MSG but I would rather not do that
in this series.
---
 drivers/net/ethernet/qlogic/qede/qede_filter.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Simon Horman May 10, 2024, 11:30 a.m. UTC | #1
On Wed, May 08, 2024 at 02:34:00PM +0000, Asbjørn Sloth Tønnesen wrote:
> Since qede_parse_flow_attr() now does error reporting
> through extack, then give it a fake extack and extract the
> error message afterwards if one was set.
> 
> The extracted error message is then passed on through
> DP_NOTICE(), including messages that was earlier issued
> with DP_INFO().
> 
> This fake extack approach is already used by
> mlxsw_env_linecard_modules_power_mode_apply() in
> drivers/net/ethernet/mellanox/mlxsw/core_env.c
> 
> Only compile tested.
> 
> Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
> 
> ---
> Note:
> Even through _msg is marked in include/linux/netlink.h as
> "don't access directly, use NL_SET_ERR_MSG", then the comment
> above NL_SET_ERR_MSG, seams to indicate that it should be fine
> to access it directly if for reading, as is done other places.
> I could also add a NL_GET_ERR_MSG but I would rather not do that
> in this series.

Reviewed-by: Simon Horman <horms@kernel.org>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 8c1c15b73125..b83432744a03 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1990,6 +1990,7 @@  static int qede_flow_spec_to_rule(struct qede_dev *edev,
 {
 	struct ethtool_rx_flow_spec_input input = {};
 	struct ethtool_rx_flow_rule *flow;
+	struct netlink_ext_ack extack;
 	__be16 proto;
 	int err;
 
@@ -2017,7 +2018,7 @@  static int qede_flow_spec_to_rule(struct qede_dev *edev,
 	if (IS_ERR(flow))
 		return PTR_ERR(flow);
 
-	err = qede_parse_flow_attr(proto, flow->rule, t, NULL);
+	err = qede_parse_flow_attr(proto, flow->rule, t, &extack);
 	if (err)
 		goto err_out;
 
@@ -2025,6 +2026,8 @@  static int qede_flow_spec_to_rule(struct qede_dev *edev,
 	err = qede_flow_spec_validate(edev, &flow->rule->action, t,
 				      fs->location);
 err_out:
+	if (extack._msg)
+		DP_NOTICE(edev, "%s\n", extack._msg);
 	ethtool_rx_flow_rule_destroy(flow);
 	return err;