net/mlx5e: TC, Split pedit offloads verify from alloc_tc_pedit_action()

Split pedit verify part into a new subfunction for better
maintainability.

Signed-off-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Oz Shlomo <ozsh@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
Roi Dayan 2021-11-11 09:09:23 +02:00 committed by Saeed Mahameed
parent 09bf979232
commit 918ed7bf76
1 changed files with 22 additions and 11 deletions

View File

@ -2993,19 +2993,13 @@ static int offload_pedit_fields(struct mlx5e_priv *priv,
static const struct pedit_headers zero_masks = {};
static int alloc_tc_pedit_action(struct mlx5e_priv *priv, int namespace,
static int verify_offload_pedit_fields(struct mlx5e_priv *priv,
struct mlx5e_tc_flow_parse_attr *parse_attr,
u32 *action_flags,
struct netlink_ext_ack *extack)
{
struct pedit_headers *cmd_masks;
int err;
u8 cmd;
err = offload_pedit_fields(priv, namespace, parse_attr, action_flags, extack);
if (err < 0)
goto out_dealloc_parsed_actions;
for (cmd = 0; cmd < __PEDIT_CMD_MAX; cmd++) {
cmd_masks = &parse_attr->hdrs[cmd].masks;
if (memcmp(cmd_masks, &zero_masks, sizeof(zero_masks))) {
@ -3013,10 +3007,27 @@ static int alloc_tc_pedit_action(struct mlx5e_priv *priv, int namespace,
netdev_warn(priv->netdev, "attempt to offload an unsupported field (cmd %d)\n", cmd);
print_hex_dump(KERN_WARNING, "mask: ", DUMP_PREFIX_ADDRESS,
16, 1, cmd_masks, sizeof(zero_masks), true);
err = -EOPNOTSUPP;
return -EOPNOTSUPP;
}
}
return 0;
}
static int alloc_tc_pedit_action(struct mlx5e_priv *priv, int namespace,
struct mlx5e_tc_flow_parse_attr *parse_attr,
u32 *action_flags,
struct netlink_ext_ack *extack)
{
int err;
err = offload_pedit_fields(priv, namespace, parse_attr, action_flags, extack);
if (err)
goto out_dealloc_parsed_actions;
err = verify_offload_pedit_fields(priv, parse_attr, extack);
if (err)
goto out_dealloc_parsed_actions;
}
}
return 0;