Skip to content

Commit 82270e1

Browse files
Paul BlakeySaeed Mahameed
authored andcommitted
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: Paul Blakey <paulb@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Reviewed-by: Mark Bloch <markb@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent e66cbc9 commit 82270e1

File tree

1 file changed

+20
-7
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+20
-7
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_rep.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,8 +1247,7 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
12471247
static int mlx5e_rep_setup_ft_cb(enum tc_setup_type type, void *type_data,
12481248
void *cb_priv)
12491249
{
1250-
struct flow_cls_offload *f = type_data;
1251-
struct flow_cls_offload cls_flower;
1250+
struct flow_cls_offload tmp, *f = type_data;
12521251
struct mlx5e_priv *priv = cb_priv;
12531252
struct mlx5_eswitch *esw;
12541253
unsigned long flags;
@@ -1261,16 +1260,30 @@ static int mlx5e_rep_setup_ft_cb(enum tc_setup_type type, void *type_data,
12611260

12621261
switch (type) {
12631262
case TC_SETUP_CLSFLOWER:
1264-
if (!mlx5_eswitch_prios_supported(esw) || f->common.chain_index)
1263+
memcpy(&tmp, f, sizeof(*f));
1264+
1265+
if (!mlx5_eswitch_prios_supported(esw) ||
1266+
tmp.common.chain_index)
12651267
return -EOPNOTSUPP;
12661268

12671269
/* Re-use tc offload path by moving the ft flow to the
12681270
* reserved ft chain.
1271+
*
1272+
* FT offload can use prio range [0, INT_MAX], so we
1273+
* normalize it to range [1, mlx5_eswitch_get_prio_range(esw)]
1274+
* as with tc, where prio 0 isn't supported.
1275+
*
1276+
* We only support chain 0 of FT offload.
12691277
*/
1270-
memcpy(&cls_flower, f, sizeof(*f));
1271-
cls_flower.common.chain_index = mlx5_eswitch_get_ft_chain(esw);
1272-
err = mlx5e_rep_setup_tc_cls_flower(priv, &cls_flower, flags);
1273-
memcpy(&f->stats, &cls_flower.stats, sizeof(f->stats));
1278+
if (tmp.common.prio >= mlx5_eswitch_get_prio_range(esw))
1279+
return -EOPNOTSUPP;
1280+
if (tmp.common.chain_index != 0)
1281+
return -EOPNOTSUPP;
1282+
1283+
tmp.common.chain_index = mlx5_eswitch_get_ft_chain(esw);
1284+
tmp.common.prio++;
1285+
err = mlx5e_rep_setup_tc_cls_flower(priv, &tmp, flags);
1286+
memcpy(&f->stats, &tmp.stats, sizeof(f->stats));
12741287
return err;
12751288
default:
12761289
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)