mlxsw: spectrum_matchall: Pass mall_entry as arg to mlxsw_sp_mall_port_sample_add()
In the preparation for future changes, have the mlxsw_sp_mall_port_sample_add() function to accept mall_entry including all needed info originally obtained from cls and act pointers. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
780ba878a1
commit
c7ea0e162f
@@ -27,6 +27,7 @@ struct mlxsw_sp_mall_entry {
|
|||||||
enum mlxsw_sp_mall_action_type type;
|
enum mlxsw_sp_mall_action_type type;
|
||||||
union {
|
union {
|
||||||
struct mlxsw_sp_mall_mirror_entry mirror;
|
struct mlxsw_sp_mall_mirror_entry mirror;
|
||||||
|
struct mlxsw_sp_port_sample sample;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -87,8 +88,7 @@ static int mlxsw_sp_mall_port_sample_set(struct mlxsw_sp_port *mlxsw_sp_port,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
mlxsw_sp_mall_port_sample_add(struct mlxsw_sp_port *mlxsw_sp_port,
|
mlxsw_sp_mall_port_sample_add(struct mlxsw_sp_port *mlxsw_sp_port,
|
||||||
struct tc_cls_matchall_offload *cls,
|
struct mlxsw_sp_mall_entry *mall_entry)
|
||||||
const struct flow_action_entry *act, bool ingress)
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@@ -98,19 +98,14 @@ mlxsw_sp_mall_port_sample_add(struct mlxsw_sp_port *mlxsw_sp_port,
|
|||||||
netdev_err(mlxsw_sp_port->dev, "sample already active\n");
|
netdev_err(mlxsw_sp_port->dev, "sample already active\n");
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
if (act->sample.rate > MLXSW_REG_MPSC_RATE_MAX) {
|
|
||||||
netdev_err(mlxsw_sp_port->dev, "sample rate not supported\n");
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
}
|
|
||||||
|
|
||||||
rcu_assign_pointer(mlxsw_sp_port->sample->psample_group,
|
rcu_assign_pointer(mlxsw_sp_port->sample->psample_group,
|
||||||
act->sample.psample_group);
|
mall_entry->sample.psample_group);
|
||||||
mlxsw_sp_port->sample->truncate = act->sample.truncate;
|
mlxsw_sp_port->sample->truncate = mall_entry->sample.truncate;
|
||||||
mlxsw_sp_port->sample->trunc_size = act->sample.trunc_size;
|
mlxsw_sp_port->sample->trunc_size = mall_entry->sample.trunc_size;
|
||||||
mlxsw_sp_port->sample->rate = act->sample.rate;
|
mlxsw_sp_port->sample->rate = mall_entry->sample.rate;
|
||||||
|
|
||||||
err = mlxsw_sp_mall_port_sample_set(mlxsw_sp_port, true,
|
err = mlxsw_sp_mall_port_sample_set(mlxsw_sp_port, true,
|
||||||
act->sample.rate);
|
mall_entry->sample.rate);
|
||||||
if (err)
|
if (err)
|
||||||
goto err_port_sample_set;
|
goto err_port_sample_set;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -157,20 +152,28 @@ int mlxsw_sp_mall_replace(struct mlxsw_sp_port *mlxsw_sp_port,
|
|||||||
ingress);
|
ingress);
|
||||||
} 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) {
|
||||||
|
netdev_err(mlxsw_sp_port->dev, "sample rate not supported\n");
|
||||||
|
err = -EOPNOTSUPP;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_SAMPLE;
|
mall_entry->type = MLXSW_SP_MALL_ACTION_TYPE_SAMPLE;
|
||||||
err = mlxsw_sp_mall_port_sample_add(mlxsw_sp_port, f, act,
|
mall_entry->sample.psample_group = act->sample.psample_group;
|
||||||
ingress);
|
mall_entry->sample.truncate = act->sample.truncate;
|
||||||
|
mall_entry->sample.trunc_size = act->sample.trunc_size;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
goto err_add_action;
|
goto errout;
|
||||||
|
|
||||||
list_add_tail(&mall_entry->list, &mlxsw_sp_port->mall_list);
|
list_add_tail(&mall_entry->list, &mlxsw_sp_port->mall_list);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_add_action:
|
errout:
|
||||||
kfree(mall_entry);
|
kfree(mall_entry);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user