From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 07F18A32A2
	for <public@inbox.dpdk.org>; Fri, 25 Oct 2019 11:52:40 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id B19BC1C2B2;
	Fri, 25 Oct 2019 11:51:58 +0200 (CEST)
Received: from mga12.intel.com (mga12.intel.com [192.55.52.136])
 by dpdk.org (Postfix) with ESMTP id 174EC1C031
 for <dev@dpdk.org>; Fri, 25 Oct 2019 11:51:35 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga004.fm.intel.com ([10.253.24.48])
 by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 25 Oct 2019 02:51:35 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.68,228,1569308400"; d="scan'208";a="223873673"
Received: from silpixa00381635.ir.intel.com (HELO
 silpixa00381635.ger.corp.intel.com) ([10.237.223.229])
 by fmsmga004.fm.intel.com with ESMTP; 25 Oct 2019 02:51:34 -0700
From: Jasvinder Singh <jasvinder.singh@intel.com>
To: dev@dpdk.org
Cc: cristian.dumitrescu@intel.com,
 Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
Date: Fri, 25 Oct 2019 11:51:16 +0100
Message-Id: <20191025105124.6950-8-jasvinder.singh@intel.com>
X-Mailer: git-send-email 2.21.0
In-Reply-To: <20191025105124.6950-1-jasvinder.singh@intel.com>
References: <20191024184630.66881-1-jasvinder.singh@intel.com>
 <20191025105124.6950-1-jasvinder.singh@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v7 07/15] sched: update memory compute to support
	flexiblity
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Update memory footprint compute function for allowing subports of
the same port to have different configuration in terms of number of
pipes, pipe queue sizes, etc.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Signed-off-by: Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
---
 lib/librte_sched/rte_sched.c | 100 ++++++++++-------------------------
 lib/librte_sched/rte_sched.h |   8 +--
 2 files changed, 34 insertions(+), 74 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index f59519b00..fdcbb214e 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -476,70 +476,6 @@ rte_sched_port_check_params(struct rte_sched_port_params *params)
 	return 0;
 }
 
-static uint32_t
-rte_sched_port_get_array_base(struct rte_sched_port_params *params, enum rte_sched_port_array array)
-{
-	uint32_t n_subports_per_port = params->n_subports_per_port;
-	uint32_t n_pipes_per_subport = params->n_pipes_per_subport;
-	uint32_t n_pipes_per_port = n_pipes_per_subport * n_subports_per_port;
-	uint32_t n_queues_per_port = RTE_SCHED_QUEUES_PER_PIPE * n_pipes_per_subport * n_subports_per_port;
-
-	uint32_t size_subport = n_subports_per_port * sizeof(struct rte_sched_subport);
-	uint32_t size_pipe = n_pipes_per_port * sizeof(struct rte_sched_pipe);
-	uint32_t size_queue = n_queues_per_port * sizeof(struct rte_sched_queue);
-	uint32_t size_queue_extra
-		= n_queues_per_port * sizeof(struct rte_sched_queue_extra);
-	uint32_t size_pipe_profiles
-		= params->n_max_pipe_profiles * sizeof(struct rte_sched_pipe_profile);
-	uint32_t size_bmp_array = rte_bitmap_get_memory_footprint(n_queues_per_port);
-	uint32_t size_per_pipe_queue_array, size_queue_array;
-
-	uint32_t base, i;
-
-	size_per_pipe_queue_array = 0;
-	for (i = 0; i < RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE; i++) {
-		if (i < RTE_SCHED_TRAFFIC_CLASS_BE)
-			size_per_pipe_queue_array +=
-				params->qsize[i] * sizeof(struct rte_mbuf *);
-		else
-			size_per_pipe_queue_array += RTE_SCHED_MAX_QUEUES_PER_TC *
-				params->qsize[i] * sizeof(struct rte_mbuf *);
-	}
-	size_queue_array = n_pipes_per_port * size_per_pipe_queue_array;
-
-	base = 0;
-
-	if (array == e_RTE_SCHED_PORT_ARRAY_SUBPORT)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_subport);
-
-	if (array == e_RTE_SCHED_PORT_ARRAY_PIPE)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_pipe);
-
-	if (array == e_RTE_SCHED_PORT_ARRAY_QUEUE)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_queue);
-
-	if (array == e_RTE_SCHED_PORT_ARRAY_QUEUE_EXTRA)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_queue_extra);
-
-	if (array == e_RTE_SCHED_PORT_ARRAY_PIPE_PROFILES)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_pipe_profiles);
-
-	if (array == e_RTE_SCHED_PORT_ARRAY_BMP_ARRAY)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_bmp_array);
-
-	if (array == e_RTE_SCHED_PORT_ARRAY_QUEUE_ARRAY)
-		return base;
-	base += RTE_CACHE_LINE_ROUNDUP(size_queue_array);
-
-	return base;
-}
-
 static uint32_t
 rte_sched_subport_get_array_base(struct rte_sched_subport_params *params,
 	enum rte_sched_subport_array array)
