Skip to content

Commit 7fac5c2

Browse files
Paul BlakeySaeed Mahameed
authored andcommitted
net/mlx5: CT: Avoid reusing modify header context for natted entries
Currently the driver is designed to reuse header modify context entries. Natted entries will always have a unique modify header, as such the modify header hashtable lookup is introducing an overhead. When the hashtable size exceeded 200k entries the tested insertion rate dropped from ~10k entries/sec to ~300 entries/sec. Don't use the re-use mechanism when creating modify headers for natted tuples. Signed-off-by: Paul Blakey <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 74097a0 commit 7fac5c2

File tree

1 file changed

+38
-12
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en

1 file changed

+38
-12
lines changed

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

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ struct mlx5_ct_entry {
150150
unsigned long flags;
151151
};
152152

153+
static void
154+
mlx5_tc_ct_entry_destroy_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
155+
struct mlx5_flow_attr *attr,
156+
struct mlx5e_mod_hdr_handle *mh);
157+
153158
static const struct rhashtable_params cts_ht_params = {
154159
.head_offset = offsetof(struct mlx5_ct_entry, node),
155160
.key_offset = offsetof(struct mlx5_ct_entry, cookie),
@@ -458,8 +463,7 @@ mlx5_tc_ct_entry_del_rule(struct mlx5_tc_ct_priv *ct_priv,
458463
ct_dbg("Deleting ct entry rule in zone %d", entry->tuple.zone);
459464

460465
mlx5_tc_rule_delete(netdev_priv(ct_priv->netdev), zone_rule->rule, attr);
461-
mlx5e_mod_hdr_detach(ct_priv->dev,
462-
ct_priv->mod_hdr_tbl, zone_rule->mh);
466+
mlx5_tc_ct_entry_destroy_mod_hdr(ct_priv, zone_rule->attr, zone_rule->mh);
463467
mlx5_put_label_mapping(ct_priv, attr->ct_attr.ct_labels_id);
464468
kfree(attr);
465469
}
@@ -686,15 +690,27 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
686690
if (err)
687691
goto err_mapping;
688692

689-
*mh = mlx5e_mod_hdr_attach(ct_priv->dev,
690-
ct_priv->mod_hdr_tbl,
691-
ct_priv->ns_type,
692-
&mod_acts);
693-
if (IS_ERR(*mh)) {
694-
err = PTR_ERR(*mh);
695-
goto err_mapping;
693+
if (nat) {
694+
attr->modify_hdr = mlx5_modify_header_alloc(ct_priv->dev, ct_priv->ns_type,
695+
mod_acts.num_actions,
696+
mod_acts.actions);
697+
if (IS_ERR(attr->modify_hdr)) {
698+
err = PTR_ERR(attr->modify_hdr);
699+
goto err_mapping;
700+
}
701+
702+
*mh = NULL;
703+
} else {
704+
*mh = mlx5e_mod_hdr_attach(ct_priv->dev,
705+
ct_priv->mod_hdr_tbl,
706+
ct_priv->ns_type,
707+
&mod_acts);
708+
if (IS_ERR(*mh)) {
709+
err = PTR_ERR(*mh);
710+
goto err_mapping;
711+
}
712+
attr->modify_hdr = mlx5e_mod_hdr_get(*mh);
696713
}
697-
attr->modify_hdr = mlx5e_mod_hdr_get(*mh);
698714

699715
dealloc_mod_hdr_actions(&mod_acts);
700716
return 0;
@@ -705,6 +721,17 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
705721
return err;
706722
}
707723

724+
static void
725+
mlx5_tc_ct_entry_destroy_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
726+
struct mlx5_flow_attr *attr,
727+
struct mlx5e_mod_hdr_handle *mh)
728+
{
729+
if (mh)
730+
mlx5e_mod_hdr_detach(ct_priv->dev, ct_priv->mod_hdr_tbl, mh);
731+
else
732+
mlx5_modify_header_dealloc(ct_priv->dev, attr->modify_hdr);
733+
}
734+
708735
static int
709736
mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
710737
struct flow_rule *flow_rule,
@@ -767,8 +794,7 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
767794
return 0;
768795

769796
err_rule:
770-
mlx5e_mod_hdr_detach(ct_priv->dev,
771-
ct_priv->mod_hdr_tbl, zone_rule->mh);
797+
mlx5_tc_ct_entry_destroy_mod_hdr(ct_priv, zone_rule->attr, zone_rule->mh);
772798
mlx5_put_label_mapping(ct_priv, attr->ct_attr.ct_labels_id);
773799
err_mod_hdr:
774800
kfree(attr);

0 commit comments

Comments
 (0)