netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Roi Dayan <roid@nvidia.com>, Maor Dickman <maord@nvidia.com>
Subject: [net-next 08/15] net/mlx5e: TC, Pass flow attr to attach/detach mod hdr functions
Date: Wed, 18 Jan 2023 10:35:55 -0800	[thread overview]
Message-ID: <20230118183602.124323-9-saeed@kernel.org> (raw)
In-Reply-To: <20230118183602.124323-1-saeed@kernel.org>

From: Roi Dayan <roid@nvidia.com>

In preparation to remove duplicate functions handling mod hdr allocation
and the fact that modify hdr should be per flow attr and not flow
pass flow attr to the attach and detach mod hdr funcs.

Signed-off-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Maor Dickman <maord@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../ethernet/mellanox/mlx5/core/en/tc_priv.h  |  2 -
 .../net/ethernet/mellanox/mlx5/core/en_tc.c   | 41 ++++++++++---------
 .../net/ethernet/mellanox/mlx5/core/en_tc.h   |  2 +
 3 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h
index 2b7fd1c0e643..f575646d2f50 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_priv.h
@@ -95,8 +95,6 @@ struct mlx5e_tc_flow {
 	 */
 	struct encap_flow_item encaps[MLX5_MAX_FLOW_FWD_VPORTS];
 	struct mlx5e_tc_flow *peer_flow;
-	struct mlx5e_mod_hdr_handle *mh; /* attached mod header instance */
-	struct mlx5e_mod_hdr_handle *slow_mh; /* attached mod header instance for slow path */
 	struct mlx5e_hairpin_entry *hpe; /* attached hairpin instance */
 	struct list_head hairpin; /* flows sharing the same hairpin */
 	struct list_head peer;    /* flows with peer flow */
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 0c04a5e7c274..455c178f4115 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -648,34 +648,34 @@ get_mod_hdr_table(struct mlx5e_priv *priv, struct mlx5e_tc_flow *flow)
 
 static int mlx5e_attach_mod_hdr(struct mlx5e_priv *priv,
 				struct mlx5e_tc_flow *flow,
-				struct mlx5e_tc_flow_parse_attr *parse_attr)
+				struct mlx5_flow_attr *attr)
 {
-	struct mlx5_modify_hdr *modify_hdr;
 	struct mlx5e_mod_hdr_handle *mh;
 
 	mh = mlx5e_mod_hdr_attach(priv->mdev, get_mod_hdr_table(priv, flow),
 				  mlx5e_get_flow_namespace(flow),
-				  &parse_attr->mod_hdr_acts);
+				  &attr->parse_attr->mod_hdr_acts);
 	if (IS_ERR(mh))
 		return PTR_ERR(mh);
 
-	modify_hdr = mlx5e_mod_hdr_get(mh);
-	flow->attr->modify_hdr = modify_hdr;
-	flow->mh = mh;
+	WARN_ON(attr->modify_hdr);
+	attr->modify_hdr = mlx5e_mod_hdr_get(mh);
+	attr->mh = mh;
 
 	return 0;
 }
 
 static void mlx5e_detach_mod_hdr(struct mlx5e_priv *priv,
-				 struct mlx5e_tc_flow *flow)
+				 struct mlx5e_tc_flow *flow,
+				 struct mlx5_flow_attr *attr)
 {
 	/* flow wasn't fully initialized */
-	if (!flow->mh)
+	if (!attr->mh)
 		return;
 
 	mlx5e_mod_hdr_detach(priv->mdev, get_mod_hdr_table(priv, flow),
-			     flow->mh);
-	flow->mh = NULL;
+			     attr->mh);
+	attr->mh = NULL;
 }
 
 static
@@ -1433,7 +1433,7 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv,
 	}
 
 	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) {
-		err = mlx5e_attach_mod_hdr(priv, flow, parse_attr);
+		err = mlx5e_attach_mod_hdr(priv, flow, attr);
 		if (err)
 			return err;
 	}
@@ -1493,7 +1493,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
 
 	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) {
 		mlx5e_mod_hdr_dealloc(&attr->parse_attr->mod_hdr_acts);
-		mlx5e_detach_mod_hdr(priv, flow);
+		mlx5e_detach_mod_hdr(priv, flow, attr);
 	}
 
 	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_COUNT)
