From patchwork Fri Jan 8 20:29:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 59391 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp751610lbb; Fri, 8 Jan 2016 11:38:33 -0800 (PST) X-Received: by 10.140.167.86 with SMTP id n83mr74667778qhn.41.1452281913563; Fri, 08 Jan 2016 11:38:33 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x206si25355850qka.52.2016.01.08.11.38.32; Fri, 08 Jan 2016 11:38:33 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id DB52661CBB; Fri, 8 Jan 2016 19:38:31 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=cErlxl5e; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 49B0061790; Fri, 8 Jan 2016 19:33:15 +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 AA23B6178A; Fri, 8 Jan 2016 19:33:09 +0000 (UTC) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by lists.linaro.org (Postfix) with ESMTPS id C91FB6178A for ; Fri, 8 Jan 2016 19:31:40 +0000 (UTC) Received: by mail-lf0-f41.google.com with SMTP id c192so181376577lfe.2 for ; Fri, 08 Jan 2016 11:31:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NbvgrBPUiEZ9mzy02j6W9QSm/rRLk/E/L2/+c2sfwTw=; b=cErlxl5eRhkhKzzx25h09T1TwLW/VDy/lTEMVvip1iE+1coEgk1fxjNeOL2Qete/b3 30Z7wsTM1t0EX+oj6y+NWlVOxhkrk5ym9buAE5ASsITQtPojRSqE9n83oUA92Kpp5yvj JXMX8lAcdl26TA0id9MEPKPPesOQ5KSBZC490= 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=NbvgrBPUiEZ9mzy02j6W9QSm/rRLk/E/L2/+c2sfwTw=; b=m+hVniMRK0ZI/jzQZiCfH3H+o3p3GIDsM9FYEQB8cIMvKMQq2gvHOyL1RDm4W6ca8J zdRSeLACOLvD++LcWeoozj7OIgNvBd+vgQrkgW6jFWkEFEOW9KAoVg2IJ2bm9l62hhuh BZynZuCyzG3bzxsDkmyjHWb84UJQrCNSwv9IAvUzV0WLmZwwOAseStXZ1rbPFdYh892u b5QMrtWV3yRom7Qct7P0/WKpHE1WbT6p7wq4sF73zYFAPBvCdTSTtF+/SEyzBgljSqpF UW/Xq0xjnCjVQJ25a2Uz22w2thoPwGE+mLiiVB2ttRTPlwEgQUjVlpRUqJ73Dmx+qUHq ckFg== X-Gm-Message-State: ALoCoQkSXdcpjMq6ucr9vSUZWSiiyGajva8n9KMIPvPfWOMCv/+x23nSoVJnEOXrqjiWIwLIMuCHS7800mI3RuKa+EhcrZXXwA== X-Received: by 10.25.79.143 with SMTP id d137mr33606692lfb.110.1452281499740; Fri, 08 Jan 2016 11:31:39 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by smtp.gmail.com with ESMTPSA id l204sm2085534lfg.49.2016.01.08.11.31.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jan 2016 11:31:39 -0800 (PST) From: Christophe Milard To: anders.roxell@linaro.org, mike.holmes@linaro.org, stuart.haslam@linaro.org, maxim.uvarov@linaro.org, bill.fischofer@linaro.org, petri.savolainen@linaro.org, edavis@broadcom.com Date: Fri, 8 Jan 2016 21:29:49 +0100 Message-Id: <1452285014-60320-7-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1452285014-60320-1-git-send-email-christophe.milard@linaro.org> References: <1452285014-60320-1-git-send-email-christophe.milard@linaro.org> Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [API-NEXT RFC 06/31] linux-generic: pool: retrieving DMA map desriptor 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" Linux-generic implementation of the function returning a DMA mapping descriptor for one, or all, defined packet pools Signed-off-by: Christophe Milard --- platform/linux-generic/include/odp_dma_internal.h | 1 + platform/linux-generic/include/odp_pool_internal.h | 4 ++ platform/linux-generic/odp_pool.c | 59 ++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/platform/linux-generic/include/odp_dma_internal.h b/platform/linux-generic/include/odp_dma_internal.h index 888ef3b..c0b3a98 100644 --- a/platform/linux-generic/include/odp_dma_internal.h +++ b/platform/linux-generic/include/odp_dma_internal.h @@ -22,6 +22,7 @@ extern "C" { #include #include #include +#include /** @addtogroup odp_dma * @{ diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index b12bca8..1558f80 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -30,6 +30,7 @@ extern "C" { #include #include #include +#include #include /** @@ -159,6 +160,9 @@ extern void *pool_entry_ptr[]; #define pool_is_secure(pool) 0 #endif +/* get a DMA mapping descriptor for a single, or all, packet pools */ +odp_dma_map_t _odp_pool_get_dma_map(odp_pool_t pool_hdl); + static inline void *get_blk(struct pool_entry_s *pool) { void *myhead; diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 125d8e6..6958ec5 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -597,6 +598,64 @@ void _odp_flush_caches(void) } } +/** + * Builds a DMA map descriptor for all packet pools. + */ +static dma_map_t *get_all_pkt_pool_dma_map(void) +{ + int i; + dma_map_t *dma_map; + dma_map_t *dma_map_head; + dma_map_t *dma_map_curr; + pool_entry_t *pool; + + dma_map_head = NULL; + dma_map_curr = NULL; + + for (i = 0; i < ODP_CONFIG_POOLS; i++) { + pool = get_pool_entry(i); + if (pool->s.params.type != ODP_POOL_PACKET) + continue; + if (dma_map_head == NULL) { + dma_map_head = + (dma_map_t *)_odp_pool_get_dma_map(pool->s.pool_hdl); + dma_map_curr = dma_map_head; + continue; + } + dma_map = (dma_map_t *)_odp_pool_get_dma_map(pool->s.pool_hdl); + dma_map_curr = _odp_dma_map_link(dma_map_curr, dma_map); + } + + return dma_map_head; +} + +/** + * Builds a DMA map descriptor for one or all packet pools. + * If the packet pool handle is invalid, all packets pools are assumed. + */ +odp_dma_map_t _odp_pool_get_dma_map(odp_pool_t pool_hdl) +{ + uint32_t pool_id; + pool_entry_t *bpool; + dma_map_t *dma_map; + + /* specific case to get a dma mapping for all existing pot pools: */ + if (pool_hdl == ODP_POOL_ALL_PKTS) + return (odp_dma_map_t)get_all_pkt_pool_dma_map(); + + pool_id = pool_handle_to_index((odp_pool_t)pool_hdl); + bpool = get_pool_entry(pool_id); + dma_map = _odp_dma_map_alloc(); + + if (odp_unlikely(dma_map == NULL)) + return ODP_DMA_REGION_INVALID; + + dma_map->addr = bpool->s.pool_base_addr; + dma_map->dma_addr = (odp_dma_addr_t)bpool->s.pool_base_addr; + dma_map->size = bpool->s.pool_size; + return (odp_dma_map_t)dma_map; +} + void odp_pool_print(odp_pool_t pool_hdl) { pool_entry_t *pool;