From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 65FA5A0546;
	Tue,  6 Apr 2021 17:12:40 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id B03EC14121B;
	Tue,  6 Apr 2021 17:11:59 +0200 (CEST)
Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com
 [67.231.148.174])
 by mails.dpdk.org (Postfix) with ESMTP id 3C6FC14121F
 for <dev@dpdk.org>; Tue,  6 Apr 2021 17:11:58 +0200 (CEST)
Received: from pps.filterd (m0045849.ppops.net [127.0.0.1])
 by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id
 136F06sZ004264 for <dev@dpdk.org>; Tue, 6 Apr 2021 08:11:57 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;
 h=from : to : cc :
 subject : date : message-id : in-reply-to : references : mime-version :
 content-transfer-encoding : content-type; s=pfpt0220;
 bh=Yo4EdKWZyn6sdv5wu7Szwvf44Rp7ZMUo0Irel90M6wU=;
 b=Dri+GQnzDhOm7nWMJ+R2X3nU+OTf8gUUQvnmxIduYkPMlhzTA6UvPpSFORt5SvicUuBi
 ePX6KJk5SGRYp12v1MOzwnOVN0LxCB2oLhknVHx4M0HoG50/511QCLecfnmpidzr92OM
 hFbM9JDS+xA1gIcLmhu6e/c2rt2ZHkKG2kCpPmrQ4VZ3AEIe2T1BFzkGNWbzwOuNk+IW
 BIruBo8G6bDDraWN8Co1Phid6Ui4EFvF8nLhYEYSxpQKBsjo69MUBIc/OdNM4r9unoLn
 V2GRjTJTxdIt+xpGwIzYBgkKhmkkeIJrOexB4xaEWzq001g47+M4/CFHLxTkv6mDrN/4 9Q== 
Received: from dc5-exch02.marvell.com ([199.233.59.182])
 by mx0a-0016f401.pphosted.com with ESMTP id 37r72p35jj-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)
 for <dev@dpdk.org>; Tue, 06 Apr 2021 08:11:57 -0700
Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com
 (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2;
 Tue, 6 Apr 2021 08:11:55 -0700
Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com
 (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend
 Transport; Tue, 6 Apr 2021 08:11:55 -0700
Received: from lab-ci-142.marvell.com (unknown [10.28.36.142])
 by maili.marvell.com (Postfix) with ESMTP id A8F3C3F7040;
 Tue,  6 Apr 2021 08:11:53 -0700 (PDT)
From: Ashwin Sekhar T K <asekhar@marvell.com>
To: <dev@dpdk.org>
CC: <jerinj@marvell.com>, <skori@marvell.com>, <skoteshwar@marvell.com>,
 <pbhagavatula@marvell.com>, <kirankumark@marvell.com>,
 <psatheesh@marvell.com>, <asekhar@marvell.com>
Date: Tue, 6 Apr 2021 20:41:14 +0530
Message-ID: <20210406151115.1889455-11-asekhar@marvell.com>
X-Mailer: git-send-email 2.31.0
In-Reply-To: <20210406151115.1889455-1-asekhar@marvell.com>
References: <20210305162149.2196166-1-asekhar@marvell.com>
 <20210406151115.1889455-1-asekhar@marvell.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain
X-Proofpoint-GUID: xmYohuTOrua6meWfrwGv5xdO4KQVbFs1
X-Proofpoint-ORIG-GUID: xmYohuTOrua6meWfrwGv5xdO4KQVbFs1
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761
 definitions=2021-04-06_04:2021-04-01,
 2021-04-06 signatures=0
Subject: [dpdk-dev] [PATCH v3 10/11] mempool/cnxk: add cn10k get count op
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
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>

Add the implementation for Marvell CN10k get count op.

Signed-off-by: Ashwin Sekhar T K <asekhar@marvell.com>
---
 drivers/mempool/cnxk/cn10k_mempool_ops.c | 28 +++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c
index c225c227df..d244a5e90f 100644
--- a/drivers/mempool/cnxk/cn10k_mempool_ops.c
+++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c
@@ -157,6 +157,32 @@ cn10k_mempool_enq(struct rte_mempool *mp, void *const *obj_table,
 	return 0;
 }
 
+static unsigned int
+cn10k_mempool_get_count(const struct rte_mempool *mp)
+{
+	struct batch_op_data *op_data;
+	unsigned int count = 0;
+	int i;
+
+	op_data = batch_op_data_get(mp->pool_id);
+
+	rte_wmb();
+	for (i = 0; i < RTE_MAX_LCORE; i++) {
+		struct batch_op_mem *mem = &op_data->mem[i];
+
+		if (mem->status == BATCH_ALLOC_OP_ISSUED)
+			count += roc_npa_aura_batch_alloc_count(mem->objs,
+								BATCH_ALLOC_SZ);
+
+		if (mem->status == BATCH_ALLOC_OP_DONE)
+			count += mem->sz;
+	}
+
+	count += cnxk_mempool_get_count(mp);
+
+	return count;
+}
+
 static int
 cn10k_mempool_alloc(struct rte_mempool *mp)
 {
@@ -215,7 +241,7 @@ static struct rte_mempool_ops cn10k_mempool_ops = {
 	.free = cn10k_mempool_free,
 	.enqueue = cn10k_mempool_enq,
 	.dequeue = cnxk_mempool_deq,
-	.get_count = cnxk_mempool_get_count,
+	.get_count = cn10k_mempool_get_count,
 	.calc_mem_size = cnxk_mempool_calc_mem_size,
 	.populate = cnxk_mempool_populate,
 };
-- 
2.31.0