Skip to content

Commit f869bcb

Browse files
w1ldptrSaeed Mahameed
authored andcommitted
net/mlx5e: Allow offloading of ct 'new' match
Allow offloading filters that match on conntrack 'new' state in order to enable UDP NEW offload in the following patch. Unhardcode ct 'established' from ct modify header infrastructure code and determine correct ct state bit according to the metadata action 'cookie' field. Signed-off-by: Vlad Buslov <[email protected]> Reviewed-by: Oz Shlomo <[email protected]> Reviewed-by: Paul Blakey <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 94ceffb commit f869bcb

File tree

1 file changed

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

1 file changed

+9
-12
lines changed

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define MLX5_CT_STATE_REPLY_BIT BIT(4)
3636
#define MLX5_CT_STATE_RELATED_BIT BIT(5)
3737
#define MLX5_CT_STATE_INVALID_BIT BIT(6)
38+
#define MLX5_CT_STATE_NEW_BIT BIT(7)
3839

3940
#define MLX5_CT_LABELS_BITS MLX5_REG_MAPPING_MBITS(LABELS_TO_REG)
4041
#define MLX5_CT_LABELS_MASK MLX5_REG_MAPPING_MASK(LABELS_TO_REG)
@@ -721,12 +722,14 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
721722
DECLARE_MOD_HDR_ACTS_ACTIONS(actions_arr, MLX5_CT_MIN_MOD_ACTS);
722723
DECLARE_MOD_HDR_ACTS(mod_acts, actions_arr);
723724
struct flow_action_entry *meta;
725+
enum ip_conntrack_info ctinfo;
724726
u16 ct_state = 0;
725727
int err;
726728

727729
meta = mlx5_tc_ct_get_ct_metadata_action(flow_rule);
728730
if (!meta)
729731
return -EOPNOTSUPP;
732+
ctinfo = meta->ct_metadata.cookie & NFCT_INFOMASK;
730733

731734
err = mlx5_get_label_mapping(ct_priv, meta->ct_metadata.labels,
732735
&attr->ct_attr.ct_labels_id);
@@ -742,7 +745,8 @@ mlx5_tc_ct_entry_create_mod_hdr(struct mlx5_tc_ct_priv *ct_priv,
742745
ct_state |= MLX5_CT_STATE_NAT_BIT;
743746
}
744747

745-
ct_state |= MLX5_CT_STATE_ESTABLISHED_BIT | MLX5_CT_STATE_TRK_BIT;
748+
ct_state |= MLX5_CT_STATE_TRK_BIT;
749+
ct_state |= ctinfo == IP_CT_NEW ? MLX5_CT_STATE_NEW_BIT : MLX5_CT_STATE_ESTABLISHED_BIT;
746750
ct_state |= meta->ct_metadata.orig_dir ? 0 : MLX5_CT_STATE_REPLY_BIT;
747751
err = mlx5_tc_ct_entry_set_registers(ct_priv, &mod_acts,
748752
ct_state,
@@ -1181,16 +1185,12 @@ mlx5_tc_ct_block_flow_offload_add(struct mlx5_ct_ft *ft,
11811185
struct mlx5_tc_ct_priv *ct_priv = ft->ct_priv;
11821186
struct flow_action_entry *meta_action;
11831187
unsigned long cookie = flow->cookie;
1184-
enum ip_conntrack_info ctinfo;
11851188
struct mlx5_ct_entry *entry;
11861189
int err;
11871190

11881191
meta_action = mlx5_tc_ct_get_ct_metadata_action(flow_rule);
11891192
if (!meta_action)
11901193
return -EOPNOTSUPP;
1191-
ctinfo = meta_action->ct_metadata.cookie & NFCT_INFOMASK;
1192-
if (ctinfo == IP_CT_NEW)
1193-
return -EOPNOTSUPP;
11941194

11951195
spin_lock_bh(&ct_priv->ht_lock);
11961196
entry = rhashtable_lookup_fast(&ft->ct_entries_ht, &cookie, cts_ht_params);
@@ -1443,7 +1443,7 @@ mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,
14431443
struct mlx5_ct_attr *ct_attr,
14441444
struct netlink_ext_ack *extack)
14451445
{
1446-
bool trk, est, untrk, unest, new, rpl, unrpl, rel, unrel, inv, uninv;
1446+
bool trk, est, untrk, unnew, unest, new, rpl, unrpl, rel, unrel, inv, uninv;
14471447
struct flow_rule *rule = flow_cls_offload_flow_rule(f);
14481448
struct flow_dissector_key_ct *mask, *key;
14491449
u32 ctstate = 0, ctstate_mask = 0;
@@ -1489,15 +1489,18 @@ mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,
14891489
rel = ct_state_on & TCA_FLOWER_KEY_CT_FLAGS_RELATED;
14901490
inv = ct_state_on & TCA_FLOWER_KEY_CT_FLAGS_INVALID;
14911491
untrk = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_TRACKED;
1492+
unnew = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_NEW;
14921493
unest = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED;
14931494
unrpl = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_REPLY;
14941495
unrel = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_RELATED;
14951496
uninv = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_INVALID;
14961497

14971498
ctstate |= trk ? MLX5_CT_STATE_TRK_BIT : 0;
1499+
ctstate |= new ? MLX5_CT_STATE_NEW_BIT : 0;
14981500
ctstate |= est ? MLX5_CT_STATE_ESTABLISHED_BIT : 0;
14991501
ctstate |= rpl ? MLX5_CT_STATE_REPLY_BIT : 0;
15001502
ctstate_mask |= (untrk || trk) ? MLX5_CT_STATE_TRK_BIT : 0;
1503+
ctstate_mask |= (unnew || new) ? MLX5_CT_STATE_NEW_BIT : 0;
15011504
ctstate_mask |= (unest || est) ? MLX5_CT_STATE_ESTABLISHED_BIT : 0;
15021505
ctstate_mask |= (unrpl || rpl) ? MLX5_CT_STATE_REPLY_BIT : 0;
15031506
ctstate_mask |= unrel ? MLX5_CT_STATE_RELATED_BIT : 0;
@@ -1515,12 +1518,6 @@ mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,
15151518
return -EOPNOTSUPP;
15161519
}
15171520

1518-
if (new) {
1519-
NL_SET_ERR_MSG_MOD(extack,
1520-
"matching on ct_state +new isn't supported");
1521-
return -EOPNOTSUPP;
1522-
}
1523-
15241521
if (mask->ct_zone)
15251522
mlx5e_tc_match_to_reg_match(spec, ZONE_TO_REG,
15261523
key->ct_zone, MLX5_CT_ZONE_MASK);

0 commit comments

Comments
 (0)