From patchwork Wed Aug 12 18:12:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 52350 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 A8E532031F for ; Wed, 12 Aug 2015 18:12:49 +0000 (UTC) Received: by lbcje9 with SMTP id je9sf8293140lbc.3 for ; Wed, 12 Aug 2015 11:12:48 -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: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=JfwWR8TVj33ufAhOAHO4jrGyvjy8TKvEoHR+okxfDiE=; b=dS2p/9BsKPzlfeJBY3Sc2mGu7QO/C5ynzYBNWeDPkcNBGd2kBAB4+C5LNYKLs2OSoI UGMXnuVijgr/Zwty5wuUr0gcbaj2zGgE8G2yMP0yIMD/9p1zHjw+1C/lfRqdKpp2KwB2 sxzzO4fpBarcYcXPHSZpC2su/HVN8fSriOJjQlu9jNP//LMVWsJrv1O3tg8HvC0/6ohg XvxLfdOpuUmZwH52UMRXEtWHeSxNyI+KBCCKCyl8VeTkhAwUc879e+RR7y26oWdFD5b4 JnSz32509GEm8/2UNdbJ6zw/2EAElTmcKCwVVuPf1kX0jFHNyPkA+zLGTu6BzDRVmVRq U5cQ== X-Gm-Message-State: ALoCoQnEOX03A90DohmAjM3XJmRPG/mGZAZhBe732/uoz33BsqSbLE6mDVPE42i36iuKJMQqJESd X-Received: by 10.152.1.164 with SMTP id 4mr3918725lan.2.1439403168640; Wed, 12 Aug 2015 11:12:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.101 with SMTP id 5ls87521lal.59.gmail; Wed, 12 Aug 2015 11:12:48 -0700 (PDT) X-Received: by 10.112.148.162 with SMTP id tt2mr16749612lbb.121.1439403168353; Wed, 12 Aug 2015 11:12:48 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id p1si5543492laj.140.2015.08.12.11.12.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2015 11:12:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lahi9 with SMTP id i9so13589923lah.2 for ; Wed, 12 Aug 2015 11:12:48 -0700 (PDT) X-Received: by 10.112.209.106 with SMTP id ml10mr32770890lbc.112.1439403168250; Wed, 12 Aug 2015 11:12:48 -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 l6csp479221lba; Wed, 12 Aug 2015 11:12:46 -0700 (PDT) X-Received: by 10.50.7.35 with SMTP id g3mr14646718iga.39.1439403166360; Wed, 12 Aug 2015 11:12:46 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id vf4si4393578igb.72.2015.08.12.11.12.45; Wed, 12 Aug 2015 11:12:46 -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 25B4662020; Wed, 12 Aug 2015 18:12:45 +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 63AB462011; Wed, 12 Aug 2015 18:12:40 +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 4911D62015; Wed, 12 Aug 2015 18:12:38 +0000 (UTC) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by lists.linaro.org (Postfix) with ESMTPS id 3B08562006 for ; Wed, 12 Aug 2015 18:12:36 +0000 (UTC) Received: by wibhh20 with SMTP id hh20so41183099wib.0 for ; Wed, 12 Aug 2015 11:12:35 -0700 (PDT) X-Received: by 10.194.178.1 with SMTP id cu1mr70325454wjc.59.1439403155206; Wed, 12 Aug 2015 11:12:35 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by smtp.googlemail.com with ESMTPSA id h6sm24989064wiy.3.2015.08.12.11.12.34 for (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Aug 2015 11:12:34 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Wed, 12 Aug 2015 19:12:16 +0100 Message-Id: <1439403136-26964-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v2] 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.215.50 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 --- v2: - restrict this feature to packet user area - expand comments include/odp/api/packet.h | 3 +++ include/odp/api/pool.h | 25 +++++++++++++++++++++++++ 2 files changed, 28 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..80fc852 100644 --- a/include/odp/api/pool.h +++ b/include/odp/api/pool.h @@ -41,6 +41,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 choose to + * allocate the memory at that point. Applications can only assume that this + * callback were called once before the packet were first used. Any subsequent + * change to the user area might be preserved after odp_packet_free() 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 +99,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 */