2024-05-07 10:45:09

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 00/14] net: qede: convert filter code to use extack

This series converts the filter code in the qede driver
to use NL_SET_ERR_MSG_*(extack, ...) for error handling.

Patch 1-12 converts qede_parse_flow_attr() to use extack,
along with all it's static helper functions.

qede_parse_flow_attr() is used in two places:
- qede_add_tc_flower_fltr()
- qede_flow_spec_to_rule()

In the latter call site extack is faked in the same way as
is done in mlxsw (patch 12).

While the conversion is going on, some error messages are silenced
in between patch 1-12. If wanted could squash patch 1-12 in a v2, but
I felt that it would be easier to review as 12 more trivial patches.

Patch 13 and 14, finishes up by converting qede_parse_actions(),
and ensures that extack is propagated to it, in both call contexts.

Asbjørn Sloth Tønnesen (14):
net: qede: use extack in qede_flow_parse_ports()
net: qede: use extack in qede_set_v6_tuple_to_profile()
net: qede: use extack in qede_set_v4_tuple_to_profile()
net: qede: use extack in qede_flow_parse_v6_common()
net: qede: use extack in qede_flow_parse_v4_common()
net: qede: use extack in qede_flow_parse_tcp_v6()
net: qede: use extack in qede_flow_parse_tcp_v4()
net: qede: use extack in qede_flow_parse_udp_v6()
net: qede: use extack in qede_flow_parse_udp_v4()
net: qede: add extack in qede_add_tc_flower_fltr()
net: qede: use extack in qede_parse_flow_attr()
net: qede: use faked extack in qede_flow_spec_to_rule()
net: qede: propagate extack through qede_flow_spec_validate()
net: qede: use extack in qede_parse_actions()

.../net/ethernet/qlogic/qede/qede_filter.c | 99 ++++++++++---------
1 file changed, 55 insertions(+), 44 deletions(-)

--
2.43.0



2024-05-07 10:45:09

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 08/14] net: qede: use extack in qede_flow_parse_udp_v6()

Convert qede_flow_parse_udp_v6() to take extack,
and drop the edev argument.

Pass extack in call to qede_flow_parse_v6_common().

In call to qede_flow_parse_udp_v6(), use NULL as extack
for now, until a subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 2c1f860d30e3..e7b9aeef5a6f 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1806,13 +1806,13 @@ qede_flow_parse_tcp_v4(struct netlink_ext_ack *extack, struct flow_rule *rule,
}

static int
-qede_flow_parse_udp_v6(struct qede_dev *edev, struct flow_rule *rule,
- struct qede_arfs_tuple *tuple)
+qede_flow_parse_udp_v6(struct netlink_ext_ack *extack, struct flow_rule *rule,
+ struct qede_arfs_tuple *tuple)
{
tuple->ip_proto = IPPROTO_UDP;
tuple->eth_proto = htons(ETH_P_IPV6);

- return qede_flow_parse_v6_common(NULL, rule, tuple);
+ return qede_flow_parse_v6_common(extack, rule, tuple);
}

static int
@@ -1866,7 +1866,7 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IP))
rc = qede_flow_parse_udp_v4(edev, rule, tuple);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IPV6))
- rc = qede_flow_parse_udp_v6(edev, rule, tuple);
+ rc = qede_flow_parse_udp_v6(NULL, rule, tuple);
else
DP_NOTICE(edev, "Invalid protocol request\n");

--
2.43.0


2024-05-07 10:46:48

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 09/14] net: qede: use extack in qede_flow_parse_udp_v4()

Convert qede_flow_parse_udp_v4() to take extack,
and drop the edev argument.

Pass extack in call to qede_flow_parse_v4_common().

In call to qede_flow_parse_udp_v4(), use NULL as extack
for now, until a subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index e7b9aeef5a6f..de6b9a60d4cf 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1816,13 +1816,13 @@ qede_flow_parse_udp_v6(struct netlink_ext_ack *extack, struct flow_rule *rule,
}

static int
-qede_flow_parse_udp_v4(struct qede_dev *edev, struct flow_rule *rule,
- struct qede_arfs_tuple *tuple)
+qede_flow_parse_udp_v4(struct netlink_ext_ack *extack, struct flow_rule *rule,
+ struct qede_arfs_tuple *tuple)
{
tuple->ip_proto = IPPROTO_UDP;
tuple->eth_proto = htons(ETH_P_IP);

- return qede_flow_parse_v4_common(NULL, rule, tuple);
+ return qede_flow_parse_v4_common(extack, rule, tuple);
}

