From patchwork Wed Jan 21 04:57:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 43432 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 37EBD2034D for ; Wed, 21 Jan 2015 04:58:19 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id pv20sf8589497lab.3 for ; Tue, 20 Jan 2015 20:58:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=XGAGsme96glvqyaJZHvzHpbX/XAlosi3rJs6YsKoa+g=; b=Xe7UP9OmqAgETIJTH8GcuHl+D9oQGJKkMTzprZwzsox2mIsXCE2dkg+mvwu9jiQ/Zj dNeHnwPTeEzCD+aJn9SFJasQyq5yuAexwYuzOuVMujxZvWpn2yABipQDMk/pNUzKbDC1 8feoD2BG8h0zJvBsO2SbL9Y6V35UZEl2MvaUdQu4xXk1cGnD1MiccaROoNCwpnzyauhQ pRvc1UM39EZwDZKitJ299KsCs1Z9g0UOauqi2cr7CLhx9JY1O0jYtYQAeerHId7y7gjy W6wgCk0qChbwJZhUQ2y0dAIIb4U/ThLnQG4jbnVRP1Bv7P8rC6GDbAR44nuVm0CbwZdI IFKQ== X-Gm-Message-State: ALoCoQlX61l1NV8HCaJohopnNlOH2wVuzJjhyr2bEVKMCg+eg1jD+MgaqojzR5sLIwDXxq/esxz6 X-Received: by 10.112.160.41 with SMTP id xh9mr28009lbb.12.1421816298154; Tue, 20 Jan 2015 20:58:18 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.2.99 with SMTP id 3ls122196lat.107.gmail; Tue, 20 Jan 2015 20:58:17 -0800 (PST) X-Received: by 10.152.4.8 with SMTP id g8mr14315842lag.58.1421816297812; Tue, 20 Jan 2015 20:58:17 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id k12si18377077laa.24.2015.01.20.20.58.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 20:58:17 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id b6so11732285lbj.11 for ; Tue, 20 Jan 2015 20:58:17 -0800 (PST) X-Received: by 10.112.44.230 with SMTP id h6mr14388097lbm.98.1421816297671; Tue, 20 Jan 2015 20:58:17 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1651539lbb; Tue, 20 Jan 2015 20:58:16 -0800 (PST) X-Received: by 10.224.161.81 with SMTP id q17mr63545908qax.34.1421816296234; Tue, 20 Jan 2015 20:58:16 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id b2si3215869qak.50.2015.01.20.20.58.15 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 20 Jan 2015 20:58:16 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDnMr-0002I8-0l; Wed, 21 Jan 2015 04:58:13 +0000 Received: from mail-ob0-f175.google.com ([209.85.214.175]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDnMh-0002A7-0z for lng-odp@lists.linaro.org; Wed, 21 Jan 2015 04:58:03 +0000 Received: by mail-ob0-f175.google.com with SMTP id wp4so17037756obc.6 for ; Tue, 20 Jan 2015 20:57:57 -0800 (PST) X-Received: by 10.60.155.228 with SMTP id vz4mr23894670oeb.37.1421816277747; Tue, 20 Jan 2015 20:57:57 -0800 (PST) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id a15sm2891071oic.18.2015.01.20.20.57.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jan 2015 20:57:56 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Tue, 20 Jan 2015 22:57:40 -0600 Message-Id: <1421816266-31223-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1421816266-31223-1-git-send-email-bill.fischofer@linaro.org> References: <1421816266-31223-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 2/8] api: pool: Add pool type X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bill.fischofer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Bill Fischofer --- platform/linux-generic/Makefile.am | 1 + .../linux-generic/include/api/odp_buffer_pool.h | 20 +- .../linux-generic/include/api/odp_platform_types.h | 6 + platform/linux-generic/include/api/odp_pool.h | 202 +++++++++++++++++++++ 4 files changed, 210 insertions(+), 19 deletions(-) create mode 100644 platform/linux-generic/include/api/odp_pool.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 00bb0f9..b90b31e 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -25,6 +25,7 @@ include_HEADERS = \ $(top_srcdir)/platform/linux-generic/include/api/odp_packet_flags.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_packet.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_packet_io.h \ + $(top_srcdir)/platform/linux-generic/include/api/odp_pool.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_queue.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_rwlock.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_schedule.h \ diff --git a/platform/linux-generic/include/api/odp_buffer_pool.h b/platform/linux-generic/include/api/odp_buffer_pool.h index 8380ac1..a9d7c14 100644 --- a/platform/linux-generic/include/api/odp_buffer_pool.h +++ b/platform/linux-generic/include/api/odp_buffer_pool.h @@ -23,6 +23,7 @@ extern "C" { #include #include #include +#include /** @addtogroup odp_buffer * Operations on a buffer pool. @@ -148,25 +149,6 @@ int odp_buffer_pool_info(odp_buffer_pool_t pool, void odp_buffer_pool_print(odp_buffer_pool_t pool); /** - * Buffer alloc - * - * The validity of a buffer can be cheked at any time with odp_buffer_is_valid() - * @param pool Pool handle - * - * @return Handle of allocated buffer - * @retval ODP_BUFFER_INVALID Buffer could not be allocated - */ -odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool); - -/** - * Buffer free - * - * @param buf Buffer handle - * - */ -void odp_buffer_free(odp_buffer_t buf); - -/** * @} */ diff --git a/platform/linux-generic/include/api/odp_platform_types.h b/platform/linux-generic/include/api/odp_platform_types.h index 41ea871..2da5204 100644 --- a/platform/linux-generic/include/api/odp_platform_types.h +++ b/platform/linux-generic/include/api/odp_platform_types.h @@ -23,6 +23,12 @@ * @{ */ +/** ODP Pool */ +typedef uint32_t odp_pool_t; + +/** Invalid Pool */ +#define ODP_POOL_INVALID (0xffffffff) + /** ODP Buffer pool */ typedef uint32_t odp_buffer_pool_t; diff --git a/platform/linux-generic/include/api/odp_pool.h b/platform/linux-generic/include/api/odp_pool.h new file mode 100644 index 0000000..60962dd --- /dev/null +++ b/platform/linux-generic/include/api/odp_pool.h @@ -0,0 +1,202 @@ +/* Copyright (c) 2013, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +/** + * @file + * + * ODP pool + */ + +#ifndef ODP_POOL_H_ +#define ODP_POOL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + + +#include +#include +#include +#include + +/** @addtogroup odp_buffer + * Operations on a pool. + * @{ + */ + +/** Maximum queue name lenght in chars */ +#define ODP_POOL_NAME_LEN 32 + +/** + * Pool parameters + * Used to communicate pool creation options. + */ +typedef struct odp_pool_param_t { + union { + struct { + uint32_t size; /**< Buffer size in bytes. The + maximum number of bytes + application will store in each + buffer. */ + uint32_t align; /**< Minimum buffer alignment in bytes. + Valid values are powers of two. + Use 0 for default alignment. + Default will always be a multiple + of 8. */ + uint32_t num; /**< Number of buffers in the pool */ + } buf; +/* Reserved for packet and timeout specific params + struct { + uint32_t seg_size; + uint32_t seg_align; + uint32_t num; + } pkt; +*/ + struct { + uint32_t __res1; /* Keep struct identical to buf, */ + uint32_t __res2; /* until pool implementation is fixed*/ + uint32_t num; /**< Number of timeouts in the pool */ + } tmo; + }; + + int type; /**< Pool type */ + +} odp_pool_param_t; + +/**< Invalid pool type */ +#define ODP_POOL_TYPE_INVALID ODP_EVENT_TYPE_INVALID +/**< Packet pool*/ +#define ODP_POOL_PACKET ODP_EVENT_PACKET +/**< Buffer pool */ +#define ODP_POOL_BUFFER ODP_EVENT_BUFFER +/**< Timeout pool */ +#define ODP_POOL_TIMEOUT ODP_EVENT_TIMEOUT + + +/** + * Create a pool + * This routine is used to create a pool. It take three + * arguments: the optional name of the pool to be created, an optional shared + * memory handle, and a parameter struct that describes the pool to be + * created. If a name is not specified the result is an anonymous pool that + * cannot be referenced by odp_pool_lookup(). + * + * @param name Name of the pool, max ODP_POOL_NAME_LEN-1 chars. + * May be specified as NULL for anonymous pools. + * + * @param shm The shared memory object in which to create the pool. + * Use ODP_SHM_NULL to reserve default memory type + * for the pool type. + * + * @param params Pool parameters. + * + * @return Handle of the created pool + * @retval ODP_POOL_INVALID Pool could not be created + */ + +odp_pool_t odp_pool_create(const char *name, odp_shm_t shm, + odp_pool_param_t *params); + +/** + * Destroy a pool previously created by odp_pool_create() + * + * @param pool Handle of the pool to be destroyed + * + * @retval 0 Success + * @retval -1 Failure + * + * @note This routine destroys a previously created pool. This call + * does not destroy any shared memory object passed to + * odp_pool_create() used to store the pool contents. The caller + * takes responsibility for that. If no shared memory object was passed as + * part of the create call, then this routine will destroy any internal shared + * memory objects associated with the pool. Results are undefined if + * an attempt is made to destroy a pool that contains allocated or + * otherwise active buffers. + */ +int odp_pool_destroy(odp_pool_t pool); + +/** + * Find a pool by name + * + * @param name Name of the pool + * + * @return Handle of found pool + * @retval ODP_POOL_INVALID Pool could not be found + * + * @note This routine cannot be used to look up an anonymous pool (one created + * with no name). + */ +odp_pool_t odp_pool_lookup(const char *name); + +/** + * Pool information struct + * Used to get information about a pool. + */ +typedef struct odp_pool_info_t { + const char *name; /**< pool name */ + odp_shm_t shm; /**< handle of shared memory area + supplied by application to + contain pool, or ODP_SHM_INVALID + if this pool is managed by ODP */ + odp_pool_param_t params; /**< pool parameters */ +} odp_pool_info_t; + +/** + * Retrieve information about a pool + * + * @param pool Pool handle + * + * @param[out] info Receives an odp_pool_info_t object + * that describes the pool. + * + * @retval 0 Success + * @retval -1 Failure. Info could not be retrieved. + */ + +int odp_pool_info(odp_pool_t pool, odp_pool_info_t *info); + +/** + * Print pool info + * + * @param pool Pool handle + * + * @note This routine writes implementation-defined information about the + * specified pool to the ODP log. The intended use is for debugging. + */ +void odp_pool_print(odp_pool_t pool); + +/** + * Buffer alloc + * + * The validity of a buffer can be cheked at any time with odp_buffer_is_valid() + * @param pool Pool handle + * + * @return Handle of allocated buffer + * @retval ODP_BUFFER_INVALID Buffer could not be allocated + */ +odp_buffer_t odp_buffer_alloc(odp_pool_t pool); + +/** + * Buffer free + * + * @param buf Buffer handle + * + */ +void odp_buffer_free(odp_buffer_t buf); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif