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>,
	Yevgeny Kliteynik <kliteyn@nvidia.com>,
	Alex Vesker <valex@nvidia.com>
Subject: [net-next 13/15] net/mlx5: DR, Modify header action of size 1 optimization
Date: Fri, 14 Apr 2023 15:09:37 -0700	[thread overview]
Message-ID: <20230414220939.136865-14-saeed@kernel.org> (raw)
In-Reply-To: <20230414220939.136865-1-saeed@kernel.org>

From: Yevgeny Kliteynik <kliteyn@nvidia.com>

Set modify header action of size 1 directly on the STE for supporting
devices, thus reducing number of hops and cache misses.

Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
Reviewed-by: Alex Vesker <valex@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../mellanox/mlx5/core/steering/dr_action.c   | 37 ++++++++++++------
 .../mellanox/mlx5/core/steering/dr_ste_v1.c   | 38 ++++++++++++-------
 .../mellanox/mlx5/core/steering/dr_types.h    |  2 +
 3 files changed, 52 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
index 8f8f0a0b38fd..0eb9a8d7f282 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_action.c
@@ -832,14 +832,20 @@ int mlx5dr_actions_build_ste_arr(struct mlx5dr_matcher *matcher,
 			}
 			break;
 		case DR_ACTION_TYP_MODIFY_HDR:
