DPDK patches and discussions
 help / color / mirror / Atom feed
From: Itamar Gozlan <igozlan@nvidia.com>
To: <igozlan@nvidia.com>, <erezsh@nvidia.com>, <hamdani@nvidia.com>,
	<kliteyn@nvidia.com>, <viacheslavo@nvidia.com>,
	<thomas@monjalon.net>, <suanmingm@nvidia.com>,
	Dariusz Sosnowski <dsosnowski@nvidia.com>,
	Ori Kam <orika@nvidia.com>, Matan Azrad <matan@nvidia.com>
Cc: <dev@dpdk.org>, <stable@dpdk.org>
Subject: [v2 12/16] net/mlx5/hws: dw order optimization code enhancement
Date: Mon, 6 May 2024 14:44:15 +0300	[thread overview]
Message-ID: <20240506114419.966498-12-igozlan@nvidia.com> (raw)
In-Reply-To: <20240506114419.966498-1-igozlan@nvidia.com>

Improving code readability by following code styles such as mlx5dr prefix
and extracting a support check to an external function call.
Also, reducing unneeded static memory allocation using a bounded size
macro.

Fixes: 88ff41793e7a ("net/mlx5/hws: reorder STE fields to improve hash")
Cc: stable@dpdk.org

Signed-off-by: Itamar Gozlan <igozlan@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 drivers/net/mlx5/hws/mlx5dr_definer.c | 39 ++++++++++++++-------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/mlx5/hws/mlx5dr_definer.c b/drivers/net/mlx5/hws/mlx5dr_definer.c
index 81d0e0e6df..cffbb7b589 100644
--- a/drivers/net/mlx5/hws/mlx5dr_definer.c
+++ b/drivers/net/mlx5/hws/mlx5dr_definer.c
@@ -31,6 +31,8 @@
 
 #define MLX5DR_DEFINER_QUOTA_BLOCK 0
 #define MLX5DR_DEFINER_QUOTA_PASS  2
+#define MLX5DR_DEFINER_MAX_ROW_LOG 32
+#define MLX5DR_DEFINER_HL_OPT_MAX 2
 
 /* Setter function based on bit offset and mask, for 32bit DW*/
 #define _DR_SET_32(p, v, byte_off, bit_off, mask) \
@@ -104,21 +106,13 @@
 	__mlx5_dw_off(typ, fld))) >> __mlx5_dw_bit_off(typ, fld)) & \
 	__mlx5_mask(typ, fld))
 
-#define MAX_ROW_LOG 31
-
-enum header_layout {
-	MLX5DR_HL_IPV4_SRC = 64,
-	MLX5DR_HL_IPV4_DST = 65,
-	MAX_HL_PRIO,
-};
-
 /* Each row (i) indicates a different matcher size, and each column (j)
  * represents {DW5, DW4, DW3, DW2, DW1, DW0}.
- * For values 0,..,2^i, and j (DW) 0,..,5: optimal_dist_dw[i][j] is 1 if the
+ * For values 0,..,2^i, and j (DW) 0,..,5: mlx5dr_optimal_dist_dw[i][j] is 1 if the
  * number of different hash results on these values equals 2^i, meaning this
  * DW hash distribution is complete.
  */
