From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 9B459A05D3 for ; Thu, 23 May 2019 10:19:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1412E1B9ED; Thu, 23 May 2019 10:17:36 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id D457D1B993 for ; Thu, 23 May 2019 10:17:10 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4N89evA019037; Thu, 23 May 2019 01:17:10 -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=pfpt0818; bh=+ieFtCc0LN3kuuJEFLJaSUFwyQMC0ljtxO5x37SUOsQ=; b=cASg/guff81+oXVFESsXLhq5T94OUiFW3JEncx46e/GCd8Ex6mwx8r5ZwQOTJ2kL+mjI +i6M1GyEZijcV3Uwh90pjrr17Mf22+HsNKhfLUcoGiPmxsgJbkHNnINnOYkNhfQjVQbx +/ohh9dieigiT1L8DVMyJ89nUwpNZW/knv2UB2oq0dcUrFAY3Ku1HukEUp7HgGg6xHZb xaO25yGcmWQgOfoyFFjVa+5AJceteAYF702Ix0qfn7zs8Qw7xLtDaTZDSmN9PmsqubpK WOjo0Le03WAUREW3S511h23J7HyXWq9IYIPDJuod3sdALtzNaGNx5eMUnC9mt7bQoK/S Qg== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2smnwk0sfp-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 23 May 2019 01:17:10 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 23 May 2019 01:16:11 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 23 May 2019 01:16:11 -0700 Received: from jerin-lab.marvell.com (unknown [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id B676C3F703F; Thu, 23 May 2019 01:16:10 -0700 (PDT) From: To: CC: , Jerin Jacob , Pavan Nikhilesh Date: Thu, 23 May 2019 13:43:35 +0530 Message-ID: <20190523081339.56348-24-jerinj@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523081339.56348-1-jerinj@marvell.com> References: <20190523081339.56348-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-23_08:, , signatures=0 Subject: [dpdk-dev] [PATCH v1 23/27] mempool/octeontx2: add remaining slow path ops X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jerin Jacob Add remaining get_count(), calc_mem_size() and populate() slow path mempool operations. Signed-off-by: Jerin Jacob Signed-off-by: Pavan Nikhilesh --- drivers/mempool/octeontx2/otx2_mempool_ops.c | 62 ++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/mempool/octeontx2/otx2_mempool_ops.c b/drivers/mempool/octeontx2/otx2_mempool_ops.c index 94570319a..966b7d7f1 100644 --- a/drivers/mempool/octeontx2/otx2_mempool_ops.c +++ b/drivers/mempool/octeontx2/otx2_mempool_ops.c @@ -7,6 +7,12 @@ #include "otx2_mempool.h" +static unsigned int +otx2_npa_get_count(const struct rte_mempool *mp) +{ + return (unsigned int)npa_lf_aura_op_available(mp->pool_id); +} + static int npa_lf_aura_pool_init(struct otx2_mbox *mbox, uint32_t aura_id, struct npa_aura_s *aura, struct npa_pool_s *pool) @@ -341,10 +347,66 @@ otx2_npa_free(struct rte_mempool *mp) otx2_npa_lf_fini(); } +static ssize_t +otx2_npa_calc_mem_size(const struct rte_mempool *mp, uint32_t obj_num, + uint32_t pg_shift, size_t *min_chunk_size, size_t *align) +{ + ssize_t mem_size; + + /* + * Simply need space for one more object to be able to + * fulfill alignment requirements. + */ + mem_size = rte_mempool_op_calc_mem_size_default(mp, obj_num + 1, + pg_shift, + min_chunk_size, align); + if (mem_size >= 0) { + /* + * Memory area which contains objects must be physically + * contiguous. + */ + *min_chunk_size = mem_size; + } + + return mem_size; +} + +static int +otx2_npa_populate(struct rte_mempool *mp, unsigned int max_objs, void *vaddr, + rte_iova_t iova, size_t len, + rte_mempool_populate_obj_cb_t *obj_cb, void *obj_cb_arg) +{ + size_t total_elt_sz; + size_t off; + + if (iova == RTE_BAD_IOVA) + return -EINVAL; + + total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size; + + /* Align object start address to a multiple of total_elt_sz */ + off = total_elt_sz - ((uintptr_t)vaddr % total_elt_sz); + + if (len < off) + return -EINVAL; + + vaddr = (char *)vaddr + off; + iova += off; + len -= off; + + npa_lf_aura_op_range_set(mp->pool_id, iova, iova + len); + + return rte_mempool_op_populate_default(mp, max_objs, vaddr, iova, len, + obj_cb, obj_cb_arg); +} + static struct rte_mempool_ops otx2_npa_ops = { .name = "octeontx2_npa", .alloc = otx2_npa_alloc, .free = otx2_npa_free, + .get_count = otx2_npa_get_count, + .calc_mem_size = otx2_npa_calc_mem_size, + .populate = otx2_npa_populate, }; MEMPOOL_REGISTER_OPS(otx2_npa_ops); -- 2.21.0