From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0041.outbound.protection.outlook.com [104.47.36.41]) by dpdk.org (Postfix) with ESMTP id E592F4B4B for ; Wed, 17 Jan 2018 09:52:47 +0100 (CET) Received: from BN6PR03CA0010.namprd03.prod.outlook.com (10.168.230.148) by BN6PR03MB2689.namprd03.prod.outlook.com (10.173.144.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Wed, 17 Jan 2018 08:52:41 +0000 Received: from BN1BFFO11FD020.protection.gbl (2a01:111:f400:7c10::1:172) by BN6PR03CA0010.outlook.office365.com (2603:10b6:404:23::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Wed, 17 Jan 2018 08:52:41 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD020.mail.protection.outlook.com (10.58.144.83) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Wed, 17 Jan 2018 08:52:41 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0H8qcNo009961; Wed, 17 Jan 2018 01:52:39 -0700 From: Hemant Agrawal To: CC: Date: Wed, 17 Jan 2018 14:21:32 +0530 Message-ID: <1516179092-22908-1-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512563473-19969-1-git-send-email-hemant.agrawal@nxp.com> References: <1512563473-19969-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131606527614417073; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(7966004)(39860400002)(346002)(396003)(376002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(76176011)(85426001)(51416003)(104016004)(36756003)(508600001)(316002)(86362001)(48376002)(59450400001)(26005)(16586007)(4326008)(2906002)(53936002)(305945005)(50226002)(106466001)(5660300001)(356003)(8936002)(2351001)(81156014)(6916009)(2950100002)(81166006)(97736004)(50466002)(105606002)(68736007)(8676002)(77096006)(6666003)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2689; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD020; 1:HvmyhWJYNDKFUAPPw9fn96EK2wHTyAIeDbfyakWpPlPoLXEgn5t14gfZ/WvJTzptR4R2/ISr3CDs5z+x5NqSslYVG7ng4VUtozS7WYt9SMV7n0H1MM4kW7FdM+unKaBO MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0abbacd8-a992-490d-78b1-08d55d87ab0b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:BN6PR03MB2689; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2689; 3:c8OtmViTl5Xm86LCt9N8cJI1MNas3T62ouSIWlEHL2mVVeET5q3Xy3TsMlB1KekruY7gxBuMrk2Vy5anTXq/SFse9vQqLPu22CBM1H/M0CDodAbDC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yNKjUK298/jeH7hgi4ejlNYBN1OKz7fcgaNkFgf/70dZDuoddhLpceNNM7h2yKGaAQLQUzuB3XaIx/9UVfWje+KAz9zIScmrFf2TFIoROopXPrQ/wW2blb92VlH2y2Ioi7HvibueWlhRdbTc9hRH02Sn80OZpwPaUrVFgno/VlqGrpFtWQYK4zIvhOdCg9SS2ANvZvcFj+glsqY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(131327999870524)(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(3231023)(944501161)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(20161123559100)(20161123563025)(20161123556025)(20161123561025)(20161123565025)(201708071742011); SRVR:BN6PR03MB2689; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BN6PR03MB2689; X-Forefront-PRVS: 0555EC8317 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR03MB2689; 23:rT1vBhf+f9pkXakMMrtgxIjHe9iq+FGTMLEbOy99/?= =?us-ascii?Q?HghAdj+ZwOUecJoQugmM2Fx2QuzKgK4+1nN4KVvyfEtjjXR2Lp4pxtJsrBOO?= =?us-ascii?Q?PpbcSG9k/WFmbNPYqcF063kGA+JiRv0HUbsd+mBAYbeSXa3YAort5NKh0Us3?= =?us-ascii?Q?mBZ2TRwQYxoQhn7ozl1LtPiVCLpdy/YqJboAcbO3IM8JyDKVNER/aWtHJjXt?= =?us-ascii?Q?UOSghSuGlLXiXJVW3Rfzs9OGPm2z9odXF5A9edoNTMr8nZclnFJg6BnqmvKf?= =?us-ascii?Q?pVQ+N5YXkpIVXWK8sNzXpk7PqWdYwa4FXr8jQV0QMuxeM1uhzffXygSq3OpF?= =?us-ascii?Q?geZSMccaWEAdS6bHyTZCGwxREh28ui/db3vbT5DJbaggWb4nRFu5IYrnPc9c?= =?us-ascii?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HrXmwhInr5Ad6SuSVIz5wQEWddnq6zZHjw20Sk3bLk/aLafSg9VLpQrvNDuj5MFvG7Qssy0YAEXzcS56PDT7AU+ZwPDRmwqSGNfEyWaGlbgfvZOwKrSlNW5wDz8t5z/r7luB3UhYgTdRF2IMkeNz+FNtpKPMDlqRTNcJRuW6cyFWb5/k9LTs=; 5:3YHDQA70P4uW3LJCRse9URB8D1hqJ4YjAojhZwHVmr18zKKb+V56CNKbs1Xf7dJxxhut2EiMR83EirHZ+Xj7sQmjO2kGMey02iqtoHawtCxhBzSA+fqv4tzpu304abPlVc1juQUuGLGBS9R1PHQLdnbZfAXLewwzHfvbbhwwYlg=; 24:xdoeHmB7jrAqTXsBbr4dd1Nvr9/EYvq3/R2XeEQsAZZ2qXUUeYhPdeOI9mSLyUXE2xIPk0aJjZZADT0P9AQ7TbYT4i7L+qjAgOuul4WNmDQ=; 7:sapYnZx4MYEu4OJUyFyeYG9OUlbowufdiD8kpmXHMO2jlnQiRi2d4r9Z3J6UvFxKukDzU9BG2/XV5i1sZsD1d0agD9jKorYJ1ho4A8YS51gmKf79HcfSf5Zl4Ft8DWec7mHWOq5w8xeXe8Q6f3Tbvo3yeCY1PlrmsyZIGJA1oDgWUD+0MfsRgHr4s74C1VQotU6JJ5iT7E1dKKGWu4XJnxP0k1TWIsiICGWMIJdVe74R2dINEyshrlLLILeZH9jt SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2018 08:52:41.2545 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0abbacd8-a992-490d-78b1-08d55d87ab0b X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2689 Subject: [dpdk-dev] [PATCH v2] mempool/dpaa: optimize phy to virt conversion 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: , X-List-Received-Date: Wed, 17 Jan 2018 08:52:48 -0000 If the allocation is from a single memzone, optimize the phy-virt address conversions. Signed-off-by: Hemant Agrawal --- v2: use register memory area instead of new flag in mempool drivers/mempool/dpaa/dpaa_mempool.c | 50 ++++++++++++++++++++++++++++++++++--- drivers/mempool/dpaa/dpaa_mempool.h | 13 ++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c index ffb81c2..ddc4e47 100644 --- a/drivers/mempool/dpaa/dpaa_mempool.c +++ b/drivers/mempool/dpaa/dpaa_mempool.c @@ -73,6 +73,8 @@ dpaa_mbuf_create_pool(struct rte_mempool *mp) rte_dpaa_bpid_info[bpid].meta_data_size = sizeof(struct rte_mbuf) + rte_pktmbuf_priv_size(mp); rte_dpaa_bpid_info[bpid].dpaa_ops_index = mp->ops_index; + rte_dpaa_bpid_info[bpid].ptov_off = 0; + rte_dpaa_bpid_info[bpid].flags = 0; bp_info = rte_malloc(NULL, sizeof(struct dpaa_bp_info), @@ -145,9 +147,20 @@ dpaa_mbuf_free_bulk(struct rte_mempool *pool, } while (i < n) { + uint64_t phy = rte_mempool_virt2iova(obj_table[i]); + + if (unlikely(!bp_info->ptov_off)) { + /* buffers are not from multiple memzones */ + if (!(bp_info->flags & DPAA_MPOOL_MULTI_MEMZONE)) { + bp_info->ptov_off + = (uint64_t)obj_table[i] - phy; + rte_dpaa_bpid_info[bp_info->bpid].ptov_off + = bp_info->ptov_off; + } + } + dpaa_buf_free(bp_info, - (uint64_t)rte_mempool_virt2iova(obj_table[i]) + - bp_info->meta_data_size); + (uint64_t)phy + bp_info->meta_data_size); i = i + 1; } @@ -215,7 +228,7 @@ dpaa_mbuf_alloc_bulk(struct rte_mempool *pool, * i.e. first buffer is valid, remaining 6 buffers * may be null. */ - bufaddr = (void *)rte_dpaa_mem_ptov(bufs[i].addr); + bufaddr = DPAA_MEMPOOL_PTOV(bp_info, bufs[i].addr); m[n] = (struct rte_mbuf *)((char *)bufaddr - bp_info->meta_data_size); DPAA_MEMPOOL_DPDEBUG("Paddr (%p), FD (%p) from BMAN", @@ -246,6 +259,36 @@ dpaa_mbuf_get_count(const struct rte_mempool *mp) return bman_query_free_buffers(bp_info->bp); } +static int +dpaa_register_memory_area(const struct rte_mempool *mp, + char *vaddr __rte_unused, + rte_iova_t paddr __rte_unused, + size_t len) +{ + struct dpaa_bp_info *bp_info; + unsigned int total_elt_sz; + + MEMPOOL_INIT_FUNC_TRACE(); + + if (!mp || !mp->pool_data) { + DPAA_MEMPOOL_ERR("Invalid mempool provided\n"); + return 0; + } + + bp_info = DPAA_MEMPOOL_TO_POOL_INFO(mp); + total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size; + + DPAA_MEMPOOL_DEBUG("Req size %lu vs Available %u\n", + len, total_elt_sz * mp->size); + + /* Detect pool area has sufficient space for elements in this memzone */ + if (len < total_elt_sz * mp->size) + /* Else, Memory will be allocated from multiple memzones */ + bp_info->flags |= DPAA_MPOOL_MULTI_MEMZONE; + + return 0; +} + struct rte_mempool_ops dpaa_mpool_ops = { .name = "dpaa", .alloc = dpaa_mbuf_create_pool, @@ -253,6 +296,7 @@ struct rte_mempool_ops dpaa_mpool_ops = { .enqueue = dpaa_mbuf_free_bulk, .dequeue = dpaa_mbuf_alloc_bulk, .get_count = dpaa_mbuf_get_count, + .register_memory_area = dpaa_register_memory_area, }; MEMPOOL_REGISTER_OPS(dpaa_mpool_ops); diff --git a/drivers/mempool/dpaa/dpaa_mempool.h b/drivers/mempool/dpaa/dpaa_mempool.h index 91da62f..02aa513 100644 --- a/drivers/mempool/dpaa/dpaa_mempool.h +++ b/drivers/mempool/dpaa/dpaa_mempool.h @@ -28,6 +28,9 @@ /* Maximum release/acquire from BMAN */ #define DPAA_MBUF_MAX_ACQ_REL 8 +/* Buffers are allocated from multiple memzones i.e. non phys contiguous */ +#define DPAA_MPOOL_MULTI_MEMZONE 0x01 + struct dpaa_bp_info { struct rte_mempool *mp; struct bman_pool *bp; @@ -35,8 +38,18 @@ struct dpaa_bp_info { uint32_t size; uint32_t meta_data_size; int32_t dpaa_ops_index; + int64_t ptov_off; + uint8_t flags; }; +static inline void * +DPAA_MEMPOOL_PTOV(struct dpaa_bp_info *bp_info, uint64_t addr) +{ + if (bp_info->ptov_off) + return ((void *)(addr + bp_info->ptov_off)); + return rte_dpaa_mem_ptov(addr); +} + #define DPAA_MEMPOOL_TO_POOL_INFO(__mp) \ ((struct dpaa_bp_info *)__mp->pool_data) -- 2.7.4