static int
@@ -1864,7 +1864,7 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
else if (ip_proto == IPPROTO_TCP && proto == htons(ETH_P_IPV6))
rc = qede_flow_parse_tcp_v6(NULL, rule, tuple);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IP))
- rc = qede_flow_parse_udp_v4(edev, rule, tuple);
+ rc = qede_flow_parse_udp_v4(NULL, rule, tuple);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IPV6))
rc = qede_flow_parse_udp_v6(NULL, rule, tuple);
else
--
2.43.0


2024-05-07 10:46:51

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 02/14] net: qede: use extack in qede_set_v6_tuple_to_profile()

Convert qede_set_v6_tuple_to_profile() to take extack,
and drop the edev argument.

Convert DP_INFO call to use NL_SET_ERR_MSG_MOD instead.

In calls to qede_set_v6_tuple_to_profile(), use NULL as extack
for now, until a subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 3995baa2daa6..19ffb0823d55 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1549,7 +1549,7 @@ static int qede_set_v4_tuple_to_profile(struct qede_dev *edev,
return 0;
}

-static int qede_set_v6_tuple_to_profile(struct qede_dev *edev,
+static int qede_set_v6_tuple_to_profile(struct netlink_ext_ack *extack,
struct qede_arfs_tuple *t,
struct in6_addr *zaddr)
{
@@ -1573,7 +1573,7 @@ static int qede_set_v6_tuple_to_profile(struct qede_dev *edev,
!memcmp(&t->src_ipv6, zaddr, sizeof(struct in6_addr))) {
t->mode = QED_FILTER_CONFIG_MODE_IP_DEST;
} else {
- DP_INFO(edev, "Invalid N-tuple\n");
+ NL_SET_ERR_MSG_MOD(extack, "Invalid N-tuple");
return -EOPNOTSUPP;
}

@@ -1752,7 +1752,7 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule,
if (err)
return err;

- return qede_set_v6_tuple_to_profile(edev, t, &zero_addr);
+ return qede_set_v6_tuple_to_profile(NULL, t, &zero_addr);
}

static int
--
2.43.0


2024-05-07 10:47:12

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 10/14] net: qede: add extack in qede_add_tc_flower_fltr()

Define extack locally, to reduce line lengths and aid future users.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index de6b9a60d4cf..5b353a160d15 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1876,6 +1876,7 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
struct flow_cls_offload *f)
{
+ struct netlink_ext_ack *extack = f->common.extack;
struct qede_arfs_fltr_node *n;
struct qede_arfs_tuple t;
int min_hlen, rc;
@@ -1903,7 +1904,7 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
}

/* parse tc actions and get the vf_id */
- rc = qede_parse_actions(edev, &f->rule->action, f->common.extack);
+ rc = qede_parse_actions(edev, &f->rule->action, extack);
if (rc)
goto unlock;

--
2.43.0


2024-05-07 10:48:05

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 05/14] net: qede: use extack in qede_flow_parse_v4_common()

Convert qede_flow_parse_v4_common() to take extack,
and drop the edev argument.

Convert DP_NOTICE call to use NL_SET_ERR_MSG_MOD instead.

Pass extack in calls to qede_flow_parse_ports() and
qede_set_v4_tuple_to_profile().

In calls to qede_flow_parse_v4_common(), use NULL as extack
for now, until a subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index d151b64a0436..056384362037 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1757,8 +1757,9 @@ qede_flow_parse_v6_common(struct netlink_ext_ack *extack,
}

static int
-qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule,
- struct qede_arfs_tuple *t)
+qede_flow_parse_v4_common(struct netlink_ext_ack *extack,
+ struct flow_rule *rule,
+ struct qede_arfs_tuple *t)
{
int err;

@@ -1768,7 +1769,8 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule,
flow_rule_match_ipv4_addrs(rule, &match);
if ((match.key->src && match.mask->src != htonl(U32_MAX)) ||
(match.key->dst && match.mask->dst != htonl(U32_MAX))) {
- DP_NOTICE(edev, "Do not support ipv4 prefix/masks\n");
+ NL_SET_ERR_MSG_MOD(extack,
+ "Do not support ipv4 prefix/masks");
return -EINVAL;
}

@@ -1776,11 +1778,11 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule,
t->dst_ipv4 = match.key->dst;
}

