From patchwork Tue Aug 11 18:31:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 52320 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 65DE122FEC for ; Tue, 11 Aug 2015 18:31:51 +0000 (UTC) Received: by lbcje9 with SMTP id je9sf20718205lbc.3 for ; Tue, 11 Aug 2015 11:31:50 -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=eNRtikhfypgIfjuI3C6LDXx+bPFwu+X7BFt4zGj1nnM=; b=LkxFIbMm4lD4d1+t2QyMOOkb6LRdYS5jhGEKDvJ/6YuH0QHvwCphmKqglTGGeyUyDH xE90/Aq3/oKuXUxJDeN6/2RrGOgpnygNyQ50xLfSF446SKFHpoiv0GXqUlE21bO5Kbt7 gBo3I8zOpGShbyFW32Pg/7hg7xTAeH54SJclHjepz9WU4jjfzVXkjlNWEvpRggVE6EBT nZMrLwCzipcOwLNmDyrGcOpbB0FI/3/w9E36T6xM+wZ3bT52wA/blYC4hzdIrpiFHR1d 2gO7nR9djEDGkvr9QxIRFy/IWk5idFtc17FEVFS5dq4Il4YW8DzdwddgfV4lvjwfYiL+ Mhvg== X-Gm-Message-State: ALoCoQnePZvvhgp24H4b9mJQBIeOnIOZyiAqZCnYaDaNDnkcmXZsmEL3Zs396l9IF9ERwM/nWeAp X-Received: by 10.112.119.166 with SMTP id kv6mr7286632lbb.3.1439317910449; Tue, 11 Aug 2015 11:31:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.8.171 with SMTP id dl11ls762320lad.28.gmail; Tue, 11 Aug 2015 11:31:50 -0700 (PDT) X-Received: by 10.112.53.229 with SMTP id e5mr27529695lbp.61.1439317909986; Tue, 11 Aug 2015 11:31:49 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id i19si1965427lbh.10.2015.08.11.11.31.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Aug 2015 11:31:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbcbn3 with SMTP id bn3so23898834lbc.2 for ; Tue, 11 Aug 2015 11:31:49 -0700 (PDT) X-Received: by 10.152.26.163 with SMTP id m3mr27774380lag.86.1439317909882; Tue, 11 Aug 2015 11:31:49 -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 l6csp2688935lba; Tue, 11 Aug 2015 11:31:48 -0700 (PDT) X-Received: by 10.107.134.96 with SMTP id i93mr29697933iod.139.1439317908535; Tue, 11 Aug 2015 11:31:48 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h10si1872709iga.77.2015.08.11.11.31.47; Tue, 11 Aug 2015 11:31:48 -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 4439362099; Tue, 11 Aug 2015 18:31:47 +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 4688061E93; Tue, 11 Aug 2015 18:31:42 +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 CD83B61FA6; Tue, 11 Aug 2015 18:31:39 +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 DF56361E90 for ; Tue, 11 Aug 2015 18:31:38 +0000 (UTC) Received: by wijp15 with SMTP id p15so187915636wij.0 for ; Tue, 11 Aug 2015 11:31:37 -0700 (PDT) X-Received: by 10.194.158.34 with SMTP id wr2mr59019620wjb.23.1439317897323; Tue, 11 Aug 2015 11:31:37 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by smtp.googlemail.com with ESMTPSA id lk16sm4571230wic.6.2015.08.11.11.31.36 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Aug 2015 11:31:36 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Tue, 11 Aug 2015 19:31:22 +0100 Message-Id: <1439317883-9334-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] api: pool: add buffer constructor 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.170 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 buffer or 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. Signed-off-by: Zoltan Kiss --- include/odp/api/pool.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/odp/api/pool.h b/include/odp/api/pool.h index 2e79a55..1bd19bf 100644 --- a/include/odp/api/pool.h +++ b/include/odp/api/pool.h @@ -41,6 +41,20 @@ extern "C" { #define ODP_POOL_NAME_LEN 32 /** + * Buffer constructor callback function for pools. + * + * @param pool Handle of the pool which owns the buffer + * @param buf_ctor_arg Opaque pointer defined in odp_pool_param_t + * @param buf Pointer to the buffer + * + * @note If the application specifies this pointer, it expects that every buffer + * is initialized with it when the underlying memory is allocated. + */ +typedef void (odp_pool_buf_ctor_t)(odp_pool_t pool, + void *buf_ctor_arg, + void *buf); + +/** * Pool parameters * Used to communicate pool creation options. */ @@ -88,6 +102,12 @@ typedef struct odp_pool_param_t { uint32_t num; } tmo; }; + + /** Buffer constructor to initialize every buffer. Use NULL if no + initialization needed. */ + odp_pool_buf_ctor_t *buf_ctor; + /** Opaque pointer passed to buffer constructor */ + void *buf_ctor_arg; } odp_pool_param_t; /** Packet pool*/