Commit dd0fbc89 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

mlxsw: spectrum_matchall: Push per-port rule add/del into separate functions

As the replace/destroy is going to be used later on per-block, push
the per-port rule addition/deletion into separate functions.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 47fa15ea
...@@ -123,6 +123,37 @@ mlxsw_sp_mall_port_sample_del(struct mlxsw_sp_port *mlxsw_sp_port) ...@@ -123,6 +123,37 @@ mlxsw_sp_mall_port_sample_del(struct mlxsw_sp_port *mlxsw_sp_port)
RCU_INIT_POINTER(mlxsw_sp_port->sample->psample_group, NULL); RCU_INIT_POINTER(mlxsw_sp_port->sample->psample_group, NULL);
} }
static int
mlxsw_sp_mall_port_rule_add(struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_mall_entry *mall_entry)
{
switch (mall_entry->type) {
case MLXSW_SP_MALL_ACTION_TYPE_MIRROR:
return mlxsw_sp_mall_port_mirror_add(mlxsw_sp_port, mall_entry);
case MLXSW_SP_MALL_ACTION_TYPE_SAMPLE:
return mlxsw_sp_mall_port_sample_add(mlxsw_sp_port, mall_entry);
default:
WARN_ON(1);
return -EINVAL;
}
}
static void
mlxsw_sp_mall_port_rule_del(struct mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_mall_entry *mall_entry)
{
switch (mall_entry->type) {
case MLXSW_SP_MALL_ACTION_TYPE_MIRROR:
mlxsw_sp_mall_port_mirror_del(mlxsw_sp_port, mall_entry);
break;
case MLXSW_SP_MALL_ACTION_TYPE_SAMPLE:
mlxsw_sp_mall_port_sample_del(mlxsw_sp_port);
break;
default:
WARN_ON(1);
}
}
int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port, int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port,
struct tc_cls_matchall_offload *f, bool ingress) struct tc_cls_matchall_offload *f, bool ingress)
{ {
...@@ -147,7 +178,6 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -147,7 +178,6 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port,
if (act->id == FLOW_ACTION_MIRRED && protocol == htons(ETH_P_ALL)) { if (act->id == FLOW_ACTION_MIRRED && protocol == htons(ETH_P_ALL)) {
mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_MIRROR; mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_MIRROR;
mall_entry->mirror.to_dev = act->dev; mall_entry->mirror.to_dev = act->dev;
err = mlxsw_sp_mall_port_mirror_add(mlxsw_sp_port, mall_entry);
} else if (act->id == FLOW_ACTION_SAMPLE && } else if (act->id == FLOW_ACTION_SAMPLE &&
protocol == htons(ETH_P_ALL)) { protocol == htons(ETH_P_ALL)) {
if (act->sample.rate > MLXSW_REG_MPSC_RATE_MAX) { if (act->sample.rate > MLXSW_REG_MPSC_RATE_MAX) {
...@@ -160,11 +190,12 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -160,11 +190,12 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port,
mall_entry->sample.truncate = act->sample.truncate; mall_entry->sample.truncate = act->sample.truncate;
mall_entry->sample.trunc_size = act->sample.trunc_size; mall_entry->sample.trunc_size = act->sample.trunc_size;
mall_entry->sample.rate = act->sample.rate; mall_entry->sample.rate = act->sample.rate;
err = mlxsw_sp_mall_port_sample_add(mlxsw_sp_port, mall_entry);
} else { } else {
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
goto errout;
} }
err = mlxsw_sp_mall_port_rule_add(mlxsw_sp_port, mall_entry);
if (err) if (err)
goto errout; goto errout;
...@@ -186,18 +217,9 @@ void mlxsw_sp_mall_destroy(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -186,18 +217,9 @@ void mlxsw_sp_mall_destroy(struct mlxsw_sp_port *mlxsw_sp_port,
netdev_dbg(mlxsw_sp_port->dev, "tc entry not found on port\n"); netdev_dbg(mlxsw_sp_port->dev, "tc entry not found on port\n");
return; return;
} }
list_del(&mall_entry->list);
switch (mall_entry->type) { mlxsw_sp_mall_port_rule_del(mlxsw_sp_port, mall_entry);
case MLXSW_SP_MALL_ACTION_TYPE_MIRROR:
mlxsw_sp_mall_port_mirror_del(mlxsw_sp_port, mall_entry);
break;
case MLXSW_SP_MALL_ACTION_TYPE_SAMPLE:
mlxsw_sp_mall_port_sample_del(mlxsw_sp_port);
break;
default:
WARN_ON(1);
}
list_del(&mall_entry->list);
kfree(mall_entry); kfree(mall_entry);
} }
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