- err = qede_flow_parse_ports(NULL, rule, t);
+ err = qede_flow_parse_ports(extack, rule, t);
if (err)
return err;

- return qede_set_v4_tuple_to_profile(NULL, t);
+ return qede_set_v4_tuple_to_profile(extack, t);
}

static int
@@ -1800,7 +1802,7 @@ qede_flow_parse_tcp_v4(struct qede_dev *edev, struct flow_rule *rule,
tuple->ip_proto = IPPROTO_TCP;
tuple->eth_proto = htons(ETH_P_IP);

- return qede_flow_parse_v4_common(edev, rule, tuple);
+ return qede_flow_parse_v4_common(NULL, rule, tuple);
}

static int
@@ -1820,7 +1822,7 @@ qede_flow_parse_udp_v4(struct qede_dev *edev, struct flow_rule *rule,
tuple->ip_proto = IPPROTO_UDP;
tuple->eth_proto = htons(ETH_P_IP);

- return qede_flow_parse_v4_common(edev, rule, tuple);
+ return qede_flow_parse_v4_common(NULL, rule, tuple);
}

static int
--
2.43.0


2024-05-07 10:55:01

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 14/14] net: qede: use extack in qede_parse_actions()

Convert DP_NOTICE/DP_INFO to NL_SET_ERR_MSG_MOD.

Keep edev around for use with QEDE_RSS_COUNT().

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 7789a8b5b065..5a3ce86fba1f 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1671,7 +1671,7 @@ static int qede_parse_actions(struct qede_dev *edev,
int i;

if (!flow_action_has_entries(flow_action)) {
- DP_NOTICE(edev, "No actions received\n");
+ NL_SET_ERR_MSG_MOD(extack, "No actions received");
return -EINVAL;
}

@@ -1687,7 +1687,8 @@ static int qede_parse_actions(struct qede_dev *edev,
break;

if (act->queue.index >= QEDE_RSS_COUNT(edev)) {
- DP_INFO(edev, "Queue out-of-bounds\n");
+ NL_SET_ERR_MSG_MOD(extack,
+ "Queue out-of-bounds");
return -EINVAL;
}
break;
--
2.43.0


2024-05-07 10:55:15

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 03/14] net: qede: use extack in qede_set_v4_tuple_to_profile()

Convert qede_set_v4_tuple_to_profile() to take extack,
and drop the edev argument.

Convert DP_INFO call to use NL_SET_ERR_MSG_MOD instead.

In calls to qede_set_v4_tuple_to_profile(), use NULL as extack
for now, until a subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 19ffb0823d55..0d429f5b9c57 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1520,7 +1520,7 @@ static int qede_flow_spec_validate_unused(struct qede_dev *edev,
return 0;
}

-static int qede_set_v4_tuple_to_profile(struct qede_dev *edev,
+static int qede_set_v4_tuple_to_profile(struct netlink_ext_ack *extack,
struct qede_arfs_tuple *t)
{
/* We must have Only 4-tuples/l4 port/src ip/dst ip
@@ -1538,7 +1538,7 @@ static int qede_set_v4_tuple_to_profile(struct qede_dev *edev,
t->dst_ipv4 && !t->src_ipv4) {
t->mode = QED_FILTER_CONFIG_MODE_IP_DEST;
} else {
- DP_INFO(edev, "Invalid N-tuple\n");
+ NL_SET_ERR_MSG_MOD(extack, "Invalid N-tuple");
return -EOPNOTSUPP;
}

@@ -1779,7 +1779,7 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule,
if (err)
return err;

- return qede_set_v4_tuple_to_profile(edev, t);
+ return qede_set_v4_tuple_to_profile(NULL, t);
}

static int
--
2.43.0


2024-05-07 10:58:12

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 13/14] net: qede: propagate extack through qede_flow_spec_validate()

Pass extack to qede_flow_spec_validate() when called in
qede_flow_spec_to_rule().

Pass extack to qede_parse_actions().

Not converting qede_flow_spec_validate() to use extack for
errors, as it's only called from qede_flow_spec_to_rule(),
where extack is faked into a DP_NOTICE anyway, so opting to
keep DP_VERBOSE/DP_NOTICE usage.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 3727ab5af088..7789a8b5b065 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1952,6 +1952,7 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
static int qede_flow_spec_validate(struct qede_dev *edev,
struct flow_action *flow_action,
struct qede_arfs_tuple *t,
+ struct netlink_ext_ack *extack,
__u32 location)
{
int err;
@@ -1976,7 +1977,7 @@ static int qede_flow_spec_validate(struct qede_dev *edev,
return -EINVAL;
}

- err = qede_parse_actions(edev, flow_action, NULL);
+ err = qede_parse_actions(edev, flow_action, extack);
if (err)
return err;

@@ -2023,7 +2024,7 @@ static int qede_flow_spec_to_rule(struct qede_dev *edev,

/* Make sure location is valid and filter isn't already set */
err = qede_flow_spec_validate(edev, &flow->rule->action, t,
- fs->location);
+ &extack, fs->location);
err_out:
if (extack._msg)
DP_NOTICE(edev, "%s\n", extack._msg);
--
2.43.0


2024-05-07 10:59:00

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 07/14] net: qede: use extack in qede_flow_parse_tcp_v4()

Convert qede_flow_parse_tcp_v4() to take extack,
and drop the edev argument.

Pass extack in call to qede_flow_parse_v4_common().

In call to qede_flow_parse_tcp_v4(), use NULL as extack
for now, until a subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index bc0e95ba1880..2c1f860d30e3 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1796,13 +1796,13 @@ qede_flow_parse_tcp_v6(struct netlink_ext_ack *extack, struct flow_rule *rule,
}

static int
-qede_flow_parse_tcp_v4(struct qede_dev *edev, struct flow_rule *rule,
- struct qede_arfs_tuple *tuple)
+qede_flow_parse_tcp_v4(struct netlink_ext_ack *extack, struct flow_rule *rule,
+ struct qede_arfs_tuple *tuple)
{
tuple->ip_proto = IPPROTO_TCP;
tuple->eth_proto = htons(ETH_P_IP);

- return qede_flow_parse_v4_common(NULL, rule, tuple);
+ return qede_flow_parse_v4_common(extack, rule, tuple);
}

static int
@@ -1860,7 +1860,7 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
}

