From patchwork Tue Jan 30 16:00:08 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: 126273 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp3492949ljd; Tue, 30 Jan 2018 08:09:08 -0800 (PST) X-Google-Smtp-Source: AH8x226yLiDvY3+gemUf8EM+XOtCjDMVRp17CyYQeXG+IUzM+dw0s0bVe1Oe6xuHB38Qtfhahq8i X-Received: by 10.55.141.198 with SMTP id p189mr39719254qkd.65.1517328548427; Tue, 30 Jan 2018 08:09:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517328548; cv=none; d=google.com; s=arc-20160816; b=cLr9WyUT3CMS5I/kIbOrLvzCRCfDc836Z7YsBzhuUD2la8OuCVlb+0KfdUl5ZcgCRx PPF00jxcDBBIOKoSzU/5JZ/GAAOIeRDaL2m6mh16ChdNfzaG6cY0xB49AMnSPs8qqHtw F4o7d/HJYTi8+CNN7p7V2sVpVUOi9Ugeod72KAf5xCQRtoV/YAMkt+FvSNP/wZrFrvcW YKzbbgfLxESmjTx61Me0mAE3JYoTHCfNd5BWOxGbzvEL3U66PccBKb0SoHtsJE5NP4de qDGTsBFRmn2sQu41ZdN+P8Sfh6cX/FO6xZfxCVH7+KWGdnSlmcHSbHx+51ZqhqGll8UA 0T9Q== 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=o5BBQxD03rwY94WbhcgWPBkBQyEstkp1gmmgE9xyqXA=; b=Ej3fnrq7/K70RdiKGpomiB5frWNcaA9FoWIDxV/r2STGLCig4L1AQ/7Wm/1bGvxTo3 nJ02gJr3gyTmTyXD/vG4tUVNJBDPbxt7eehqv8iFV5WfiKx4ZR++Gq3ndNh2/8aoGEiz pgu0CVJ6n77NUrlD4+CFWCO01D40HMwhzK0+ZhjKmJmaESaeM3s0IOEMsdRrTJCt8vHw amEluuzHsElBgs0JS24RxA3PM9R9iDNb1QfM+utOJj9ZhoLD/jF5Akc4PiXYhuRGwBwR zuLWAzxd6h2oYPlIqPOpEHuLzvJpEHCMhjviq0xBgkwXrenyO9x6USrHDpBET0dUH0qj hotg== 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 y1si1420074qtk.162.2018.01.30.08.09.08; Tue, 30 Jan 2018 08:09:08 -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 1299F617C4; Tue, 30 Jan 2018 16:09:08 +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 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 CEA1161767; Tue, 30 Jan 2018 16:01:14 +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 483ED60C5E; Tue, 30 Jan 2018 16:00:29 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 81B6761506 for ; Tue, 30 Jan 2018 16:00:19 +0000 (UTC) Received: from mxback6g.mail.yandex.net (mxback6g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:167]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 13BC9560373D for ; Tue, 30 Jan 2018 19:00:18 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback6g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id BFPONncvQq-0H2Wjbv8; Tue, 30 Jan 2018 19:00:17 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id Nz8CQ597Mi-0HRaeXfm; Tue, 30 Jan 2018 19:00:17 +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: Tue, 30 Jan 2018 19:00:08 +0300 Message-Id: <1517328009-16379-11-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517328009-16379-1-git-send-email-odpbot@yandex.ru> References: <1517328009-16379-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 437 Subject: [lng-odp] [PATCH v1 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: ab7875c186fe80cfe103c5be5634b0eda312aed4 **/ 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