From patchwork Wed Jun 1 13:18:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 13138 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 268065AB7; Wed, 1 Jun 2016 15:18:14 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 564995A9C for ; Wed, 1 Jun 2016 15:18:12 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 01 Jun 2016 06:18:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,401,1459839600"; d="scan'208";a="966652533" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 01 Jun 2016 06:18:09 -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 u51DI9nY027510; Wed, 1 Jun 2016 14:18:09 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u51DI939029590; Wed, 1 Jun 2016 14:18:09 +0100 Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id u51DI8PU029585; Wed, 1 Jun 2016 14:18:08 +0100 From: Ferruh Yigit To: dev@dpdk.org Cc: Anatoly Burakov , Olivier Matz , Ferruh Yigit Date: Wed, 1 Jun 2016 14:18:06 +0100 Message-Id: <1464787086-29555-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] ivshmem: add all memzones of mempool to metada 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 --- 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); }