From patchwork Sun Mar 12 12:30:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 95167 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp783048qgd; Sun, 12 Mar 2017 05:31:02 -0700 (PDT) X-Received: by 10.200.43.185 with SMTP id m54mr27818881qtm.122.1489321862709; Sun, 12 Mar 2017 05:31:02 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p53si12311459qtp.306.2017.03.12.05.31.01; Sun, 12 Mar 2017 05:31:02 -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 sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5F81563C96; Sun, 12 Mar 2017 12:31:01 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 C142963C87; Sun, 12 Mar 2017 12:30:54 +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 E21A263C87; Sun, 12 Mar 2017 12:30:52 +0000 (UTC) Received: from mail-ot0-f175.google.com (mail-ot0-f175.google.com [74.125.82.175]) by lists.linaro.org (Postfix) with ESMTPS id 2281662D0B for ; Sun, 12 Mar 2017 12:30:52 +0000 (UTC) Received: by mail-ot0-f175.google.com with SMTP id x37so99512846ota.2 for ; Sun, 12 Mar 2017 05:30:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qvNAvCkh66aRCbTK/+40hHURcGOU0Ipi7hDzps+uuh4=; b=qGGSjYywbbul1QbH1Q7Cy1NAXdq1cy5X30jSZT7z1gakykoBag85wqftTyHRBZZPLE u/lHAroYjNzMxxyBPSfrbd9FjtUeLVa8i0ck/+YqghMHK456710LxyXqh6X6LioKJ6yZ Vimd9NHs7sIMVt7R6I6XiOeBNgHQOdkBnyiGtuFbYqcSc0h6AuNas9gBkan+pCZKsl8o cUoRLQrzOeYSV4pNQP3pl4Dlo161EsMQL/gVB08Ui0qQqheZLlj2kYIDEMjsM5rS8GvZ UCMC27WVvK1MaGU7WZIDCK5R1HJzoJSDUtYiiRiNdD50wxvUivWhUZAt5uwDuymUKceP RQlg== X-Gm-Message-State: AFeK/H3a1EdRYh5OQb/hOBOJLWsz6+TPYocFrnvA5OzUu892GWjTVTCJ7CqMm/AMjQr1vABs7+eq1g== X-Received: by 10.157.82.91 with SMTP id q27mr13902815otg.50.1489321851452; Sun, 12 Mar 2017 05:30:51 -0700 (PDT) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id 62sm6663155otq.34.2017.03.12.05.30.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Mar 2017 05:30:50 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sun, 12 Mar 2017 07:30:35 -0500 Message-Id: <20170312123045.3852-2-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.12.0.rc1 In-Reply-To: <20170312123045.3852-1-bill.fischofer@linaro.org> References: <20170312123045.3852-1-bill.fischofer@linaro.org> Subject: [lng-odp] [PATCHv2 01/11] linux-generic: pool: restructure pool routines 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: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Restructure pool routines in preparation for introducing packet references. Signed-off-by: Bill Fischofer --- platform/linux-generic/include/odp_pool_internal.h | 33 ++++++++++++++- platform/linux-generic/odp_pool.c | 47 +--------------------- 2 files changed, 34 insertions(+), 46 deletions(-) -- 2.12.0.rc1 diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index ebb779da..e767251a 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -122,9 +122,40 @@ static inline odp_buffer_hdr_t *buf_hdl_to_hdr(odp_buffer_t buf) return pool_buf_hdl_to_hdr(pool, buf); } +static inline odp_pool_t pool_index_to_handle(uint32_t pool_idx) +{ + return _odp_cast_scalar(odp_pool_t, pool_idx); +} + +static inline uint32_t pool_id_from_buf(odp_buffer_t buf) +{ + odp_buffer_bits_t handle; + + handle.handle = buf; + return handle.pool_id; +} + int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[], odp_buffer_hdr_t *buf_hdr[], int num); -void buffer_free_multi(const odp_buffer_t buf[], int num_free); +void buffer_free_to_pool(uint32_t pool_id, const odp_buffer_t buf[], int num); + +static inline void buffer_free_multi(const odp_buffer_t buf[], int num) +{ + uint32_t next_pool, pool_id = pool_id_from_buf(buf[0]); + int i, first = 0; + + for (i = 1; i < num; i++) { + next_pool = pool_id_from_buf(buf[i]); + + if (odp_unlikely(next_pool != pool_id)) { + buffer_free_to_pool(pool_id, &buf[first], i - first); + first = i; + pool_id = next_pool; + } + } + + buffer_free_to_pool(pool_id, &buf[first], num - first); +} #ifdef __cplusplus } diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 145002d9..9df9ba21 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -47,19 +47,6 @@ typedef struct pool_local_t { pool_table_t *pool_tbl; static __thread pool_local_t local; -static inline odp_pool_t pool_index_to_handle(uint32_t pool_idx) -{ - return _odp_cast_scalar(odp_pool_t, pool_idx); -} - -static inline uint32_t pool_id_from_buf(odp_buffer_t buf) -{ - odp_buffer_bits_t handle; - - handle.handle = buf; - return handle.pool_id; -} - int odp_pool_init_global(void) { uint32_t i; @@ -672,8 +659,8 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[], return num_ch + num_deq; } -static inline void buffer_free_to_pool(uint32_t pool_id, - const odp_buffer_t buf[], int num) +void buffer_free_to_pool(uint32_t pool_id, + const odp_buffer_t buf[], int num) { pool_t *pool; int i; @@ -733,36 +720,6 @@ static inline void buffer_free_to_pool(uint32_t pool_id, cache->num = cache_num + num; } -void buffer_free_multi(const odp_buffer_t buf[], int num_total) -{ - uint32_t pool_id; - int num; - int i; - int first = 0; - - while (1) { - num = 1; - i = 1; - pool_id = pool_id_from_buf(buf[first]); - - /* 'num' buffers are from the same pool */ - if (num_total > 1) { - for (i = first; i < num_total; i++) - if (pool_id != pool_id_from_buf(buf[i])) - break; - - num = i - first; - } - - buffer_free_to_pool(pool_id, &buf[first], num); - - if (i == num_total) - return; - - first = i; - } -} - odp_buffer_t odp_buffer_alloc(odp_pool_t pool_hdl) { odp_buffer_t buf;