-			if (action->rewrite->ptrn && action->rewrite->arg) {
-				attr.modify_index = mlx5dr_arg_get_obj_id(action->rewrite->arg);
-				attr.modify_actions = action->rewrite->ptrn->num_of_actions;
-				attr.modify_pat_idx = action->rewrite->ptrn->index;
-			} else {
-				attr.modify_index = action->rewrite->index;
+			if (action->rewrite->single_action_opt) {
 				attr.modify_actions = action->rewrite->num_of_actions;
-				attr.modify_pat_idx = MLX5DR_INVALID_PATTERN_INDEX;
+				attr.single_modify_action = action->rewrite->data;
+			} else {
+				if (action->rewrite->ptrn && action->rewrite->arg) {
+					attr.modify_index =
+						mlx5dr_arg_get_obj_id(action->rewrite->arg);
+					attr.modify_actions = action->rewrite->ptrn->num_of_actions;
+					attr.modify_pat_idx = action->rewrite->ptrn->index;
+				} else {
+					attr.modify_index = action->rewrite->index;
+					attr.modify_actions = action->rewrite->num_of_actions;
+					attr.modify_pat_idx = MLX5DR_INVALID_PATTERN_INDEX;
+				}
 			}
 			if (action->rewrite->modify_ttl)
 				dr_action_modify_ttl_adjust(dmn, &attr, rx_rule,
@@ -1998,9 +2004,15 @@ static int dr_action_create_modify_action(struct mlx5dr_domain *dmn,
 	action->rewrite->data = (u8 *)hw_actions;
 	action->rewrite->num_of_actions = num_hw_actions;
 
-	ret = mlx5dr_ste_alloc_modify_hdr(action);
-	if (ret)
-		goto free_hw_actions;
+	if (num_hw_actions == 1 &&
+	    dmn->info.caps.sw_format_ver >= MLX5_STEERING_FORMAT_CONNECTX_6DX) {
+		action->rewrite->single_action_opt = true;
+	} else {
+		action->rewrite->single_action_opt = false;
+		ret = mlx5dr_ste_alloc_modify_hdr(action);
+		if (ret)
+			goto free_hw_actions;
+	}
 
 	return 0;
 
@@ -2151,6 +2163,7 @@ int mlx5dr_action_destroy(struct mlx5dr_action *action)
 		break;
 	case DR_ACTION_TYP_TNL_L3_TO_L2:
 		mlx5dr_ste_free_modify_hdr(action);
+		kfree(action->rewrite->data);
 		refcount_dec(&action->rewrite->dmn->refcount);
 		break;
 	case DR_ACTION_TYP_L2_TO_TNL_L2:
@@ -2161,7 +2174,9 @@ int mlx5dr_action_destroy(struct mlx5dr_action *action)
 		refcount_dec(&action->reformat->dmn->refcount);
 		break;
 	case DR_ACTION_TYP_MODIFY_HDR:
-		mlx5dr_ste_free_modify_hdr(action);
+		if (!action->rewrite->single_action_opt)
+			mlx5dr_ste_free_modify_hdr(action);
+		kfree(action->rewrite->data);
 		refcount_dec(&action->rewrite->dmn->refcount);
 		break;
 	case DR_ACTION_TYP_SAMPLER:
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c
index d2d312454564..4c0704ad166b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c
@@ -499,16 +499,21 @@ static void dr_ste_v1_set_accelerated_rewrite_actions(u8 *hw_ste_p,
 						      u8 *d_action,
 						      u16 num_of_actions,
 						      u32 rewrite_pattern,
-						      u32 rewrite_args)
+						      u32 rewrite_args,
+						      u8 *action_data)
 {
-	MLX5_SET(ste_double_action_accelerated_modify_action_list_v1, d_action,
-		 action_id, DR_STE_V1_ACTION_ID_ACCELERATED_LIST);
-	MLX5_SET(ste_double_action_accelerated_modify_action_list_v1, d_action,
-		 modify_actions_pattern_pointer, rewrite_pattern);
-	MLX5_SET(ste_double_action_accelerated_modify_action_list_v1, d_action,
-		 number_of_modify_actions, num_of_actions);
-	MLX5_SET(ste_double_action_accelerated_modify_action_list_v1, d_action,
-		 modify_actions_argument_pointer, rewrite_args);
+	if (action_data) {
+		memcpy(d_action, action_data, DR_MODIFY_ACTION_SIZE);
+	} else {
+		MLX5_SET(ste_double_action_accelerated_modify_action_list_v1, d_action,
+			 action_id, DR_STE_V1_ACTION_ID_ACCELERATED_LIST);
+		MLX5_SET(ste_double_action_accelerated_modify_action_list_v1, d_action,
+			 modify_actions_pattern_pointer, rewrite_pattern);
+		MLX5_SET(ste_double_action_accelerated_modify_action_list_v1, d_action,
+			 number_of_modify_actions, num_of_actions);
+		MLX5_SET(ste_double_action_accelerated_modify_action_list_v1, d_action,
+			 modify_actions_argument_pointer, rewrite_args);
+	}
 
 	dr_ste_v1_set_reparse(hw_ste_p);
 }
@@ -532,14 +537,16 @@ static void dr_ste_v1_set_rewrite_actions(u8 *hw_ste_p,
 					  u8 *action,
 					  u16 num_of_actions,
 					  u32 rewrite_pattern,
-					  u32 rewrite_args)
+					  u32 rewrite_args,
+					  u8 *action_data)
 {
 	if (rewrite_pattern != MLX5DR_INVALID_PATTERN_INDEX)
 		return dr_ste_v1_set_accelerated_rewrite_actions(hw_ste_p,
 								 action,
 								 num_of_actions,
 								 rewrite_pattern,
-								 rewrite_args);
+								 rewrite_args,
+								 action_data);
 
 	/* fall back to the code that doesn't support accelerated modify header */
 	return dr_ste_v1_set_basic_rewrite_actions(hw_ste_p,
@@ -653,7 +660,8 @@ void dr_ste_v1_set_actions_tx(struct mlx5dr_domain *dmn,
 		dr_ste_v1_set_rewrite_actions(last_ste, action,
 					      attr->modify_actions,
 					      attr->modify_pat_idx,
-					      attr->modify_index);
+					      attr->modify_index,
+					      attr->single_modify_action);
 		action_sz -= DR_STE_ACTION_DOUBLE_SZ;
 		action += DR_STE_ACTION_DOUBLE_SZ;
 		allow_encap = false;
@@ -784,7 +792,8 @@ void dr_ste_v1_set_actions_rx(struct mlx5dr_domain *dmn,
 		dr_ste_v1_set_rewrite_actions(last_ste, action,
 					      attr->decap_actions,
 					      attr->decap_pat_idx,
-					      attr->decap_index);
+					      attr->decap_index,
+					      NULL);
 		action_sz -= DR_STE_ACTION_DOUBLE_SZ;
 		action += DR_STE_ACTION_DOUBLE_SZ;
 		allow_modify_hdr = false;
@@ -840,7 +849,8 @@ void dr_ste_v1_set_actions_rx(struct mlx5dr_domain *dmn,
 		dr_ste_v1_set_rewrite_actions(last_ste, action,
 					      attr->modify_actions,
 					      attr->modify_pat_idx,
-					      attr->modify_index);
+					      attr->modify_index,
+					      attr->single_modify_action);
 		action_sz -= DR_STE_ACTION_DOUBLE_SZ;
 		action += DR_STE_ACTION_DOUBLE_SZ;
 	}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
index 3ffda3d302e0..37b7b1a79f93 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
@@ -267,6 +267,7 @@ struct mlx5dr_ste_actions_attr {
 	u32	modify_index;
 	u32	modify_pat_idx;
 	u16	modify_actions;
+	u8	*single_modify_action;
 	u32	decap_index;
 	u32	decap_pat_idx;
 	u16	decap_actions;
@@ -1035,6 +1036,7 @@ struct mlx5dr_action_rewrite {
 	u8 *data;
 	u16 num_of_actions;
 	u32 index;
+	u8 single_action_opt:1;
 	u8 allow_rx:1;
 	u8 allow_tx:1;
 	u8 modify_ttl:1;
-- 
2.39.2


  parent reply	other threads:[~2023-04-14 22:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 22:09 [pull request][net-next 00/15] mlx5 updates 2023-04-14 Saeed Mahameed
2023-04-14 22:09 ` [net-next 01/15] net/mlx5: DR, Move ACTION_CACHE_LINE_SIZE macro to header Saeed Mahameed
2023-04-17  7:20   ` patchwork-bot+netdevbpf
2023-04-14 22:09 ` [net-next 02/15] net/mlx5: DR, Add cache for modify header pattern Saeed Mahameed
2023-04-14 22:09 ` [net-next 03/15] net/mlx5: DR, Split chunk allocation to HW-dependent ways Saeed Mahameed
2023-04-14 22:09 ` [net-next 04/15] net/mlx5: DR, Check for modify_header_argument device capabilities Saeed Mahameed
2023-04-14 22:09 ` [net-next 05/15] net/mlx5: DR, Add create/destroy for modify-header-argument general object Saeed Mahameed
2023-04-14 22:09 ` [net-next 06/15] net/mlx5: DR, Add support for writing modify header argument Saeed Mahameed
2023-04-14 22:09 ` [net-next 07/15] net/mlx5: DR, Read ICM memory into dedicated buffer Saeed Mahameed
2023-04-14 22:09 ` [net-next 08/15] net/mlx5: DR, Fix QP continuous allocation Saeed Mahameed
2023-04-14 22:09 ` [net-next 09/15] net/mlx5: DR, Add modify header arg pool mechanism Saeed Mahameed
2023-04-14 22:09 ` [net-next 10/15] net/mlx5: DR, Add modify header argument pointer to actions attributes Saeed Mahameed
2023-04-14 22:09 ` [net-next 11/15] net/mlx5: DR, Apply new accelerated modify action and decapl3 Saeed Mahameed
2023-04-14 22:09 ` [net-next 12/15] net/mlx5: DR, Support decap L3 action using pattern / arg mechanism Saeed Mahameed
2023-04-14 22:09 ` Saeed Mahameed [this message]
2023-04-14 22:09 ` [net-next 14/15] net/mlx5: DR, Add support for the pattern/arg parameters in debug dump Saeed Mahameed
2023-04-14 22:09 ` [net-next 15/15] net/mlx5: DR, Enable patterns and arguments for supporting devices Saeed Mahameed

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=20230414220939.136865-14-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kliteyn@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=valex@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).