if (ip_proto == IPPROTO_TCP && proto == htons(ETH_P_IP))
- rc = qede_flow_parse_tcp_v4(edev, rule, tuple);
+ rc = qede_flow_parse_tcp_v4(NULL, rule, tuple);
else if (ip_proto == IPPROTO_TCP && proto == htons(ETH_P_IPV6))
rc = qede_flow_parse_tcp_v6(NULL, rule, tuple);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IP))
--
2.43.0


2024-05-07 10:59:07

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 04/14] net: qede: use extack in qede_flow_parse_v6_common()

Convert qede_flow_parse_v6_common() to take extack,
and drop the edev argument.

Convert DP_NOTICE call to use NL_SET_ERR_MSG_MOD instead.

Pass extack in calls to qede_flow_parse_ports() and
qede_set_v6_tuple_to_profile().

In calls to qede_flow_parse_v6_common(), use NULL as extack
for now, until a subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 0d429f5b9c57..d151b64a0436 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1722,7 +1722,8 @@ qede_flow_parse_ports(struct netlink_ext_ack *extack, struct flow_rule *rule,
}

static int
-qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule,
+qede_flow_parse_v6_common(struct netlink_ext_ack *extack,
+ struct flow_rule *rule,
struct qede_arfs_tuple *t)
{
struct in6_addr zero_addr, addr;
@@ -1739,8 +1740,8 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule,
memcmp(&match.mask->src, &addr, sizeof(addr))) ||
(memcmp(&match.key->dst, &zero_addr, sizeof(addr)) &&
memcmp(&match.mask->dst, &addr, sizeof(addr)))) {
- DP_NOTICE(edev,
- "Do not support IPv6 address prefix/mask\n");
+ NL_SET_ERR_MSG_MOD(extack,
+ "Do not support IPv6 address prefix/mask");
return -EINVAL;
}

@@ -1748,11 +1749,11 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule,
memcpy(&t->dst_ipv6, &match.key->dst, sizeof(addr));
}

