Commit 24e28b60 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-qede-convert-filter-code-to-use-extack'

Asbjørn Sloth Tønnesen says:

====================
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 v3, 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.

v1: https://lore.kernel.org/netdev/20240507104421.1628139-1-ast@fiberby.net/
====================

Link: https://lore.kernel.org/r/20240508143404.95901-1-ast@fiberby.netSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents d50729f1 84154879
...@@ -1520,8 +1520,8 @@ static int qede_flow_spec_validate_unused(struct qede_dev *edev, ...@@ -1520,8 +1520,8 @@ static int qede_flow_spec_validate_unused(struct qede_dev *edev,
return 0; return 0;
} }
static int qede_set_v4_tuple_to_profile(struct qede_dev *edev, static int qede_set_v4_tuple_to_profile(struct qede_arfs_tuple *t,
struct qede_arfs_tuple *t) struct netlink_ext_ack *extack)
{ {
/* We must have Only 4-tuples/l4 port/src ip/dst ip /* We must have Only 4-tuples/l4 port/src ip/dst ip
* as an input. * as an input.
...@@ -1538,7 +1538,7 @@ static int qede_set_v4_tuple_to_profile(struct qede_dev *edev, ...@@ -1538,7 +1538,7 @@ static int qede_set_v4_tuple_to_profile(struct qede_dev *edev,
t->dst_ipv4 && !t->src_ipv4) { t->dst_ipv4 && !t->src_ipv4) {
t->mode = QED_FILTER_CONFIG_MODE_IP_DEST; t->mode = QED_FILTER_CONFIG_MODE_IP_DEST;
} else { } else {
DP_INFO(edev, "Invalid N-tuple\n"); NL_SET_ERR_MSG_MOD(extack, "Invalid N-tuple");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1549,9 +1549,9 @@ static int qede_set_v4_tuple_to_profile(struct qede_dev *edev, ...@@ -1549,9 +1549,9 @@ static int qede_set_v4_tuple_to_profile(struct qede_dev *edev,
return 0; return 0;
} }
static int qede_set_v6_tuple_to_profile(struct qede_dev *edev, static int qede_set_v6_tuple_to_profile(struct qede_arfs_tuple *t,
struct qede_arfs_tuple *t, struct in6_addr *zaddr,
struct in6_addr *zaddr) struct netlink_ext_ack *extack)
{ {
/* We must have Only 4-tuples/l4 port/src ip/dst ip /* We must have Only 4-tuples/l4 port/src ip/dst ip
* as an input. * as an input.
...@@ -1573,7 +1573,7 @@ static int qede_set_v6_tuple_to_profile(struct qede_dev *edev, ...@@ -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))) { !memcmp(&t->src_ipv6, zaddr, sizeof(struct in6_addr))) {
t->mode = QED_FILTER_CONFIG_MODE_IP_DEST; t->mode = QED_FILTER_CONFIG_MODE_IP_DEST;
} else { } else {
DP_INFO(edev, "Invalid N-tuple\n"); NL_SET_ERR_MSG_MOD(extack, "Invalid N-tuple");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1671,7 +1671,7 @@ static int qede_parse_actions(struct qede_dev *edev, ...@@ -1671,7 +1671,7 @@ static int qede_parse_actions(struct qede_dev *edev,
int i; int i;
if (!flow_action_has_entries(flow_action)) { 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; return -EINVAL;
} }
...@@ -1687,7 +1687,8 @@ static int qede_parse_actions(struct qede_dev *edev, ...@@ -1687,7 +1687,8 @@ static int qede_parse_actions(struct qede_dev *edev,
break; break;
if (act->queue.index >= QEDE_RSS_COUNT(edev)) { 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; return -EINVAL;
} }
break; break;
...@@ -1700,8 +1701,8 @@ static int qede_parse_actions(struct qede_dev *edev, ...@@ -1700,8 +1701,8 @@ static int qede_parse_actions(struct qede_dev *edev,
} }
static int static int
qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule, qede_flow_parse_ports(struct flow_rule *rule, struct qede_arfs_tuple *t,
struct qede_arfs_tuple *t) struct netlink_ext_ack *extack)
{ {
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) { if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) {
struct flow_match_ports match; struct flow_match_ports match;
...@@ -1709,7 +1710,8 @@ qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule, ...@@ -1709,7 +1710,8 @@ qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule,
flow_rule_match_ports(rule, &match); flow_rule_match_ports(rule, &match);
if ((match.key->src && match.mask->src != htons(U16_MAX)) || if ((match.key->src && match.mask->src != htons(U16_MAX)) ||
(match.key->dst && match.mask->dst != 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; return -EINVAL;
} }
...@@ -1721,8 +1723,9 @@ qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule, ...@@ -1721,8 +1723,9 @@ qede_flow_parse_ports(struct qede_dev *edev, struct flow_rule *rule,
} }
static int static int
qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule, qede_flow_parse_v6_common(struct flow_rule *rule,
struct qede_arfs_tuple *t) struct qede_arfs_tuple *t,
struct netlink_ext_ack *extack)
{ {
struct in6_addr zero_addr, addr; struct in6_addr zero_addr, addr;
int err; int err;
...@@ -1738,8 +1741,8 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule, ...@@ -1738,8 +1741,8 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule,
memcmp(&match.mask->src, &addr, sizeof(addr))) || memcmp(&match.mask->src, &addr, sizeof(addr))) ||
(memcmp(&match.key->dst, &zero_addr, sizeof(addr)) && (memcmp(&match.key->dst, &zero_addr, sizeof(addr)) &&
memcmp(&match.mask->dst, &addr, sizeof(addr)))) { memcmp(&match.mask->dst, &addr, sizeof(addr)))) {
DP_NOTICE(edev, NL_SET_ERR_MSG_MOD(extack,
"Do not support IPv6 address prefix/mask\n"); "Do not support IPv6 address prefix/mask");
return -EINVAL; return -EINVAL;
} }
...@@ -1747,16 +1750,17 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule, ...@@ -1747,16 +1750,17 @@ qede_flow_parse_v6_common(struct qede_dev *edev, struct flow_rule *rule,
memcpy(&t->dst_ipv6, &match.key->dst, sizeof(addr)); memcpy(&t->dst_ipv6, &match.key->dst, sizeof(addr));
} }
err = qede_flow_parse_ports(edev, rule, t); err = qede_flow_parse_ports(rule, t, extack);
if (err) if (err)
return err; return err;
return qede_set_v6_tuple_to_profile(edev, t, &zero_addr); return qede_set_v6_tuple_to_profile(t, &zero_addr, extack);
} }
static int static int
qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule, qede_flow_parse_v4_common(struct flow_rule *rule,
struct qede_arfs_tuple *t) struct qede_arfs_tuple *t,
struct netlink_ext_ack *extack)
{ {
int err; int err;
...@@ -1766,7 +1770,8 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule, ...@@ -1766,7 +1770,8 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule,
flow_rule_match_ipv4_addrs(rule, &match); flow_rule_match_ipv4_addrs(rule, &match);
if ((match.key->src && match.mask->src != htonl(U32_MAX)) || if ((match.key->src && match.mask->src != htonl(U32_MAX)) ||
(match.key->dst && match.mask->dst != 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; return -EINVAL;
} }
...@@ -1774,56 +1779,57 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule, ...@@ -1774,56 +1779,57 @@ qede_flow_parse_v4_common(struct qede_dev *edev, struct flow_rule *rule,
t->dst_ipv4 = match.key->dst; t->dst_ipv4 = match.key->dst;
} }
err = qede_flow_parse_ports(edev, rule, t); err = qede_flow_parse_ports(rule, t, extack);
if (err) if (err)
return err; return err;
return qede_set_v4_tuple_to_profile(edev, t); return qede_set_v4_tuple_to_profile(t, extack);
} }
static int static int
qede_flow_parse_tcp_v6(struct qede_dev *edev, struct flow_rule *rule, qede_flow_parse_tcp_v6(struct flow_rule *rule, struct qede_arfs_tuple *tuple,
struct qede_arfs_tuple *tuple) struct netlink_ext_ack *extack)
{ {
tuple->ip_proto = IPPROTO_TCP; tuple->ip_proto = IPPROTO_TCP;
tuple->eth_proto = htons(ETH_P_IPV6); tuple->eth_proto = htons(ETH_P_IPV6);
return qede_flow_parse_v6_common(edev, rule, tuple); return qede_flow_parse_v6_common(rule, tuple, extack);
} }
static int static int
qede_flow_parse_tcp_v4(struct qede_dev *edev, struct flow_rule *rule, qede_flow_parse_tcp_v4(struct flow_rule *rule, struct qede_arfs_tuple *tuple,
struct qede_arfs_tuple *tuple) struct netlink_ext_ack *extack)
{ {
tuple->ip_proto = IPPROTO_TCP; tuple->ip_proto = IPPROTO_TCP;
tuple->eth_proto = htons(ETH_P_IP); tuple->eth_proto = htons(ETH_P_IP);
return qede_flow_parse_v4_common(edev, rule, tuple); return qede_flow_parse_v4_common(rule, tuple, extack);
} }
static int static int
qede_flow_parse_udp_v6(struct qede_dev *edev, struct flow_rule *rule, qede_flow_parse_udp_v6(struct flow_rule *rule, struct qede_arfs_tuple *tuple,
struct qede_arfs_tuple *tuple) struct netlink_ext_ack *extack)
{ {
tuple->ip_proto = IPPROTO_UDP; tuple->ip_proto = IPPROTO_UDP;
tuple->eth_proto = htons(ETH_P_IPV6); tuple->eth_proto = htons(ETH_P_IPV6);
return qede_flow_parse_v6_common(edev, rule, tuple); return qede_flow_parse_v6_common(rule, tuple, extack);
} }
static int static int
qede_flow_parse_udp_v4(struct qede_dev *edev, struct flow_rule *rule, qede_flow_parse_udp_v4(struct flow_rule *rule, struct qede_arfs_tuple *tuple,
struct qede_arfs_tuple *tuple) struct netlink_ext_ack *extack)
{ {
tuple->ip_proto = IPPROTO_UDP; tuple->ip_proto = IPPROTO_UDP;
tuple->eth_proto = htons(ETH_P_IP); tuple->eth_proto = htons(ETH_P_IP);
return qede_flow_parse_v4_common(edev, rule, tuple); return qede_flow_parse_v4_common(rule, tuple, extack);
} }
static int static int
qede_parse_flow_attr(struct qede_dev *edev, __be16 proto, qede_parse_flow_attr(__be16 proto, struct flow_rule *rule,
struct flow_rule *rule, struct qede_arfs_tuple *tuple) struct qede_arfs_tuple *tuple,
struct netlink_ext_ack *extack)
{ {
struct flow_dissector *dissector = rule->match.dissector; struct flow_dissector *dissector = rule->match.dissector;
int rc = -EINVAL; int rc = -EINVAL;
...@@ -1837,14 +1843,15 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto, ...@@ -1837,14 +1843,15 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
BIT_ULL(FLOW_DISSECTOR_KEY_BASIC) | BIT_ULL(FLOW_DISSECTOR_KEY_BASIC) |
BIT_ULL(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | BIT_ULL(FLOW_DISSECTOR_KEY_IPV6_ADDRS) |
BIT_ULL(FLOW_DISSECTOR_KEY_PORTS))) { BIT_ULL(FLOW_DISSECTOR_KEY_PORTS))) {
DP_NOTICE(edev, "Unsupported key set:0x%llx\n", NL_SET_ERR_MSG_FMT_MOD(extack, "Unsupported key used: 0x%llx",
dissector->used_keys); dissector->used_keys);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (proto != htons(ETH_P_IP) && if (proto != htons(ETH_P_IP) &&
proto != htons(ETH_P_IPV6)) { 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; return -EPROTONOSUPPORT;
} }
...@@ -1856,15 +1863,15 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto, ...@@ -1856,15 +1863,15 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
} }
if (ip_proto == IPPROTO_TCP && proto == htons(ETH_P_IP)) 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(rule, tuple, extack);
else if (ip_proto == IPPROTO_TCP && proto == htons(ETH_P_IPV6)) 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(rule, tuple, extack);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IP)) 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(rule, tuple, extack);
else if (ip_proto == IPPROTO_UDP && proto == htons(ETH_P_IPV6)) 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(rule, tuple, extack);
else else
DP_NOTICE(edev, "Invalid protocol request\n"); NL_SET_ERR_MSG_MOD(extack, "Invalid protocol request");
return rc; return rc;
} }
...@@ -1872,6 +1879,7 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto, ...@@ -1872,6 +1879,7 @@ qede_parse_flow_attr(struct qede_dev *edev, __be16 proto,
int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto, int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
struct flow_cls_offload *f) struct flow_cls_offload *f)
{ {
struct netlink_ext_ack *extack = f->common.extack;
struct qede_arfs_fltr_node *n; struct qede_arfs_fltr_node *n;
struct qede_arfs_tuple t; struct qede_arfs_tuple t;
int min_hlen, rc; int min_hlen, rc;
...@@ -1884,7 +1892,7 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto, ...@@ -1884,7 +1892,7 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
} }
/* parse flower attribute and prepare filter */ /* parse flower attribute and prepare filter */
rc = qede_parse_flow_attr(edev, proto, f->rule, &t); rc = qede_parse_flow_attr(proto, f->rule, &t, extack);
if (rc) if (rc)
goto unlock; goto unlock;
...@@ -1899,7 +1907,7 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto, ...@@ -1899,7 +1907,7 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
} }
/* parse tc actions and get the vf_id */ /* 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) if (rc)
goto unlock; goto unlock;
...@@ -1946,7 +1954,8 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto, ...@@ -1946,7 +1954,8 @@ int qede_add_tc_flower_fltr(struct qede_dev *edev, __be16 proto,
static int qede_flow_spec_validate(struct qede_dev *edev, static int qede_flow_spec_validate(struct qede_dev *edev,
struct flow_action *flow_action, struct flow_action *flow_action,
struct qede_arfs_tuple *t, struct qede_arfs_tuple *t,
__u32 location) __u32 location,
struct netlink_ext_ack *extack)
{ {
int err; int err;
...@@ -1970,7 +1979,7 @@ static int qede_flow_spec_validate(struct qede_dev *edev, ...@@ -1970,7 +1979,7 @@ static int qede_flow_spec_validate(struct qede_dev *edev,
return -EINVAL; return -EINVAL;
} }
err = qede_parse_actions(edev, flow_action, NULL); err = qede_parse_actions(edev, flow_action, extack);
if (err) if (err)
return err; return err;
...@@ -1983,6 +1992,7 @@ static int qede_flow_spec_to_rule(struct qede_dev *edev, ...@@ -1983,6 +1992,7 @@ static int qede_flow_spec_to_rule(struct qede_dev *edev,
{ {
struct ethtool_rx_flow_spec_input input = {}; struct ethtool_rx_flow_spec_input input = {};
struct ethtool_rx_flow_rule *flow; struct ethtool_rx_flow_rule *flow;
struct netlink_ext_ack extack;
__be16 proto; __be16 proto;
int err; int err;
...@@ -2010,14 +2020,16 @@ static int qede_flow_spec_to_rule(struct qede_dev *edev, ...@@ -2010,14 +2020,16 @@ static int qede_flow_spec_to_rule(struct qede_dev *edev,
if (IS_ERR(flow)) if (IS_ERR(flow))
return PTR_ERR(flow); return PTR_ERR(flow);
err = qede_parse_flow_attr(edev, proto, flow->rule, t); err = qede_parse_flow_attr(proto, flow->rule, t, &extack);
if (err) if (err)
goto err_out; goto err_out;
/* Make sure location is valid and filter isn't already set */ /* Make sure location is valid and filter isn't already set */
err = qede_flow_spec_validate(edev, &flow->rule->action, t, err = qede_flow_spec_validate(edev, &flow->rule->action, t,
fs->location); fs->location, &extack);
err_out: err_out:
if (extack._msg)
DP_NOTICE(edev, "%s\n", extack._msg);
ethtool_rx_flow_rule_destroy(flow); ethtool_rx_flow_rule_destroy(flow);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment