From patchwork Sat Jun 21 00:16:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rosenboim, Leonid" X-Patchwork-Id: 32300 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 851C1203C2 for ; Sat, 21 Jun 2014 00:16:27 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id y20sf28833578ier.1 for ; Fri, 20 Jun 2014 17:16:27 -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:thread-topic:thread-index :date:message-id:references:in-reply-to:accept-language:mime-version :cc:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-language:content-type; bh=UECxBTUjYubzTqoR0nI9cHZ1CnYbfgYEzunpj/cusT0=; b=Mhv4+LTlUp5LeHYkC0H6eEMyGEWbaD/JLxy08HMDE5zZDLvqoY5qHrs1DOkRD/IZJo eZVGUjJYNNsr9tGKHWohGPmQy7P4ZyCGqjT1Knyag4X0ZjkSLq/RLS0/8gFFQ4jP1t5L eBrzgeQABMqh8KmCCFvDVWHrTtMsp8MX3uNmzBmF0rnDfDpZ1+8j3P4NrCmoTJVVwUcU CkxS5147SHFk7Ac0g6gyvIA5L99NvIamJGt32uB3A8kj0p2P3e46MsvvIi3+fMKtlhsi +ayfhfpMriGi76vm233E0hbF9vCvA2ztRpKgp7qJAJsrHIMcU59+cfXqPPndzyfQ7Ztr cYzw== X-Gm-Message-State: ALoCoQnRcY0kbTMOg4qSzH9/6ujEHQ8SuZeTbxoEnzNSpCfMspQCEd0q3JJem2NxI6bAWqyjaHXs X-Received: by 10.182.125.4 with SMTP id mm4mr2626509obb.49.1403309786944; Fri, 20 Jun 2014 17:16:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.131 with SMTP id b3ls243795qge.29.gmail; Fri, 20 Jun 2014 17:16:26 -0700 (PDT) X-Received: by 10.220.114.140 with SMTP id e12mr217583vcq.37.1403309786824; Fri, 20 Jun 2014 17:16:26 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id fj4si1571006vcb.24.2014.06.20.17.16.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Jun 2014 17:16:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id oy12so4256361veb.9 for ; Fri, 20 Jun 2014 17:16:26 -0700 (PDT) X-Received: by 10.220.103.141 with SMTP id k13mr5671856vco.25.1403309786600; Fri, 20 Jun 2014 17:16:26 -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.221.37.5 with SMTP id tc5csp58784vcb; Fri, 20 Jun 2014 17:16:26 -0700 (PDT) X-Received: by 10.140.89.201 with SMTP id v67mr9879664qgd.71.1403309785791; Fri, 20 Jun 2014 17:16:25 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id u10si12977886qab.8.2014.06.20.17.16.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 20 Jun 2014 17:16:25 -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-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Wy8x2-00020s-GS; Sat, 21 Jun 2014 00:14:36 +0000 Received: from mail-by2lp0244.outbound.protection.outlook.com ([207.46.163.244] helo=na01-by2-obe.outbound.protection.outlook.com) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Wy8ww-00020m-4J for lng-odp@lists.linaro.org; Sat, 21 Jun 2014 00:14:30 +0000 Received: from SN2PR07MB031.namprd07.prod.outlook.com (10.255.174.41) by SN2PR07MB029.namprd07.prod.outlook.com (10.255.174.39) with Microsoft SMTP Server (TLS) id 15.0.969.15; Sat, 21 Jun 2014 00:16:11 +0000 Received: from SN2PR07MB031.namprd07.prod.outlook.com ([169.254.1.192]) by SN2PR07MB031.namprd07.prod.outlook.com ([169.254.1.192]) with mapi id 15.00.0969.007; Sat, 21 Jun 2014 00:16:10 +0000 From: "Rosenboim, Leonid" To: Bala Manoharan , Ciprian Barbu Thread-Topic: [lng-odp] [PATCH]ODP Buffer Management support for Scatter-gather list Thread-Index: AQHPib4IguYgupJkME2Q0StDLhVQ05t4LAWAgAB4mgCAAR+xgIAAegQAgAB4bm4= Date: Sat, 21 Jun 2014 00:16:10 +0000 Message-ID: <1403309770199.7872@caviumnetworks.com> References: <1402960310-11288-1-git-send-email-bala.manoharan@linaro.org> , In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [64.2.3.195] x-microsoft-antispam: BCL:0;PCL:0;RULEID: x-forefront-prvs: 0249EFCB0B x-forefront-antispam-report: SFV:NSPM; SFS:(428001)(53754006)(51444003)(199002)(189002)(377454003)(24454002)(85306003)(77096002)(74662001)(99286002)(31966008)(95666004)(99396002)(36756003)(46102001)(77982001)(4396001)(76482001)(79102001)(83322001)(19580405001)(19580395003)(18206015023)(74502001)(15975445006)(106356001)(86362001)(92726001)(21056001)(561944003)(92566001)(50986999)(15202345003)(76176999)(54356999)(106116001)(85852003)(64706001)(20776003)(80022001)(66066001)(83072002)(105586002)(87936001)(81342001)(2656002)(101416001)(81542001)(16236675004)(93886003)(85806002)(19607625011); DIR:OUT; SFP:; SCL:1; SRVR:SN2PR07MB029; H:SN2PR07MB031.namprd07.prod.outlook.com; FPR:; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (: caviumnetworks.com does not designate permitted sender hosts) MIME-Version: 1.0 X-OriginatorOrg: caviumnetworks.com X-Topics: patch Cc: lng-odp-forward Subject: Re: [lng-odp] [PATCH]ODP Buffer Management support for Scatter-gather list 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: , 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: leonid.rosenboim@caviumnetworks.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.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 Content-Language: en-US Here are my 2 cents: Regarding buffer split/merge APIs, I can think of situations where an implementation might need to allocate an additional buffer if there is no sufficient space for e.g. storing the S/G array, so I suggest to add a odp_pool_t argument to both split and merge functions. An application that has no specific preference, may just pass the value of the first buffer's pool identifier in that argument, and I think that should fit most application needs. Regarding the request to be able to create buffers from application-specified memory regions, I strongly recommend to assign this functionality to odp_buffer_pool.h module, instead of odp_buffer.h, and to create an API for creating a pool using user-supplied memory range. An application then can create a buffer pool using that special memory (e.g. shmem), and subsequently use the pool id to allocate and release (bot explicitly and implicitly) buffers from that pool as required. - Leo diff --git a/include/odp_buffer.h b/include/odp_buffer.h index d79e76d..c313168 100644 --- a/include/odp_buffer.h +++ b/include/odp_buffer.h @@ -92,6 +92,79 @@ int odp_buffer_is_valid(odp_buffer_t buf); */ void odp_buffer_print(odp_buffer_t buf); +/** +*Number of segments in this scatter-gather List +* +*@param buf Buffer Handle +* +*@return Total number of segments in this scatter-gather List. +* +**/ +int odp_buffer_segment_count(odp_buffer_t buf) + +/** +*Address of the segment in the buffer list. +* +*@param buf Buffer Handle +*@param n Index number for the segment in the SG list +*@param size Returns the size of the current addressable segment + +*@return Segment start address +**/ + +void* odp_buffer_segment_addr(odp_buffer_t buf, int n, size_t* size); + +/* +*Creates ODP Buffer from a memory region +* +*@param addr Address of the memory region +*@param size Size of the memory region +* +*@return Buffer Handle to the newly create odp buffer +*/ +odp_buffer_t odp_buffer_from_memory_region(void* addr, int size ); We should keep consistent with buffer sizes, odp_buffer_size for instance returns a size_t. Also, does this assume that the data will be copied, so that the user can safely free the memory area pointed to by addr? + +/** +* Merge Buffer list into a singe buffer +*@param buf Array of ODP Buffer Handles +*@param num Number of Buffers in the buf Array + +*@return Buffer Handle to the newly created odp buffer +**/ +odp_buffer_t odp_buffer_merge(odp_buffer_t[] buf, int num); + Which pool should the resulting buffer be allocated from? Will there be an SG list in the resulting buffer or just one big chunk? +/** +* Split a single Buffer into a list of odp buffers +* +*@param buf Buffer Handle +* +*@param size Maximum size of the individual buffers +* +*@return Array of newly created Buffer Handle +**/ +odp_buffer_t[] odp_buffer_split(odp_buffer_t buf, int size); This doesn't seem entirely related to SG support. Is there zero-copy here? + +/** +* Append a buffer at the end of a scatter-gather list of buffer +* +*@param buf Buffer Handle to the scatter-gather list of buffer +* +*@param tail Buffer Handle to the buffer which is appended +* +*@return 1 if success 0 otherwise +**/ +int odp_buffer_append(odp_buffer_t buf, odp_buffer_t tail ); + +/** +* Add a buffer at the head of a existing Scatter-gather Buffer +* +*@param buf Buffer Handle to the scatter-gather list of buffer +*