- err = qede_flow_parse_ports(NULL, rule, t);
+ err = qede_flow_parse_ports(extack, rule, t);
if (err)
return err;

- return qede_set_v6_tuple_to_profile(NULL, t, &zero_addr);
+ return qede_set_v6_tuple_to_profile(extack, t, &zero_addr);
}

static int
@@ -1789,7 +1790,7 @@ qede_flow_parse_tcp_v6(struct qede_dev *edev, struct flow_rule *rule,
tuple->ip_proto = IPPROTO_TCP;
tuple->eth_proto = htons(ETH_P_IPV6);

- return qede_flow_parse_v6_common(edev, rule, tuple);
+ return qede_flow_parse_v6_common(NULL, rule, tuple);
}

static int
@@ -1809,7 +1810,7 @@ qede_flow_parse_udp_v6(struct qede_dev *edev, struct flow_rule *rule,
tuple->ip_proto = IPPROTO_UDP;
tuple->eth_proto = htons(ETH_P_IPV6);

- return qede_flow_parse_v6_common(edev, rule, tuple);
+ return qede_flow_parse_v6_common(NULL, rule, tuple);
}

static int
--
2.43.0


2024-05-07 11:00:02

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 11/14] net: qede: use extack in qede_parse_flow_attr()

Convert qede_parse_flow_attr() to take extack,
and drop the edev argument.

Convert DP_NOTICE calls to use NL_SET_ERR_MSG_* instead.

Pass extack in calls to qede_flow_parse_{tcp,udp}_v{4,6}().

In calls to qede_parse_flow_attr(), if extack is
unavailable, then use NULL for now, until a
subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
.../net/ethernet/qlogic/qede/qede_filter.c | 23 ++++++++++---------
1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 5b353a160d15..8734c864f324 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1826,7 +1826,7 @@ qede_flow_parse_udp_v4(struct netlink_ext_ack *extack, struct flow_rule *rule,
}

static int
-qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
+qede_parse_flow_attr(struct netlink_ext_ack *extack, __be16 proto,
struct flow_rule *rule, struct qede_arfs_tuple *tuple)
{
struct flow_dissector *dissector = rule->match.dissector;
@@ -1841,14 +1841,15 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
BIT_ULL(FLOW_DISSECTOR_KEY_BASIC) |
BIT_ULL(FLOW_DISSECTOR_KEY_IPV6_ADDRS) |
BIT_ULL(FLOW_DISSECTOR_KEY_PORTS))) {
- DP_NOTICE(edev, "Unsupported key set:0x%llx\n",
- dissector->used_keys);
+ NL_SET_ERR_MSG_FMT_MOD(extack, "Unsupported key used: 0x%llx",
+ dissector->used_keys);
return -EOPNOTSUPP;
}

if (proto != htons(ETH_P_IP) &&
proto != htons(ETH_P_IPV6)) {
- DP_NOTICE(edev, "Unsupported proto=0x%x\n", proto);
+ NL_SET_ERR_MSG_FMT_MOD(extack, "Unsupported proto=0x%x",
+ proto);
return -EPROTONOSUPPORT;
}

@@ -1860,15 +1861,15 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
}

if (ip_proto == IPPROTO_TCP && proto == htons(ETH_P_IP))
- rc = qede_flow_parse_tcp_v4(NULL, rule, tuple);
+ rc = qede_flow_parse_tcp_v4(extack, rule, tuple);
else if (ip_proto == IPPROTO_TCP && proto == htons(ETH_P_IPV6))
- rc = qede_flow_parse_tcp_v6(NULL, rule, tuple);
+ rc = qede_flow_parse_tcp_v6(extack, rule, tuple);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IP))
- rc = qede_flow_parse_udp_v4(NULL, rule, tuple);
+ rc = qede_flow_parse_udp_v4(extack, rule, tuple);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IPV6))
- rc = qede_flow_parse_udp_v6(NULL, rule, tuple);
+ rc = qede_flow_parse_udp_v6(extack, rule, tuple);
else
- DP_NOTICE(edev, "Invalid protocol request\n");
+ NL_SET_ERR_MSG_MOD(extack, "Invalid protocol request");

return rc;
}
@@ -1889,7 +1890,7 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
}

