From patchwork Tue Nov 11 16:26:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 40598 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 D79A1218DE for ; Tue, 11 Nov 2014 16:26:48 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id h11sf923281wiw.3 for ; Tue, 11 Nov 2014 08:26:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:date:from:user-agent :mime-version:to:references:in-reply-to: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-type :content-transfer-encoding; bh=K/ksdgAedmhSUiCTgtJpYnrYJyCWUm0AkETHfAkRKm4=; b=L5pYr1DVJtbALBPwfWQRiAqeGQNUxq4nwXqi8WbiYGA7QnK5rJ8MAsDtJcxiageyUS 0amMF54GuE0w3fgwW9OE37n3mop6+mOYWf2mykwTn6aXzhafgPeBJ0ixl+Fswc/7VDOy KKNutsPnpL+fd2NCt42QUdC63yeS01l6z0rB6ApkZhviNPH9RvLwP4lRfeJjg3ufDm51 VhqhgdaDdsmYsH0U7i7xIYgqLBc8MgBS3836VQiqsfcpX51f6Ox6SG/Nkg0/qZ3kMGbp hXgmmVX6nZRdzZzDh6xUJGzcxLZt+2MHWWlhIHvxIBlXm/pCGbLBOA75eXMT9itzyEpt SKog== X-Gm-Message-State: ALoCoQlEVpZBKderP0LbVRemRjIbhhzOYqJifMGLqVZ+q11wvJaMKOf2pdb0smp06A1VGJ+ImFSZ X-Received: by 10.112.201.169 with SMTP id kb9mr188598lbc.20.1415723207769; Tue, 11 Nov 2014 08:26:47 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.243.33 with SMTP id wv1ls285852lac.3.gmail; Tue, 11 Nov 2014 08:26:47 -0800 (PST) X-Received: by 10.152.20.130 with SMTP id n2mr22022260lae.39.1415723207484; Tue, 11 Nov 2014 08:26:47 -0800 (PST) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id b8si12525863laf.116.2014.11.11.08.26.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 08:26:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id gf13so9935453lab.17 for ; Tue, 11 Nov 2014 08:26:47 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr37055529lbc.34.1415723207309; Tue, 11 Nov 2014 08:26:47 -0800 (PST) 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.184.201 with SMTP id ew9csp283459lbc; Tue, 11 Nov 2014 08:26:46 -0800 (PST) X-Received: by 10.224.80.71 with SMTP id s7mr18717864qak.35.1415723205841; Tue, 11 Nov 2014 08:26:45 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id j4si37577340qai.6.2014.11.11.08.26.44 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Nov 2014 08:26:45 -0800 (PST) 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 1XoEHD-00014I-VF; Tue, 11 Nov 2014 16:26:43 +0000 Received: from mail-lb0-f181.google.com ([209.85.217.181]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XoEH0-00013k-Hw for lng-odp@lists.linaro.org; Tue, 11 Nov 2014 16:26:30 +0000 Received: by mail-lb0-f181.google.com with SMTP id l4so7782613lbv.40 for ; Tue, 11 Nov 2014 08:26:24 -0800 (PST) X-Received: by 10.112.57.227 with SMTP id l3mr16270922lbq.68.1415723184841; Tue, 11 Nov 2014 08:26:24 -0800 (PST) Received: from [172.22.39.11] ([195.238.92.128]) by mx.google.com with ESMTPSA id x8sm6073800lae.24.2014.11.11.08.26.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Nov 2014 08:26:24 -0800 (PST) Message-ID: <546238AF.6060400@linaro.org> Date: Tue, 11 Nov 2014 18:26:23 +0200 From: Taras Kondratiuk User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Bill Fischofer , lng-odp@lists.linaro.org References: <1415715226-20067-1-git-send-email-bill.fischofer@linaro.org> In-Reply-To: <1415715226-20067-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: Re: [lng-odp] [PATCHv4 ODP v1.0 Buffer/Packet APIs 9/9] Implement ODP v1.0 buffer/packet APIs for linux-generic 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: taras.kondratiuk@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.44 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 On 11/11/2014 04:13 PM, Bill Fischofer wrote: > v4 fixes bufcount initialization during pool creation > > Signed-off-by: Bill Fischofer > --- > platform/linux-generic/odp_buffer.c | 263 ++++++- > platform/linux-generic/odp_buffer_pool.c | 664 +++++++--------- > platform/linux-generic/odp_packet.c | 1200 +++++++++++++++++++++++------ > platform/linux-generic/odp_packet_flags.c | 202 ----- > 4 files changed, 1458 insertions(+), 871 deletions(-) > delete mode 100644 platform/linux-generic/odp_packet_flags.c [snip] > diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c > index a48d7d6..3e37d60 100644 > --- a/platform/linux-generic/odp_buffer_pool.c > +++ b/platform/linux-generic/odp_buffer_pool.c [snip] > @@ -431,93 +291,172 @@ odp_buffer_pool_t odp_buffer_pool_lookup(const char *name) > return ODP_BUFFER_POOL_INVALID; > } > > - > -odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool_hdl) > +odp_buffer_pool_t odp_buffer_pool_next(odp_buffer_pool_t pool_hdl, > + char *name, > + size_t *udata_size, > + odp_buffer_pool_param_t *params, > + int *predef) > { > - pool_entry_t *pool; > - odp_buffer_chunk_hdr_t *chunk; > - odp_buffer_bits_t handle; > - uint32_t pool_id = pool_handle_to_index(pool_hdl); > - > - pool = get_pool_entry(pool_id); > - chunk = local_chunk[pool_id]; > - > - if (chunk == NULL) { > - LOCK(&pool->s.lock); > - chunk = rem_chunk(pool); > - UNLOCK(&pool->s.lock); > + pool_entry_t *next_pool; > + uint32_t pool_id; > > - if (chunk == NULL) > - return ODP_BUFFER_INVALID; > + /* NULL input means first element */ > + if (pool_hdl == ODP_BUFFER_POOL_INVALID) { > + pool_id = 0; > + next_pool = get_pool_entry(pool_id); > + } else { > + pool_id = pool_handle_to_index(pool_hdl); > > - local_chunk[pool_id] = chunk; > + if (pool_id == ODP_CONFIG_BUFFER_POOLS) > + return ODP_BUFFER_POOL_INVALID; > + else > + next_pool = get_pool_entry(++pool_id); > } > > - if (chunk->chunk.num_bufs == 0) { > - /* give the chunk buffer */ > - local_chunk[pool_id] = NULL; > - chunk->buf_hdr.type = pool->s.buf_type; > + /* Only interested in pools that exist */ > + while (next_pool->s.shm == ODP_SHM_INVALID) { > + if (pool_id == ODP_CONFIG_BUFFER_POOLS) > + return ODP_BUFFER_POOL_INVALID; > + else > + next_pool = get_pool_entry(++pool_id); > + } pool_id should be incremented before comparing it with ODP_CONFIG_BUFFER_POOLS. Otherwise for the last pool next_pool will point out of pool_entry_ptr array. Working fix: diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c index 3e37d60..2724a11 100644 --- a/platform/linux-generic/odp_buffer_pool.c +++ b/platform/linux-generic/odp_buffer_pool.c @@ -307,18 +307,18 @@ odp_buffer_pool_t odp_buffer_pool_next(odp_buffer_pool_t pool_hdl, } else { pool_id = pool_handle_to_index(pool_hdl); - if (pool_id == ODP_CONFIG_BUFFER_POOLS) + if (++pool_id == ODP_CONFIG_BUFFER_POOLS) return ODP_BUFFER_POOL_INVALID; else - next_pool = get_pool_entry(++pool_id); + next_pool = get_pool_entry(pool_id); } /* Only interested in pools that exist */ while (next_pool->s.shm == ODP_SHM_INVALID) { - if (pool_id == ODP_CONFIG_BUFFER_POOLS) + if (++pool_id == ODP_CONFIG_BUFFER_POOLS) return ODP_BUFFER_POOL_INVALID; else - next_pool = get_pool_entry(++pool_id); + next_pool = get_pool_entry(pool_id); } /* Found the next pool, so return info about it */