Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Yevgeny Kliteynik <kliteyn@nvidia.com>,
	Erez Shitrit <erezsh@nvidia.com>, Alex Vesker <valex@nvidia.com>,
	Saeed Mahameed <saeedm@nvidia.com>
Subject: [net-next 15/17] net/mlx5: DR, Remove rehash ctrl struct from dr_htbl
Date: Thu, 26 Aug 2021 17:58:00 -0700	[thread overview]
Message-ID: <20210827005802.236119-16-saeed@kernel.org> (raw)
In-Reply-To: <20210827005802.236119-1-saeed@kernel.org>

From: Yevgeny Kliteynik <kliteyn@nvidia.com>

The calculations to decide for the maximum allowed collision threshold
are simple and there is no reason to save them on the htbl struct.

Signed-off-by: Erez Shitrit <erezsh@nvidia.com>
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_rule.c     |  8 ++++---
 .../mellanox/mlx5/core/steering/dr_ste.c      | 16 --------------
 .../mellanox/mlx5/core/steering/dr_types.h    | 21 +++++++++++++++++--
 3 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
index 72c75d8e6bbf..f853a48e07b2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
@@ -628,18 +628,20 @@ static bool dr_rule_need_enlarge_hash(struct mlx5dr_ste_htbl *htbl,
 				      struct mlx5dr_domain_rx_tx *nic_dmn)
 {
 	struct mlx5dr_ste_htbl_ctrl *ctrl = &htbl->ctrl;
+	int threshold;
 
 	if (dmn->info.max_log_sw_icm_sz <= htbl->chunk_size)
 		return false;
 
-	if (!ctrl->may_grow)
+	if (!mlx5dr_ste_htbl_may_grow(htbl))
 		return false;
 
 	if (dr_get_bits_per_mask(htbl->byte_mask) * BITS_PER_BYTE <= htbl->chunk_size)
 		return false;
 
-	if (ctrl->num_of_collisions >= ctrl->increase_threshold &&
-	    (ctrl->num_of_valid_entries - ctrl->num_of_collisions) >= ctrl->increase_threshold)
+	threshold = mlx5dr_ste_htbl_increase_threshold(htbl);
+	if (ctrl->num_of_collisions >= threshold &&
+	    (ctrl->num_of_valid_entries - ctrl->num_of_collisions) >= threshold)
 		return true;
 
 	return false;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c
index 6ea314ff05ec..15fecb491c55 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c
@@ -467,21 +467,6 @@ int mlx5dr_ste_create_next_htbl(struct mlx5dr_matcher *matcher,
 	return -ENOENT;
 }
 
-static void dr_ste_set_ctrl(struct mlx5dr_ste_htbl *htbl)
-{
-	struct mlx5dr_ste_htbl_ctrl *ctrl = &htbl->ctrl;
-	int num_of_entries;
-
-	htbl->ctrl.may_grow = true;
-
-	if (htbl->chunk_size == DR_CHUNK_SIZE_MAX - 1 || !htbl->byte_mask)
-		htbl->ctrl.may_grow = false;
-
-	/* Threshold is 50%, one is added to table of size 1 */
-	num_of_entries = mlx5dr_icm_pool_chunk_size_to_entries(htbl->chunk_size);
-	ctrl->increase_threshold = (num_of_entries + 1) / 2;
-}
-
 struct mlx5dr_ste_htbl *mlx5dr_ste_htbl_alloc(struct mlx5dr_icm_pool *pool,
 					      enum mlx5dr_icm_chunk_size chunk_size,
 					      u16 lu_type, u16 byte_mask)
@@ -518,7 +503,6 @@ struct mlx5dr_ste_htbl *mlx5dr_ste_htbl_alloc(struct mlx5dr_icm_pool *pool,
 	}
 
 	htbl->chunk_size = chunk_size;
-	dr_ste_set_ctrl(htbl);
 	return htbl;
 
 out_free_htbl:
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 caff9fc4b8ca..9ba4f379afa5 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
@@ -171,8 +171,6 @@ struct mlx5dr_ste_htbl_ctrl {
 
 	/* total number of collisions entries attached to this table */
 	unsigned int num_of_collisions;
-	unsigned int increase_threshold;
-	u8 may_grow:1;
 };
 
 struct mlx5dr_ste_htbl {
@@ -1088,6 +1086,25 @@ mlx5dr_icm_pool_chunk_size_to_byte(enum mlx5dr_icm_chunk_size chunk_size,
 	return entry_size * num_of_entries;
 }
 
+static inline int
+mlx5dr_ste_htbl_increase_threshold(struct mlx5dr_ste_htbl *htbl)
+{
+	int num_of_entries =
+		mlx5dr_icm_pool_chunk_size_to_entries(htbl->chunk_size);
+
+	/* Threshold is 50%, one is added to table of size 1 */
+	return (num_of_entries + 1) / 2;
+}
+
+static inline bool
+mlx5dr_ste_htbl_may_grow(struct mlx5dr_ste_htbl *htbl)
+{
+	if (htbl->chunk_size == DR_CHUNK_SIZE_MAX - 1 || !htbl->byte_mask)
+		return false;
+
+	return true;
+}
+
 static inline struct mlx5dr_cmd_vport_cap *
 mlx5dr_get_vport_cap(struct mlx5dr_cmd_caps *caps, u32 vport)
 {
-- 
2.31.1


  parent reply	other threads:[~2021-08-27  0:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27  0:57 [pull request][net-next 00/17] mlx5 updates 2021-08-26 Saeed Mahameed
2021-08-27  0:57 ` [net-next 01/17] net/mlx5: DR, Added support for REMOVE_HEADER packet reformat Saeed Mahameed
2021-08-27  9:10   ` patchwork-bot+netdevbpf
2021-08-27  0:57 ` [net-next 02/17] net/mlx5: DR, Split modify VLAN state to separate pop/push states Saeed Mahameed
2021-08-27  0:57 ` [net-next 03/17] net/mlx5: DR, Enable VLAN pop on TX and VLAN push on RX Saeed Mahameed
2021-08-27  0:57 ` [net-next 04/17] net/mlx5: DR, Enable QP retransmission Saeed Mahameed
2021-08-27  0:57 ` [net-next 05/17] net/mlx5: DR, Improve error flow in actions_build_ste_arr Saeed Mahameed
2021-08-27  0:57 ` [net-next 06/17] net/mlx5: DR, Warn and ignore SW steering rule insertion on QP err Saeed Mahameed
2021-08-27  0:57 ` [net-next 07/17] net/mlx5: DR, Reduce print level for FT chaining level check Saeed Mahameed
2021-08-27  0:57 ` [net-next 08/17] net/mlx5: DR, Support IPv6 matching on flow label for STEv0 Saeed Mahameed
2021-08-27  0:57 ` [net-next 09/17] net/mlx5: DR, replace uintN_t with kernel-style types Saeed Mahameed
2021-08-27  0:57 ` [net-next 10/17] net/mlx5: DR, Use FW API when updating FW-owned flow table Saeed Mahameed
2021-08-27  0:57 ` [net-next 11/17] net/mlx5: DR, Add ignore_flow_level support for multi-dest flow tables Saeed Mahameed
2021-08-27  0:57 ` [net-next 12/17] net/mlx5: DR, Skip source port matching on FDB RX domain Saeed Mahameed
2021-08-27  0:57 ` [net-next 13/17] net/mlx5: DR, Merge DR_STE_SIZE enums Saeed Mahameed
2021-08-27  0:57 ` [net-next 14/17] net/mlx5: DR, Remove HW specific STE type from nic domain Saeed Mahameed
2021-08-27  0:58 ` Saeed Mahameed [this message]
2021-08-27  0:58 ` [net-next 16/17] net/mlx5: DR, Improve rule tracking memory consumption Saeed Mahameed
2021-08-27  0:58 ` [net-next 17/17] net/mlx5: DR, Add support for update FTE 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=20210827005802.236119-16-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=davem@davemloft.net \
    --cc=erezsh@nvidia.com \
    --cc=kliteyn@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=valex@nvidia.com \
    --subject='Re: [net-next 15/17] net/mlx5: DR, Remove rehash ctrl struct from dr_htbl' \
    /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

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).