From patchwork Fri Nov 17 17: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: 119190 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp758799qgn; Fri, 17 Nov 2017 09:01:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMbg4A1uZal3D8A6DSHCuI2EOZf04bRs4qqg+zgxJA76raSsJ2lWWFfZlCGLhfOYVCWBbJm8 X-Received: by 10.55.78.72 with SMTP id c69mr9250808qkb.105.1510938065182; Fri, 17 Nov 2017 09:01:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510938065; cv=none; d=google.com; s=arc-20160816; b=MFNCzz0/FWDaghJ54nINvfGmbnRLSoFkRTSB8KwqAK5rWMFE3s8E+/HPsUwGk8uZ15 mWswCcjIMcTLPHVRAH59zElWw8hyTONG5vyGDonyYydq2ysNsIqpVcLjdg8u41yCAB7R +veamPFoCn05y06BJ/jEUDwCcy5SzmdETSPxgbmxTZIfj3mrfLNs2MXaugZ5Mg6HNWmO onSv92KkWm9ypDSqnDGBM460566XPaZMeVc1+XcWKbr5vUaOZ8rotbh9Mxf7/zrXlkSb zXR3WW8mWFCeRY/dqqnvdXMKjaNmr3nz522zY5fkvgxB1ymwfBGZCV5G917qt4RinEaG tvww== 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=Mre7kV8RAwsiYdrTfN8uKDo9i2w38r3ec2P+M7zWcY8=; b=sPGIW+elwIsztoLD6Deo2qNPFpbSKDcBfxD/dK9EPzSaZeAhS4EaLMVxw2RL/fIvMM Po9B5WNT7bsj21b7bKpOSeGNMoALEcdpQXtOtifyz55AFsfK6zD62ThQKcJO7QBrq6hr U52FWhXLZbdOqq3wR8Xzxz+tmIRb/fLy+aI43wcCDjWGoOg7VxrYFRWiU/j14S8frpXD 10zNnu0D8Tabl99lrfY6JHRk13C7jNdOEd2nEfNNUokd2NkIEhxyE8RfXflEM4CwxDnx OF9kf1MUTsjW/6SrPCRe5HxGWQL/czm2+yNAse/aJfpreTTllAoMaXF1CFlegZPT+GJ0 0DMw== 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 x38si3365620qtj.432.2017.11.17.09.01.04; Fri, 17 Nov 2017 09:01:05 -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 C73C260856; Fri, 17 Nov 2017 17:01: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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 91B7D607F1; Fri, 17 Nov 2017 17:00:29 +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 2B28E607F1; Fri, 17 Nov 2017 17:00:18 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id DC76C604A1 for ; Fri, 17 Nov 2017 17:00:15 +0000 (UTC) Received: from mxback4o.mail.yandex.net (mxback4o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1e]) by forward105j.mail.yandex.net (Yandex) with ESMTP id 448181849C7 for ; Fri, 17 Nov 2017 20:00:11 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback4o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id WrMC9kDHSN-0Bv8kVZx; Fri, 17 Nov 2017 20:00:11 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id fMGIr6c0ch-0A4Ofsap; Fri, 17 Nov 2017 20: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: Fri, 17 Nov 2017 20:00:07 +0300 Message-Id: <1510938009-12495-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510938009-12495-1-git-send-email-odpbot@yandex.ru> References: <1510938009-12495-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 297 Subject: [lng-odp] [PATCH 2.0 v2 1/3] linux-gen: pktio: add IO interface operation 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 implementations will allocate pktio entries operations data from this pool. 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: c785d2a3749494734a049a6e261df1b741ea22e0 **/ include/odp/api/spec/packet_io.h | 5 ++ platform/linux-dpdk/Makefile.am | 2 + platform/linux-generic/Makefile.am | 2 + .../linux-generic/include/odp_packet_io_pool.h | 27 +++++++++++ platform/linux-generic/odp_packet_io.c | 9 ++++ platform/linux-generic/odp_packet_io_pool.c | 54 ++++++++++++++++++++++ 6 files changed, 99 insertions(+) create mode 100644 platform/linux-generic/include/odp_packet_io_pool.h create mode 100644 platform/linux-generic/odp_packet_io_pool.c diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h index 52af646a6..70dacd3c9 100644 --- a/include/odp/api/spec/packet_io.h +++ b/include/odp/api/spec/packet_io.h @@ -1188,6 +1188,11 @@ uint64_t odp_pktin_ts_res(odp_pktio_t pktio); */ odp_time_t odp_pktin_ts_from_ns(odp_pktio_t pktio, uint64_t ns); +/** + * Packet IO operations data pool name + */ +#define ODP_PKTIO_OPS_DATA_POOL_NAME "ODP_PKTIO_OPS_DATA" + /** * @} */ diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index f27d2b50c..9efd7fa5b 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -206,6 +206,7 @@ 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_pkt_queue_internal.h \ ${srcdir}/include/odp_pool_internal.h \ ${top_srcdir}/platform/linux-generic/include/odp_pool_subsystem.h \ @@ -260,6 +261,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..769edcf90 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -175,6 +175,7 @@ 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_ring_internal.h \ pktio/ethtool.h \ pktio/common.h \ @@ -244,6 +245,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..59f6e41c1 --- /dev/null +++ b/platform/linux-generic/include/odp_packet_io_pool.h @@ -0,0 +1,27 @@ +/* Copyright (c) 2013, 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/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index a1c708616..432fcf7eb 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..edfa2ced9 --- /dev/null +++ b/platform/linux-generic/odp_packet_io_pool.c @@ -0,0 +1,54 @@ +/* Copyright (c) 2013, 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_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; +}