From patchwork Fri Dec 30 11:59:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 89325 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp6388497qgi; Fri, 30 Dec 2016 03:04:35 -0800 (PST) X-Received: by 10.55.50.210 with SMTP id y201mr36664772qky.307.1483095875068; Fri, 30 Dec 2016 03:04:35 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k95si24507798qkh.19.2016.12.30.03.04.34; Fri, 30 Dec 2016 03:04:35 -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 dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C016B607E5; Fri, 30 Dec 2016 11:04:34 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 9F9C160EFF; Fri, 30 Dec 2016 11:00:44 +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 AEE2560EFF; Fri, 30 Dec 2016 11:00:41 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 4841060EBB for ; Fri, 30 Dec 2016 11:00:13 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id y21so235131604lfa.1 for ; Fri, 30 Dec 2016 03:00:13 -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=dzdFjpgs+uAb5z1BDP6IrDUQCbTnv8KkonL2O9o3jQw=; b=LyP8Q+L92xJn1is31f3Euxhm8vVgQbNBRkTg9wir89059yEy6AK41yj88XlI+Y79yn fZwVroKa72OmiYpQn9Q6GiG0rasdNQUVHgNy3/5kRBEuMWxkCZ+9/byhrU+SfyiUi7mr DpEi8CpyvdH8kUE0REAuIec/q2jHZncwi5A3BTC+1H4WazMU6HcmEBN049+gJ4/+8aRh ne7Se75C5fDhy/FltbmS2mGU6fRKdtUQRlpXgtj9tYOZTsdt4WMpVqcv7/wufQF6UZk4 nsaMrBi8T8D4cixPy27tl9ZpKvyjVobTaOaHuqm6Pi0ydofzX5jJ/m6SPLWBb1mBQdJ5 g+Ow== X-Gm-Message-State: AIkVDXIK9jx7L/NZh0w32qhMpiu/I4Rh/wkQQI5WDp5SxnSJOQhXYBMkOM2nyOJm2hKWL7Lcve8= X-Received: by 10.25.23.210 with SMTP id 79mr8201969lfx.41.1483095611894; Fri, 30 Dec 2016 03:00:11 -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 84sm7921566lja.17.2016.12.30.03.00.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Dec 2016 03:00:11 -0800 (PST) From: Christophe Milard To: francois.ozog@linaro.org, forrest.shi@linaro.org, mike.holmes@linaro.org, yi.he@linaro.org, bill.fischofer@linaro.org, petri.savolainen@nokia.com, lng-odp@lists.linaro.org Date: Fri, 30 Dec 2016 12:59:24 +0100 Message-Id: <1483099167-3133-4-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483099167-3133-1-git-send-email-christophe.milard@linaro.org> References: <1483099167-3133-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv3 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..a9cd7b7 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 = ODPDRV_SHM_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 *)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 *)pool, size); +} + +void odpdrv_shm_pool_free(odpdrv_shm_pool_t pool, void *addr) +{ + (void)_odp_ishm_pool_free((_odp_ishm_pool_t *)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 *)pool); +} + +/** + * @} + */