From patchwork Thu Sep 25 20:25:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rosenboim, Leonid" X-Patchwork-Id: 37934 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 029C820560 for ; Thu, 25 Sep 2014 20:25:50 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id hi2sf5006270wib.7 for ; Thu, 25 Sep 2014 13:25: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: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=q6tDwSdtOLA0+vHA2XSxLHeYB7fs4olXX/SDq8Dj154=; b=l64TsaQyMXLudlzolZCTvGmB6kY8q/XnYMkZUfXh8/4/CS655Y29yzwE+lKwRUd5AY v5B4JOYf8ATUYPj1VOTRGXWDO/fBk8MqwagU3x6pt5yfFPoYbmGghFto8FV38x4wisbq ct8h0IrrXnVRtLuRkRs9tcTkUDA/b7M+oKcCjFxkPfc+YjYIO8I3rrMlf8Ai0hy7CnZz OxlQbNIzq2udtv2WfLeSw1VMu/hsrt7rNlctGEGP/YaBAwCBGAqdwcnnckIrJrPQDR2b +H20meWusVpL4VzHEpynDc3rMpM9pG+gj9BumcPik195A+UwvriUn65vp4c+Q/H+/qki M71g== X-Gm-Message-State: ALoCoQnep1kcb4JtAG3uQZj5CpBFJoLFpSFnnqDHtTLzrXEKlopMswOf5/B6pyI0G3i4g+k7UKS+ X-Received: by 10.152.21.137 with SMTP id v9mr2482447lae.1.1411676750161; Thu, 25 Sep 2014 13:25:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.103 with SMTP id v7ls348347lal.32.gmail; Thu, 25 Sep 2014 13:25:49 -0700 (PDT) X-Received: by 10.112.164.203 with SMTP id ys11mr14970388lbb.83.1411676749815; Thu, 25 Sep 2014 13:25:49 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by mx.google.com with ESMTPS id i9si4472896lbv.104.2014.09.25.13.25.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Sep 2014 13:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id l4so13383478lbv.30 for ; Thu, 25 Sep 2014 13:25:49 -0700 (PDT) X-Received: by 10.152.179.226 with SMTP id dj2mr15996264lac.40.1411676749452; Thu, 25 Sep 2014 13:25: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.130.169 with SMTP id of9csp820182lbb; Thu, 25 Sep 2014 13:25:48 -0700 (PDT) X-Received: by 10.224.46.6 with SMTP id h6mr22726498qaf.45.1411676747979; Thu, 25 Sep 2014 13:25:47 -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 f11si3749105qgd.22.2014.09.25.13.25.46 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 25 Sep 2014 13:25:47 -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 1XXFbk-0001e8-Mp; Thu, 25 Sep 2014 20:25:44 +0000 Received: from mail-bl2on0064.outbound.protection.outlook.com ([65.55.169.64] helo=na01-bl2-obe.outbound.protection.outlook.com) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XXFbb-0001Ye-Ui for lng-odp@lists.linaro.org; Thu, 25 Sep 2014 20:25:36 +0000 Received: from SN2PR07MB031.namprd07.prod.outlook.com (10.255.174.41) by SN2PR07MB031.namprd07.prod.outlook.com (10.255.174.41) with Microsoft SMTP Server (TLS) id 15.0.1034.13; Thu, 25 Sep 2014 20:25:27 +0000 Received: from SN2PR07MB031.namprd07.prod.outlook.com ([169.254.1.203]) by SN2PR07MB031.namprd07.prod.outlook.com ([169.254.1.203]) with mapi id 15.00.1034.003; Thu, 25 Sep 2014 20:25:27 +0000 From: "Rosenboim, Leonid" To: Ola Liljedahl , Bill Fischofer Thread-Topic: [lng-odp] [PATCH] Add API odp_buffer_pool_delete Thread-Index: AQHP2DQdJMrlnjLP0USweauXKEI6TJwRzZ+AgAAvw1qAAARrgIAAIP4AgAAo6aY= Date: Thu, 25 Sep 2014 20:25:27 +0000 Message-ID: <1411676727128.92858@caviumnetworks.com> References: <1411589561-20050-1-git-send-email-anders.roxell@linaro.org> <1411589561-20050-2-git-send-email-anders.roxell@linaro.org> <1411660186731.24886@caviumnetworks.com> , In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [64.2.3.195] x-microsoft-antispam: BCL:0;PCL:0;RULEID:;SRVR:SN2PR07MB031; x-forefront-prvs: 0345CFD558 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(35774003)(377454003)(199003)(24454002)(53754006)(189002)(15975445006)(19627405001)(76482002)(77982003)(20776003)(21056001)(76176999)(19580395003)(66066001)(81542003)(15202345003)(99286002)(77096002)(31966008)(106116001)(85306004)(50986999)(46102003)(74502003)(64706001)(4396001)(101416001)(19617315012)(54356999)(83072002)(85852003)(106356001)(97736003)(83322001)(99396003)(81342003)(19580405001)(85806002)(92726001)(2656002)(16236675004)(36756003)(117636001)(74662003)(95666004)(87936001)(90102001)(105586002)(79102003)(86362001)(16601075003)(80022003)(92566001)(10300001)(93886004)(120916001)(107046002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR07MB031; H:SN2PR07MB031.namprd07.prod.outlook.com; FPR:; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-OriginatorOrg: caviumnetworks.com X-Topics: patch Cc: lng-odp-forward Subject: Re: [lng-odp] [PATCH] Add API odp_buffer_pool_delete 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.217.171 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 Ola, Do you have any specific platform in mind when writing this remark ? I am having some difficulty wrapping my head around this remark, because it is hard for me to imagine how a buffer pool can keep track of free buffers, yet unable to tell how many such free buffers currently available in storage. If it can not track the number of free buffers, how would it know to tell that it is empty and refuse an allocation request. Alternatively, if a pool implements a counter of free buffers rather than allocated (outstanding) buffers, all that is needed to implement the functionality I proposed, os to save the buffer count that was supplied at creation time, and compare that with free buffer count, presto. In other words, what use is a buffer pool if it cant even track the number of buffers it has to offer for allocation ? - Leo diff --git a/platform/linux-generic/include/api/odp_buffer_pool.h b/platform/linux-generic/include/api/odp_buffer_pool.h index fe88898..fca2c62 100644 --- a/platform/linux-generic/include/api/odp_buffer_pool.h +++ b/platform/linux-generic/include/api/odp_buffer_pool.h @@ -34,6 +34,15 @@ typedef uint32_t odp_buffer_pool_t; /** + * Delete a buffer pool + * + * @param pool_hdl Buffer pool handle + * + * @return 0 if successful else -1 + */ +int odp_buffer_pool_delete(odp_buffer_pool_t pool_hdl); + +/** * Create a buffer pool * * @param name Name of the pool (max ODP_BUFFER_POOL_NAME_LEN - 1 chars) diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index 4d9ff45..7ba793d 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -375,6 +375,31 @@ static void link_bufs(pool_entry_t *pool) } } +int odp_buffer_pool_delete(odp_buffer_pool_t pool_hdl) +{ + pool_entry_t *pool; + if (odp_unlikely(ODP_CONFIG_BUFFER_POOLS <= pool_hdl)) + ODP_ERR("set_handle: Bad pool handle %u\n", pool_hdl); + + pool = get_pool_entry(pool_hdl); + pool->s.free_bufs = 0; + strcpy(pool->s.name, ""); + /* Need to restore this because this is setup in + * odp_buffer_pool_init_global + * */ + pool->s.pool_hdl = pool_hdl; + pool->s.buf_base = 0; + pool->s.buf_size = 0; + pool->s.buf_offset = 0; + pool->s.num_bufs = 0; + pool->s.pool_base_addr = NULL; + pool->s.pool_size = 0; + pool->s.user_size = 0; + pool->s.user_align = 0; + pool->s.buf_type = ODP_BUFFER_POOL_INVALID; + pool->s.hdr_size = 0; + return 0; +} odp_buffer_pool_t odp_buffer_pool_create(const char *name, void *base_addr, uint64_t size,