@@ -860,22 +796,44 @@ rte_sched_subport_check_params(struct rte_sched_subport_params *params,
 }
 
 uint32_t
-rte_sched_port_get_memory_footprint(struct rte_sched_port_params *params)
+rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params,
+	struct rte_sched_subport_params **subport_params)
 {
-	uint32_t size0, size1;
+	uint32_t size0 = 0, size1 = 0, i;
 	int status;
 
-	status = rte_sched_port_check_params(params);
+	status = rte_sched_port_check_params(port_params);
 	if (status != 0) {
-		RTE_LOG(NOTICE, SCHED,
-			"Port scheduler params check failed (%d)\n", status);
+		RTE_LOG(ERR, SCHED,
+			"%s: Port scheduler port params check failed (%d)\n",
+			__func__, status);
 
 		return 0;
 	}
 
+	for (i = 0; i < port_params->n_subports_per_port; i++) {
+		struct rte_sched_subport_params *sp = subport_params[i];
+
+		status = rte_sched_subport_check_params(sp,
+				port_params->n_pipes_per_subport,
+				port_params->rate);
+		if (status != 0) {
+			RTE_LOG(ERR, SCHED,
+				"%s: Port scheduler subport params check failed (%d)\n",
+				__func__, status);
+
+			return 0;
+		}
+	}
+
 	size0 = sizeof(struct rte_sched_port);
-	size1 = rte_sched_port_get_array_base(params,
-			e_RTE_SCHED_PORT_ARRAY_TOTAL);
+
+	for (i = 0; i < port_params->n_subports_per_port; i++) {
+		struct rte_sched_subport_params *sp = subport_params[i];
+
+		size1 += rte_sched_subport_get_array_base(sp,
+					e_RTE_SCHED_SUBPORT_ARRAY_TOTAL);
+	}
 
 	return size0 + size1;
 }
diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h
index 5001f09ed..40f02f124 100644
--- a/lib/librte_sched/rte_sched.h
+++ b/lib/librte_sched/rte_sched.h
@@ -373,14 +373,16 @@ rte_sched_pipe_config(struct rte_sched_port *port,
 /**
  * Hierarchical scheduler memory footprint size per port
  *
- * @param params
+ * @param port_params
  *   Port scheduler configuration parameter structure
+ * @param subport_params
+ *   Array of subport parameter structures
  * @return
  *   Memory footprint size in bytes upon success, 0 otherwise
  */
 uint32_t
-rte_sched_port_get_memory_footprint(struct rte_sched_port_params *params);
-
+rte_sched_port_get_memory_footprint(struct rte_sched_port_params *port_params,
+	struct rte_sched_subport_params **subport_params);
 /*
  * Statistics
  *
-- 
2.21.0