From patchwork Thu Nov 16 09:00:06 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: 119025 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5339494qgn; Thu, 16 Nov 2017 01:03:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMawp8sF/paLxgCX8GviAv8xHJCBymdjaxITb72VjCv+XzDVn/l3pdQ2XNRFr/RNBPblQ7qK X-Received: by 10.200.22.234 with SMTP id y39mr1267363qtk.59.1510823021166; Thu, 16 Nov 2017 01:03:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510823021; cv=none; d=google.com; s=arc-20160816; b=gKS0yf72OUtXlsBmH9Po4KRqczXWnYKtKCL49N5k1tG16o26e+vTIBX5c9hWrxbrpm IzRW8Rq79Oh7dTymm5wmweKEgj8QViZNRMqVPcu9ZwO7XK1ShVH89EXahmCx2i/N/Imc GIjC5IongEks8yRZG6H+W6WB9xs5HG9KqLnMSpZAQnkfn5t2Rdu08Xnx8GyE0pDtXnxP jlJVrP2Nn10FPhCYSafq0seVDXhVvRiWzVbDLqyj/hFpYd6NJoiM/Dis3uInp3hP35v3 ErA5YsW9Vp+Nqz7HDQEoBz4AAJAY3gzIZcELiv/swLDrS8H2vWrJUFiOohKFirJBuQOp nKWw== 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=u9w0cbw2UEjUNeYUM3AVkDoUcGrL/rrORWkkcI0PI8E=; b=IuIU+w01wl23V++m6T64uDfTaZI14YDEnncA6795Grpdx+nYeP9k56Gh8HGHZ9/bVN mAstn21e6aDo9yzxV5+nLY9YF+QEYxgrGeurAkDePdEYXJUnFBhsj9h12sUf0YhEBHEi mT0+Ht4a8NpSqERVPkJlHGEr3LlCGaM2+3X9wEbQHg8+UqUICYp8XnyrU1dKqa7w4KSf sNWGTbG41aywu058vUYViq7NfZiCjHCyFRKrtwE2QgdlmJ7FK+nIrXicP8OlGl1WoYip vNH8yaNF0IeAOyh8CcKRU5Rb1CwJoCufWu26Vu3GvOEPG+gcpNglgP2oENNXzVbQ+hZl ASRw== 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 e64si648424qkc.65.2017.11.16.01.03.40; Thu, 16 Nov 2017 01:03:41 -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 AFC236084B; Thu, 16 Nov 2017 09:03:40 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 DA518607A9; Thu, 16 Nov 2017 09:00:40 +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 AE62C60731; Thu, 16 Nov 2017 09:00:19 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id B8F9D60746 for ; Thu, 16 Nov 2017 09:00:11 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 4A4C951027E1 for ; Thu, 16 Nov 2017 12:00:09 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Ovv8K1xSMp-09MmY4oe; Thu, 16 Nov 2017 12:00:09 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id uK4C5BL58q-08H4xnmJ; Thu, 16 Nov 2017 12:00:08 +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: Thu, 16 Nov 2017 12:00:06 +0300 Message-Id: <1510822807-12483-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510822807-12483-1-git-send-email-odpbot@yandex.ru> References: <1510822807-12483-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 297 Subject: [lng-odp] [PATCH 2.0 v1 2/3] linux-gen: pktio: add pktio ops_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 Add memory pool for pktio entry private data. 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: 9a2195f21322cf4bcf5f0b7b2fb827746597d8a1 **/ .../include/odp_pktio_ops_subsystem.h | 31 ++++++++++++++ platform/linux-generic/pktio/subsystem.c | 50 +++++++++++++++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index cb107fed2..110c113b4 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -16,6 +16,7 @@ extern "C" { #include #include +#include /* ODP packet IO operations subsystem declaration */ ODP_SUBSYSTEM_DECLARE(pktio_ops); @@ -88,10 +89,40 @@ typedef ODP_MODULE_CLASS(pktio_ops) { /* Maximum size of pktio specific ops data.*/ #define ODP_PKTIO_ODPS_DATA_MAX_SIZE 80000 +/* Pktio ops data pool */ +#define ODP_PKTIO_OPS_DATA_POOL_SIZE 160000 +#define ODP_PKTIO_OPS_DATA_POOL_NAME "ODP_PKTIO_OPS_DATA" + /* Extract pktio ops data from pktio entry structure */ #define odp_ops_data(_p, _mod) \ ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s.ops_data) +#define odp_ops_data_alloc(_p, _mod) \ +({ \ + odpdrv_shm_pool_t _pool = ODPDRV_SHM_POOL_INVALID; \ + uint64_t _size = sizeof(pktio_ops_ ## _mod ## _data_t); \ + \ + _p->s.ops_data = NULL; \ + _pool = odpdrv_shm_pool_lookup(ODP_PKTIO_OPS_DATA_POOL_NAME); \ + if (_pool != ODPDRV_SHM_POOL_INVALID) \ + _p->s.ops_data = odpdrv_shm_pool_alloc(_pool, _size); \ + \ + ((pktio_ops_ ## _mod ## _data_t *)_p->s.ops_data); \ +}) + +#define odp_ops_data_free(_p) \ +({ \ + int _result = -1; \ + odpdrv_shm_pool_t _pool = ODPDRV_SHM_POOL_INVALID; \ + \ + _pool = odpdrv_shm_pool_lookup(ODP_PKTIO_OPS_DATA_POOL_NAME); \ + if (_pool != ODPDRV_SHM_POOL_INVALID) { \ + odpdrv_shm_pool_free(_pool, _p->s.ops_data); \ + _result = 0; \ + } \ + _result; \ +}) + #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/pktio/subsystem.c b/platform/linux-generic/pktio/subsystem.c index a3b36c144..abcec7253 100644 --- a/platform/linux-generic/pktio/subsystem.c +++ b/platform/linux-generic/pktio/subsystem.c @@ -15,9 +15,55 @@ ODP_SUBSYSTEM_DEFINE(pktio_ops, "packet IO operations", SUBSYSTEM_VERSION); /* Instantiate init and term functions */ -ODP_SUBSYSTEM_FOREACH_TEMPLATE(pktio_ops, init_global, ODP_ERR) +SUBSYSTEM_FOREACH_TEMPLATE(pktio_ops, init_global, ODP_ERR) +SUBSYSTEM_FOREACH_TEMPLATE(pktio_ops, term_global, ODP_ERR) ODP_SUBSYSTEM_FOREACH_TEMPLATE(pktio_ops, init_local, ODP_ERR) -ODP_SUBSYSTEM_FOREACH_TEMPLATE(pktio_ops, term_global, ODP_ABORT) + +int odp_pktio_ops_init_global(bool continue_on_errors) +{ + odpdrv_shm_pool_t pktio_ops_pool = ODPDRV_SHM_POOL_INVALID; + odpdrv_shm_pool_param_t 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"); + if (!continue_on_errors) + return -1; + } + + return pktio_ops_init_global(continue_on_errors); +} + +int odp_pktio_ops_term_global(bool continue_on_errors) +{ + int result = 0; + odpdrv_shm_pool_t pktio_ops_pool = ODPDRV_SHM_POOL_INVALID; + + result = pktio_ops_term_global(continue_on_errors); + if (result) { + ODP_ERR("error to pktio_ops_term_global\n"); + if (!continue_on_errors) + return -1; + } + + pktio_ops_pool = odpdrv_shm_pool_lookup(ODP_PKTIO_OPS_DATA_POOL_NAME); + if (pktio_ops_pool != ODPDRV_SHM_POOL_INVALID) { + if (odpdrv_shm_pool_destroy(pktio_ops_pool)) { + ODP_ERR("error pool_destroy pktio_ops pool\n"); + result = -1; + } + } else { + ODP_ERR("error pool_lookup pktio_ops pool\n"); + result = -1; + } + + return result; +} /* Temporary variable to enable link modules, * will remove in Makefile scheme changes.