DPDK patches and discussions
 help / color / mirror / Atom feed
From: Qi Zhang <qi.z.zhang@intel.com>
To: qiming.yang@intel.com
Cc: dev@dpdk.org, Qi Zhang <qi.z.zhang@intel.com>,
	Victor Raj <victor.raj@intel.com>
Subject: [dpdk-dev] [PATCH 20/27] net/ice/base: modify recursive way of adding nodes
Date: Tue, 15 Dec 2020 14:05:12 +0800	[thread overview]
Message-ID: <20201215060519.302145-21-qi.z.zhang@intel.com> (raw)
In-Reply-To: <20201215060519.302145-1-qi.z.zhang@intel.com>

Remove the recursive way of adding the nodes to the layer in order
to reduce the stack usage. Instead the algorithm is modified to use
a while loop.

The previous code was scanning recursively the nodes horizontally.
The total stack consumption will be based on number of nodes present
on that layer. In some cases it can consume more stack.

Signed-off-by: Victor Raj <victor.raj@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/base/ice_sched.c | 124 +++++++++++++++++--------------
 1 file changed, 70 insertions(+), 54 deletions(-)

diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c
index ac48bbe279..b75a44f54c 100644
--- a/drivers/net/ice/base/ice_sched.c
+++ b/drivers/net/ice/base/ice_sched.c
@@ -965,7 +965,7 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
 }
 
 /**
- * ice_sched_add_nodes_to_layer - Add nodes to a given layer
+ * ice_sched_add_nodes_to_hw_layer - Add nodes to hw layer
  * @pi: port information structure
  * @tc_node: pointer to TC node
  * @parent: pointer to parent node
@@ -974,82 +974,98 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
  * @first_node_teid: pointer to the first node TEID
  * @num_nodes_added: pointer to number of nodes added
  *
- * This function add nodes to a given layer.
+ * Add nodes into specific hw layer.
  */
 static enum ice_status
-ice_sched_add_nodes_to_layer(struct ice_port_info *pi,
-			     struct ice_sched_node *tc_node,
-			     struct ice_sched_node *parent, u8 layer,
-			     u16 num_nodes, u32 *first_node_teid,
-			     u16 *num_nodes_added)
+ice_sched_add_nodes_to_hw_layer(struct ice_port_info *pi,
+				struct ice_sched_node *tc_node,
+				struct ice_sched_node *parent, u8 layer,
+				u16 num_nodes, u32 *first_node_teid,
+				u16 *num_nodes_added)
 {
-	u32 *first_teid_ptr = first_node_teid;
-	u16 new_num_nodes, max_child_nodes;
-	enum ice_status status = ICE_SUCCESS;
-	struct ice_hw *hw = pi->hw;
-	u16 num_added = 0;
-	u32 temp;
+	u16 max_child_nodes;
 
 	*num_nodes_added = 0;
 
 	if (!num_nodes)
-		return status;
+		return ICE_SUCCESS;
 
-	if (!parent || layer < hw->sw_entry_point_layer)
+	if (!parent || layer < pi->hw->sw_entry_point_layer)
 		return ICE_ERR_PARAM;
 
 	/* max children per node per layer */
-	max_child_nodes = hw->max_children[parent->tx_sched_layer];
+	max_child_nodes = pi->hw->max_children[parent->tx_sched_layer];
 
-	/* current number of children + required nodes exceed max children ? */
+	/* current number of children + required nodes exceed max children */
 	if ((parent->num_children + num_nodes) > max_child_nodes) {
 		/* Fail if the parent is a TC node */
 		if (parent == tc_node)
 			return ICE_ERR_CFG;
+		return ICE_ERR_MAX_LIMIT;
+	}
+
+	return ice_sched_add_elems(pi, tc_node, parent, layer, num_nodes,
+				   num_nodes_added, first_node_teid);
+}
+
+/**
+ * ice_sched_add_nodes_to_layer - Add nodes to a given layer
+ * @pi: port information structure
+ * @tc_node: pointer to TC node
+ * @parent: pointer to parent node
+ * @layer: layer number to add nodes
+ * @num_nodes: number of nodes to be added
+ * @first_node_teid: pointer to the first node TEID
+ * @num_nodes_added: pointer to number of nodes added
+ *
+ * This function add nodes to a given layer.
+ */
+static enum ice_status
+ice_sched_add_nodes_to_layer(struct ice_port_info *pi,
+			     struct ice_sched_node *tc_node,
+			     struct ice_sched_node *parent, u8 layer,
+			     u16 num_nodes, u32 *first_node_teid,
+			     u16 *num_nodes_added)
+{
+	u32 *first_teid_ptr = first_node_teid;
+	u16 new_num_nodes = num_nodes;
+	enum ice_status status = ICE_SUCCESS;
 
+	*num_nodes_added = 0;
+	while (*num_nodes_added < num_nodes) {
+		u16 max_child_nodes, num_added = 0;
+		u32 temp;
+
+		status = ice_sched_add_nodes_to_hw_layer(pi, tc_node, parent,
+							 layer,	new_num_nodes,
+							 first_teid_ptr,
+							 &num_added);
+		*num_nodes_added += num_added;
+		/* break if all the nodes are added successfully */
+		if (status == ICE_SUCCESS && (*num_nodes_added == num_nodes))
+			break;
+		/* break if the error is not max limit */
+		if (status != ICE_SUCCESS && status != ICE_ERR_MAX_LIMIT)
+			break;
+		/* Exceeded the max children */
+		max_child_nodes = pi->hw->max_children[parent->tx_sched_layer];
 		/* utilize all the spaces if the parent is not full */
 		if (parent->num_children < max_child_nodes) {
 			new_num_nodes = max_child_nodes - parent->num_children;
-			/* this recursion is intentional, and wouldn't
-			 * go more than 2 calls
+		} else {
+			/* This parent is full, try the next sibling */
+			parent = parent->sibling;
+			/* Don't modify the first node TEID memory if the
+			 * first node was added already in the above call.
+			 * Instead send some temp memory for all other
+			 * recursive calls.
 			 */
-			status = ice_sched_add_nodes_to_layer(pi, tc_node,
-							      parent, layer,
-							      new_num_nodes,
-							      first_node_teid,
-							      &num_added);
-			if (status != ICE_SUCCESS)
-				return status;
-
-			*num_nodes_added += num_added;
-		}
-		/* Don't modify the first node TEID memory if the first node was
-		 * added already in the above call. Instead send some temp
-		 * memory for all other recursive calls.
-		 */
-		if (num_added)
-			first_teid_ptr = &temp;
-
-		new_num_nodes = num_nodes - num_added;
-
-		/* This parent is full, try the next sibling */
-		parent = parent->sibling;
+			if (num_added)
+				first_teid_ptr = &temp;
 
-		/* this recursion is intentional, for 1024 queues
-		 * per VSI, it goes max of 16 iterations.
-		 * 1024 / 8 = 128 layer 8 nodes
-		 * 128 /8 = 16 (add 8 nodes per iteration)
-		 */
-		status = ice_sched_add_nodes_to_layer(pi, tc_node, parent,
-						      layer, new_num_nodes,
-						      first_teid_ptr,
-						      &num_added);
-		*num_nodes_added += num_added;
-		return status;
+			new_num_nodes = num_nodes - num_added;
+		}
 	}
