mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 16:12:59 +02:00
Merge branch 'add-support-for-flower-actions-mirred-and-redirect'
Daniel Machon says: ==================== Add support for flower actions mirred and redirect This series adds support for the two tc flower actions mirred and redirect. Both actions are implemented by means of a port mask and a mask mode. The mask mode controls how the mask is applied, and together they are used by the switch to make a forwarding decision. Both actions are configurable via the IS0 or IS2 VCAP's (ingress stage 0 and 2, respectively). Patch #1: adds support for tc flower mirred action. Patch #2: adds support for tc flower redirect action. Signed-off-by: Daniel Machon <daniel.machon@microchip.com> ==================== Link: https://lore.kernel.org/r/20240405-mirror-redirect-actions-v2-0-875d4c1927c8@microchip.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
commit
1c25fe9a04
|
|
@ -1004,6 +1004,64 @@ static int sparx5_tc_action_vlan_push(struct vcap_admin *admin,
|
|||
return err;
|
||||
}
|
||||
|
||||
static void sparx5_tc_flower_set_port_mask(struct vcap_u72_action *ports,
|
||||
struct net_device *ndev)
|
||||
{
|
||||
struct sparx5_port *port = netdev_priv(ndev);
|
||||
int byidx = port->portno / BITS_PER_BYTE;
|
||||
int biidx = port->portno % BITS_PER_BYTE;
|
||||
|
||||
ports->value[byidx] |= BIT(biidx);
|
||||
}
|
||||
|
||||
static int sparx5_tc_action_mirred(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,
|
||||
"Mirror action not supported in this VCAP");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
err = vcap_rule_add_action_u32(vrule, VCAP_AF_MASK_MODE,
|
||||
SPX5_PMM_OR_DSTMASK);
|
||||
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);
|
||||
}
|
||||
|
||||
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,
|
||||
|
|
@ -1150,6 +1208,16 @@ static int sparx5_tc_flower_replace(struct net_device *ndev,
|
|||
if (err)
|
||||
goto out;
|
||||
break;
|
||||
case FLOW_ACTION_MIRRED:
|
||||
err = sparx5_tc_action_mirred(admin, vrule, fco, act);
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -2907,6 +2907,18 @@ int vcap_rule_add_action_u32(struct vcap_rule *rule,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(vcap_rule_add_action_u32);
|
||||
|
||||
/* Add a 72 bit action field with value to the rule */
|
||||
int vcap_rule_add_action_u72(struct vcap_rule *rule,
|
||||
enum vcap_action_field action,
|
||||
struct vcap_u72_action *fieldval)
|
||||
{
|
||||
struct vcap_client_actionfield_data data;
|
||||
|
||||
memcpy(&data.u72, fieldval, sizeof(data.u72));
|
||||
return vcap_rule_add_action(rule, action, VCAP_FIELD_U72, &data);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vcap_rule_add_action_u72);
|
||||
|
||||
static int vcap_read_counter(struct vcap_rule_internal *ri,
|
||||
struct vcap_counter *ctr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -200,6 +200,8 @@ int vcap_rule_add_action_bit(struct vcap_rule *rule,
|
|||
enum vcap_action_field action, enum vcap_bit val);
|
||||
int vcap_rule_add_action_u32(struct vcap_rule *rule,
|
||||
enum vcap_action_field action, u32 value);
|
||||
int vcap_rule_add_action_u72(struct vcap_rule *rule, enum vcap_action_field action,
|
||||
struct vcap_u72_action *fieldval);
|
||||
|
||||
/* Get number of rules in a vcap instance lookup chain id range */
|
||||
int vcap_admin_rule_count(struct vcap_admin *admin, int cid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user