From patchwork Sun Mar 5 12:21:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 94897 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp988185qgd; Sun, 5 Mar 2017 04:22:04 -0800 (PST) X-Received: by 10.55.33.71 with SMTP id h68mr10450298qkh.287.1488716524354; Sun, 05 Mar 2017 04:22:04 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k13si13380493qta.271.2017.03.05.04.22.04; Sun, 05 Mar 2017 04:22:04 -0800 (PST) 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 09E8060A57; Sun, 5 Mar 2017 12:22:04 +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_H2 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 4231160C40; Sun, 5 Mar 2017 12:21:35 +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 33C8D60A57; Sun, 5 Mar 2017 12:21:31 +0000 (UTC) Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com [209.85.128.176]) by lists.linaro.org (Postfix) with ESMTPS id F1DB160A45 for ; Sun, 5 Mar 2017 12:21:29 +0000 (UTC) Received: by mail-wr0-f176.google.com with SMTP id l37so99743795wrc.1 for ; Sun, 05 Mar 2017 04:21:29 -0800 (PST) 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=CzQSPaMt/Nnp+cXB3KtF4YIiEkdonYuXI13yVywbAD0=; b=MIOy71+jrHGSEm+n31PwbdbHQ8VA7YMlIDC0ERkpNQCYTmZpZtt6tdwnEC/wNV+g07 SE/wtEWVpHluGy/fu49PlUyzqBB6iKXe0Ka5PKkE86kNwmOr11BrQBtuouqanrkthIc4 GHQsxK8OL4fjYELBmtX1MCI3UuXbM0qdE5Hb+Iu/bwIHeTT0HvCucZXaRkukPgowSMr0 km9zmYp/ye0/YfzJT0YideaN68AROFhMhpMSrKYuK4HxTIh1cp3r4fi8ns4RCSZZUl4w 4gZ7a/9SqsfoJeL0Mi38p0/Sz+fgVAUmt1jCX+hLakfLpNw2eSrvFUe440Upr9WbsorK fRuw== X-Gm-Message-State: AMke39kuO7bAXHlDgmgZph2hoL/20eUjgK7R0CmvXBFsVxAVBiEYwsvuZo+9CHU+7r5nKsly22cOiA== X-Received: by 10.223.135.153 with SMTP id b25mr10260549wrb.169.1488716488805; Sun, 05 Mar 2017 04:21:28 -0800 (PST) Received: from Ubuntu15.localdomain ([109.74.56.122]) by smtp.gmail.com with ESMTPSA id 127sm10686971wmt.20.2017.03.05.04.21.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 05 Mar 2017 04:21:27 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Sun, 5 Mar 2017 13:21:15 +0100 Message-Id: <1488716485-15002-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1488716485-15002-1-git-send-email-bill.fischofer@linaro.org> References: <1488716485-15002-1-git-send-email-bill.fischofer@linaro.org> Subject: [lng-odp] [PATCH 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.5.0 diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index ebb779d..e767251 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 145002d..9df9ba2 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;