/* parse flower attribute and prepare filter */
- rc = qede_parse_flow_attr(edev, proto, f->rule, &t);
+ rc = qede_parse_flow_attr(extack, proto, f->rule, &t);
if (rc)
goto unlock;

@@ -2015,7 +2016,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(edev, proto, flow->rule, t);
+ err = qede_parse_flow_attr(NULL, proto, flow->rule, t);
if (err)
goto err_out;

--
2.43.0


2024-05-07 11:00:13

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 12/14] net: qede: use faked extack in qede_flow_spec_to_rule()

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 <[email protected]>
---

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(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 8734c864f324..3727ab5af088 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1989,6 +1989,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;

@@ -2016,7 +2017,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(NULL, proto, flow->rule, t);
+ err = qede_parse_flow_attr(&extack, proto, flow->rule, t);
if (err)
goto err_out;

@@ -2024,6 +2025,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;

--
2.43.0


2024-05-07 11:13:28

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 06/14] net: qede: use extack in qede_flow_parse_tcp_v6()

Convert qede_flow_parse_tcp_v6() to take extack,
and drop the edev argument.

Pass extack in call to qede_flow_parse_v6_common().

In call to qede_flow_parse_tcp_v6(), use NULL as extack
for now, until a subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index 056384362037..bc0e95ba1880 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1786,13 +1786,13 @@ qede_flow_parse_v4_common(struct netlink_ext_ack *extack,
}

static int
-qede_flow_parse_tcp_v6(struct qede_dev *edev, struct flow_rule *rule,
- struct qede_arfs_tuple *tuple)
+qede_flow_parse_tcp_v6(struct netlink_ext_ack *extack, struct flow_rule *rule,
+ struct qede_arfs_tuple *tuple)
{
tuple->ip_proto = IPPROTO_TCP;
tuple->eth_proto = htons(ETH_P_IPV6);

- return qede_flow_parse_v6_common(NULL, rule, tuple);
+ return qede_flow_parse_v6_common(extack, rule, tuple);
}

static int
@@ -1862,7 +1862,7 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
if (ip_proto == IPPROTO_TCP && proto == htons(ETH_P_IP))
rc = qede_flow_parse_tcp_v4(edev, rule, tuple);
else if (ip_proto == IPPROTO_TCP && proto == htons(ETH_P_IPV6))
- rc = qede_flow_parse_tcp_v6(edev, rule, tuple);
+ rc = qede_flow_parse_tcp_v6(NULL, rule, tuple);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IP))
rc = qede_flow_parse_udp_v4(edev, rule, tuple);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IPV6))
--
2.43.0


2024-05-07 11:13:34

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: [PATCH net-next 01/14] net: qede: use extack in qede_flow_parse_ports()

Convert qede_flow_parse_ports to use extack,
and drop the edev argument.

Convert DP_NOTICE call to use NL_SET_ERR_MSG_MOD instead.

In calls to qede_flow_parse_ports(), use NULL as extack
for now, until a subsequent patch makes extack available.

Only compile tested.

Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
---
drivers/net/ethernet/qlogic/qede/qede_filter.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
index ded48523c383..3995baa2daa6 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
@@ -1700,7 +1700,7 @@ static int qede_parse_actions(struct qede_dev *edev,
}

static int
-qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule,
+qede_flow_parse_ports(struct netlink_ext_ack *extack, struct flow_rule *rule,
struct qede_arfs_tuple *t)
{
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) {
@@ -1709,7 +1709,8 @@ qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule,
flow_rule_match_ports(rule, &match);
if ((match.key->src && match.mask->src != htons(U16_MAX)) ||
(match.key->dst && match.mask->dst != htons(U16_MAX))) {
- DP_NOTICE(edev, "Do not support ports masks\n");
+ NL_SET_ERR_MSG_MOD(extack,
+ "Do not support ports masks");
return -EINVAL;
}

@@ -1747,7 +1748,7 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule,
memcpy(&t->dst_ipv6, &match.key->dst, sizeof(addr));
}

- err = qede_flow_parse_ports(edev, rule, t);
+ err = qede_flow_parse_ports(NULL, rule, t);
if (err)
return err;

@@ -1774,7 +1775,7 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule,
t->dst_ipv4 = match.key->dst;
}

