From patchwork Tue Jan 17 18:18: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: 91708 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp599223qgi; Tue, 17 Jan 2017 09:21:17 -0800 (PST) X-Received: by 10.55.174.130 with SMTP id x124mr13166844qke.63.1484673677171; Tue, 17 Jan 2017 09:21:17 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h30si17056182qta.318.2017.01.17.09.21.16; Tue, 17 Jan 2017 09:21:17 -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 9A982609CE; Tue, 17 Jan 2017 17:21:16 +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 EC04E60EC2; Tue, 17 Jan 2017 17:18:53 +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 E6566609E7; Tue, 17 Jan 2017 17:18:45 +0000 (UTC) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id BA187609E1 for ; Tue, 17 Jan 2017 17:18:42 +0000 (UTC) Received: by mail-lf0-f52.google.com with SMTP id k86so113541571lfi.0 for ; Tue, 17 Jan 2017 09:18:42 -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=egNuteFVLsS7aYy84HXOo2HiOr/7e6qH1UQHSajnik2cwzcHa8DrXARlor+XRL+T5f 7S6KOJzIKNio2BD1J31YHbaWmu/9JgcHOt/s6XDBA4C/p8VQBouotIOUdA0CE5BiE8K6 i5dCvwQGpLSEy3Xv0Y7ZzrOwpbLm03wT6L17M1PqNknm9Dt5hdv6/w5rqXyDg0YTxW2M lYT22iLJ+lgPRL32rdQ73esFzNkXa2jPL1ZBQgFKL6xURzk1FQG6f4hJ9aVhuSO287JB 9SYnnfBg6OyZDLtovj+EFTEZ7qMKyBS+A5rDFzWoorB7+HLTzg64zHxE+upQLJUng40Y P+nw== X-Gm-Message-State: AIkVDXJUgauV9pgw3/hjRZJO69qrHafUh3aqNjj3+TK9coh/JHfFcB6OvdUAV9AD23lqsVoo+O4= X-Received: by 10.25.4.9 with SMTP id 9mr13176001lfe.45.1484673521490; Tue, 17 Jan 2017 09:18:41 -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 14sm9365278lju.16.2017.01.17.09.18.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Jan 2017 09:18:40 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, yi.he@linaro.org, forrest.shi@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Tue, 17 Jan 2017 19:18:00 +0100 Message-Id: <1484677083-12831-4-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484677083-12831-1-git-send-email-christophe.milard@linaro.org> References: <1484677083-12831-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv8 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); +} + +/** + * @} + */