From patchwork Fri Nov 17 17:00:08 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: 119191 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp759897qgn; Fri, 17 Nov 2017 09:01:51 -0800 (PST) X-Google-Smtp-Source: AGs4zMbGWxfllV7SU3AdBmNBYxCH1FvdC5jBtcVGQe2RJzH6mZQ/o29cLtLMXeC9cE8Bk6kDNY4/ X-Received: by 10.200.24.80 with SMTP id n16mr9385689qtk.193.1510938110664; Fri, 17 Nov 2017 09:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510938110; cv=none; d=google.com; s=arc-20160816; b=zqWHoS7yQwDYlwqCbyDO+URio9VAIQDI0fiqYp6EigDDI/6rQ+LkrxSphx+0cKBZoS uz+MWofqxJ5vu/OihWGpmGl1ZYc0zjqek23M3r3yQ+EFp06NJNlAKaOOElJDA/aQb/pz PMhI6RgzLv4kDFA8zYkqer5C8vF9qvfqCipm2+rnbm3MdFj3MH+ng5umfG6WX+4gap1l komdNjvayhW+OQu93jf0P18lrMZ2biJuGyr33UViBKn6rExy8F1VNNFn6l36mRmhEuVm FjhRe7EM20/AoAPq/fExL9X4isVNHzxq9d5Ce8hR96vKThVz0mtCpetsd/OsMJSiW3iT SJ3A== 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=dpR+jeNCiQimGXifs92oJZBLIajAK0TPXl92nFclMJE=; b=oV6wGcKZStp3lVwy4lnOCqC/EFWGG6EzkIi2d/aM3veAYdryuko+4Pk0eExPgSIVhH hKXzzTx7qGGrjptQNqVPpUMUfaUgm8ihk2PhX30K0ejfAYkp9qX2zeod9H5RawD9NMwm KZ5tkonwcv1gDkpZzUb7tOT/J6lP2QD7aWq0ztWme/nky6FZ5ARZjFv22CHD/JAmgnQm QI8z6SDvdgw5DPnup0FaIK344pzUcgQTb16Iio87mcF9NvCnWIO7ih+FjoBzMZonKD6e hkqlhblkgWHk1WfD2AR8SG6nA5lOKuxnlbKOYLUeXTVJh+Ug14w3n0M4Aw/hV3TrVll1 j2zA== 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 u21si3216279qkl.34.2017.11.17.09.01.50; Fri, 17 Nov 2017 09:01:50 -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 398196088C; Fri, 17 Nov 2017 17:01:50 +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 57E26607E5; Fri, 17 Nov 2017 17: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 9F382607F6; Fri, 17 Nov 2017 17:00:20 +0000 (UTC) Received: from forward101p.mail.yandex.net (forward101p.mail.yandex.net [77.88.28.101]) by lists.linaro.org (Postfix) with ESMTPS id 0B259607BA for ; Fri, 17 Nov 2017 17:00:13 +0000 (UTC) Received: from mxback1j.mail.yandex.net (mxback1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10a]) by forward101p.mail.yandex.net (Yandex) with ESMTP id 03A966A85365 for ; Fri, 17 Nov 2017 20:00:12 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id MsXwFhR1Aw-0BrWqxCh; Fri, 17 Nov 2017 20:00:11 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id fMGIr6c0ch-0B4uZxot; Fri, 17 Nov 2017 20:00:11 +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:08 +0300 Message-Id: <1510938009-12495-3-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 2/3] linux-gen: pktio: add IO interface operations data allocate/free API 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 Pktios may use added macros to alloc/free operation data buffers 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_pktio_ops_subsystem.h | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/platform/linux-generic/include/odp_pktio_ops_subsystem.h b/platform/linux-generic/include/odp_pktio_ops_subsystem.h index cb107fed2..42cb6d2c5 100644 --- a/platform/linux-generic/include/odp_pktio_ops_subsystem.h +++ b/platform/linux-generic/include/odp_pktio_ops_subsystem.h @@ -15,7 +15,9 @@ extern "C" { #endif #include +#include #include +#include /* ODP packet IO operations subsystem declaration */ ODP_SUBSYSTEM_DECLARE(pktio_ops); @@ -92,6 +94,32 @@ typedef ODP_MODULE_CLASS(pktio_ops) { #define odp_ops_data(_p, _mod) \ ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s.ops_data) +#define odp_ops_data_alloc(_p, _size) \ +({ \ + odpdrv_shm_pool_t _pool; \ + \ + _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, \ + ROUNDUP_CACHE_LINE(_size)); \ + \ + _p->s.ops_data; \ +}) + +#define odp_ops_data_free(_p) \ +({ \ + 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, _p->s.ops_data); \ + _result = 0; \ + } \ + _result; \ +}) + #ifdef __cplusplus } #endif