From patchwork Mon Jan 2 16:49:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 89555 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp7665608qgi; Mon, 2 Jan 2017 08:50:36 -0800 (PST) X-Received: by 10.200.39.51 with SMTP id g48mr54202579qtg.256.1483375836763; Mon, 02 Jan 2017 08:50:36 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b1si30991103qkd.177.2017.01.02.08.50.36; Mon, 02 Jan 2017 08:50:36 -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 67A83608A0; Mon, 2 Jan 2017 16:50:36 +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 DFF61608BB; Mon, 2 Jan 2017 16:50:02 +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 A8AF66064F; Mon, 2 Jan 2017 16:49:37 +0000 (UTC) Received: from mail-lf0-f48.google.com (mail-lf0-f48.google.com [209.85.215.48]) by lists.linaro.org (Postfix) with ESMTPS id B012E6090A for ; Mon, 2 Jan 2017 16:49:10 +0000 (UTC) Received: by mail-lf0-f48.google.com with SMTP id y21so272478515lfa.1 for ; Mon, 02 Jan 2017 08:49:10 -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=sJZin5t+0wQg7HCswTN0wEOJelSseqrP7klMW0zW/4jRNvvSPVEbVMxsuC3wXPuSZ/ lkuHQ2eBfQ8AxlZEZb1oREva0iLnSLD9Gjim+88JcBh0PHGGyeAOZqXzui/N6Y5EVVyZ RLqvOUzmiWBC+wMJCvvYNnQNtMECdbgPXlmufJYGqZE0bXMj/NyOXoOEmKSmYR9RHsc7 C/CJ7tXZLRhTsr/ZDATR2ySxkIaF9lqXdmcFWUIDb81CoFPl1VdZGvbCgk3Kg36tJFZi etwKpzJGMJFWzPz/5Fr+fmT50ilZhnDJcLwc7y8W4YUaee7zdFnFdgduvoSsVv/ukGHt bhjA== X-Gm-Message-State: AIkVDXKmbICxSXmJrsLymnabcmjiUebV+TdO9TJ9v3PSQAP2IZOT/FsJ0UEPZYi8HgzdUa+V24k= X-Received: by 10.46.83.9 with SMTP id h9mr2599805ljb.72.1483375749403; Mon, 02 Jan 2017 08:49:09 -0800 (PST) Received: from localhost.localdomain (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id d2sm6131093lfe.13.2017.01.02.08.49.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Jan 2017 08:49:08 -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, lng-odp@lists.linaro.org Date: Mon, 2 Jan 2017 17:49:00 +0100 Message-Id: <1483375743-7408-4-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483375743-7408-1-git-send-email-christophe.milard@linaro.org> References: <1483375743-7408-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv4 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); +} + +/** + * @} + */