From patchwork Mon Nov 20 13:00:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 119278 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp3771599edl; Mon, 20 Nov 2017 05:00:32 -0800 (PST) X-Google-Smtp-Source: AGs4zMYT6yEuRQU7EjKgwKIUyw7TYTl4oj3y4+tFllNOEyanmP3yLZ/rAW6JrITNrTg2u0Uo63uR X-Received: by 10.55.8.137 with SMTP id 131mr18946957qki.310.1511182832079; Mon, 20 Nov 2017 05:00:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511182832; cv=none; d=google.com; s=arc-20160816; b=SyUSkka/0eM3xJN1Ta1cYFzWftTAJxo8N7JLDcuua/wGvbETyZgewWzNU5aMHSjeQ+ Y0lrXtmN0BGeJ5F+Ol4ptH+ZqqiV63hl9hKAVZq+YiXJESDb4L/s0eAZmKu1rjs7AjU5 7RVMW2R/2fxFgF618nAhkEEBAiZevUfluvx2OyruguNwyIGjfWPzpYiM9f07xzAewTrl bjz7FejrEAeFJLTm8zCttTps0LWDZRMMbypQ/adqpeBu3Spjs4tMPH4BhoZjKmZaDwI4 RaOnht99rxDmsAkaMI/KsNNvt9BqeSx6DuB7vzHyEfWLCWQ2ItLmbVtT7hgmVAGQu+gM 2Z9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=5hxFBq3PxuF9PMsDtukG9PK2f14XsiGkNFXyvwk8yIA=; b=ZeMvoRdz1RDqzMa9xf1faMbNJjB2gpa0mKtiOwJDrcXlTxKJMyPYfDGW8vnfaYY+VZ LMmnG1V5GHRBmTz8qjNOAN2lqYwdbCKrCxaLVMgJOXRFS/5WuCgBebfO2/lKKkrwSYOG yW8SUnwwl6B0TZ4f2/GNoGvQK0Pi+0ok+tbYepPxMhwyqBBrKhume9lGMwPR1xZK0qMk NhNYioL+9sUbZiOv+qBDEPhQhH66/JNOPpl2V4BGQS3sEGA9mshY3My9YVVjtdno5jZW rAhY0wPLT0gkZacXTG79/w/WsZg43A2b6EPWjQhXL5lE6RLhcwNwnvkJNjC8PHNdR1y4 XxkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id h52si119190qte.369.2017.11.20.05.00.30; Mon, 20 Nov 2017 05:00:32 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id ADCCB60843; Mon, 20 Nov 2017 13:00:30 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 54EA460604; Mon, 20 Nov 2017 13:00:25 +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 92760607A0; Mon, 20 Nov 2017 13:00:16 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id BF2296068D for ; Mon, 20 Nov 2017 13:00:12 +0000 (UTC) Received: from mxback4o.mail.yandex.net (mxback4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1e]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 0EFF8421A4 for ; Mon, 20 Nov 2017 16:00:11 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback4o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 9LefZVKMcA-0AbOoDRx; Mon, 20 Nov 2017 16:00:11 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id l67znhGFCa-0ABiUBw1; Mon, 20 Nov 2017 16:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 20 Nov 2017 16:00:07 +0300 Message-Id: <1511182808-32328-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511182808-32328-1-git-send-email-odpbot@yandex.ru> References: <1511182808-32328-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 297 Subject: [lng-odp] [PATCH 2.0 v3 1/2] linux-gen: pktio: add pktio operations data pool 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" From: Bogdan Pricope Pktio instances need a memory area where to store configuration or state information. The size and structure of this area depends on pktio type. This pool is meant to be used for allocation of such memory areas. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 297 (bogdanPricope:2_0_ops_alloc_pr) ** https://github.com/Linaro/odp/pull/297 ** Patch: https://github.com/Linaro/odp/pull/297.patch ** Base sha: 6cd43041e55bd73a02ca202f835e590b3ad5c354 ** Merge commit sha: 7b05757dc100acc261053cf8e9cb253091ceaf91 **/ platform/linux-dpdk/Makefile.am | 3 ++ platform/linux-generic/Makefile.am | 3 ++ .../linux-generic/include/odp_packet_io_pool.h | 27 ++++++++++ .../include/odp_packet_io_pool_access.h | 58 ++++++++++++++++++++++ platform/linux-generic/odp_packet_io.c | 9 ++++ platform/linux-generic/odp_packet_io_pool.c | 55 ++++++++++++++++++++ 6 files changed, 155 insertions(+) create mode 100644 platform/linux-generic/include/odp_packet_io_pool.h create mode 100644 platform/linux-generic/include/odp_packet_io_pool_access.h create mode 100644 platform/linux-generic/odp_packet_io_pool.c diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index f27d2b50c..ee6c36e21 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -206,6 +206,8 @@ noinst_HEADERS = \ ${top_srcdir}/platform/linux-generic/include/odp_packet_io_internal.h \ ${srcdir}/include/odp_errno_define.h \ ${top_srcdir}/platform/linux-generic/include/odp_packet_io_ring_internal.h \ + ${top_srcdir}/platform/linux-generic/include/odp_packet_io_pool.h \ + ${top_srcdir}/platform/linux-generic/include/odp_packet_io_pool_access.h \ ${top_srcdir}/platform/linux-generic/include/odp_pkt_queue_internal.h \ ${srcdir}/include/odp_pool_internal.h \ ${top_srcdir}/platform/linux-generic/include/odp_pool_subsystem.h \ @@ -260,6 +262,7 @@ __LIB__libodp_dpdk_la_SOURCES = \ ../linux-generic/pktio/subsystem.c \ odp_packet_flags.c \ ../linux-generic/odp_packet_io.c \ + ../linux-generic/odp_packet_io_pool.c \ ../linux-generic/pktio/loopback.c \ ../linux-generic/odp_pkt_queue.c \ pool/dpdk.c \ diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 56ef03c6f..a4aaa7693 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -175,6 +175,8 @@ noinst_HEADERS = \ include/odp_name_table_internal.h \ include/odp_packet_internal.h \ include/odp_packet_io_internal.h \ + include/odp_packet_io_pool.h \ + include/odp_packet_io_pool_access.h \ include/odp_packet_io_ring_internal.h \ pktio/ethtool.h \ pktio/common.h \ @@ -244,6 +246,7 @@ __LIB__libodp_linux_la_SOURCES = \ odp_packet.c \ odp_packet_flags.c \ odp_packet_io.c \ + odp_packet_io_pool.c \ pktio/ethtool.c \ pktio/subsystem.c \ pktio/ipc.c \ diff --git a/platform/linux-generic/include/odp_packet_io_pool.h b/platform/linux-generic/include/odp_packet_io_pool.h new file mode 100644 index 000000000..59ad053b1 --- /dev/null +++ b/platform/linux-generic/include/odp_packet_io_pool.h @@ -0,0 +1,27 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP packet IO pool + */ + +#ifndef ODP_PACKET_IO_POOL_H_ +#define ODP_PACKET_IO_POOL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int _odp_packet_io_pool_create(void); +int _odp_packet_io_pool_destroy(void); + +#ifdef __cplusplus +} +#endif + +#endif /* ODP_PACKET_IO_POOL_H_*/ diff --git a/platform/linux-generic/include/odp_packet_io_pool_access.h b/platform/linux-generic/include/odp_packet_io_pool_access.h new file mode 100644 index 000000000..cdd7dd968 --- /dev/null +++ b/platform/linux-generic/include/odp_packet_io_pool_access.h @@ -0,0 +1,58 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP packet IO pool + */ + +#ifndef ODP_PACKET_IO_POOL_ACCESS_H_ +#define ODP_PACKET_IO_POOL_ACCESS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** + * Packet IO operations data pool name + */ +#define ODP_PKTIO_OPS_DATA_POOL_NAME "ODP_PKTIO_OPS_DATA" + +#define ODP_OPS_DATA_ALLOC(_size) \ +({ \ + odpdrv_shm_pool_t _pool; \ + void *_ops_data = NULL; \ + \ + _pool = odpdrv_shm_pool_lookup(ODP_PKTIO_OPS_DATA_POOL_NAME); \ + if (_pool != ODPDRV_SHM_POOL_INVALID) \ + _ops_data = odpdrv_shm_pool_alloc(_pool, \ + ROUNDUP_CACHE_LINE(_size)); \ + \ + _ops_data; \ +}) + +#define ODP_OPS_DATA_FREE(_ops_data) \ +({ \ + odpdrv_shm_pool_t _pool; \ + int _result = -1; \ + \ + _pool = odpdrv_shm_pool_lookup(ODP_PKTIO_OPS_DATA_POOL_NAME); \ + if (_pool != ODPDRV_SHM_POOL_INVALID) { \ + odpdrv_shm_pool_free(_pool, _ops_data); \ + _result = 0; \ + } \ + _result; \ +}) + +#ifdef __cplusplus +} +#endif + +#endif /* ODP_PACKET_IO_POOL_ACCESS_H_*/ diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index a1c708616..efeac0269 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -76,6 +77,10 @@ int odp_pktio_init_global(void) pktio_entry_ptr[i] = pktio_entry; } + if (_odp_packet_io_pool_create()) { + odp_shm_free(shm); + return -1; + } return odp_pktio_ops_init_global(true); } @@ -1122,6 +1127,10 @@ int odp_pktio_term_global(void) ret = odp_pktio_ops_term_global(false); + ret = _odp_packet_io_pool_destroy(); + if (ret) + ODP_ERR("unable to destroy pktio pool\n"); + ret = odp_shm_free(odp_shm_lookup("odp_pktio_entries")); if (ret != 0) ODP_ERR("shm free failed for odp_pktio_entries"); diff --git a/platform/linux-generic/odp_packet_io_pool.c b/platform/linux-generic/odp_packet_io_pool.c new file mode 100644 index 000000000..3e1860475 --- /dev/null +++ b/platform/linux-generic/odp_packet_io_pool.c @@ -0,0 +1,55 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" + +#include +#include +#include +#include +#include "odp_packet_io_pool.h" +#include "odp_packet_io_pool_access.h" +#include "odp_debug_internal.h" + +#define ODP_PKTIO_OPS_DATA_POOL_SIZE 160000 + +int _odp_packet_io_pool_create(void) +{ + odpdrv_shm_pool_t pktio_ops_pool; + odpdrv_shm_pool_param_t pktio_ops_param; + + odp_memset(&pktio_ops_param, 0, sizeof(pktio_ops_param)); + pktio_ops_param.pool_size = ODP_PKTIO_OPS_DATA_POOL_SIZE; + pktio_ops_param.min_alloc = 1; + pktio_ops_param.max_alloc = ODP_PKTIO_OPS_DATA_POOL_SIZE; + + pktio_ops_pool = odpdrv_shm_pool_create(ODP_PKTIO_OPS_DATA_POOL_NAME, + &pktio_ops_param); + if (pktio_ops_pool == ODPDRV_SHM_POOL_INVALID) { + ODP_ERR("error to pool_create pktio_ops pool\n"); + return -1; + } + + return 0; +} + +int _odp_packet_io_pool_destroy(void) +{ + odpdrv_shm_pool_t pktio_ops_pool; + + pktio_ops_pool = odpdrv_shm_pool_lookup(ODP_PKTIO_OPS_DATA_POOL_NAME); + if (pktio_ops_pool == ODPDRV_SHM_POOL_INVALID) { + ODP_ERR("error pool_lookup pktio_ops pool\n"); + return -1; + } + + if (odpdrv_shm_pool_destroy(pktio_ops_pool)) { + ODP_ERR("error pool_destroy pktio_ops pool\n"); + return -1; + } + + return 0; +}