From patchwork Wed Oct 8 07:50:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 38463 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E2DA920447 for ; Wed, 8 Oct 2014 07:51:45 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id hi2sf3749304wib.5 for ; Wed, 08 Oct 2014 00:51:45 -0700 (PDT) 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:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=QJw3ngaI3apc+xFC3aSL9Xs1rffPT+rLaY1eqFEsjnc=; b=RlEbgEAZjSLzIvUo8YByW6HHEoQMys9vBtW7z/Y/qpBg4Uz1iZitI/BH6M2Iwuerzl DxG4rpLESafG3QrmUW2ZHxqfEBi/hFW/Qk3wI4gRVpaZnp7Qr3O2Op0rpbf/85fI6pFG ZrzwM+k9OeUAFkv/paFmvahDEArmRDWjEGJ5SxBdWH4PBRQj8sWG4j8nJoE8QTos1U7/ xJaloCrtpyCY1d61O0yhxEbSJE5O5SkUsjq4rLRKSVY6kPaaeq6UZEEeQR7ew+X4GTON QpK9PohhffdhhwXi29v2O5i0xx1I5ygXMQIj/OI4zkBlK4czQ7o8/ZQZaigTElvxx0MT m6PA== X-Gm-Message-State: ALoCoQnfcH3zT3CdswbIES+bbAtIIahFVrT50SQgxF9M7C3kK43yh5PVLtCdt5wJWG1XEzzFj/Qw X-Received: by 10.180.79.101 with SMTP id i5mr1315928wix.5.1412754705118; Wed, 08 Oct 2014 00:51:45 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.227 with SMTP id p3ls31329laf.39.gmail; Wed, 08 Oct 2014 00:51:44 -0700 (PDT) X-Received: by 10.112.161.70 with SMTP id xq6mr9181975lbb.49.1412754704735; Wed, 08 Oct 2014 00:51:44 -0700 (PDT) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com [209.85.217.178]) by mx.google.com with ESMTPS id j15si31955363lbg.30.2014.10.08.00.51.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Oct 2014 00:51:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id w7so7523996lbi.23 for ; Wed, 08 Oct 2014 00:51:44 -0700 (PDT) X-Received: by 10.152.204.231 with SMTP id lb7mr9425292lac.44.1412754704603; Wed, 08 Oct 2014 00:51:44 -0700 (PDT) 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.84.229 with SMTP id c5csp18279lbz; Wed, 8 Oct 2014 00:51:43 -0700 (PDT) X-Received: by 10.224.166.200 with SMTP id n8mr10722285qay.46.1412754703293; Wed, 08 Oct 2014 00:51:43 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id k2si10147832qaf.20.2014.10.08.00.51.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 08 Oct 2014 00:51:43 -0700 (PDT) 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 1Xbm29-0007Sn-O9; Wed, 08 Oct 2014 07:51:41 +0000 Received: from mail-yk0-f169.google.com ([209.85.160.169]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xbm22-0007Si-Rt for lng-odp@lists.linaro.org; Wed, 08 Oct 2014 07:51:34 +0000 Received: by mail-yk0-f169.google.com with SMTP id 10so3604198ykt.0 for ; Wed, 08 Oct 2014 00:51:29 -0700 (PDT) X-Received: by 10.236.160.100 with SMTP id t64mr12479768yhk.7.1412754689492; Wed, 08 Oct 2014 00:51:29 -0700 (PDT) Received: from bala-PowerEdge-T110-II.caveonetworks.com ([111.93.218.67]) by mx.google.com with ESMTPSA id o40sm9605428yha.37.2014.10.08.00.51.26 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Oct 2014 00:51:29 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Wed, 8 Oct 2014 13:20:09 +0530 Message-Id: <1412754609-4452-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Topics: patch Subject: [lng-odp] [ODP/PATCH v1] ODP Buffer Segment Support API 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: bala.manoharan@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.178 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 This patch contains ODP Buffer Management missing APIs The intent of this patch is to port the missing APIs from Buffer Management design document into Linux-generic repo. The dummy functions will be replaced during linux-generic implementation. Signed-off-by: Balasubramanian Manoharan --- platform/linux-generic/include/api/odp_buffer.h | 203 ++++++++++++++++++++- .../linux-generic/include/api/odp_buffer_pool.h | 30 +++ platform/linux-generic/odp_buffer.c | 120 ++++++++++++ platform/linux-generic/odp_buffer_pool.c | 7 + 4 files changed, 351 insertions(+), 9 deletions(-) diff --git a/platform/linux-generic/include/api/odp_buffer.h b/platform/linux-generic/include/api/odp_buffer.h index d8577fd..aeb75ed 100644 --- a/platform/linux-generic/include/api/odp_buffer.h +++ b/platform/linux-generic/include/api/odp_buffer.h @@ -28,8 +28,34 @@ extern "C" { */ typedef uint32_t odp_buffer_t; -#define ODP_BUFFER_INVALID (0xffffffff) /**< Invalid buffer */ +/** +* ODP buffer segment +*/ +typedef uint32_t odp_buffer_segment_t; +/** +* ODP buffer type +*/ +typedef enum odp_buffer_type { + ODP_BUFFER_TYPE_INVALID = -1, /**< Buffer type invalid */ + ODP_BUFFER_TYPE_ANY = 0, /**< Buffer that can hold any other + buffer type */ + ODP_BUFFER_TYPE_RAW = 1, /**< Raw buffer, + no additional metadata */ + ODP_BUFFER_TYPE_PACKET = 2, /**< Packet buffer */ + ODP_BUFFER_TYPE_TIMEOUT = 3 /**< Timeout buffer */ +} odp_buffer_type_e; + +/** +* ODP buffer options +*/ +typedef enum odp_buffer_opts { + ODP_BUFFER_OPTS_NONE, + ODP_BUFFER_OPTS_UNSEGMENTED +} odp_buffer_opts_e; + +#define ODP_BUFFER_INVALID (0xffffffff) /**< Invalid buffer */ +#define ODP_SEGMENT_INVALID (0xffffffff) /**< Invalid segment */ /** * Buffer start address @@ -58,14 +84,6 @@ size_t odp_buffer_size(odp_buffer_t buf); */ int odp_buffer_type(odp_buffer_t buf); -#define ODP_BUFFER_TYPE_INVALID (-1) /**< Buffer type invalid */ -#define ODP_BUFFER_TYPE_ANY 0 /**< Buffer that can hold any other - buffer type */ -#define ODP_BUFFER_TYPE_RAW 1 /**< Raw buffer, no additional metadata */ -#define ODP_BUFFER_TYPE_PACKET 2 /**< Packet buffer */ -#define ODP_BUFFER_TYPE_TIMEOUT 3 /**< Timeout buffer */ - - /** * Tests if buffer is valid * @@ -76,6 +94,110 @@ int odp_buffer_type(odp_buffer_t buf); int odp_buffer_is_valid(odp_buffer_t buf); /** + * Tests if buffer is segmented + * + * @param[in] buf Buffer handle + * + * @return 1 if buffer has more than one segment, + * otherwise 0 + */ + +int odp_buffer_is_segmented(odp_buffer_t buf); + +/** + * Get address and size of user meta data associated with a buffer + * + * @param[in] buf Buffer handle + * @param[out] udata_size Number of bytes of user meta data available + * at the returned address + * @return Address of the user meta data for this buffer + * or NULL if the buffer has no user meta data. + */ +void *odp_buffer_udata(odp_buffer_t buf, size_t *udata_size); + +/** + * Get address of user meta data associated with a buffer + * + * @param[in] buf Buffer handle + * + * @return Address of the user meta data for this buffer + * or NULL if the buffer has no user meta data. + */ +void *odp_buffer_udata_addr(odp_buffer_t buf); + +/** + * Get count of number of segments in a buffer + * + * @param[in] buf Buffer handle + * + * @return Count of the number of segments in buf + */ +size_t odp_buffer_segment_count(odp_buffer_t buf); + +/** + * Get the segment identifier for a buffer segment by index + * + * @param[in] buf Buffer handle + * @param[in] ndx Segment index of segment of interest + * + * @return Segment identifier or ODP_SEGMENT_INVALID if the + * supplied ndx is out of range. + */ +odp_buffer_segment_t odp_buffer_segment_by_index(odp_buffer_t buf, size_t ndx); + +/** + * Get the next segment identifier for a buffer segment + * + * @param[in] buf Buffer handle + * @param[in] seg Segment identifier of the previous segment + * + * @return Segment identifier of the next segment, + or ODP_SEGMENT_INVALID. + */ +odp_buffer_segment_t odp_buffer_segment_next(odp_buffer_t buf, + odp_buffer_segment_t seg); +/** + * Get start address for a specified buffer segment + * + * @param[in] buf Buffer handle + * @param[in] seg Segment identifier of the buffer to be addressed + * @param[out] seglen Returned number of bytes in this buffer + * segment available at returned address + * + * @return Segment start address or NULL + */ +void *odp_buffer_segment_map(odp_buffer_t buf, odp_buffer_segment_t seg, +size_t *seglen); + +/** + *Unmap a buffer segment + * + * @param[in] seg Buffer segment handle + */ +void odp_buffer_segment_unmap(odp_buffer_segment_t seg); + +/** +* Get start address for a specified buffer offset +* +* @param[in] buf Buffer handle +* @param[in] offset Byte offset within the buffer to be addressed +* @param[out] seglen Returned number of bytes in this buffer +* segment available at returned address +* +* @return Offset start address or NULL +*/ +void *odp_buffer_offset_map(odp_buffer_t buf, size_t offset, +size_t *seglen); + +/** + * Unmap a buffer segment by offset + * + * @param[in] buf Buffer handle + * @param[in] offset Buffer offset + */ +void odp_buffer_offset_unmap(odp_buffer_t buf, size_t offset); + +/** * Print buffer metadata to STDOUT * * @param buf Buffer handle @@ -83,6 +205,69 @@ int odp_buffer_is_valid(odp_buffer_t buf); */ void odp_buffer_print(odp_buffer_t buf); +/** + * Split a buffer into two buffers at a specified split point + * + * @param[in] buf Handle of buffer to split + * @param[in] offset Byte offset within buf to split buffer + * + * @return Buffer handle of the created split buffer + */ +odp_buffer_t odp_buffer_split(odp_buffer_t buf, size_t offset); + +/** + * Join two buffers into a single buffer + * + * @param[in] buf1 Buffer handle of first buffer to join + * @param[in] buf2 Buffer handle of second buffer to join + * + * @return Buffer handle of the joined buffer + */ +odp_buffer_t odp_buffer_join(odp_buffer_t buf1, odp_buffer_t buf2); + +/** + * Trim a buffer at a specified trim point + * + * @param[in] buf Buffer handle of buffer to trim + * @param[in] offset byte offset within buf to trim + * + * @return Handle of the trimmed buffer or + * ODP_BUFFER_INVALID if the operation was not performed + */ +odp_buffer_t odp_buffer_trim(odp_buffer_t buf, size_t offset); +/** + * Extend a buffer for a specified number of bytes + * + * @param[in] buf Buffer handle of buffer to expand + * @param[in] ext size, in bytes, of the extent to add to the + * existing buffer. + * + * @return Handle of the extended buffer or ODP_BUFFER_INVALID + * if the operation was not performed + */ +odp_buffer_t odp_buffer_extend(odp_buffer_t buf, size_t ext); + +/** + * Clone a buffer, returning an exact copy of it + * + * @param[in] buf Buffer handle of buffer to duplicate + * + * @return Handle of the duplicated buffer or ODP_BUFFER_INVALID + * if the operation was not performed + */ +odp_buffer_t odp_buffer_clone(odp_buffer_t buf); + +/** + * Copy a buffer, returning an exact copy of it + * + * @param[in] buf Buffer handle of buffer to copy + * + * @return Handle of the copied buffer or ODP_BUFFER_INVALID + * if the operation was not performed + */ +odp_buffer_t odp_buffer_copy(odp_buffer_t buf); + + #ifdef __cplusplus } diff --git a/platform/linux-generic/include/api/odp_buffer_pool.h b/platform/linux-generic/include/api/odp_buffer_pool.h index fe88898..f85d96c 100644 --- a/platform/linux-generic/include/api/odp_buffer_pool.h +++ b/platform/linux-generic/include/api/odp_buffer_pool.h @@ -52,6 +52,27 @@ odp_buffer_pool_t odp_buffer_pool_create(const char *name, /** + * Get the next buffer pool from its predecessor + * + * @param[in] pool Buffer pool handle + * @param[out] name Name of the pool + * (max ODP_BUFFER_POOL_NAME_LEN - 1 chars) + * @param[out] udata_size Size of user meta data used by this pool. + * @param[out] buf_num Number of buffers contained in this pool + * @param[out] buf_size Default size of application data in each buffer + * @param[out] buf_type Buffer type of the pool + * @param[out] buf_opts Buffer options for this pool + * @param[out] predef Predefined (1) or Created (0). + * + * @return Buffer pool handle + */ +odp_buffer_pool_t odp_buffer_pool_next(odp_buffer_pool_t pool, + char *name, size_t *udata_size, + size_t *buf_num, size_t *buf_size, + enum odp_buffer_type *buf_type, + enum odp_buffer_opts *buf_opts, + uint32_t *predef); +/** * Find a buffer pool by name * * @param name Name of the pool @@ -80,6 +101,15 @@ void odp_buffer_pool_print(odp_buffer_pool_t pool); */ odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool); +/** +* Allocate a buffer from a buffer pool +* +* @param[in] pool Pool handle +* @param[in] size Size of object to store in buffer +* +* @return Buffer handle or ODP_BUFFER_INVALID +*/ +odp_buffer_t odp_buffer_alloc_size(odp_buffer_pool_t pool, size_t size); /** * Buffer free diff --git a/platform/linux-generic/odp_buffer.c b/platform/linux-generic/odp_buffer.c index e54e0e7..7f4b4f0 100644 --- a/platform/linux-generic/odp_buffer.c +++ b/platform/linux-generic/odp_buffer.c @@ -45,6 +45,21 @@ int odp_buffer_is_valid(odp_buffer_t buf) return (handle.index != ODP_BUFFER_INVALID_INDEX); } +int odp_buffer_is_segmented(odp_buffer_t buf) +{ + odp_buffer_hdr_t *buf_hdr = odp_buf_to_hdr(buf); + + if (buf_hdr->scatter.num_bufs == 0) + return 0; + else + return 1; +} + +size_t odp_buffer_segment_count(odp_buffer_t buf) +{ + odp_buffer_hdr_t *buf_hdr = odp_buf_to_hdr(buf); + return (size_t)buf_hdr->scatter.num_bufs + 1; +} int odp_buffer_snprint(char *str, size_t n, odp_buffer_t buf) { @@ -101,8 +116,113 @@ void odp_buffer_print(odp_buffer_t buf) printf("\n%s\n", str); } +void *odp_buffer_udata(odp_buffer_t buf, size_t *udata_size) +{ + (void)buf; + (void)udata_size; + ODP_UNIMPLEMENTED(); + return 0; +} + +void *odp_buffer_udata_addr(odp_buffer_t buf) +{ + (void)buf; + ODP_UNIMPLEMENTED(); + return 0; +} + +odp_buffer_segment_t odp_buffer_segment_by_index(odp_buffer_t buf, + size_t ndx) +{ + (void)buf; + (void)ndx; + ODP_UNIMPLEMENTED(); + return 0; +} + +odp_buffer_segment_t odp_buffer_segment_next(odp_buffer_t buf, + odp_buffer_segment_t seg) +{ + (void)buf; + (void)seg; + ODP_UNIMPLEMENTED(); + return 0; +} + +void *odp_buffer_segment_map(odp_buffer_t buf, odp_buffer_segment_t seg, + size_t *seglen) +{ + (void)buf; + (void)seg; + (void)seglen; + ODP_UNIMPLEMENTED(); + return 0; +} +void *odp_buffer_offset_map(odp_buffer_t buf, size_t offset, +size_t *seglen) +{ + (void)buf; + (void)offset; + (void)seglen; + ODP_UNIMPLEMENTED(); + return 0; +} +void odp_buffer_offset_unmap(odp_buffer_t buf, size_t offset) +{ + (void)buf; + (void)offset; + ODP_UNIMPLEMENTED(); + return; +} + void odp_buffer_copy_scatter(odp_buffer_t buf_dst, odp_buffer_t buf_src) { (void)buf_dst; (void)buf_src; } + +odp_buffer_t odp_buffer_split(odp_buffer_t buf, size_t offset) +{ + (void)buf; + (void)offset; + ODP_UNIMPLEMENTED(); + return 0; +} + +odp_buffer_t odp_buffer_join(odp_buffer_t buf1, odp_buffer_t buf2) +{ + (void)buf1; + (void)buf2; + ODP_UNIMPLEMENTED(); + return 0; +} + +odp_buffer_t odp_buffer_trim(odp_buffer_t buf, size_t offset) +{ + (void)buf; + (void)offset; + ODP_UNIMPLEMENTED(); + return 0; +} +odp_buffer_t odp_buffer_extend(odp_buffer_t buf, size_t ext) +{ + (void)buf; + (void)ext; + ODP_UNIMPLEMENTED(); + return 0; +} + +odp_buffer_t odp_buffer_clone(odp_buffer_t buf) +{ + (void)buf; + ODP_UNIMPLEMENTED(); + return 0; +} + +odp_buffer_t odp_buffer_copy(odp_buffer_t buf) +{ + (void)buf; + ODP_UNIMPLEMENTED(); + return 0; +} + diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index a48d7d6..bff4db5 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -471,6 +471,13 @@ odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool_hdl) return handle.u32; } +odp_buffer_t odp_buffer_alloc_size(odp_buffer_pool_t pool, size_t size) +{ + (void)pool; + (void) size; + ODP_ERR("%s function is yet to be implemented", __func__); + return 0; +} void odp_buffer_free(odp_buffer_t buf) {