From patchwork Fri Jan 13 07:55:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 91268 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp56105qgi; Thu, 12 Jan 2017 22:58:14 -0800 (PST) X-Received: by 10.200.42.179 with SMTP id b48mr17341199qta.246.1484290694623; Thu, 12 Jan 2017 22:58:14 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 86si7808116qku.249.2017.01.12.22.58.14; Thu, 12 Jan 2017 22:58:14 -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 4F4D460821; Fri, 13 Jan 2017 06:58:14 +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 5F933608C5; Fri, 13 Jan 2017 06:57:09 +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 B95EB6083A; Fri, 13 Jan 2017 06:57:00 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id E43AA608BF for ; Fri, 13 Jan 2017 06:56:31 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id v186so29608747lfa.1 for ; Thu, 12 Jan 2017 22:56:31 -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=RvUAg0kMgq2Gq/ekIivOx7GXP0O3ms04jQodiZYQ0uCtIz0m29G/umScXxHtkAojyz YnscUoG9bCLtj8CA+w0mtvjGHcnZbtxzaOpkValahZYykHbFug7VtprDmozUXw9XQz1I TotnUg1uuaqZ0SdwcKaZCpVQXez2qLXM6TFY7Z+mxalkqhv0ZM6ImjadX3HIpnqYGOCO 8wpCoDaK+tNbh9KwQv/Sq0JkqP+1tXRpXhK4ov/ayW1t4t+aLoHUwEb/UM+bejBzTri6 /jmr6KIG6o+uDsOrGGqcZzjhhCUoGZ6paAPNepBjRKBUCG84kikn76qUJ+dog5WUsGPu OxBA== X-Gm-Message-State: AIkVDXKN3uUNyX8RT+xZ9SkLh3O5Ddtnl3H/8NlYa4W0y/vjCqS7F3u7GbIZ+LAjcCzEUU2R8Is= X-Received: by 10.25.27.147 with SMTP id b141mr1960300lfb.183.1484290590731; Thu, 12 Jan 2017 22:56:30 -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 e7sm3327034lfb.10.2017.01.12.22.56.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Jan 2017 22:56:30 -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: Fri, 13 Jan 2017 08:55:40 +0100 Message-Id: <1484294143-29882-4-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484294143-29882-1-git-send-email-christophe.milard@linaro.org> References: <1484294143-29882-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv7 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); +} + +/** + * @} + */