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 DE37EA045E for ; Sat, 1 Jun 2019 03:53:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4A53C1BA00; Sat, 1 Jun 2019 03:50:26 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 63B4C1B9FD for ; Sat, 1 Jun 2019 03:50:24 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x511jb5Z000471 for ; Fri, 31 May 2019 18:50:23 -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=xNAux10+uFdWlIbxU6G0sUegztzn7BSlpZXXyWFRN6yANzG+qUmcInDxs09sUanKSLJg qQzn0CdspwuFppH3JxN4S3z12W+mXDkUd/gMISRRR44ICwpSK7POOBl3iGM2LbZyLzVP QgpSLGscNhzWhL7fktkBeRSGEsrB4ZyDBnJdYCS3TDQXF9lGGTCls9UKDGSnlvvEhrKS gf1RW64egMB4rlQfiLruWniBddVrgolhgyJ1YDFyq+gTHVCEhRLCsouAYqoOd4g1nH5q pSiKoXSCaSfSnkcsLVF1ZorZR824Jg1hndzA0GofZ9GUL8gT2pM2IaI7jRDZj6sLjo1U kA== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 2sufgn8309-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 31 May 2019 18:50:23 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 31 May 2019 18:50:22 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 31 May 2019 18:50:22 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 873A53F703F; Fri, 31 May 2019 18:50:21 -0700 (PDT) From: To: , Jerin Jacob , Nithin Dabilpuram , Vamsi Attunuru CC: Pavan Nikhilesh Date: Sat, 1 Jun 2019 07:19:01 +0530 Message-ID: <20190601014905.45531-24-jerinj@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190601014905.45531-1-jerinj@marvell.com> References: <20190523081339.56348-1-jerinj@marvell.com> <20190601014905.45531-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-06-01_02:, , signatures=0 Subject: [dpdk-dev] [PATCH v2 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