-
-	status = ice_sched_add_elems(pi, tc_node, parent, layer, num_nodes,
-				     num_nodes_added, first_node_teid);
 	return status;
 }
 
-- 
2.26.2


  parent reply	other threads:[~2020-12-15  6:08 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15  6:04 [dpdk-dev] [PATCH 00/27] ice base code update Qi Zhang
2020-12-15  6:04 ` [dpdk-dev] [PATCH 01/27] net/ice/base: modify ptype map for UDP Qi Zhang
2020-12-15  6:04 ` [dpdk-dev] [PATCH 02/27] net/ice/base: increased control queue timeout Qi Zhang
2020-12-15  6:04 ` [dpdk-dev] [PATCH 03/27] net/ice/base: read more security revision options Qi Zhang
2020-12-15  6:04 ` [dpdk-dev] [PATCH 04/27] net/ice/base: refactor interface for flash read Qi Zhang
2020-12-15  6:04 ` [dpdk-dev] [PATCH 05/27] net/ice/base: allow reading inactive flash security revision Qi Zhang
2020-12-15  6:04 ` [dpdk-dev] [PATCH 06/27] net/ice/base: allow reading arbitrary size data with flash read Qi Zhang
2020-12-15  6:04 ` [dpdk-dev] [PATCH 07/27] net/ice/base: read Option ROM combo version from CIVD section Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 08/27] net/ice/base: implement inactive NVM version get Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 09/27] net/ice/base: support GTP filtering via advanced switch filter Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 10/27] net/ice/base: cleanup some macros Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 11/27] net/ice/base: add definitions for FW health status codes Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 12/27] net/ice/base: add function for NVM checksum verification Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 13/27] net/ice/base: add condition to copy module info into memory Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 14/27] net/ice/base: add interface to support configuring VLAN mode Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 15/27] net/ice/base: support VXLAN VNI field in FDIR Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 16/27] net/ice/base: fix incorrect tunnel destroy Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 17/27] net/ice/base: add functionality to check if DVM is supported Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 18/27] net/ice/base: resend some AQ commands when EBUSY Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 19/27] net/ice/base: change get PHY capability error level Qi Zhang
2020-12-15  6:05 ` Qi Zhang [this message]
2020-12-15  6:05 ` [dpdk-dev] [PATCH 21/27] net/ice/base: fix for dereference of null pointer Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 22/27] net/ice/base: use Mode 4 to get PHY Abilites Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 23/27] net/ice/base: align macro names to the specification Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 24/27] net/ice/base: add eCPRI over MAC type 0 flow support Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 25/27] net/ice/base: add eCPRI over UDP " Qi Zhang
2021-01-05 16:24   ` Ferruh Yigit
2020-12-15  6:05 ` [dpdk-dev] [PATCH 26/27] net/ice/base: remove unused struct member Qi Zhang
2020-12-15  6:05 ` [dpdk-dev] [PATCH 27/27] net/ice/base: change a structure Qi Zhang
2020-12-24  3:16 ` [dpdk-dev] [PATCH 00/27] ice base code update Yang, Qiming
2020-12-28 10:34   ` Zhang, Qi Z
2021-01-05 16:22     ` Ferruh Yigit

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=20201215060519.302145-21-qi.z.zhang@intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=dev@dpdk.org \
    --cc=qiming.yang@intel.com \
    --cc=victor.raj@intel.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).