@@ -1604,7 +1604,7 @@ mlx5e_tc_offload_to_slow_path(struct mlx5_eswitch *esw,
 		goto err_offload;
 	}
 
-	flow->slow_mh = mh;
+	flow->attr->slow_mh = mh;
 	flow->chain_mapping = chain_mapping;
 	flow_flag_set(flow, SLOW);
 
@@ -1629,6 +1629,7 @@ mlx5e_tc_offload_to_slow_path(struct mlx5_eswitch *esw,
 void mlx5e_tc_unoffload_from_slow_path(struct mlx5_eswitch *esw,
 				       struct mlx5e_tc_flow *flow)
 {
+	struct mlx5e_mod_hdr_handle *slow_mh = flow->attr->slow_mh;
 	struct mlx5_flow_attr *slow_attr;
 
 	slow_attr = mlx5_alloc_flow_attr(MLX5_FLOW_NAMESPACE_FDB);
@@ -1641,16 +1642,16 @@ void mlx5e_tc_unoffload_from_slow_path(struct mlx5_eswitch *esw,
 	slow_attr->action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST;
 	slow_attr->esw_attr->split_count = 0;
 	slow_attr->flags |= MLX5_ATTR_FLAG_SLOW_PATH;
-	if (flow->slow_mh) {
+	if (slow_mh) {
 		slow_attr->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR;
-		slow_attr->modify_hdr = mlx5e_mod_hdr_get(flow->slow_mh);
+		slow_attr->modify_hdr = mlx5e_mod_hdr_get(slow_mh);
 	}
 	mlx5e_tc_unoffload_fdb_rules(esw, flow, slow_attr);
-	if (flow->slow_mh) {
-		mlx5e_mod_hdr_detach(esw->dev, get_mod_hdr_table(flow->priv, flow), flow->slow_mh);
+	if (slow_mh) {
+		mlx5e_mod_hdr_detach(esw->dev, get_mod_hdr_table(flow->priv, flow), slow_mh);
 		mlx5_chains_put_chain_mapping(esw_chains(esw), flow->chain_mapping);
 		flow->chain_mapping = 0;
-		flow->slow_mh = NULL;
+		flow->attr->slow_mh = NULL;
 	}
 	flow_flag_clear(flow, SLOW);
 	kfree(slow_attr);
@@ -1927,7 +1928,7 @@ post_process_attr(struct mlx5e_tc_flow *flow,
 			if (err)
 				goto err_out;
 		} else {
-			err = mlx5e_attach_mod_hdr(flow->priv, flow, attr->parse_attr);
+			err = mlx5e_attach_mod_hdr(flow->priv, flow, attr);
 			if (err)
 				goto err_out;
 		}
@@ -2144,7 +2145,7 @@ static void mlx5e_tc_del_fdb_flow(struct mlx5e_priv *priv,
 		if (vf_tun && attr->modify_hdr)
 			mlx5_modify_header_dealloc(priv->mdev, attr->modify_hdr);
 		else
-			mlx5e_detach_mod_hdr(priv, flow);
+			mlx5e_detach_mod_hdr(priv, flow, attr);
 	}
 
 	if (attr->action & MLX5_FLOW_CONTEXT_ACTION_COUNT)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
index 50af70ef22f3..01d76ff67315 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h
@@ -71,6 +71,8 @@ struct mlx5_flow_attr {
 	u32 action;
 	struct mlx5_fc *counter;
 	struct mlx5_modify_hdr *modify_hdr;
+	struct mlx5e_mod_hdr_handle *mh; /* attached mod header instance */
+	struct mlx5e_mod_hdr_handle *slow_mh; /* attached mod header instance for slow path */
 	struct mlx5_ct_attr ct_attr;
 	struct mlx5e_sample_attr sample_attr;
 	struct mlx5e_meter_attr meter_attr;
-- 
2.39.0


  parent reply	other threads:[~2023-01-18 18:36 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-18 18:35 [pull request][net-next 00/15] mlx5 updates 2023-01-18 Saeed Mahameed
2023-01-18 18:35 ` [net-next 01/15] net/mlx5e: Suppress Send WQEBB room warning for PAGE_SIZE >= 16KB Saeed Mahameed
2023-01-18 21:31   ` Jacob Keller
2023-01-20  4:00   ` patchwork-bot+netdevbpf
2023-01-18 18:35 ` [net-next 02/15] net/mlx5: Suppress error logging on UCTX creation Saeed Mahameed
2023-01-18 21:32   ` Jacob Keller
2023-01-18 18:35 ` [net-next 03/15] net/mlx5: Add adjphase function to support hardware-only offset control Saeed Mahameed
2023-01-18 21:33   ` Jacob Keller
2023-01-20  3:46     ` Jakub Kicinski
2023-01-20  3:56       ` Rahul Rameshbabu
2023-01-20  4:03         ` Jakub Kicinski
2023-01-20  4:26           ` Rahul Rameshbabu
2023-01-20  5:08             ` Jakub Kicinski
2023-01-20  5:22               ` Rahul Rameshbabu
2023-01-20  5:45                 ` Jakub Kicinski
2023-01-20  6:02                   ` Rahul Rameshbabu
2023-01-20 17:21             ` Jacob Keller
2023-01-20 18:00               ` Rahul Rameshbabu
2023-01-20 23:58                 ` Jacob Keller
2023-01-21  0:06                   ` Jakub Kicinski
2023-01-22 21:11                     ` Rahul Rameshbabu
2023-01-23  2:22                       ` Richard Cochran
2023-01-23  2:48                         ` Rahul Rameshbabu
2023-01-23  2:58                           ` Richard Cochran
2023-01-23 18:44                             ` Rahul Rameshbabu
2023-01-23 19:13                               ` Jacob Keller
2023-01-23 22:39                                 ` Richard Cochran
2023-01-23 22:36                               ` Richard Cochran
2023-01-24 10:33                                 ` Bar Shapira
2023-01-24 19:15                                   ` Richard Cochran
2023-01-25  0:48                                     ` Jakub Kicinski
2023-01-25  2:26                                       ` Rahul Rameshbabu
2023-01-25  8:28                                       ` Gal Pressman
2023-01-23  2:15                   ` Richard Cochran
2023-01-23 18:14                     ` Jacob Keller
2023-01-18 18:35 ` [net-next 04/15] net/mlx5: Add hardware extended range support for PTP adjtime and adjphase Saeed Mahameed
2023-01-18 21:35   ` Jacob Keller
2023-01-18 18:35 ` [net-next 05/15] net/mlx5: E-switch, Remove redundant comment about meta rules Saeed Mahameed
2023-01-18 21:40   ` Jacob Keller
2023-01-18 18:35 ` [net-next 06/15] net/mlx5e: Fail with messages when params are not valid for XSK Saeed Mahameed
2023-01-18 21:41   ` Jacob Keller
2023-01-18 18:35 ` [net-next 07/15] net/mlx5e: Add warning when log WQE size is smaller than log stride size Saeed Mahameed
2023-01-18 21:42   ` Jacob Keller
2023-01-18 18:35 ` Saeed Mahameed [this message]
2023-01-18 21:42   ` [net-next 08/15] net/mlx5e: TC, Pass flow attr to attach/detach mod hdr functions Jacob Keller
2023-01-18 18:35 ` [net-next 09/15] net/mlx5e: TC, Add tc prefix to attach/detach " Saeed Mahameed
2023-01-18 21:44   ` Jacob Keller
2023-01-18 18:35 ` [net-next 10/15] net/mlx5e: TC, Use common function allocating flow mod hdr or encap mod hdr Saeed Mahameed
2023-01-18 21:45   ` Jacob Keller
2023-01-18 18:35 ` [net-next 11/15] net/mlx5e: Warn when destroying mod hdr hash table that is not empty Saeed Mahameed
2023-01-18 21:45   ` Jacob Keller
2023-01-18 18:35 ` [net-next 12/15] net/mlx5: E-Switch, Fix typo for egress Saeed Mahameed
2023-01-18 21:46   ` Jacob Keller
2023-01-18 18:36 ` [net-next 13/15] net/mlx5e: Support Geneve and GRE with VF tunnel offload Saeed Mahameed
2023-01-18 21:48   ` Jacob Keller
2023-01-18 18:36 ` [net-next 14/15] net/mlx5e: Remove redundant allocation of spec in create indirect fwd group Saeed Mahameed
2023-01-18 21:50   ` Jacob Keller
2023-01-18 18:36 ` [net-next 15/15] net/mlx5e: Use read lock for eswitch get callbacks Saeed Mahameed
2023-01-18 21:51   ` Jacob Keller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230118183602.124323-9-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=maord@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=roid@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).