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 9DE4EA2EFC
	for <public@inbox.dpdk.org>; Mon, 14 Oct 2019 18:25:51 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id E60211D174;
	Mon, 14 Oct 2019 18:24:26 +0200 (CEST)
Received: from mga05.intel.com (mga05.intel.com [192.55.52.43])
 by dpdk.org (Postfix) with ESMTP id F241E1C43F
 for <dev@dpdk.org>; Mon, 14 Oct 2019 18:24:09 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga003.fm.intel.com ([10.253.24.29])
 by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 14 Oct 2019 09:24:09 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.67,296,1566889200"; d="scan'208";a="201503641"
Received: from silpixa00381635.ir.intel.com (HELO
 silpixa00381635.ger.corp.intel.com) ([10.237.223.229])
 by FMSMGA003.fm.intel.com with ESMTP; 14 Oct 2019 09:24:08 -0700
From: Jasvinder Singh <jasvinder.singh@intel.com>
To: dev@dpdk.org
Cc: cristian.dumitrescu@intel.com,
 Lukasz Krakowiak <lukaszx.krakowiak@intel.com>
Date: Mon, 14 Oct 2019 18:23:42 +0100
Message-Id: <20191014172347.139114-11-jasvinder.singh@intel.com>
X-Mailer: git-send-email 2.21.0
In-Reply-To: <20191014172347.139114-1-jasvinder.singh@intel.com>
References: <20191014120951.152654-1-jasvinder.singh@intel.com>
 <20191014172347.139114-1-jasvinder.singh@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH v5 10/15] sched: update queue stats read for
	config flexibility
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>

Modify pipe queue stats read function to allow different 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 | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c
index e14506b2d..1faa580d0 100644
--- a/lib/librte_sched/rte_sched.c
+++ b/lib/librte_sched/rte_sched.c
@@ -282,16 +282,6 @@ enum rte_sched_subport_array {
 	e_RTE_SCHED_SUBPORT_ARRAY_TOTAL,
 };
 
-#ifdef RTE_SCHED_COLLECT_STATS
-
-static inline uint32_t
-rte_sched_port_queues_per_subport(struct rte_sched_port *port)
-{
-	return RTE_SCHED_QUEUES_PER_PIPE * port->n_pipes_per_subport;
-}
-
-#endif
-
 static inline uint32_t
 rte_sched_subport_pipe_queues(struct rte_sched_subport *subport)
 {
@@ -320,7 +310,12 @@ struct rte_sched_subport *subport, uint32_t qindex)
 static inline uint32_t
 rte_sched_port_queues_per_port(struct rte_sched_port *port)
 {
-	return RTE_SCHED_QUEUES_PER_PIPE * port->n_pipes_per_subport * port->n_subports_per_port;
+	uint32_t n_queues = 0, i;
+
+	for (i = 0; i < port->n_subports_per_port; i++)
+		n_queues += rte_sched_subport_pipe_queues(port->subports[i]);
+
+	return n_queues;
 }
 
 static inline uint16_t
@@ -1474,8 +1469,10 @@ rte_sched_queue_read_stats(struct rte_sched_port *port,
 	struct rte_sched_queue_stats *stats,
 	uint16_t *qlen)
 {
+	struct rte_sched_subport *s;
 	struct rte_sched_queue *q;
 	struct rte_sched_queue_extra *qe;
+	uint32_t subport_id, subport_qmask, subport_qindex;
 
 	/* Check user parameters */
 	if (port == NULL) {
@@ -1501,8 +1498,13 @@ rte_sched_queue_read_stats(struct rte_sched_port *port,
 			"%s: Incorrect value for parameter qlen\n", __func__);
 		return -EINVAL;
 	}
-	q = port->queue + queue_id;
-	qe = port->queue_extra + queue_id;
+	subport_qmask = port->n_pipes_per_subport_log2 + 4;
+	subport_id = (queue_id >> subport_qmask) & (port->n_subports_per_port - 1);
+
+	s = port->subports[subport_id];
+	subport_qindex = ((1 << subport_qmask) - 1) & queue_id;
+	q = s->queue + subport_qindex;
+	qe = s->queue_extra + subport_qindex;
 
 	/* Copy queue stats and clear */
 	memcpy(stats, &qe->stats, sizeof(struct rte_sched_queue_stats));
-- 
2.21.0