-int optimal_dist_dw[MAX_ROW_LOG][DW_SELECTORS_MATCH] = {
+int mlx5dr_optimal_dist_dw[MLX5DR_DEFINER_MAX_ROW_LOG][DW_SELECTORS_MATCH] = {
 	{1, 1, 1, 1, 1, 1}, {0, 1, 1, 0, 1, 0}, {0, 1, 1, 0, 1, 0},
 	{1, 0, 1, 0, 1, 0}, {0, 0, 0, 1, 1, 0}, {0, 1, 1, 0, 1, 0},
 	{0, 0, 0, 0, 1, 0}, {0, 1, 1, 0, 1, 0}, {0, 0, 0, 0, 0, 0},
@@ -3471,16 +3465,16 @@ mlx5dr_definer_find_best_range_fit(struct mlx5dr_definer *definer,
 
 static void mlx5dr_definer_optimize_order(struct mlx5dr_definer *definer, int num_log)
 {
-	uint8_t hl_prio[MAX_HL_PRIO - 1] = {MLX5DR_HL_IPV4_SRC,
-					    MLX5DR_HL_IPV4_DST,
-					    MAX_HL_PRIO};
+	uint8_t hl_prio[MLX5DR_DEFINER_HL_OPT_MAX];
 	int dw = 0, i = 0, j;
 	int *dw_flag;
 	uint8_t tmp;
 
-	dw_flag = optimal_dist_dw[num_log];
+	dw_flag = mlx5dr_optimal_dist_dw[num_log];
+	hl_prio[0] = __mlx5_dw_off(definer_hl, ipv4_src_dest_outer.source_address);
+	hl_prio[1] = __mlx5_dw_off(definer_hl, ipv4_src_dest_outer.destination_address);
 
-	while (hl_prio[i] != MAX_HL_PRIO) {
+	while (i < MLX5DR_DEFINER_HL_OPT_MAX) {
 		j = 0;
 		/* Finding a candidate to improve its hash distribution */
 		while (j < DW_SELECTORS_MATCH && (hl_prio[i] != definer->dw_selector[j]))
@@ -3632,6 +3626,16 @@ int mlx5dr_definer_compare(struct mlx5dr_definer *definer_a,
 	return 0;
 }
 
+static int
+mlx5dr_definer_optimize_order_supported(struct mlx5dr_definer *match_definer,
+					struct mlx5dr_matcher *matcher)
+{
+	return !mlx5dr_definer_is_jumbo(match_definer) &&
+	       !mlx5dr_matcher_req_fw_wqe(matcher) &&
+	       !mlx5dr_matcher_is_resizable(matcher) &&
+	       !mlx5dr_matcher_is_insert_by_idx(matcher);
+}
+
 static int
 mlx5dr_definer_calc_layout(struct mlx5dr_matcher *matcher,
 			   struct mlx5dr_definer *match_definer,
@@ -3693,10 +3697,7 @@ mlx5dr_definer_calc_layout(struct mlx5dr_matcher *matcher,
 		goto free_fc;
 	}
 
-	if (!mlx5dr_definer_is_jumbo(match_definer) &&
-	    !mlx5dr_matcher_req_fw_wqe(matcher) &&
-	    !mlx5dr_matcher_is_resizable(matcher) &&
-	    !mlx5dr_matcher_is_insert_by_idx(matcher))
+	if (mlx5dr_definer_optimize_order_supported(match_definer, matcher))
 		mlx5dr_definer_optimize_order(match_definer, matcher->attr.rule.num_log);
 
 	/* Find the range definer layout for match templates fcrs */
-- 
2.39.3


  parent reply	other threads:[~2024-05-06 11:45 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-14 11:42 [PATCH 01/13] net/mlx5/hws: move warn into debug level when needed Itamar Gozlan
2024-03-14 11:42 ` [PATCH 02/13] common/mlx5: fix error in mlx5 prm structs Itamar Gozlan
2024-03-14 11:42 ` [PATCH 03/13] net/mlx5/hws: fix wrong comment in mlx5dr_send Itamar Gozlan
2024-03-14 11:42 ` [PATCH 04/13] net/mlx5/hws: remove unused capabilities and fields Itamar Gozlan
2024-03-14 11:42 ` [PATCH 05/13] net/mlx5/hws: return -rte_errno on rule creation failure Itamar Gozlan
2024-03-14 11:42 ` [PATCH 06/13] net/mlx5/hws: simplify send_queues_close code Itamar Gozlan
2024-03-14 11:42 ` [PATCH 07/13] net/mlx5/hws: fix error flow in mlx5dr_context_open Itamar Gozlan
2024-03-14 11:42 ` [PATCH 08/13] net/mlx5/hws: fix code analysis error in passing 0 enum val Itamar Gozlan
2024-03-14 11:42 ` [PATCH 09/13] net/mlx5/hws: simplify code for updating CQ doorbell record Itamar Gozlan
2024-03-14 11:42 ` [PATCH 10/13] net/mlx5/hws: fix rule is in resize check Itamar Gozlan
2024-03-14 11:42 ` [PATCH 11/13] net/mlx5/hws: drop at attach number of actions Itamar Gozlan
2024-03-14 11:42 ` [PATCH 12/13] net/mlx5/hws: extending tag saving for match and jumbo Itamar Gozlan
2024-03-14 11:42 ` [PATCH 13/13] net/mlx5/hws: fix port ID for root matcher and rule Itamar Gozlan
2024-03-18 12:56 ` [PATCH 01/13] net/mlx5/hws: move warn into debug level when needed Raslan Darawsheh
2024-03-18 14:48   ` Thomas Monjalon
2024-03-19  7:33     ` Raslan Darawsheh
2024-03-20 16:35       ` Yevgeny Kliteynik
2024-05-06 11:44 ` [v2 01/16] " Itamar Gozlan
2024-05-06 11:44   ` [v2 02/16] common/mlx5: fix error in mlx5 prm structs Itamar Gozlan
2024-05-06 11:44   ` [v2 03/16] net/mlx5/hws: fix wrong comment in mlx5dr send Itamar Gozlan
2024-05-06 11:44   ` [v2 04/16] net/mlx5/hws: remove unused capabilities and fields Itamar Gozlan
2024-05-06 11:44   ` [v2 05/16] net/mlx5/hws: negating rte errno on rule creation failure Itamar Gozlan
2024-05-06 11:44   ` [v2 06/16] net/mlx5/hws: simplify send queues close code Itamar Gozlan
2024-05-06 11:44   ` [v2 07/16] net/mlx5/hws: fix error flow in mlx5dr context open Itamar Gozlan
2024-05-06 11:44   ` [v2 08/16] net/mlx5/hws: fix code analysis error in passing 0 enum val Itamar Gozlan
2024-05-06 11:44   ` [v2 09/16] net/mlx5/hws: simplify code for updating CQ doorbell record Itamar Gozlan
2024-05-06 11:44   ` [v2 10/16] net/mlx5/hws: drop at attach number of actions Itamar Gozlan
2024-05-06 11:44   ` [v2 11/16] net/mlx5/hws: extending tag saving for match and jumbo Itamar Gozlan
2024-05-06 11:44   ` Itamar Gozlan [this message]
2024-05-06 11:44   ` [v2 13/16] net/mlx5/hws: set default miss when replacing table Itamar Gozlan
2024-05-06 11:44   ` [v2 14/16] net/mlx5/hws: fix invalid memory access in decapl3 Itamar Gozlan
2024-05-06 11:44   ` [v2 15/16] net/mlx5/hws: dump action ste arrays info Itamar Gozlan
2024-05-06 11:44   ` [v2 16/16] net/mlx5/hws: fix action template only term param dump print Itamar Gozlan
2024-05-20 10:50   ` [v2 01/16] net/mlx5/hws: move warn into debug level when needed Raslan Darawsheh

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=20240506114419.966498-12-igozlan@nvidia.com \
    --to=igozlan@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=erezsh@nvidia.com \
    --cc=hamdani@nvidia.com \
    --cc=kliteyn@nvidia.com \
    --cc=matan@nvidia.com \
    --cc=orika@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=suanmingm@nvidia.com \
    --cc=thomas@monjalon.net \
    --cc=viacheslavo@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).