Skip to content

Commit 8dc47c0

Browse files
Paul Blakeykuba-moo
authored andcommitted
net/mlx5e: Update restore chain id for slow path packets
Currently encap slow path rules just forward to software without setting the chain id miss register, so driver doesn't restore the chain, and packets hitting this rule will restart from tc chain 0 instead of continuing to the chain the encap rule was on. Fix this by setting the chain id miss register to the chain id mapping. Fixes: 8f1e0b9 ("net/mlx5: E-Switch, Mark miss packets with new chain id mapping") Signed-off-by: Paul Blakey <[email protected]> Reviewed-by: Oz Shlomo <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 19b43a4 commit 8dc47c0

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct mlx5e_tc_flow {
9696
struct encap_flow_item encaps[MLX5_MAX_FLOW_FWD_VPORTS];
9797
struct mlx5e_tc_flow *peer_flow;
9898
struct mlx5e_mod_hdr_handle *mh; /* attached mod header instance */
99+
struct mlx5e_mod_hdr_handle *slow_mh; /* attached mod header instance for slow path */
99100
struct mlx5e_hairpin_entry *hpe; /* attached hairpin instance */
100101
struct list_head hairpin; /* flows sharing the same hairpin */
101102
struct list_head peer; /* flows with peer flow */
@@ -111,6 +112,7 @@ struct mlx5e_tc_flow {
111112
struct completion del_hw_done;
112113
struct mlx5_flow_attr *attr;
113114
struct list_head attrs;
115+
u32 chain_mapping;
114116
};
115117

116118
struct mlx5_flow_handle *

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

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,8 +1405,13 @@ mlx5e_tc_offload_to_slow_path(struct mlx5_eswitch *esw,
14051405
struct mlx5e_tc_flow *flow,
14061406
struct mlx5_flow_spec *spec)
14071407
{
1408+
struct mlx5e_tc_mod_hdr_acts mod_acts = {};
1409+
struct mlx5e_mod_hdr_handle *mh = NULL;
14081410
struct mlx5_flow_attr *slow_attr;
14091411
struct mlx5_flow_handle *rule;
1412+
bool fwd_and_modify_cap;
1413+
u32 chain_mapping = 0;
1414+
int err;
14101415

14111416
slow_attr = mlx5_alloc_flow_attr(MLX5_FLOW_NAMESPACE_FDB);
14121417
if (!slow_attr)
@@ -1417,13 +1422,56 @@ mlx5e_tc_offload_to_slow_path(struct mlx5_eswitch *esw,
14171422
slow_attr->esw_attr->split_count = 0;
14181423
slow_attr->flags |= MLX5_ATTR_FLAG_SLOW_PATH;
14191424

1425+
fwd_and_modify_cap = MLX5_CAP_ESW_FLOWTABLE((esw)->dev, fdb_modify_header_fwd_to_table);
1426+
if (!fwd_and_modify_cap)
1427+
goto skip_restore;
1428+
1429+
err = mlx5_chains_get_chain_mapping(esw_chains(esw), flow->attr->chain, &chain_mapping);
1430+
if (err)
1431+
goto err_get_chain;
1432+
1433+
err = mlx5e_tc_match_to_reg_set(esw->dev, &mod_acts, MLX5_FLOW_NAMESPACE_FDB,
1434+
CHAIN_TO_REG, chain_mapping);
1435+
if (err)
1436+
goto err_reg_set;
1437+
1438+
mh = mlx5e_mod_hdr_attach(esw->dev, get_mod_hdr_table(flow->priv, flow),
1439+
MLX5_FLOW_NAMESPACE_FDB, &mod_acts);
1440+
if (IS_ERR(mh)) {
1441+
err = PTR_ERR(mh);
1442+
goto err_attach;
1443+
}
1444+
1445+
slow_attr->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
1446+
slow_attr->modify_hdr = mlx5e_mod_hdr_get(mh);
1447+
1448+
skip_restore:
14201449
rule = mlx5e_tc_offload_fdb_rules(esw, flow, spec, slow_attr);
1421-
if (!IS_ERR(rule))
1422-
flow_flag_set(flow, SLOW);
1450+
if (IS_ERR(rule)) {
1451+
err = PTR_ERR(rule);
1452+
goto err_offload;
1453+
}
14231454

1455+
flow->slow_mh = mh;
1456+
flow->chain_mapping = chain_mapping;
1457+
flow_flag_set(flow, SLOW);
1458+
1459+
mlx5e_mod_hdr_dealloc(&mod_acts);
14241460
kfree(slow_attr);
14251461

14261462
return rule;
1463+
1464+
err_offload:
1465+
if (fwd_and_modify_cap)
1466+
mlx5e_mod_hdr_detach(esw->dev, get_mod_hdr_table(flow->priv, flow), mh);
1467+
err_attach:
1468+
err_reg_set:
1469+
if (fwd_and_modify_cap)
1470+
mlx5_chains_put_chain_mapping(esw_chains(esw), chain_mapping);
1471+
err_get_chain:
1472+
mlx5e_mod_hdr_dealloc(&mod_acts);
1473+
kfree(slow_attr);
1474+
return ERR_PTR(err);
14271475
}
14281476

14291477
void mlx5e_tc_unoffload_from_slow_path(struct mlx5_eswitch *esw,
@@ -1441,7 +1489,17 @@ void mlx5e_tc_unoffload_from_slow_path(struct mlx5_eswitch *esw,
14411489
slow_attr->action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
14421490
slow_attr->esw_attr->split_count = 0;
14431491
slow_attr->flags |= MLX5_ATTR_FLAG_SLOW_PATH;
1492+
if (flow->slow_mh) {
1493+
slow_attr->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
1494+
slow_attr->modify_hdr = mlx5e_mod_hdr_get(flow->slow_mh);
1495+
}
14441496
mlx5e_tc_unoffload_fdb_rules(esw, flow, slow_attr);
1497+
if (flow->slow_mh) {
1498+
mlx5e_mod_hdr_detach(esw->dev, get_mod_hdr_table(flow->priv, flow), flow->slow_mh);
1499+
mlx5_chains_put_chain_mapping(esw_chains(esw), flow->chain_mapping);
1500+
flow->chain_mapping = 0;
1501+
flow->slow_mh = NULL;
1502+
}
14451503
flow_flag_clear(flow, SLOW);
14461504
kfree(slow_attr);
14471505
}

0 commit comments

Comments
 (0)