- err = qede_flow_parse_ports(edev, rule, t);
+ err = qede_flow_parse_ports(NULL, rule, t);
if (err)
return err;

--
2.43.0


2024-05-08 10:15:29

by Przemek Kitszel

[permalink] [raw]
Subject: Re: [PATCH net-next 01/14] net: qede: use extack in qede_flow_parse_ports()

On 5/7/24 12:44, Asbjørn Sloth Tønnesen wrote:
> Convert qede_flow_parse_ports to use extack,
> and drop the edev argument.
>
> Convert DP_NOTICE call to use NL_SET_ERR_MSG_MOD instead.
>
> In calls to qede_flow_parse_ports(), use NULL as extack
> for now, until a subsequent patch makes extack available.
>
> Only compile tested.
>
> Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
> ---
> drivers/net/ethernet/qlogic/qede/qede_filter.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
> index ded48523c383..3995baa2daa6 100644
> --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
> +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
> @@ -1700,7 +1700,7 @@ static int qede_parse_actions(struct qede_dev *edev,
> }
>
> static int
> -qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule,
> +qede_flow_parse_ports(struct netlink_ext_ack *extack, struct flow_rule *rule,
> struct qede_arfs_tuple *t)

there are ~40 cases in drivers/net/ethernet that have an extack param as
not the last one, and over 1250 that have an extack as the last param.
My grepping was very naive, and counted both forward declarations and
implementations, but it's clear what is the preference.

Could you please convert the series to be that way?

> {
> if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) {
> @@ -1709,7 +1709,8 @@ qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule,
> flow_rule_match_ports(rule, &match);
> if ((match.key->src && match.mask->src != htons(U16_MAX)) ||
> (match.key->dst && match.mask->dst != htons(U16_MAX))) {
> - DP_NOTICE(edev, "Do not support ports masks\n");
> + NL_SET_ERR_MSG_MOD(extack,
> + "Do not support ports masks");
> return -EINVAL;
> }
>
> @@ -1747,7 +1748,7 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule,
> memcpy(&t->dst_ipv6, &match.key->dst, sizeof(addr));
> }
>
> - err = qede_flow_parse_ports(edev, rule, t);
> + err = qede_flow_parse_ports(NULL, rule, t);
> if (err)
> return err;
>
> @@ -1774,7 +1775,7 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule,
> t->dst_ipv4 = match.key->dst;
> }
>
> - err = qede_flow_parse_ports(edev, rule, t);
> + err = qede_flow_parse_ports(NULL, rule, t);
> if (err)
> return err;
>


2024-05-08 10:41:53

by Asbjørn Sloth Tønnesen

[permalink] [raw]
Subject: Re: [PATCH net-next 01/14] net: qede: use extack in qede_flow_parse_ports()

Hi Przemek,

Thank you for the review!

On 5/8/24 10:07 AM, Przemek Kitszel wrote:
> On 5/7/24 12:44, Asbjørn Sloth Tønnesen wrote:
>> Convert qede_flow_parse_ports to use extack,
>> and drop the edev argument.
>>
>> Convert DP_NOTICE call to use NL_SET_ERR_MSG_MOD instead.
>>
>> In calls to qede_flow_parse_ports(), use NULL as extack
>> for now, until a subsequent patch makes extack available.
>>
>> Only compile tested.
>>
>> Signed-off-by: Asbjørn Sloth Tønnesen <[email protected]>
>> ---
>>   drivers/net/ethernet/qlogic/qede/qede_filter.c | 9 +++++----
>>   1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c
>> index ded48523c383..3995baa2daa6 100644
>> --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c
>> +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c
>> @@ -1700,7 +1700,7 @@ static int qede_parse_actions(struct qede_dev *edev,
>>   }
>>   static int
>> -qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule,
>> +qede_flow_parse_ports(struct netlink_ext_ack *extack, struct flow_rule *rule,
>>                 struct qede_arfs_tuple *t)
>
> there are ~40 cases in drivers/net/ethernet that have an extack param as
> not the last one, and over 1250 that have an extack as the last param.
> My grepping was very naive, and counted both forward declarations and
> implementations, but it's clear what is the preference.
>
> Could you please convert the series to be that way?

Sure, will do that in v2.

--
Best regards
Asbjørn Sloth Tønnesen
Network Engineer
Fiberby - AS42541