From patchwork Fri Jun 3 16:38:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 13198 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id A7FD85A5E; Fri, 3 Jun 2016 18:43:09 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 608D15A4E for ; Fri, 3 Jun 2016 18:43:07 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 03 Jun 2016 09:38:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,413,1459839600"; d="scan'208";a="990503048" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 03 Jun 2016 09:38:40 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u53Gced2011726; Fri, 3 Jun 2016 17:38:40 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u53GceXS008166; Fri, 3 Jun 2016 17:38:40 +0100 Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id u53Gcd36008162; Fri, 3 Jun 2016 17:38:39 +0100 From: Ferruh Yigit To: dev@dpdk.org Cc: Anatoly Burakov , Olivier Matz , Ferruh Yigit Date: Fri, 3 Jun 2016 17:38:38 +0100 Message-Id: <1464971918-8131-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <5751B053.3080902@intel.com> References: <5751B053.3080902@intel.com> Subject: [dpdk-dev] [PATCH v2] ivshmem: add all memzones of mempool to metadata X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Mempool consist of multiple memzones, at least from two of them. ivshmem assumes mempool and elements are all in same memzone. Updating code to add all memzones when a mempool added. Fixes: d1d914ebbc25 ("mempool: allocate in several memory chunks by default") Signed-off-by: Ferruh Yigit Acked-by: Anatoly Burakov Acked-by: Olivier Matz --- v2: * fix patch title metada -> metadata --- lib/librte_ivshmem/rte_ivshmem.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/librte_ivshmem/rte_ivshmem.c b/lib/librte_ivshmem/rte_ivshmem.c index c8b332c..5c83920 100644 --- a/lib/librte_ivshmem/rte_ivshmem.c +++ b/lib/librte_ivshmem/rte_ivshmem.c @@ -548,25 +548,39 @@ add_ring_to_metadata(const struct rte_ring * r, } static int -add_mempool_to_metadata(const struct rte_mempool * mp, - struct ivshmem_config * config) +add_mempool_memzone_to_metadata(const void *addr, + struct ivshmem_config *config) { - struct rte_memzone * mz; - int ret; + struct rte_memzone *mz; - mz = get_memzone_by_addr(mp); - ret = 0; + mz = get_memzone_by_addr(addr); if (!mz) { RTE_LOG(ERR, EAL, "Cannot find memzone for mempool!\n"); return -1; } - /* mempool consists of memzone and ring */ - ret = add_memzone_to_metadata(mz, config); + return add_memzone_to_metadata(mz, config); +} + +static int +add_mempool_to_metadata(const struct rte_mempool *mp, + struct ivshmem_config *config) +{ + struct rte_mempool_memhdr *memhdr; + int ret; + + ret = add_mempool_memzone_to_metadata(mp, config); if (ret < 0) return -1; + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { + ret = add_mempool_memzone_to_metadata(memhdr->addr, config); + if (ret < 0) + return -1; + } + + /* mempool consists of memzone and ring */ return add_ring_to_metadata(mp->ring, config); }