Skip to content

Commit

Permalink
dpaa2-switch: reorganize dpaa2_switch_cls_flower_replace
Browse files Browse the repository at this point in the history
Extract the necessary steps to offload a filter by using the ACL table
in a separate function - dpaa2_switch_cls_flower_replace_acl().
This is intended to help with the code readability when the mirroring
support is added.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ioana Ciornei authored and David S. Miller committed Jul 29, 2021
1 parent adcb7aa commit c5f6d49
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ static int dpaa2_switch_tc_parse_action_acl(struct ethsw_core *ethsw,
return err;
}

int dpaa2_switch_cls_flower_replace(struct dpaa2_switch_filter_block *block,
static int
dpaa2_switch_cls_flower_replace_acl(struct dpaa2_switch_filter_block *block,
struct flow_cls_offload *cls)
{
struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
Expand All @@ -386,11 +387,6 @@ int dpaa2_switch_cls_flower_replace(struct dpaa2_switch_filter_block *block,
struct flow_action_entry *act;
int err;

if (!flow_offload_has_one_action(&rule->action)) {
NL_SET_ERR_MSG(extack, "Only singular actions are supported");
return -EOPNOTSUPP;
}

if (dpaa2_switch_acl_tbl_is_full(block)) {
NL_SET_ERR_MSG(extack, "Maximum filter capacity reached");
return -ENOMEM;
Expand Down Expand Up @@ -425,6 +421,30 @@ int dpaa2_switch_cls_flower_replace(struct dpaa2_switch_filter_block *block,
return err;
}

int dpaa2_switch_cls_flower_replace(struct dpaa2_switch_filter_block *block,
struct flow_cls_offload *cls)
{
struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
struct netlink_ext_ack *extack = cls->common.extack;
struct flow_action_entry *act;

if (!flow_offload_has_one_action(&rule->action)) {
NL_SET_ERR_MSG(extack, "Only singular actions are supported");
return -EOPNOTSUPP;
}

act = &rule->action.entries[0];
switch (act->id) {
case FLOW_ACTION_REDIRECT:
case FLOW_ACTION_TRAP:
case FLOW_ACTION_DROP:
return dpaa2_switch_cls_flower_replace_acl(block, cls);
default:
NL_SET_ERR_MSG_MOD(extack, "Action not supported");
return -EOPNOTSUPP;
}
}

int dpaa2_switch_cls_flower_destroy(struct dpaa2_switch_filter_block *block,
struct flow_cls_offload *cls)
{
Expand Down

0 comments on commit c5f6d49

Please sign in to comment.