From patchwork Thu Jan 12 10:50:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 91068 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1538089qgi; Thu, 12 Jan 2017 01:52:40 -0800 (PST) X-Received: by 10.237.51.37 with SMTP id u34mr12996317qtd.40.1484214759868; Thu, 12 Jan 2017 01:52:39 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x36si5742524qtd.230.2017.01.12.01.52.39; Thu, 12 Jan 2017 01:52:39 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 84DD2609CE; Thu, 12 Jan 2017 09:52:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 51D1760935; Thu, 12 Jan 2017 09:51:35 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 4D402608F7; Thu, 12 Jan 2017 09:51:27 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id D1E66608F7 for ; Thu, 12 Jan 2017 09:51:24 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id z134so5780299lff.3 for ; Thu, 12 Jan 2017 01:51:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zU/Fst4OP+SAbn8Wz6rR6k2ctH2ECsmnBhlDwpc5p3k=; b=qAuJBCod1pXYVp8EVlviAaBuWfVw1c92SBPamiGB1bQjD03AvKX7wwmDKKw2aWEA0Y VMPhM5yG/1o4yvZvmDnfx1cXAgT9FTnoIhmvLxAshKVXBs5ecrGonjAYQ8IxBbw6jKD+ g0LykslRMPZ3bBma5exptSh1Mxf9nQEkGA1AL847mK4/pSEm3Bymsr26cVBkbR/Szpmh G60LK3s0aUeIKw4vP12Fw03Izy4jTp4VUJ1ngCzxYakdyApgx1HfyoqiWl+pWwH+oKYr 2v807jd7txDB3LMQv1oY2vdNbh8KOYywJE8P7L0f6c5eQxvAEQuU32hbDNNBfexWF70l LmOQ== X-Gm-Message-State: AIkVDXLaYeROWmdklvBIhkhl/KkxxIUe+XZlx0EBSTt3qj0qaUVfBst4kk33YQpS4motL1Bb8I8= X-Received: by 10.46.6.17 with SMTP id 17mr5256153ljg.14.1484214683721; Thu, 12 Jan 2017 01:51:23 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id 10sm2208243ljh.11.2017.01.12.01.51.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Jan 2017 01:51:23 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, yi.he@linaro.org, forrest.shi@linaro.org, francois.ozog@linaro.org, lng-odp@lists.linaro.org Date: Thu, 12 Jan 2017 11:50:35 +0100 Message-Id: <1484218238-37755-4-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484218238-37755-1-git-send-email-christophe.milard@linaro.org> References: <1484218238-37755-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv6 3/6] linux-gen: drv: shm: adding pool allocator X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Adding functions to create memory pools and allocate / free memory from the created pools. These functions calls their _ishm conterpart, of course. Signed-off-by: Christophe Milard --- platform/linux-generic/drv_shm.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) -- 2.7.4 diff --git a/platform/linux-generic/drv_shm.c b/platform/linux-generic/drv_shm.c index 9b2560d..325632e 100644 --- a/platform/linux-generic/drv_shm.c +++ b/platform/linux-generic/drv_shm.c @@ -8,6 +8,7 @@ #include #include #include <_ishm_internal.h> +#include <_ishmpool_internal.h> static inline uint32_t from_handle(odpdrv_shm_t shm) { @@ -100,3 +101,46 @@ int odpdrv_shm_print_all(const char *title) { return _odp_ishm_status(title); } + +odpdrv_shm_pool_t odpdrv_shm_pool_create(const char *pool_name, + odpdrv_shm_pool_param_t *param) +{ + int flags; + + /* force unique address for all ODP threads */ + flags = _ODP_ISHM_SINGLE_VA; + return (odpdrv_shm_pool_t)_odp_ishm_pool_create(pool_name, + param->pool_size, + param->min_alloc, + param->max_alloc, + flags); +} + +int odpdrv_shm_pool_destroy(odpdrv_shm_pool_t pool) +{ + return _odp_ishm_pool_destroy((_odp_ishm_pool_t *)(void*)pool); +} + +odpdrv_shm_pool_t odpdrv_shm_pool_lookup(const char *name) +{ + return (odpdrv_shm_pool_t)_odp_ishm_pool_lookup(name); +} + +void *odpdrv_shm_pool_alloc(odpdrv_shm_pool_t pool, uint64_t size) +{ + return _odp_ishm_pool_alloc((_odp_ishm_pool_t *)(void*)pool, size); +} + +void odpdrv_shm_pool_free(odpdrv_shm_pool_t pool, void *addr) +{ + (void)_odp_ishm_pool_free((_odp_ishm_pool_t *)(void*)pool, addr); +} + +int odpdrv_shm_pool_print(const char *title, odpdrv_shm_pool_t pool) +{ + return _odp_ishm_pool_status(title, (_odp_ishm_pool_t *)(void*)pool); +} + +/** + * @} + */