Skip to content

Commit 6702782

Browse files
Paul Blakeykuba-moo
authored andcommitted
net/mlx5e: TC, Set CT miss to the specific ct action instance
Currently, CT misses restore the missed chain on the tc skb extension so tc will continue from the relevant chain. Instead, restore the CT action's miss cookie on the extension, which will instruct tc to continue from the this specific CT action instance on the relevant filter's action list. Map the CT action's miss_cookie to a new miss object (ACT_MISS), and use this miss mapping instead of the current chain miss object (CHAIN_MISS) for CT action misses. To restore this new miss mapping value, add a RX restore rule for each such mapping value. Signed-off-by: Paul Blakey <[email protected]> Reviewed-by: Roi Dayan <[email protected]> Reviewed-by: Oz Sholmo <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 235ff07 commit 6702782

File tree

5 files changed

+82
-24
lines changed

5 files changed

+82
-24
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct mlx5_tc_ct_debugfs {
5959

6060
struct mlx5_tc_ct_priv {
6161
struct mlx5_core_dev *dev;
62+
struct mlx5e_priv *priv;
6263
const struct net_device *netdev;
6364
struct mod_hdr_tbl *mod_hdr_tbl;
6465
struct xarray tuple_ids;
@@ -85,7 +86,6 @@ struct mlx5_ct_flow {
8586
struct mlx5_flow_attr *pre_ct_attr;
8687
struct mlx5_flow_handle *pre_ct_rule;
8788
struct mlx5_ct_ft *ft;
88-
u32 chain_mapping;
8989
};
9090

9191
struct mlx5_ct_zone_rule {
@@ -1445,6 +1445,7 @@ mlx5_tc_ct_parse_action(struct mlx5_tc_ct_priv *priv,
14451445
attr->ct_attr.zone = act->ct.zone;
14461446
attr->ct_attr.ct_action = act->ct.action;
14471447
attr->ct_attr.nf_ft = act->ct.flow_table;
1448+
attr->ct_attr.act_miss_cookie = act->miss_cookie;
14481449

14491450
return 0;
14501451
}
@@ -1782,7 +1783,7 @@ mlx5_tc_ct_del_ft_cb(struct mlx5_tc_ct_priv *ct_priv, struct mlx5_ct_ft *ft)
17821783
* + ft prio (tc chain) +
17831784
* + original match +
17841785
* +---------------------+
1785-
* | set chain miss mapping
1786+
* | set act_miss_cookie mapping
17861787
* | set fte_id
17871788
* | set tunnel_id
17881789
* | do decap
@@ -1827,7 +1828,7 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,
18271828
struct mlx5_flow_attr *pre_ct_attr;
18281829
struct mlx5_modify_hdr *mod_hdr;
18291830
struct mlx5_ct_flow *ct_flow;
1830-
int chain_mapping = 0, err;
1831+
int act_miss_mapping = 0, err;
18311832
struct mlx5_ct_ft *ft;
18321833
u16 zone;
18331834

@@ -1862,22 +1863,18 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,
18621863
pre_ct_attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST |
18631864
MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
18641865

1865-
/* Write chain miss tag for miss in ct table as we
1866-
* don't go though all prios of this chain as normal tc rules
1867-
* miss.
1868-
*/
1869-
err = mlx5_chains_get_chain_mapping(ct_priv->chains, attr->chain,
1870-
&chain_mapping);
1866+
err = mlx5e_tc_action_miss_mapping_get(ct_priv->priv, attr, attr->ct_attr.act_miss_cookie,
1867+
&act_miss_mapping);
18711868
if (err) {
1872-
ct_dbg("Failed to get chain register mapping for chain");
1873-
goto err_get_chain;
1869+
ct_dbg("Failed to get register mapping for act miss");
1870+
goto err_get_act_miss;
18741871
}
1875-
ct_flow->chain_mapping = chain_mapping;
1872+
attr->ct_attr.act_miss_mapping = act_miss_mapping;
18761873

18771874
err = mlx5e_tc_match_to_reg_set(priv->mdev, pre_mod_acts, ct_priv->ns_type,
1878-
MAPPED_OBJ_TO_REG, chain_mapping);
1875+
MAPPED_OBJ_TO_REG, act_miss_mapping);
18791876
if (err) {
1880-
ct_dbg("Failed to set chain register mapping");
1877+
ct_dbg("Failed to set act miss register mapping");
18811878
goto err_mapping;
18821879
}
18831880

@@ -1941,8 +1938,8 @@ __mlx5_tc_ct_flow_offload(struct mlx5_tc_ct_priv *ct_priv,
19411938
mlx5_modify_header_dealloc(priv->mdev, pre_ct_attr->modify_hdr);
19421939
err_mapping:
19431940
mlx5e_mod_hdr_dealloc(pre_mod_acts);
1944-
mlx5_chains_put_chain_mapping(ct_priv->chains, ct_flow->chain_mapping);
1945-
err_get_chain:
1941+
mlx5e_tc_action_miss_mapping_put(ct_priv->priv, attr, act_miss_mapping);
1942+
err_get_act_miss:
19461943
kfree(ct_flow->pre_ct_attr);
19471944
err_alloc_pre:
19481945
mlx5_tc_ct_del_ft_cb(ct_priv, ft);
@@ -1981,7 +1978,7 @@ __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv,
19811978
mlx5_tc_rule_delete(priv, ct_flow->pre_ct_rule, pre_ct_attr);
19821979
mlx5_modify_header_dealloc(priv->mdev, pre_ct_attr->modify_hdr);
19831980

1984-
mlx5_chains_put_chain_mapping(ct_priv->chains, ct_flow->chain_mapping);
1981+
mlx5e_tc_action_miss_mapping_put(ct_priv->priv, attr, attr->ct_attr.act_miss_mapping);
19851982
mlx5_tc_ct_del_ft_cb(ct_priv, ct_flow->ft);
19861983

19871984
kfree(ct_flow->pre_ct_attr);
@@ -2154,6 +2151,7 @@ mlx5_tc_ct_init(struct mlx5e_priv *priv, struct mlx5_fs_chains *chains,
21542151
}
21552152

21562153
spin_lock_init(&ct_priv->ht_lock);
2154+
ct_priv->priv = priv;
21572155
ct_priv->ns_type = ns_type;
21582156
ct_priv->chains = chains;
21592157
ct_priv->netdev = priv->netdev;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ struct mlx5_ct_attr {
2828
struct mlx5_ct_flow *ct_flow;
2929
struct nf_flowtable *nf_ft;
3030
u32 ct_labels_id;
31+
u32 act_miss_mapping;
32+
u64 act_miss_cookie;
3133
};
3234

3335
#define zone_to_reg_ct {\

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

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,6 +3816,7 @@ mlx5e_clone_flow_attr_for_post_act(struct mlx5_flow_attr *attr,
38163816
attr2->parse_attr = parse_attr;
38173817
attr2->dest_chain = 0;
38183818
attr2->dest_ft = NULL;
3819+
attr2->act_id_restore_rule = NULL;
38193820

38203821
if (ns_type == MLX5_FLOW_NAMESPACE_FDB) {
38213822
attr2->esw_attr->out_count = 0;
@@ -5699,14 +5700,19 @@ static bool mlx5e_tc_restore_tunnel(struct mlx5e_priv *priv, struct sk_buff *skb
56995700
return true;
57005701
}
57015702

5702-
static bool mlx5e_tc_restore_skb_chain(struct sk_buff *skb, struct mlx5_tc_ct_priv *ct_priv,
5703-
u32 chain, u32 zone_restore_id,
5704-
u32 tunnel_id, struct mlx5e_tc_update_priv *tc_priv)
5703+
static bool mlx5e_tc_restore_skb_tc_meta(struct sk_buff *skb, struct mlx5_tc_ct_priv *ct_priv,
5704+
struct mlx5_mapped_obj *mapped_obj, u32 zone_restore_id,
5705+
u32 tunnel_id, struct mlx5e_tc_update_priv *tc_priv)
57055706
{
57065707
struct mlx5e_priv *priv = netdev_priv(skb->dev);
57075708
struct tc_skb_ext *tc_skb_ext;
5709+
u64 act_miss_cookie;
5710+
u32 chain;
57085711

5709-
if (chain) {
5712+
chain = mapped_obj->type == MLX5_MAPPED_OBJ_CHAIN ? mapped_obj->chain : 0;
5713+
act_miss_cookie = mapped_obj->type == MLX5_MAPPED_OBJ_ACT_MISS ?
5714+
mapped_obj->act_miss_cookie : 0;
5715+
if (chain || act_miss_cookie) {
57105716
if (!mlx5e_tc_ct_restore_flow(ct_priv, skb, zone_restore_id))
57115717
return false;
57125718

@@ -5716,7 +5722,12 @@ static bool mlx5e_tc_restore_skb_chain(struct sk_buff *skb, struct mlx5_tc_ct_pr
57165722
return false;
57175723
}
57185724

5719-
tc_skb_ext->chain = chain;
5725+
if (act_miss_cookie) {
5726+
tc_skb_ext->act_miss_cookie = act_miss_cookie;
5727+
tc_skb_ext->act_miss = 1;
5728+
} else {
5729+
tc_skb_ext->chain = chain;
5730+
}
57205731
}
57215732

57225733
if (tc_priv)
@@ -5786,8 +5797,9 @@ bool mlx5e_tc_update_skb(struct mlx5_cqe64 *cqe, struct sk_buff *skb,
57865797

57875798
switch (mapped_obj.type) {
57885799
case MLX5_MAPPED_OBJ_CHAIN:
5789-
return mlx5e_tc_restore_skb_chain(skb, ct_priv, mapped_obj.chain, zone_restore_id,
5790-
tunnel_id, tc_priv);
5800+
case MLX5_MAPPED_OBJ_ACT_MISS:
5801+
return mlx5e_tc_restore_skb_tc_meta(skb, ct_priv, &mapped_obj, zone_restore_id,
5802+
tunnel_id, tc_priv);
57915803
case MLX5_MAPPED_OBJ_SAMPLE:
57925804
mlx5e_tc_restore_skb_sample(priv, skb, &mapped_obj, tc_priv);
57935805
tc_priv->skb_done = true;
@@ -5821,3 +5833,41 @@ bool mlx5e_tc_update_skb_nic(struct mlx5_cqe64 *cqe, struct sk_buff *skb)
58215833
return mlx5e_tc_update_skb(cqe, skb, mapping_ctx, mapped_obj_id, ct_priv, zone_restore_id,
58225834
0, NULL);
58235835
}
5836+
5837+
int mlx5e_tc_action_miss_mapping_get(struct mlx5e_priv *priv, struct mlx5_flow_attr *attr,
5838+
u64 act_miss_cookie, u32 *act_miss_mapping)
5839+
{
5840+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
5841+
struct mlx5_mapped_obj mapped_obj = {};
5842+
struct mapping_ctx *ctx;
5843+
int err;
5844+
5845+
ctx = esw->offloads.reg_c0_obj_pool;
5846+
5847+
mapped_obj.type = MLX5_MAPPED_OBJ_ACT_MISS;
5848+
mapped_obj.act_miss_cookie = act_miss_cookie;
5849+
err = mapping_add(ctx, &mapped_obj, act_miss_mapping);
5850+
if (err)
5851+
return err;
5852+
5853+
attr->act_id_restore_rule = esw_add_restore_rule(esw, *act_miss_mapping);
5854+
if (IS_ERR(attr->act_id_restore_rule))
5855+
goto err_rule;
5856+
5857+
return 0;
5858+
5859+
err_rule:
5860+
mapping_remove(ctx, *act_miss_mapping);
5861+
return err;
5862+
}
5863+
5864+
void mlx5e_tc_action_miss_mapping_put(struct mlx5e_priv *priv, struct mlx5_flow_attr *attr,
5865+
u32 act_miss_mapping)
5866+
{
5867+
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
5868+
struct mapping_ctx *ctx;
5869+
5870+
ctx = esw->offloads.reg_c0_obj_pool;
5871+
mlx5_del_flow_rules(attr->act_id_restore_rule);
5872+
mapping_remove(ctx, act_miss_mapping);
5873+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ struct mlx5_flow_attr {
9797
struct mlx5_flow_attr *branch_true;
9898
struct mlx5_flow_attr *branch_false;
9999
struct mlx5_flow_attr *jumping_attr;
100+
struct mlx5_flow_handle *act_id_restore_rule;
100101
/* keep this union last */
101102
union {
102103
DECLARE_FLEX_ARRAY(struct mlx5_esw_flow_attr, esw_attr);
@@ -400,4 +401,9 @@ mlx5e_tc_update_skb_nic(struct mlx5_cqe64 *cqe, struct sk_buff *skb)
400401
{ return true; }
401402
#endif
402403

404+
int mlx5e_tc_action_miss_mapping_get(struct mlx5e_priv *priv, struct mlx5_flow_attr *attr,
405+
u64 act_miss_cookie, u32 *act_miss_mapping);
406+
void mlx5e_tc_action_miss_mapping_put(struct mlx5e_priv *priv, struct mlx5_flow_attr *attr,
407+
u32 act_miss_mapping);
408+
403409
#endif /* __MLX5_EN_TC_H__ */

drivers/net/ethernet/mellanox/mlx5/core/eswitch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ enum mlx5_mapped_obj_type {
5252
MLX5_MAPPED_OBJ_CHAIN,
5353
MLX5_MAPPED_OBJ_SAMPLE,
5454
MLX5_MAPPED_OBJ_INT_PORT_METADATA,
55+
MLX5_MAPPED_OBJ_ACT_MISS,
5556
};
5657

5758
struct mlx5_mapped_obj {
5859
enum mlx5_mapped_obj_type type;
5960
union {
6061
u32 chain;
62+
u64 act_miss_cookie;
6163
struct {
6264
u32 group_id;
6365
u32 rate;

0 commit comments

Comments
 (0)