aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Machon <daniel.machon@microchip.com>2024-04-05 09:44:50 +0200
committerPaolo Abeni <pabeni@redhat.com>2024-04-09 10:45:10 +0200
commit1164b8e0b108507b41e2564a9461bc0a6e38283c (patch)
tree78006a3364b9b1585db529a56bd91ae4649825fd
parent48ba00da2eb4b54a7e6ed2ca3a9f2e575dff48c9 (diff)
downloadnet-next-1164b8e0b108507b41e2564a9461bc0a6e38283c.tar.gz
net: sparx5: add support for tc flower redirect action
Add support for the flower redirect action. Two VCAP actions are encoded in the rule - one for the port mask, and one for the port mask mode. When the rule is hit, the port mask is used as the final destination set, replacing all other port masks. Signed-off-by: Daniel Machon <daniel.machon@microchip.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r--drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
index fb2e3004183a55..82dd270adae683 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc_flower.c
@@ -1038,6 +1038,30 @@ static int sparx5_tc_action_mirred(struct vcap_admin *admin,
return vcap_rule_add_action_u72(vrule, VCAP_AF_PORT_MASK, &ports);
}
+static int sparx5_tc_action_redirect(struct vcap_admin *admin,
+ struct vcap_rule *vrule,
+ struct flow_cls_offload *fco,
+ struct flow_action_entry *act)
+{
+ struct vcap_u72_action ports = {0};
+ int err;
+
+ if (admin->vtype != VCAP_TYPE_IS0 && admin->vtype != VCAP_TYPE_IS2) {
+ NL_SET_ERR_MSG_MOD(fco->common.extack,
+ "Redirect action not supported in this VCAP");
+ return -EOPNOTSUPP;
+ }
+
+ err = vcap_rule_add_action_u32(vrule, VCAP_AF_MASK_MODE,
+ SPX5_PMM_REPLACE_ALL);
+ if (err)
+ return err;
+
+ sparx5_tc_flower_set_port_mask(&ports, act->dev);
+
+ return vcap_rule_add_action_u72(vrule, VCAP_AF_PORT_MASK, &ports);
+}
+
/* Remove rule keys that may prevent templates from matching a keyset */
static void sparx5_tc_flower_simplify_rule(struct vcap_admin *admin,
struct vcap_rule *vrule,
@@ -1189,6 +1213,11 @@ static int sparx5_tc_flower_replace(struct net_device *ndev,
if (err)
goto out;
break;
+ case FLOW_ACTION_REDIRECT:
+ err = sparx5_tc_action_redirect(admin, vrule, fco, act);
+ if (err)
+ goto out;
+ break;
case FLOW_ACTION_ACCEPT:
err = sparx5_tc_set_actionset(admin, vrule);
if (err)