From patchwork Mon Apr 25 01:13:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 66551 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp785126qge; Sun, 24 Apr 2016 18:14:25 -0700 (PDT) X-Received: by 10.107.178.18 with SMTP id b18mr36198731iof.83.1461546865340; Sun, 24 Apr 2016 18:14:25 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 184si20690490ioo.84.2016.04.24.18.14.25; Sun, 24 Apr 2016 18:14:25 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id D41B061A07; Mon, 25 Apr 2016 01:14:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id CC55461A30; Mon, 25 Apr 2016 01:13:33 +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 0B87761A3D; Mon, 25 Apr 2016 01:13:26 +0000 (UTC) Received: from mail-oi0-f47.google.com (mail-oi0-f47.google.com [209.85.218.47]) by lists.linaro.org (Postfix) with ESMTPS id 14D80619D1 for ; Mon, 25 Apr 2016 01:13:24 +0000 (UTC) Received: by mail-oi0-f47.google.com with SMTP id k142so163442734oib.1 for ; Sun, 24 Apr 2016 18:13:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kDNzOkfxV/YXzbsMXxwicAAZDE6ce2QDLsua289cfIw=; b=AWDrElwS40AAvwq0zIhpAe6pAFrISbHHsyLS30fZxFAbeTNIPgh8CcJbA5iEINAc1L thWfslytGYwAmGtXWMdZBvsBBMehN+ZSWQYdxlDS3dSLlAUY+5WtLANDPUudxBoZRqvW A7/73Z8LmmyJtefjQm+i0XknpED58zFwSH+1+ZXyUF2Y0wyyj2DO/BsJEnulVPApvqju qbqfoXDZyzVy9I+zU99Sq8mKOs1nATcMqS0emdyqeD8ahYG2azvaSvnN7EtB4yu9vYec 8Ls0+SUTLi8Up0ZQw8Yd+CYn9u7n6GuBxinkyIhSXwqyB++TtJTmLs3pL74GbIXmwbLM F3Ig== X-Gm-Message-State: AOPr4FX0yabPQJ5xRxJRI+NObn2EIpcUYSxDDHEMb/YzrDSJ0oKqrPij8HTO2sItBxD5wPTYRok= X-Received: by 10.202.60.5 with SMTP id j5mr13268686oia.43.1461546803611; Sun, 24 Apr 2016 18:13:23 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id t5sm2216138oie.18.2016.04.24.18.13.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 Apr 2016 18:13:23 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sun, 24 Apr 2016 20:13:16 -0500 Message-Id: <1461546799-18112-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461546799-18112-1-git-send-email-bill.fischofer@linaro.org> References: <1461546799-18112-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH 2/5] linux-generic: pool: correct segment head/tail manipulation X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" 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" Correct the implementation of several internal routines that perform low-level segment manipulation in support of the extend/trunc APIs. Signed-off-by: Bill Fischofer --- platform/linux-generic/odp_pool.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index eb12604..93c61ca 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -533,6 +533,7 @@ int seg_alloc_head(odp_buffer_hdr_t *buf_hdr, int segcount) buf_hdr->addr[i] = newsegs[i]; buf_hdr->segcount += segcount; + buf_hdr->size = buf_hdr->segcount * pool->s.seg_size; return 0; } @@ -543,13 +544,14 @@ void seg_free_head(odp_buffer_hdr_t *buf_hdr, int segcount) int s_cnt = buf_hdr->segcount; int i; - for (i = 0; i < s_cnt; i++) + for (i = 0; i < segcount; i++) ret_blk(&pool->s, buf_hdr->addr[i]); for (i = 0; i < s_cnt - segcount; i++) buf_hdr->addr[i] = buf_hdr->addr[i + segcount]; buf_hdr->segcount -= segcount; + buf_hdr->size = buf_hdr->segcount * pool->s.seg_size; } int seg_alloc_tail(odp_buffer_hdr_t *buf_hdr, int segcount) @@ -569,6 +571,7 @@ int seg_alloc_tail(odp_buffer_hdr_t *buf_hdr, int segcount) } buf_hdr->segcount += segcount; + buf_hdr->size = buf_hdr->segcount * pool->s.seg_size; return 0; } @@ -579,10 +582,11 @@ void seg_free_tail(odp_buffer_hdr_t *buf_hdr, int segcount) int s_cnt = buf_hdr->segcount; int i; - for (i = s_cnt - 1; i > s_cnt - segcount; i--) + for (i = s_cnt - 1; i >= s_cnt - segcount; i--) ret_blk(&pool->s, buf_hdr->addr[i]); buf_hdr->segcount -= segcount; + buf_hdr->size = buf_hdr->segcount * pool->s.seg_size; } odp_buffer_t buffer_alloc(odp_pool_t pool_hdl, size_t size)