Commit 82270e12 authored by Paul Blakey's avatar Paul Blakey Committed by Saeed Mahameed

net/mlx5: ft: Check prio and chain sanity for ft offload

Before changing the chain from original chain to ft offload chain,
make sure user doesn't actually use chains.

While here, normalize the prio range to that which we support.
Signed-off-by: default avatarPaul Blakey <paulb@mellanox.com>
Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent e66cbc96
...@@ -1247,8 +1247,7 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data, ...@@ -1247,8 +1247,7 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
static int mlx5e_rep_setup_ft_cb(enum tc_setup_type type, void *type_data, static int mlx5e_rep_setup_ft_cb(enum tc_setup_type type, void *type_data,
void *cb_priv) void *cb_priv)
{ {
struct flow_cls_offload *f = type_data; struct flow_cls_offload tmp, *f = type_data;
struct flow_cls_offload cls_flower;
struct mlx5e_priv *priv = cb_priv; struct mlx5e_priv *priv = cb_priv;
struct mlx5_eswitch *esw; struct mlx5_eswitch *esw;
unsigned long flags; unsigned long flags;
...@@ -1261,16 +1260,30 @@ static int mlx5e_rep_setup_ft_cb(enum tc_setup_type type, void *type_data, ...@@ -1261,16 +1260,30 @@ static int mlx5e_rep_setup_ft_cb(enum tc_setup_type type, void *type_data,
switch (type) { switch (type) {
case TC_SETUP_CLSFLOWER: case TC_SETUP_CLSFLOWER:
if (!mlx5_eswitch_prios_supported(esw) || f->common.chain_index) memcpy(&tmp, f, sizeof(*f));
if (!mlx5_eswitch_prios_supported(esw) ||
tmp.common.chain_index)
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Re-use tc offload path by moving the ft flow to the /* Re-use tc offload path by moving the ft flow to the
* reserved ft chain. * reserved ft chain.
*
* FT offload can use prio range [0, INT_MAX], so we
* normalize it to range [1, mlx5_eswitch_get_prio_range(esw)]
* as with tc, where prio 0 isn't supported.
*
* We only support chain 0 of FT offload.
*/ */
memcpy(&cls_flower, f, sizeof(*f)); if (tmp.common.prio >= mlx5_eswitch_get_prio_range(esw))
cls_flower.common.chain_index = mlx5_eswitch_get_ft_chain(esw); return -EOPNOTSUPP;
err = mlx5e_rep_setup_tc_cls_flower(priv, &cls_flower, flags); if (tmp.common.chain_index != 0)
memcpy(&f->stats, &cls_flower.stats, sizeof(f->stats)); return -EOPNOTSUPP;
tmp.common.chain_index = mlx5_eswitch_get_ft_chain(esw);
tmp.common.prio++;
err = mlx5e_rep_setup_tc_cls_flower(priv, &tmp, flags);
memcpy(&f->stats, &tmp.stats, sizeof(f->stats));
return err; return err;
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
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