From patchwork Fri Aug 14 18:55:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 52460 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 3E0EA22B12 for ; Fri, 14 Aug 2015 18:59:09 +0000 (UTC) Received: by lbck9 with SMTP id k9sf29363262lbc.0 for ; Fri, 14 Aug 2015 11:59:07 -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: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=3jSpgJuVREwg45t5S37FwAXRI9MrKRw9tIY6F4QR3s8=; b=GfhVYSoz0eRbrvKzhCbd7h7Nf9451ekXtwLwa1Lv3EjRyF2rLoldBsDmcUkQD2Jjpr 73JTRgmAcw6E7EEQYsy/m1z6FsI28RCiL9gsRyg7JpxPoxfbrX2c8qH/uQg465L9rMtA eDDEVpNPnBRrYdPJvh+l1VBGqnFVfN8x1LTMUlzAGxhJsxRocPBlG/sSWyYplc7ijbah KHvqkCs+T3onVul81rzeWPeDAr6Ifvp9gG13z6NuSXdUwgvpaXgwQrDF38+HTgmzwHh6 XgaqfXsKN+UzC4SgQ2hDbSnUXzyufsWdpV8wGxHmoQr70WQh1DHB7eT4L4wQ1RMsENwJ Z9aQ== X-Gm-Message-State: ALoCoQmwJ4aeqRJsPFgDikFyZle1Y95p1NiSrQldEj4YT4mneOYVNz6uyKGsMYx0U8SAgngHPkEw X-Received: by 10.112.54.166 with SMTP id k6mr13432719lbp.0.1439578747852; Fri, 14 Aug 2015 11:59:07 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.8.171 with SMTP id dl11ls371733lad.28.gmail; Fri, 14 Aug 2015 11:59:07 -0700 (PDT) X-Received: by 10.112.157.136 with SMTP id wm8mr21143560lbb.26.1439578747695; Fri, 14 Aug 2015 11:59:07 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id f3si6511904lag.4.2015.08.14.11.59.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Aug 2015 11:59:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbpu9 with SMTP id pu9so50696900lbb.3 for ; Fri, 14 Aug 2015 11:59:07 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr45088083lbc.112.1439578747570; Fri, 14 Aug 2015 11:59:07 -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.7.198 with SMTP id l6csp1817850lba; Fri, 14 Aug 2015 11:59:06 -0700 (PDT) X-Received: by 10.140.237.70 with SMTP id i67mr41690136qhc.48.1439578745932; Fri, 14 Aug 2015 11:59:05 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p40si10934190qkh.123.2015.08.14.11.59.04; Fri, 14 Aug 2015 11:59:05 -0700 (PDT) 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; Received: by lists.linaro.org (Postfix, from userid 109) id C56F96229E; Fri, 14 Aug 2015 18:59:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 2713E61CE1; Fri, 14 Aug 2015 18:58:59 +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 022E36228E; Fri, 14 Aug 2015 18:58:10 +0000 (UTC) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by lists.linaro.org (Postfix) with ESMTPS id 8406F622A9 for ; Fri, 14 Aug 2015 18:55:55 +0000 (UTC) Received: by wicja10 with SMTP id ja10so26541872wic.1 for ; Fri, 14 Aug 2015 11:55:54 -0700 (PDT) X-Received: by 10.194.90.225 with SMTP id bz1mr2422252wjb.110.1439578554600; Fri, 14 Aug 2015 11:55:54 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by smtp.googlemail.com with ESMTPSA id jr5sm9498962wjc.14.2015.08.14.11.55.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Aug 2015 11:55:54 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Fri, 14 Aug 2015 19:55:42 +0100 Message-Id: <1439578544-12730-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439486903-14811-1-git-send-email-zoltan.kiss@linaro.org> References: <1439486903-14811-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v4 1/3] api: pool: add packet user area initializer for pool creation parameters X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zoltan.kiss@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.177 as permitted sender) smtp.mailfrom=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 Applications can preset certain parts of the packet user area, so when that memory will be allocated it starts from a known state. If the platform allocates the memory during pool creation, it's enough to run the constructor after that. If it's allocating memory on demand, it should call the constructor each time. Porting applications to ODP can benefit from this. If the application can't afford to change its whole packet handling to ODP, it's likely it needs to maintain its own metadata in the user area. And probably it needs to set constant fields in that metadata e.g. to mark that this is an ODP packet, and/or store the handle of the packet itself. Signed-off-by: Zoltan Kiss Reviewed-by: Balasubramanian Manoharan --- v2: - restrict this feature to packet user area - expand comments v3: - include packet.h in pool.h v4: - fix grammar based on Bill's comments include/odp/api/packet.h | 3 +++ include/odp/api/pool.h | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/odp/api/packet.h b/include/odp/api/packet.h index 3a454b5..f5d2142 100644 --- a/include/odp/api/packet.h +++ b/include/odp/api/packet.h @@ -73,6 +73,9 @@ extern "C" { * @note The default headroom and tailroom used for packets is specified by * the ODP_CONFIG_PACKET_HEADROOM and ODP_CONFIG_PACKET_TAILROOM defines in * odp_config.h. + * @note Data changed in user area might be preserved by the platform from + * previous usage of the buffer, so values preset in uarea_init() are not + * guaranteed. */ odp_packet_t odp_packet_alloc(odp_pool_t pool, uint32_t len); diff --git a/include/odp/api/pool.h b/include/odp/api/pool.h index 2e79a55..01f770f 100644 --- a/include/odp/api/pool.h +++ b/include/odp/api/pool.h @@ -21,6 +21,7 @@ extern "C" { #include +#include /** @defgroup odp_pool ODP POOL * Operations on a pool. @@ -41,6 +42,23 @@ extern "C" { #define ODP_POOL_NAME_LEN 32 /** + * Packet user area initializer callback function for pools. + * + * @param pkt Handle of the packet + * @param uarea_init_arg Opaque pointer defined in odp_pool_param_t + * + * @note If the application specifies this pointer, it expects that every buffer + * is initialized exactly once with it when the underlying memory is allocated. + * It is not called from odp_packet_alloc(), unless the platform chooses to + * allocate the memory at that point. Applications can only assume that this + * callback is called once before the packet is first used. Any subsequent + * change to the user area might be preserved after odp_packet_free() is called, + * so applications should take care of (re)initialization if they change data + * preset by this function. + */ +typedef void (odp_packet_uarea_init_t)(odp_packet_t pkt, void *uarea_init_arg); + +/** * Pool parameters * Used to communicate pool creation options. */ @@ -82,6 +100,14 @@ typedef struct odp_pool_param_t { /** User area size in bytes. Specify as 0 if no user area is needed. */ uint32_t uarea_size; + + /** Initialize every packet's user area at allocation + time. Use NULL if no initialization needed. */ + odp_packet_uarea_init_t *uarea_init; + + /** Opaque pointer passed to packet user area + constructor. */ + void *uarea_init_arg; } pkt; struct { /** Number of timeouts in the pool */