|
|
d8f823 |
From 0adbd26f7bfb53e99b9726e4c4ba399ce91fb7b5 Mon Sep 17 00:00:00 2001
|
|
|
d8f823 |
From: Alaa Hleihel <ahleihel@redhat.com>
|
|
|
d8f823 |
Date: Tue, 19 May 2020 07:49:08 -0400
|
|
|
d8f823 |
Subject: [PATCH 246/312] [netdrv] net/mlx5e: CT: Support clear action
|
|
|
d8f823 |
|
|
|
d8f823 |
Message-id: <20200519074934.6303-38-ahleihel@redhat.com>
|
|
|
d8f823 |
Patchwork-id: 310539
|
|
|
d8f823 |
Patchwork-instance: patchwork
|
|
|
d8f823 |
O-Subject: [RHEL8.3 BZ 1663246 37/63] net/mlx5e: CT: Support clear action
|
|
|
d8f823 |
Bugzilla: 1790219 1663246
|
|
|
d8f823 |
RH-Acked-by: Marcelo Leitner <mleitner@redhat.com>
|
|
|
d8f823 |
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
|
|
|
d8f823 |
RH-Acked-by: John Linville <linville@redhat.com>
|
|
|
d8f823 |
RH-Acked-by: Ivan Vecera <ivecera@redhat.com>
|
|
|
d8f823 |
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
|
|
|
d8f823 |
RH-Acked-by: Kamal Heib <kheib@redhat.com>
|
|
|
d8f823 |
|
|
|
d8f823 |
Bugzilla: http://bugzilla.redhat.com/1663246
|
|
|
d8f823 |
Bugzilla: http://bugzilla.redhat.com/1790219
|
|
|
d8f823 |
Upstream: v5.7-rc1
|
|
|
d8f823 |
|
|
|
d8f823 |
commit 1ef3018f5af3da6376fae546e4dfc3f05f063815
|
|
|
d8f823 |
Author: Paul Blakey <paulb@mellanox.com>
|
|
|
d8f823 |
Date: Thu Mar 12 12:23:17 2020 +0200
|
|
|
d8f823 |
|
|
|
d8f823 |
net/mlx5e: CT: Support clear action
|
|
|
d8f823 |
|
|
|
d8f823 |
Clear action, as with software, removes all ct metadata from
|
|
|
d8f823 |
the packet.
|
|
|
d8f823 |
|
|
|
d8f823 |
Signed-off-by: Paul Blakey <paulb@mellanox.com>
|
|
|
d8f823 |
Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
|
|
|
d8f823 |
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
|
d8f823 |
|
|
|
d8f823 |
Signed-off-by: Alaa Hleihel <ahleihel@redhat.com>
|
|
|
d8f823 |
Signed-off-by: Frantisek Hrbata <fhrbata@redhat.com>
|
|
|
d8f823 |
---
|
|
|
d8f823 |
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 90 ++++++++++++++++++++--
|
|
|
d8f823 |
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h | 7 +-
|
|
|
d8f823 |
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 10 ++-
|
|
|
d8f823 |
3 files changed, 95 insertions(+), 12 deletions(-)
|
|
|
d8f823 |
|
|
|
d8f823 |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
|
|
|
d8f823 |
index c75dc97fd3a7..956d9ddcdeed 100644
|
|
|
d8f823 |
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
|
|
|
d8f823 |
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
|
|
|
d8f823 |
@@ -1048,12 +1048,79 @@ __mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
|
|
|
d8f823 |
return err;
|
|
|
d8f823 |
}
|
|
|
d8f823 |
|
|
|
d8f823 |
+static int
|
|
|
d8f823 |
+__mlx5_tc_ct_flow_offload_clear(struct mlx5e_priv *priv,
|
|
|
d8f823 |
+ struct mlx5e_tc_flow *flow,
|
|
|
d8f823 |
+ struct mlx5_flow_spec *orig_spec,
|
|
|
d8f823 |
+ struct mlx5_esw_flow_attr *attr,
|
|
|
d8f823 |
+ struct mlx5e_tc_mod_hdr_acts *mod_acts,
|
|
|
d8f823 |
+ struct mlx5_flow_handle **flow_rule)
|
|
|
d8f823 |
+{
|
|
|
d8f823 |
+ struct mlx5_tc_ct_priv *ct_priv = mlx5_tc_ct_get_ct_priv(priv);
|
|
|
d8f823 |
+ struct mlx5_eswitch *esw = ct_priv->esw;
|
|
|
d8f823 |
+ struct mlx5_esw_flow_attr *pre_ct_attr;
|
|
|
d8f823 |
+ struct mlx5_modify_hdr *mod_hdr;
|
|
|
d8f823 |
+ struct mlx5_flow_handle *rule;
|
|
|
d8f823 |
+ struct mlx5_ct_flow *ct_flow;
|
|
|
d8f823 |
+ int err;
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ ct_flow = kzalloc(sizeof(*ct_flow), GFP_KERNEL);
|
|
|
d8f823 |
+ if (!ct_flow)
|
|
|
d8f823 |
+ return -ENOMEM;
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ /* Base esw attributes on original rule attribute */
|
|
|
d8f823 |
+ pre_ct_attr = &ct_flow->pre_ct_attr;
|
|
|
d8f823 |
+ memcpy(pre_ct_attr, attr, sizeof(*attr));
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ err = mlx5_tc_ct_entry_set_registers(ct_priv, mod_acts, 0, 0, 0, 0);
|
|
|
d8f823 |
+ if (err) {
|
|
|
d8f823 |
+ ct_dbg("Failed to set register for ct clear");
|
|
|
d8f823 |
+ goto err_set_registers;
|
|
|
d8f823 |
+ }
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ mod_hdr = mlx5_modify_header_alloc(esw->dev,
|
|
|
d8f823 |
+ MLX5_FLOW_NAMESPACE_FDB,
|
|
|
d8f823 |
+ mod_acts->num_actions,
|
|
|
d8f823 |
+ mod_acts->actions);
|
|
|
d8f823 |
+ if (IS_ERR(mod_hdr)) {
|
|
|
d8f823 |
+ err = PTR_ERR(mod_hdr);
|
|
|
d8f823 |
+ ct_dbg("Failed to add create ct clear mod hdr");
|
|
|
d8f823 |
+ goto err_set_registers;
|
|
|
d8f823 |
+ }
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ dealloc_mod_hdr_actions(mod_acts);
|
|
|
d8f823 |
+ pre_ct_attr->modify_hdr = mod_hdr;
|
|
|
d8f823 |
+ pre_ct_attr->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ rule = mlx5_eswitch_add_offloaded_rule(esw, orig_spec, pre_ct_attr);
|
|
|
d8f823 |
+ if (IS_ERR(rule)) {
|
|
|
d8f823 |
+ err = PTR_ERR(rule);
|
|
|
d8f823 |
+ ct_dbg("Failed to add ct clear rule");
|
|
|
d8f823 |
+ goto err_insert;
|
|
|
d8f823 |
+ }
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ attr->ct_attr.ct_flow = ct_flow;
|
|
|
d8f823 |
+ ct_flow->pre_ct_rule = rule;
|
|
|
d8f823 |
+ *flow_rule = rule;
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ return 0;
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+err_insert:
|
|
|
d8f823 |
+ mlx5_modify_header_dealloc(priv->mdev, mod_hdr);
|
|
|
d8f823 |
+err_set_registers:
|
|
|
d8f823 |
+ netdev_warn(priv->netdev,
|
|
|
d8f823 |
+ "Failed to offload ct clear flow, err %d\n", err);
|
|
|
d8f823 |
+ return err;
|
|
|
d8f823 |
+}
|
|
|
d8f823 |
+
|
|
|
d8f823 |
struct mlx5_flow_handle *
|
|
|
d8f823 |
mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
|
|
|
d8f823 |
struct mlx5e_tc_flow *flow,
|
|
|
d8f823 |
struct mlx5_flow_spec *spec,
|
|
|
d8f823 |
- struct mlx5_esw_flow_attr *attr)
|
|
|
d8f823 |
+ struct mlx5_esw_flow_attr *attr,
|
|
|
d8f823 |
+ struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts)
|
|
|
d8f823 |
{
|
|
|
d8f823 |
+ bool clear_action = attr->ct_attr.ct_action & TCA_CT_ACT_CLEAR;
|
|
|
d8f823 |
struct mlx5_tc_ct_priv *ct_priv = mlx5_tc_ct_get_ct_priv(priv);
|
|
|
d8f823 |
struct mlx5_flow_handle *rule;
|
|
|
d8f823 |
int err;
|
|
|
d8f823 |
@@ -1062,7 +1129,12 @@ mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
|
|
|
d8f823 |
return ERR_PTR(-EOPNOTSUPP);
|
|
|
d8f823 |
|
|
|
d8f823 |
mutex_lock(&ct_priv->control_lock);
|
|
|
d8f823 |
- err = __mlx5_tc_ct_flow_offload(priv, flow, spec, attr, &rule;;
|
|
|
d8f823 |
+ if (clear_action)
|
|
|
d8f823 |
+ err = __mlx5_tc_ct_flow_offload_clear(priv, flow, spec, attr,
|
|
|
d8f823 |
+ mod_hdr_acts, &rule;;
|
|
|
d8f823 |
+ else
|
|
|
d8f823 |
+ err = __mlx5_tc_ct_flow_offload(priv, flow, spec, attr,
|
|
|
d8f823 |
+ &rule;;
|
|
|
d8f823 |
mutex_unlock(&ct_priv->control_lock);
|
|
|
d8f823 |
if (err)
|
|
|
d8f823 |
return ERR_PTR(err);
|
|
|
d8f823 |
@@ -1080,11 +1152,15 @@ __mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *ct_priv,
|
|
|
d8f823 |
mlx5_eswitch_del_offloaded_rule(esw, ct_flow->pre_ct_rule,
|
|
|
d8f823 |
pre_ct_attr);
|
|
|
d8f823 |
mlx5_modify_header_dealloc(esw->dev, pre_ct_attr->modify_hdr);
|
|
|
d8f823 |
- mlx5_eswitch_del_offloaded_rule(esw, ct_flow->post_ct_rule,
|
|
|
d8f823 |
- &ct_flow->post_ct_attr);
|
|
|
d8f823 |
- mlx5_esw_chains_put_chain_mapping(esw, ct_flow->chain_mapping);
|
|
|
d8f823 |
- idr_remove(&ct_priv->fte_ids, ct_flow->fte_id);
|
|
|
d8f823 |
- mlx5_tc_ct_del_ft_cb(ct_priv, ct_flow->ft);
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ if (ct_flow->post_ct_rule) {
|
|
|
d8f823 |
+ mlx5_eswitch_del_offloaded_rule(esw, ct_flow->post_ct_rule,
|
|
|
d8f823 |
+ &ct_flow->post_ct_attr);
|
|
|
d8f823 |
+ mlx5_esw_chains_put_chain_mapping(esw, ct_flow->chain_mapping);
|
|
|
d8f823 |
+ idr_remove(&ct_priv->fte_ids, ct_flow->fte_id);
|
|
|
d8f823 |
+ mlx5_tc_ct_del_ft_cb(ct_priv, ct_flow->ft);
|
|
|
d8f823 |
+ }
|
|
|
d8f823 |
+
|
|
|
d8f823 |
kfree(ct_flow);
|
|
|
d8f823 |
}
|
|
|
d8f823 |
|
|
|
d8f823 |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h
|
|
|
d8f823 |
index 464c86595309..6b2c893372da 100644
|
|
|
d8f823 |
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h
|
|
|
d8f823 |
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h
|
|
|
d8f823 |
@@ -9,6 +9,7 @@
|
|
|
d8f823 |
#include <net/tc_act/tc_ct.h>
|
|
|
d8f823 |
|
|
|
d8f823 |
struct mlx5_esw_flow_attr;
|
|
|
d8f823 |
+struct mlx5e_tc_mod_hdr_acts;
|
|
|
d8f823 |
struct mlx5_rep_uplink_priv;
|
|
|
d8f823 |
struct mlx5e_tc_flow;
|
|
|
d8f823 |
struct mlx5e_priv;
|
|
|
d8f823 |
@@ -97,7 +98,8 @@ struct mlx5_flow_handle *
|
|
|
d8f823 |
mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
|
|
|
d8f823 |
struct mlx5e_tc_flow *flow,
|
|
|
d8f823 |
struct mlx5_flow_spec *spec,
|
|
|
d8f823 |
- struct mlx5_esw_flow_attr *attr);
|
|
|
d8f823 |
+ struct mlx5_esw_flow_attr *attr,
|
|
|
d8f823 |
+ struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);
|
|
|
d8f823 |
void
|
|
|
d8f823 |
mlx5_tc_ct_delete_flow(struct mlx5e_priv *priv,
|
|
|
d8f823 |
struct mlx5e_tc_flow *flow,
|
|
|
d8f823 |
@@ -142,7 +144,8 @@ static inline struct mlx5_flow_handle *
|
|
|
d8f823 |
mlx5_tc_ct_flow_offload(struct mlx5e_priv *priv,
|
|
|
d8f823 |
struct mlx5e_tc_flow *flow,
|
|
|
d8f823 |
struct mlx5_flow_spec *spec,
|
|
|
d8f823 |
- struct mlx5_esw_flow_attr *attr)
|
|
|
d8f823 |
+ struct mlx5_esw_flow_attr *attr,
|
|
|
d8f823 |
+ struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts)
|
|
|
d8f823 |
{
|
|
|
d8f823 |
return ERR_PTR(-EOPNOTSUPP);
|
|
|
d8f823 |
}
|
|
|
d8f823 |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
|
|
|
d8f823 |
index f88b199487d2..48e4d7a5f7b8 100644
|
|
|
d8f823 |
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
|
|
|
d8f823 |
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
|
|
|
d8f823 |
@@ -1151,11 +1151,15 @@ mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw,
|
|
|
d8f823 |
struct mlx5_flow_spec *spec,
|
|
|
d8f823 |
struct mlx5_esw_flow_attr *attr)
|
|
|
d8f823 |
{
|
|
|
d8f823 |
+ struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts;
|
|
|
d8f823 |
struct mlx5_flow_handle *rule;
|
|
|
d8f823 |
- struct mlx5e_tc_mod_hdr_acts;
|
|
|
d8f823 |
|
|
|
d8f823 |
- if (flow_flag_test(flow, CT))
|
|
|
d8f823 |
- return mlx5_tc_ct_flow_offload(flow->priv, flow, spec, attr);
|
|
|
d8f823 |
+ if (flow_flag_test(flow, CT)) {
|
|
|
d8f823 |
+ mod_hdr_acts = &attr->parse_attr->mod_hdr_acts;
|
|
|
d8f823 |
+
|
|
|
d8f823 |
+ return mlx5_tc_ct_flow_offload(flow->priv, flow, spec, attr,
|
|
|
d8f823 |
+ mod_hdr_acts);
|
|
|
d8f823 |
+ }
|
|
|
d8f823 |
|
|
|
d8f823 |
rule = mlx5_eswitch_add_offloaded_rule(esw, spec, attr);
|
|
|
d8f823 |
if (IS_ERR(rule))
|
|
|
d8f823 |
--
|
|
|
d8f823 |
2.13.6
|
|
|
d8f823 |
|