From patchwork Wed Jan 31 14:00:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 126350 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp778100ljc; Wed, 31 Jan 2018 06:24:36 -0800 (PST) X-Google-Smtp-Source: AH8x224m1HO0HGYE9nOYWBdUWoAbcGX2UgLUI1YJusW/0abBjBPWU+oWU5zC5GarmYkrtCOhGfvV X-Received: by 10.55.72.208 with SMTP id v199mr6176822qka.295.1517408676370; Wed, 31 Jan 2018 06:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517408676; cv=none; d=google.com; s=arc-20160816; b=QwgeTEROxwCh5F88PmYxxhuK9C9ls+Bz+5xG6WmdCQbvXXLhLMzibE5ALodval8SGB VdFc9xfTcPlz1n35yv0oCPbKg/I6nstr7+dTIQYaLSRKHpBVhrUDCZHIMhbFH2nDjUO+ +UR+kHV4EQF2sO4mGYd9pB8Niwv9c7aA5MSdTT4tYGjbGznFa70Eud2vk4o+TwCuF6gz 5uufXSo4gNtA+WbiQ9V9mQGQqcPtCUcaCEc4nDPHAoATg6SJuvMiJ/sgXnZ+cRP5Cma5 il3+edpiAPy4OUIWYzNB8tUKoQQXcVqXqEzgZm35NShy2jQYLMFwylGZhM4EXAi7iDnx 2FCA== 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=O0cb734NXUxntvBBjdLkAwBjd4LLc1a+v2UBOEHp6Uc=; b=iF/E5etXHLUiquhcA9fk5hyPmADX9X1VvgtG6bTx2ohTVMijy2qmZufgfy7naJ7vaQ +nmDfqWNLIZ4kRowzMDWLOLkxVqN0W4yrkxREnHDfUp+dTCtu9THj9jx9YnTm/Urjs5t qiVo5tTrKWbEv++XzXKYSeI4sdtplBhzUeEm2PWK8vkWUYoSSPlqYtn62aOF3KU6Cxg8 /OiPibedm0xWq9bvMqEO+b+ikwjyvhRNsdqFUsGxHGDkcHwtaJZqJCozoRNn9ue0q1nu gyOYylRJTkBLSxA2MLXU6uncOvPEPLBEYKir0BbAMKlLYRnz1TKMqSuDXUy/npF6d+ge qSDw== 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 o56si4826892qto.84.2018.01.31.06.24.36; Wed, 31 Jan 2018 06:24:36 -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 EA732617AF; Wed, 31 Jan 2018 14:24:35 +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_H2 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 11C65617CA; Wed, 31 Jan 2018 14:06:47 +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 6EEBA617FD; Wed, 31 Jan 2018 14:06:39 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id C3BCA617CA for ; Wed, 31 Jan 2018 14:01:41 +0000 (UTC) Received: from mxback6j.mail.yandex.net (mxback6j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10f]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 3413A5105685 for ; Wed, 31 Jan 2018 17:00:20 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback6j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id i2nTydbSHA-0JZ0f4vm; Wed, 31 Jan 2018 17:00:19 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0JVSAolN; Wed, 31 Jan 2018 17:00:19 +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: Wed, 31 Jan 2018 17:00:10 +0300 Message-Id: <1517407211-19105-11-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517407211-19105-1-git-send-email-odpbot@yandex.ru> References: <1517407211-19105-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 437 Subject: [lng-odp] [PATCH v2 10/11] linux-gen: pktio: inline pktio index function 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: Petri Savolainen Inline packet IO interface handle to index conversion function which may be used frequently. Signed-off-by: Petri Savolainen --- /** Email created from pull request 437 (psavol:master-packet-optim) ** https://github.com/Linaro/odp/pull/437 ** Patch: https://github.com/Linaro/odp/pull/437.patch ** Base sha: b95ccd3db6eeb7358a877541747e06354429acdd ** Merge commit sha: 3c2134ecc18e4fd52cd526b5c067815ca73864cc **/ platform/linux-generic/Makefile.am | 3 +++ .../include-abi/odp/api/abi/packet_io.h | 4 +++ .../include/odp/api/plat/pktio_inlines.h | 27 +++++++++++++++++++ .../include/odp/api/plat/pktio_inlines_api.h | 31 ++++++++++++++++++++++ .../linux-generic/include/odp_packet_io_internal.h | 13 ++++----- platform/linux-generic/odp_packet.c | 4 ++- platform/linux-generic/odp_packet_io.c | 17 +++--------- platform/linux-generic/odp_pktio_api.c | 14 ++++++++++ 8 files changed, 93 insertions(+), 20 deletions(-) create mode 100644 platform/linux-generic/include/odp/api/plat/pktio_inlines.h create mode 100644 platform/linux-generic/include/odp/api/plat/pktio_inlines_api.h create mode 100644 platform/linux-generic/odp_pktio_api.c diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 10e38ac3c..1c2b625cb 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -30,6 +30,8 @@ odpapiplatinclude_HEADERS = \ include/odp/api/plat/packet_inline_types.h \ include/odp/api/plat/packet_inlines.h \ include/odp/api/plat/packet_inlines_api.h \ + include/odp/api/plat/pktio_inlines.h \ + include/odp/api/plat/pktio_inlines_api.h \ include/odp/api/plat/pool_inline_types.h \ include/odp/api/plat/std_clib_inlines.h \ include/odp/api/plat/strong_types.h \ @@ -205,6 +207,7 @@ __LIB__libodp_linux_la_SOURCES += \ odp_byteorder.c \ odp_packet_api.c \ odp_packet_flags_api.c \ + odp_pktio_api.c \ odp_std_clib.c \ odp_sync.c \ odp_thread_api.c \ diff --git a/platform/linux-generic/include-abi/odp/api/abi/packet_io.h b/platform/linux-generic/include-abi/odp/api/abi/packet_io.h index a84e858e6..07931b817 100644 --- a/platform/linux-generic/include-abi/odp/api/abi/packet_io.h +++ b/platform/linux-generic/include-abi/odp/api/abi/packet_io.h @@ -51,6 +51,10 @@ typedef struct odp_pktout_queue_t { * @} */ +#define _ODP_INLINE static inline +#include +#include + #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/include/odp/api/plat/pktio_inlines.h b/platform/linux-generic/include/odp/api/plat/pktio_inlines.h new file mode 100644 index 000000000..6a2aa72d8 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/pktio_inlines.h @@ -0,0 +1,27 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_PKTIO_INLINES_H_ +#define ODP_PLAT_PKTIO_INLINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +static inline int _odp_pktio_index(odp_pktio_t pktio) +{ + return (int)(uintptr_t)pktio - 1; +} + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/pktio_inlines_api.h b/platform/linux-generic/include/odp/api/plat/pktio_inlines_api.h new file mode 100644 index 000000000..5b59a4378 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/pktio_inlines_api.h @@ -0,0 +1,31 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + */ + +#ifndef ODP_PLAT_PKTIO_INLINES_API_H_ +#define ODP_PLAT_PKTIO_INLINES_API_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +_ODP_INLINE int odp_pktio_index(odp_pktio_t pktio) +{ + return _odp_pktio_index(pktio); +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index ad34e964a..1de0cbf90 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -18,6 +18,8 @@ extern "C" { #endif +#include +#include #include #include #include @@ -235,13 +237,10 @@ typedef struct pktio_if_ops { extern void *pktio_entry_ptr[]; -static inline int pktio_to_id(odp_pktio_t pktio) -{ - return _odp_typeval(pktio) - 1; -} - static inline pktio_entry_t *get_pktio_entry(odp_pktio_t pktio) { + int idx; + if (odp_unlikely(pktio == ODP_PKTIO_INVALID)) return NULL; @@ -251,7 +250,9 @@ static inline pktio_entry_t *get_pktio_entry(odp_pktio_t pktio) return NULL; } - return pktio_entry_ptr[pktio_to_id(pktio)]; + idx = _odp_pktio_index(pktio); + + return pktio_entry_ptr[idx]; } static inline int pktio_cls_enabled(pktio_entry_t *entry) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 488dcbddf..1909bae25 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include @@ -1269,7 +1271,7 @@ void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len, int odp_packet_input_index(odp_packet_t pkt) { - return odp_pktio_index(packet_hdr(pkt)->input); + return _odp_pktio_index(packet_hdr(pkt)->input); } void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ctx) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 460891d06..4eae4ed1e 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -481,7 +482,7 @@ int odp_pktio_start(odp_pktio_t hdl) } } - sched_fn->pktio_start(pktio_to_id(hdl), num, index, odpq); + sched_fn->pktio_start(_odp_pktio_index(hdl), num, index, odpq); } return res; @@ -1022,16 +1023,6 @@ int odp_pktio_info(odp_pktio_t hdl, odp_pktio_info_t *info) return 0; } -int odp_pktio_index(odp_pktio_t pktio) -{ - pktio_entry_t *entry = get_pktio_entry(pktio); - - if (!entry || is_free(entry)) - return -1; - - return pktio_to_id(pktio); -} - uint64_t odp_pktin_ts_res(odp_pktio_t hdl) { pktio_entry_t *entry; @@ -1361,7 +1352,7 @@ int odp_pktin_queue_config(odp_pktio_t pktio, mode == ODP_PKTIN_MODE_SCHED) { odp_queue_param_t queue_param; char name[ODP_QUEUE_NAME_LEN]; - int pktio_id = pktio_to_id(pktio); + int pktio_id = _odp_pktio_index(pktio); snprintf(name, sizeof(name), "odp-pktin-%i-%i", pktio_id, i); @@ -1496,7 +1487,7 @@ int odp_pktout_queue_config(odp_pktio_t pktio, odp_queue_param_t queue_param; queue_t q_int; char name[ODP_QUEUE_NAME_LEN]; - int pktio_id = pktio_to_id(pktio); + int pktio_id = _odp_pktio_index(pktio); snprintf(name, sizeof(name), "odp-pktout-%i-%i", pktio_id, i); diff --git a/platform/linux-generic/odp_pktio_api.c b/platform/linux-generic/odp_pktio_api.c new file mode 100644 index 000000000..f4dc33466 --- /dev/null +++ b/platform/linux-generic/odp_pktio_api.c @@ -0,0 +1,14 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "config.h" + +#include +#include + +/* Include non-inlined versions of API functions */ +#define _ODP_INLINE +#include