From patchwork Wed Jan 31 14:00:01 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: 126333 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp755242ljc; Wed, 31 Jan 2018 06:00:40 -0800 (PST) X-Google-Smtp-Source: AH8x224FqoibvZ9c4Ms3Yj3rEgp5HANCNnFG5cKbZB0UB8UMAU7IGDIzbXDmwp+IGb8JPeUhugW4 X-Received: by 10.233.230.67 with SMTP id x3mr13212369qkl.202.1517407240678; Wed, 31 Jan 2018 06:00:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517407240; cv=none; d=google.com; s=arc-20160816; b=wKFFMrUXvFGZ7CjYWSAsdhwC6vwWQFIYkn/mZGsiRItsBNNRSrVeuWMLraOPPynH9I aJTV/dgZ/I3PxJB9eiz8hdOfzZVWE8W2tLwjw79rzv4i9TW0TG/j/1Wz2dv2LwLLeRDj me6wfYQfNAJlEMC67JZv0aCwI8S6NoCddwjtUkcoj7q20oIvngkpcUoxMY0pMpMDAuot ORXqI46qmWw4ePsSC8SR2GY0P+xMttSwFbz83covaxw2UGI+rTHYi4COVv2neUs8jdGD LfsnUvDr3O53VIStlygvvjum0rWANMLcTEopuD4H3wVhCcPxhiBW05ldX8gdDR2pvYm2 fdww== 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=GZu2VpHLMaMBAKFFWY/Ef19XNB+1uexS6KfdrpEBIbI=; b=a5JLaFPSYWd/pxJbsf2tx8WabadRB3TajEUNDjqvJVTCxfVNdPgwiP+NoxGG+UZuDN QQjS4bcwGTPLMucOxVEpXTZ5pw5m+vVl851AU+5HvoNUxSbGIhqgvxkSHyc96jo7kTOG ktHHkdDQEreWu4yGqYcAD/fOdJjOWtenPNp1whqSLHLfTRRUOS7OA9/kCazblfB176bK QDgERsmd6OQ5+IYVkX/DDwgPCqq3uOZNAnTqAzqGIHEX+gmpMpdnoVCtfWU98zR+FQ0m /VCwv+CxBMLTg3fjfdq7fHO5i1b+haGWRm6iKtGEDX0rSUvf7urxC3deHvfIEAdBvPXl PQ6Q== 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 o56si4787382qto.84.2018.01.31.06.00.39; Wed, 31 Jan 2018 06:00:40 -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 29A5461794; Wed, 31 Jan 2018 14:00:39 +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 3DA22608EC; Wed, 31 Jan 2018 14:00:25 +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 5C89360C56; Wed, 31 Jan 2018 14:00:17 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id ABBC360872 for ; Wed, 31 Jan 2018 14:00:14 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward100o.mail.yandex.net (Yandex) with ESMTP id 32B282A25464 for ; Wed, 31 Jan 2018 17:00:13 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id ROHoIzoH4n-0DOup0Bm; Wed, 31 Jan 2018 17:00:13 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0CVuoDRk; Wed, 31 Jan 2018 17:00:12 +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:01 +0300 Message-Id: <1517407211-19105-2-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 1/11] linux-gen: packet: use inlined flow hash and ts set 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 Use inlined version of flow hash set function. Also changed API to use inlined timestamp function, so that the same function is not implemented twice. 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/include/odp_packet_internal.h | 7 +++++++ platform/linux-generic/odp_packet.c | 6 ++---- platform/linux-generic/pktio/dpdk.c | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 01e0cae17..32e41d7f5 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -331,6 +331,13 @@ static inline int packet_hdr_has_ipv6(odp_packet_hdr_t *pkt_hdr) return pkt_hdr->p.input_flags.ipv6; } +static inline void packet_set_flow_hash(odp_packet_hdr_t *pkt_hdr, + uint32_t flow_hash) +{ + pkt_hdr->flow_hash = flow_hash; + pkt_hdr->p.input_flags.flow_hash = 1; +} + static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, odp_time_t *ts) { if (ts != NULL) { diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index a4cd05f62..8d6185987 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1352,16 +1352,14 @@ void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - pkt_hdr->flow_hash = flow_hash; - pkt_hdr->p.input_flags.flow_hash = 1; + packet_set_flow_hash(pkt_hdr, flow_hash); } void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - pkt_hdr->timestamp = timestamp; - pkt_hdr->p.input_flags.timestamp = 1; + packet_set_ts(pkt_hdr, ×tamp); } /* diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 6fd4b1924..4ae72e10a 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -483,7 +483,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, pktio_entry->s.config.parser.layer); if (mbuf->ol_flags & PKT_RX_RSS_HASH) - odp_packet_flow_hash_set(pkt, mbuf->hash.rss); + packet_set_flow_hash(pkt_hdr, mbuf->hash.rss); packet_set_ts(pkt_hdr, ts); @@ -723,7 +723,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, pktio_entry->s.config.parser.layer); if (mbuf->ol_flags & PKT_RX_RSS_HASH) - odp_packet_flow_hash_set(pkt, mbuf->hash.rss); + packet_set_flow_hash(pkt_hdr, mbuf->hash.rss); packet_set_ts(pkt_hdr, ts); From patchwork Wed Jan 31 14:00:02 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: 126334 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp758166ljc; Wed, 31 Jan 2018 06:03:05 -0800 (PST) X-Google-Smtp-Source: AH8x224Mc6FUCpHtWH8BJPAWx8bO4ueDO4u//1KUb7C8WwzD617hUGRE34BNVIFeNJAinq/jWErs X-Received: by 10.37.121.4 with SMTP id u4mr1567725ybc.302.1517407385694; Wed, 31 Jan 2018 06:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517407385; cv=none; d=google.com; s=arc-20160816; b=faMW38qXZozp6ChwQ4j/U+OXWDogcO8G6CbsFE/IAe8GUPJ1lrNGjDK2ZKqyTsKf/m HNqcud2RXEL3CbwGzgCHB1oz9DbiEIHBC7yCyqhEShvt9ra2tT3LDgc4nnvZR21cQj2b RmxXMWIZWbQllLAJZo/5cqbRiMDfTyPKH6Plw9kQI3xO2RNDhtVpeowcUwCgiTEZul46 VVeY2MLklu0FVvXSs63ju7PqOmvcfqFe3ndlY2YE44ANEtAPWXatQuAEHn+4KtYAkAZ4 c/rYEMyCIfFFdQbaBcSrBMwr1Ydo6hr59gdbIlfhAfTflidSPEFN08/wwI7dYT4QwSgl swug== 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=ieAvB5kp5cE8RFg0QVnXsqztm0TFFSX6xCWEJNl+yEI=; b=QjPXsB/Tdd0pLDNueiL17i1ktNVhDGwHvNTjexjOMhhOb4PP7NDGvMqTLfug0Hi5z/ mW1CBuMIUiRirj+XFElPH0Ojn4mYatv8MAUA3Ht4Z+MTbPX4yG8y5dXGH+leUsXgUKPz g+ZEXYGBoEOkZa2+MmoAKSli1zyDUB4z8aKm7YImCfMl8yXzAh7GII20lIluaghUZ6Q4 fspXn0oMh1NUvEwuZB/qU3Lx4xKDQ7mPGSvb1refx+fgGTpPS6RAZsX6mjgyQeInzBAs XjMLpxQJrn23bwm2I8HJ2vvEVPqUSKuotPJT5SKtDRU8aA0P9U3yAmEbcSsJk5M8SKhl Lg3A== 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 s63si962595yba.752.2018.01.31.06.03.05; Wed, 31 Jan 2018 06:03: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 4BCBC617DA; Wed, 31 Jan 2018 14:03:05 +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 EE18361510; Wed, 31 Jan 2018 14:00:35 +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 8E0A1616E5; Wed, 31 Jan 2018 14:00:23 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id D76BE608EC for ; Wed, 31 Jan 2018 14:00:15 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 5772934C1935 for ; Wed, 31 Jan 2018 17:00:14 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id iEOpJUkbw8-0EI8ooJg; Wed, 31 Jan 2018 17:00:14 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0DVSXAHT; Wed, 31 Jan 2018 17:00:13 +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:02 +0300 Message-Id: <1517407211-19105-3-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 2/11] linux-gen: packet: remove dummy doxygen documentation 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 Use @cond tag to hide internal functions from Doxygen. 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 **/ .../include/odp/api/plat/packet_inlines.h | 39 +++------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index fb9c524fb..765bafb4f 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -23,63 +23,52 @@ #include #include -/** @internal Inline function @param pkt_ptr @param offset @param seg_len - * @param seg_idx @return */ +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + void *_odp_packet_map(void *pkt_ptr, uint32_t offset, uint32_t *seg_len, int *seg_idx); -/** @internal Inline function offsets */ extern const _odp_packet_inline_offset_t _odp_packet_inline; - -/** @internal Pool inline function offsets */ -extern const _odp_pool_inline_offset_t _odp_pool_inline; +extern const _odp_pool_inline_offset_t _odp_pool_inline; #ifndef _ODP_HAVE_PACKET_SEG_NDX #include -/** @internal Inline function @param seg @return */ static inline uint32_t _odp_packet_seg_to_ndx(odp_packet_seg_t seg) { return _odp_typeval(seg); } -/** @internal Inline function @param ndx @return */ static inline odp_packet_seg_t _odp_packet_seg_from_ndx(uint32_t ndx) { return _odp_cast_scalar(odp_packet_seg_t, ndx); } #endif -/** @internal Inline function @param pkt @return */ static inline void *_odp_packet_data(odp_packet_t pkt) { return _odp_pkt_get(pkt, void *, data); } -/** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_seg_len(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint32_t, seg_len); } -/** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_len(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint32_t, frame_len); } -/** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_headroom(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint16_t, headroom); } -/** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_tailroom(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint16_t, tailroom); } -/** @internal Inline function @param pkt @return */ static inline odp_pool_t _odp_packet_pool(odp_packet_t pkt) { void *pool = _odp_pkt_get(pkt, void *, pool); @@ -87,31 +76,26 @@ static inline odp_pool_t _odp_packet_pool(odp_packet_t pkt) return _odp_pool_get(pool, odp_pool_t, pool_hdl); } -/** @internal Inline function @param pkt @return */ static inline odp_pktio_t _odp_packet_input(odp_packet_t pkt) { return _odp_pkt_get(pkt, odp_pktio_t, input); } -/** @internal Inline function @param pkt @return */ static inline int _odp_packet_num_segs(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint8_t, segcount); } -/** @internal Inline function @param pkt @return */ static inline void *_odp_packet_user_ptr(odp_packet_t pkt) { return _odp_pkt_get(pkt, void *, user_ptr); } -/** @internal Inline function @param pkt @return */ static inline void *_odp_packet_user_area(odp_packet_t pkt) { return _odp_pkt_get(pkt, void *, user_area); } -/** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_user_area_size(odp_packet_t pkt) { void *pool = _odp_pkt_get(pkt, void *, pool); @@ -119,25 +103,21 @@ static inline uint32_t _odp_packet_user_area_size(odp_packet_t pkt) return _odp_pool_get(pool, uint32_t, uarea_size); } -/** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_l2_offset(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint16_t, l2_offset); } -/** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_l3_offset(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint16_t, l3_offset); } -/** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_l4_offset(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint16_t, l4_offset); } -/** @internal Inline function @param pkt @param len @return */ static inline void *_odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) { uint32_t offset = _odp_packet_l2_offset(pkt); @@ -156,7 +136,6 @@ static inline void *_odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) return data + offset; } -/** @internal Inline function @param pkt @param len @return */ static inline void *_odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) { uint32_t offset = _odp_packet_l3_offset(pkt); @@ -175,7 +154,6 @@ static inline void *_odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) return data + offset; } -/** @internal Inline function @param pkt @param len @return */ static inline void *_odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) { uint32_t offset = _odp_packet_l4_offset(pkt); @@ -194,31 +172,26 @@ static inline void *_odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) return data + offset; } -/** @internal Inline function @param pkt @return */ static inline uint32_t _odp_packet_flow_hash(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint32_t, flow_hash); } -/** @internal Inline function @param pkt @return */ static inline odp_time_t _odp_packet_ts(odp_packet_t pkt) { return _odp_pkt_get(pkt, odp_time_t, timestamp); } -/** @internal Inline function @param pkt @return */ static inline void *_odp_packet_head(odp_packet_t pkt) { return (uint8_t *)_odp_packet_data(pkt) - _odp_packet_headroom(pkt); } -/** @internal Inline function @param pkt @return */ static inline int _odp_packet_is_segmented(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint8_t, segcount) > 1; } -/** @internal Inline function @param pkt @return */ static inline odp_packet_seg_t _odp_packet_first_seg(odp_packet_t pkt) { (void)pkt; @@ -226,13 +199,11 @@ static inline odp_packet_seg_t _odp_packet_first_seg(odp_packet_t pkt) return _odp_packet_seg_from_ndx(0); } -/** @internal Inline function @param pkt @return */ static inline odp_packet_seg_t _odp_packet_last_seg(odp_packet_t pkt) { return _odp_packet_seg_from_ndx(_odp_packet_num_segs(pkt) - 1); } -/** @internal Inline function @param pkt @param seg @return */ static inline odp_packet_seg_t _odp_packet_next_seg(odp_packet_t pkt, odp_packet_seg_t seg) { @@ -243,17 +214,17 @@ static inline odp_packet_seg_t _odp_packet_next_seg(odp_packet_t pkt, return seg + 1; } -/** @internal Inline function @param pkt @param offset @param len */ static inline void _odp_packet_prefetch(odp_packet_t pkt, uint32_t offset, uint32_t len) { (void)pkt; (void)offset; (void)len; } -/** @internal Inline function @param pkt @return */ static inline odp_buffer_t packet_to_buffer(odp_packet_t pkt) { return (odp_buffer_t)pkt; } +/** @endcond */ + #endif From patchwork Wed Jan 31 14:00:03 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: 126356 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp781656ljc; Wed, 31 Jan 2018 06:29:00 -0800 (PST) X-Google-Smtp-Source: AH8x224EA3ULHJcNgkDm2KvVzCQiiXJ8v0/tK8vD4yhgUGRY4EcKfMC3DRr4rqI34g0hL5dW5Pot X-Received: by 10.200.46.214 with SMTP id i22mr53275558qta.157.1517408939848; Wed, 31 Jan 2018 06:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517408939; cv=none; d=google.com; s=arc-20160816; b=AtUCBw4mAQMiWGhYTrlUOvvB8JYd9WyH1Ag7hA9yBRiq0+cYSY39rqNmBE6PFF6NOW 3njFequJgaoeZNPYeGt9/ycJEtJfANpg0bbTIOc9MFUpdPqwqh9V1vyaFmbin1/0Vnvm JGHradz3MPkP4DOp1qq8tPgCHcscLSTwO5do8A/JO5gt59OooxMo4iz4Q//7t8PHEQzF Qk9o4vcn7u15X6kEFMp24JI8OKSut4lHHeINxBO9yuJ86jWcDkfd2nKhjXiYTjig0DOY IwgCkazffHofWQxXbst9sw7XIH4tgQxnStGpn9fhPxezaS4xwE8OBf+yCWxpGe9eyuLi 3I1A== 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=F0LuuABFVf/zBklQdK6ysy2lYA8W8EHKy42urpReHyM=; b=TU2+97vhzxFNivLX0GgR35WKy1AcHfWkfWk692FdFmle6fScz0GoojfbxbGgO/Lx6n JtLIcwjXSBCCjMgCGAwjjSWRl3JNklBND98v251+VYJ4ynkw01xtCRjc+1cOt/C+x+KG GKNoA31vGNHn5w657WDmgnlRNLI0eQY1d11EZJyPPDrsQGMRi3nK0Us8G4uiNkwdIopP iUsWfWvmnA938rueJjrCNCOWSXpze4hfcpTlqOeL+Tw3IoGcJ/j0bOFBm61GJitWjqLh LQkv4H70LQbJ5eeWncyF22EWMar1Ss2ni824X300tfFy9m+bXw0VqOHKwNSHG8p3bzDN dT3Q== 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 l17si634059qkk.475.2018.01.31.06.28.59; Wed, 31 Jan 2018 06:28:59 -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 86F71617A6; Wed, 31 Jan 2018 14:28:59 +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 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 3B89D6181D; Wed, 31 Jan 2018 14:08:05 +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 E1C6761807; Wed, 31 Jan 2018 14:07:50 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id 3F8F261732 for ; Wed, 31 Jan 2018 14:02:17 +0000 (UTC) Received: from mxback2j.mail.yandex.net (mxback2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10b]) by forward104p.mail.yandex.net (Yandex) with ESMTP id 090E0185229 for ; Wed, 31 Jan 2018 17:00:15 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id SAie31dQJw-0EK8XvcR; Wed, 31 Jan 2018 17:00:14 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0EVSCxFF; Wed, 31 Jan 2018 17:00:14 +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:03 +0300 Message-Id: <1517407211-19105-4-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 3/11] linux-gen: packet: inline copy functions 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 commonly used packet to/from memory copy functions. 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 **/ .../include/odp/api/plat/packet_inlines.h | 36 ++++++++ .../include/odp/api/plat/packet_inlines_api.h | 12 +++ platform/linux-generic/odp_packet.c | 96 +++++++++++----------- 3 files changed, 96 insertions(+), 48 deletions(-) diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index 765bafb4f..90e205fd4 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -23,11 +23,19 @@ #include #include +#include + /** @cond _ODP_HIDE_FROM_DOXYGEN_ */ void *_odp_packet_map(void *pkt_ptr, uint32_t offset, uint32_t *seg_len, int *seg_idx); +int _odp_packet_copy_from_mem_seg(odp_packet_t pkt, uint32_t offset, + uint32_t len, const void *src); + +int _odp_packet_copy_to_mem_seg(odp_packet_t pkt, uint32_t offset, + uint32_t len, void *dst); + extern const _odp_packet_inline_offset_t _odp_packet_inline; extern const _odp_pool_inline_offset_t _odp_pool_inline; @@ -225,6 +233,34 @@ static inline odp_buffer_t packet_to_buffer(odp_packet_t pkt) return (odp_buffer_t)pkt; } +static inline int _odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset, + uint32_t len, const void *src) +{ + uint32_t seg_len = _odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)_odp_packet_data(pkt); + + if (odp_unlikely(offset + len > seg_len)) + return _odp_packet_copy_from_mem_seg(pkt, offset, len, src); + + memcpy(data + offset, src, len); + + return 0; +} + +static inline int _odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, + uint32_t len, void *dst) +{ + uint32_t seg_len = _odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)_odp_packet_data(pkt); + + if (odp_unlikely(offset + len > seg_len)) + return _odp_packet_copy_to_mem_seg(pkt, offset, len, dst); + + memcpy(dst, data + offset, len); + + return 0; +} + /** @endcond */ #endif diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h index c90a69c52..9b31c923f 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h @@ -140,4 +140,16 @@ _ODP_INLINE void odp_packet_prefetch(odp_packet_t pkt, uint32_t offset, return _odp_packet_prefetch(pkt, offset, len); } +_ODP_INLINE int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset, + uint32_t len, const void *src) +{ + return _odp_packet_copy_from_mem(pkt, offset, len, src); +} + +_ODP_INLINE int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, + uint32_t len, void *dst) +{ + return _odp_packet_copy_to_mem(pkt, offset, len, dst); +} + #endif diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 8d6185987..2867e67e9 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -334,6 +334,54 @@ void *_odp_packet_map(void *pkt_ptr, uint32_t offset, uint32_t *seg_len, return packet_map(pkt_ptr, offset, seg_len, seg_idx); } +int _odp_packet_copy_from_mem_seg(odp_packet_t pkt, uint32_t offset, + uint32_t len, const void *src) +{ + void *mapaddr; + uint32_t seglen = 0; /* GCC */ + uint32_t cpylen; + const uint8_t *srcaddr = (const uint8_t *)src; + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + + if (offset + len > pkt_hdr->frame_len) + return -1; + + while (len > 0) { + mapaddr = packet_map(pkt_hdr, offset, &seglen, NULL); + cpylen = len > seglen ? seglen : len; + memcpy(mapaddr, srcaddr, cpylen); + offset += cpylen; + srcaddr += cpylen; + len -= cpylen; + } + + return 0; +} + +int _odp_packet_copy_to_mem_seg(odp_packet_t pkt, uint32_t offset, + uint32_t len, void *dst) +{ + void *mapaddr; + uint32_t seglen = 0; /* GCC */ + uint32_t cpylen; + uint8_t *dstaddr = (uint8_t *)dst; + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + + if (offset + len > pkt_hdr->frame_len) + return -1; + + while (len > 0) { + mapaddr = packet_map(pkt_hdr, offset, &seglen, NULL); + cpylen = len > seglen ? seglen : len; + memcpy(dstaddr, mapaddr, cpylen); + offset += cpylen; + dstaddr += cpylen; + len -= cpylen; + } + + return 0; +} + #include void packet_parse_reset(odp_packet_hdr_t *pkt_hdr) @@ -1595,54 +1643,6 @@ odp_packet_t odp_packet_copy_part(odp_packet_t pkt, uint32_t offset, return newpkt; } -int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, - uint32_t len, void *dst) -{ - void *mapaddr; - uint32_t seglen = 0; /* GCC */ - uint32_t cpylen; - uint8_t *dstaddr = (uint8_t *)dst; - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - if (offset + len > pkt_hdr->frame_len) - return -1; - - while (len > 0) { - mapaddr = packet_map(pkt_hdr, offset, &seglen, NULL); - cpylen = len > seglen ? seglen : len; - memcpy(dstaddr, mapaddr, cpylen); - offset += cpylen; - dstaddr += cpylen; - len -= cpylen; - } - - return 0; -} - -int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset, - uint32_t len, const void *src) -{ - void *mapaddr; - uint32_t seglen = 0; /* GCC */ - uint32_t cpylen; - const uint8_t *srcaddr = (const uint8_t *)src; - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - if (offset + len > pkt_hdr->frame_len) - return -1; - - while (len > 0) { - mapaddr = packet_map(pkt_hdr, offset, &seglen, NULL); - cpylen = len > seglen ? seglen : len; - memcpy(mapaddr, srcaddr, cpylen); - offset += cpylen; - srcaddr += cpylen; - len -= cpylen; - } - - return 0; -} - int odp_packet_copy_from_pkt(odp_packet_t dst, uint32_t dst_offset, odp_packet_t src, uint32_t src_offset, uint32_t len) From patchwork Wed Jan 31 14:00:04 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: 126347 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp774856ljc; Wed, 31 Jan 2018 06:20:41 -0800 (PST) X-Google-Smtp-Source: AH8x227PsDtxmqd6HfVk4+VTC2Gk6PEEpY/aCZcn4MJjGoCsTPe/Rs7DBCLaHMBy+GP2VqqZKA/h X-Received: by 10.200.54.208 with SMTP id b16mr53033954qtc.187.1517408441845; Wed, 31 Jan 2018 06:20:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517408441; cv=none; d=google.com; s=arc-20160816; b=e/FUoZeSLLo6uBE393LhZnmmHvigzWcYLYUambmPTOKTRWibg6hCE1kKimozXeBYNJ Jgu8ka6fjJM0MmlVXiWdu4t2Rv0slf7w3cEsXhHymNhZoK/JfPsYhOwGONZr2/0z6xr2 lCuZx0+rZhukSt1ygX2vTJTl08NNQNCwivGhG10qhSeFYDzSq67vecroGJC45IwYs6JL 0FbOyczSiK8r6B9AgwsioY2bG9NFbBL2MrUntbtpnYkI3lW/Zb2unf2k6WGIsrgjMGVi /PHt89dTcyGXz9MD509Rc6M42dwx6XiivNJjtDyJvU7YlZCO/Mz1QZ7+O91ZstFabjC1 AIog== 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=dp/rZM1WgJ6kHv3YEQd2z3t5JbRVPpmzy29ka28zgok=; b=GN5B0ichQYM94YoUqCWdiI4j3yOU0WooHCj7HdYjv7fpX6TBUtnCefdRZVhk8FGuYn DE2H4t2GgaOClfJHF6qH4kEmkdxMjuQXxO5y7a17FFDdao6oqa8DW9ZFNHWObZBp/MXk AQI+VXHhDV07k75evmTNofL58FZyI9gMFSNd+53MPNaxgwiZWm1GeknNAARMGykiW0Lh NbPxBnUfMES06Wwsl+5v4iMAapONp2NdNb3uceI6Vr1kyWH0iOPXfy02RpGT8bcm0/HG EYcRpHbZBLGHCQRJfI/vcci8dI8kK3peozSh5onXMxREu8Su6q04k3P4XjVfn+nYQ3kQ o2pA== 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 h199si2046077qke.456.2018.01.31.06.20.41; Wed, 31 Jan 2018 06:20: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 6D20B617D6; Wed, 31 Jan 2018 14:20:41 +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 99F26617C3; Wed, 31 Jan 2018 14:05:21 +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 076BC60813; Wed, 31 Jan 2018 14:05:17 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id 0A6C0617C6 for ; Wed, 31 Jan 2018 14:01:14 +0000 (UTC) Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward105j.mail.yandex.net (Yandex) with ESMTP id B413C18639B for ; Wed, 31 Jan 2018 17:00:15 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id QyMFTbP6k6-0FRWV15D; Wed, 31 Jan 2018 17:00:15 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0FVWLKmA; Wed, 31 Jan 2018 17:00:15 +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:04 +0300 Message-Id: <1517407211-19105-5-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 4/11] linux-gen: packet: use inlined copy functions 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 Use always inlined versions of packet to/from memory copy functions. 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/odp_traffic_mngr.c | 24 ++++++++++++------------ platform/linux-generic/pktio/dpdk.c | 4 ++-- platform/linux-generic/pktio/netmap.c | 4 ++-- platform/linux-generic/pktio/pcap.c | 5 +++-- platform/linux-generic/pktio/socket_mmap.c | 7 ++++--- platform/linux-generic/pktio/tap.c | 5 +++-- 6 files changed, 26 insertions(+), 23 deletions(-) diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index 557e77ba3..03094cc37 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -1941,8 +1941,8 @@ static void egress_vlan_marking(tm_vlan_marking_t *vlan_marking, * correctness rather then performance. */ split_hdr = hdr_len < (_ODP_ETHHDR_LEN + _ODP_VLANHDR_LEN); if (split_hdr) { - odp_packet_copy_to_mem(odp_pkt, _ODP_ETHHDR_LEN, - _ODP_VLANHDR_LEN, &vlan_hdr); + _odp_packet_copy_to_mem(odp_pkt, _ODP_ETHHDR_LEN, + _ODP_VLANHDR_LEN, &vlan_hdr); vlan_hdr_ptr = &vlan_hdr; } @@ -1956,8 +1956,8 @@ static void egress_vlan_marking(tm_vlan_marking_t *vlan_marking, vlan_hdr_ptr->tci = _odp_cpu_to_be_16(new_tci); if (split_hdr) - odp_packet_copy_from_mem(odp_pkt, _ODP_ETHHDR_LEN, - _ODP_VLANHDR_LEN, &vlan_hdr); + _odp_packet_copy_from_mem(odp_pkt, _ODP_ETHHDR_LEN, + _ODP_VLANHDR_LEN, &vlan_hdr); } static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, @@ -1980,8 +1980,8 @@ static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, * correctness rather then performance. */ split_hdr = hdr_len < 12; if (split_hdr) { - odp_packet_copy_to_mem(odp_pkt, l3_offset, - _ODP_IPV4HDR_LEN, &ipv4_hdr); + _odp_packet_copy_to_mem(odp_pkt, l3_offset, + _ODP_IPV4HDR_LEN, &ipv4_hdr); ipv4_hdr_ptr = &ipv4_hdr; } @@ -2022,8 +2022,8 @@ static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, ipv4_hdr_ptr->tos = new_tos; ipv4_hdr_ptr->chksum = _odp_cpu_to_be_16((~ones_compl_sum) & 0xFFFF); if (split_hdr) - odp_packet_copy_from_mem(odp_pkt, l3_offset, - _ODP_IPV4HDR_LEN, &ipv4_hdr); + _odp_packet_copy_from_mem(odp_pkt, l3_offset, + _ODP_IPV4HDR_LEN, &ipv4_hdr); } static void egress_ipv6_tc_marking(tm_tos_marking_t *tos_marking, @@ -2046,8 +2046,8 @@ static void egress_ipv6_tc_marking(tm_tos_marking_t *tos_marking, * correctness rather then performance. */ split_hdr = hdr_len < 4; if (split_hdr) { - odp_packet_copy_to_mem(odp_pkt, l3_offset, - _ODP_IPV6HDR_LEN, &ipv6_hdr); + _odp_packet_copy_to_mem(odp_pkt, l3_offset, + _ODP_IPV6HDR_LEN, &ipv6_hdr); ipv6_hdr_ptr = &ipv6_hdr; } @@ -2075,8 +2075,8 @@ static void egress_ipv6_tc_marking(tm_tos_marking_t *tos_marking, ipv6_hdr_ptr->ver_tc_flow = _odp_cpu_to_be_32(new_ver_tc_flow); if (split_hdr) - odp_packet_copy_from_mem(odp_pkt, l3_offset, - _ODP_IPV6HDR_LEN, &ipv6_hdr); + _odp_packet_copy_from_mem(odp_pkt, l3_offset, + _ODP_IPV6HDR_LEN, &ipv6_hdr); } static void tm_egress_marking(tm_system_t *tm_system, odp_packet_t odp_pkt) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 4ae72e10a..86d7a4513 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -471,7 +471,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, pkt_hdr = odp_packet_hdr(pkt); pull_tail(pkt_hdr, alloc_len - pkt_len); - if (odp_packet_copy_from_mem(pkt, 0, pkt_len, data) != 0) + if (_odp_packet_copy_from_mem(pkt, 0, pkt_len, data) != 0) goto fail; pkt_hdr->input = pktio_entry->s.handle; @@ -649,7 +649,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, /* Packet always fits in mbuf */ data = rte_pktmbuf_append(mbuf_table[i], pkt_len); - odp_packet_copy_to_mem(pkt_table[i], 0, pkt_len, data); + _odp_packet_copy_to_mem(pkt_table[i], 0, pkt_len, data); if (odp_unlikely(pktio_entry->s.chksum_insert_ena)) { odp_pktout_config_opt_t *pktout_capa = diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index a7c479001..c03564f4e 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -652,7 +652,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, /* For now copy the data in the mbuf, worry about zero-copy later */ - if (odp_packet_copy_from_mem(pkt, 0, len, slot.buf) != 0) + if (_odp_packet_copy_from_mem(pkt, 0, len, slot.buf) != 0) goto fail; pkt_hdr->input = pktio_entry->s.handle; @@ -938,7 +938,7 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index, buf = NETMAP_BUF(ring, ring->slot[slot_id].buf_idx); - if (odp_packet_copy_to_mem(pkt, 0, pkt_len, buf)) { + if (_odp_packet_copy_to_mem(pkt, 0, pkt_len, buf)) { i = NM_INJECT_RETRIES; break; } diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index 7fc925149..76cbf9eef 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -249,7 +250,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, pkt_hdr = odp_packet_hdr(pkt); - if (odp_packet_copy_from_mem(pkt, 0, hdr->caplen, data) != 0) { + if (_odp_packet_copy_from_mem(pkt, 0, hdr->caplen, data) != 0) { ODP_ERR("failed to copy packet data\n"); break; } @@ -283,7 +284,7 @@ static int _pcapif_dump_pkt(pkt_pcap_t *pcap, odp_packet_t pkt) hdr.len = hdr.caplen; (void)gettimeofday(&hdr.ts, NULL); - if (odp_packet_copy_to_mem(pkt, 0, hdr.len, pcap->buf) != 0) + if (_odp_packet_copy_to_mem(pkt, 0, hdr.len, pcap->buf) != 0) return -1; pcap_dump(pcap->tx_dump, &hdr, pcap->buf); diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index b53173d29..2ace1a597 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -243,8 +244,8 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, continue; } hdr = odp_packet_hdr(pkt_table[nb_rx]); - ret = odp_packet_copy_from_mem(pkt_table[nb_rx], 0, - pkt_len, pkt_buf); + ret = _odp_packet_copy_from_mem(pkt_table[nb_rx], 0, + pkt_len, pkt_buf); if (ret != 0) { odp_packet_free(pkt_table[nb_rx]); mmap_rx_user_ready(ppd.raw); /* drop */ @@ -345,7 +346,7 @@ static inline unsigned pkt_mmap_v2_tx(int sock, struct ring *ring, buf = (uint8_t *)ppd.raw + TPACKET2_HDRLEN - sizeof(struct sockaddr_ll); - odp_packet_copy_to_mem(pkt_table[i], 0, pkt_len, buf); + _odp_packet_copy_to_mem(pkt_table[i], 0, pkt_len, buf); mmap_tx_user_ready(ppd.raw); diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index ebd4d94be..ccfa19b25 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -273,7 +274,7 @@ static odp_packet_t pack_odp_pkt(pktio_entry_t *pktio_entry, const void *data, if (num != 1) return ODP_PACKET_INVALID; - if (odp_packet_copy_from_mem(pkt, 0, len, data) < 0) { + if (_odp_packet_copy_from_mem(pkt, 0, len, data) < 0) { ODP_ERR("failed to copy packet data\n"); odp_packet_free(pkt); return ODP_PACKET_INVALID; @@ -352,7 +353,7 @@ static int tap_pktio_send_lockless(pktio_entry_t *pktio_entry, break; } - if (odp_packet_copy_to_mem(pkts[i], 0, pkt_len, buf) < 0) { + if (_odp_packet_copy_to_mem(pkts[i], 0, pkt_len, buf) < 0) { ODP_ERR("failed to copy packet data\n"); break; } From patchwork Wed Jan 31 14:00:05 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: 126336 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp760920ljc; Wed, 31 Jan 2018 06:05:45 -0800 (PST) X-Google-Smtp-Source: AH8x225TbbeJu6hThzYlFY4kAUbvp/24WE7DUqaOw7WUah0sEjkrSez5HDd62dg73xJCQpcG69Hw X-Received: by 10.37.9.9 with SMTP id 9mr21515843ybj.398.1517407544793; Wed, 31 Jan 2018 06:05:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517407544; cv=none; d=google.com; s=arc-20160816; b=nvqySIcIBRNbC4WZcFyI+TMx+Ikpdumga7HraOcgg4tpIKNuXqHZGz7J/+vNAz9Cvw 6IA4iKPSMOuCulthyDp2NUTewuXhGjHe0ATo55uJwtHbGqa6e7rOqWOe8hBzdmacx4fq ARw8qEPGmUxOoDg/HqSmUA0EG1CKPEivgH4h5zCumbAg4dkOR1ANzJUEuue7TU9GCbr+ 9NeHl9xSrImezZH4mwKrZ7FH1gzQXLLJmvDbahBwvcABwSdsbqAEL0/x/aCIqB0dBltV mXk8OhkHF3+sxPV5+HN2idD8aECj+O1b3Rj6hztpMxuCBKI6sAhrBmWbruD7Tzbhzl4T w6xA== 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=AJ/z/gLAmrlrU+Qzr3ImqQnAxHVBbxYixBzCe2LbdAc=; b=vHpz8mKyipRPFqlUz0NKJtVY6tYF9ACxctQ702ii0eCwNwzM14RQjfRusnakRFHMdM 5KccPwOSJ8re01xhI/VTSZpaODFRlUENk1AW8ELwVtMwiQ/YQ7RvUlHaFes1vBmnW1UJ wnM7INks3uaXW+a3NolA17E46heaIeNk6bL0HMjcelPBMtKzGbsBeCsxNfw4B6LQml5M Md74DErWFVYa+o27VUJvO1eaAsjORLa3nQFBUySfP5LMr4+0fw4+ZZBCsQgaYj9/S02+ AvTipAgXM2zSgsDjsjmNJfkLr0IWiLLlTVmYz47Yw1GMUAJ8bm0FzwDrIxjW0Z2Hbhxp RKAw== 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 41si2212753qtz.152.2018.01.31.06.05.44; Wed, 31 Jan 2018 06:05:44 -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 38597617F8; Wed, 31 Jan 2018 14:05:44 +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 B2D6C617A4; Wed, 31 Jan 2018 14:00:49 +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 7867D60C4C; Wed, 31 Jan 2018 14:00:30 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id AAD3160872 for ; Wed, 31 Jan 2018 14:00:18 +0000 (UTC) Received: from mxback11j.mail.yandex.net (mxback11j.mail.yandex.net [IPv6:2a02:6b8:0:1619::84]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 986B44085C36 for ; Wed, 31 Jan 2018 17:00:16 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback11j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id m6dHKVQpte-0Geel2Pn; Wed, 31 Jan 2018 17:00:16 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0FV8Jt0n; Wed, 31 Jan 2018 17:00:15 +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:05 +0300 Message-Id: <1517407211-19105-6-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 5/11] linux-gen: packet: remove odp_packet_hdr 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 Use only one function (packet_hdr) in handle to header pointer conversion. odp_packet_hdr is bad name for an implementation internal function as API function prefix is odp_packet_. 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 **/ .../include/odp/api/plat/packet_inlines.h | 5 ----- .../linux-generic/include/odp_packet_internal.h | 8 ++++---- platform/linux-generic/odp_crypto.c | 4 ++-- platform/linux-generic/odp_ipsec.c | 8 ++++---- platform/linux-generic/odp_packet.c | 10 +++++----- platform/linux-generic/odp_packet_flags.c | 22 +++++++++++----------- platform/linux-generic/odp_packet_io.c | 4 ++-- platform/linux-generic/pktio/dpdk.c | 12 ++++++------ platform/linux-generic/pktio/ipc.c | 14 +++++++------- platform/linux-generic/pktio/loop.c | 2 +- platform/linux-generic/pktio/netmap.c | 2 +- platform/linux-generic/pktio/pcap.c | 2 +- platform/linux-generic/pktio/socket.c | 2 +- platform/linux-generic/pktio/socket_mmap.c | 2 +- platform/linux-generic/pktio/tap.c | 2 +- 15 files changed, 47 insertions(+), 52 deletions(-) diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index 90e205fd4..dee8f71ce 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -228,11 +228,6 @@ static inline void _odp_packet_prefetch(odp_packet_t pkt, uint32_t offset, (void)pkt; (void)offset; (void)len; } -static inline odp_buffer_t packet_to_buffer(odp_packet_t pkt) -{ - return (odp_buffer_t)pkt; -} - static inline int _odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset, uint32_t len, const void *src) { diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 32e41d7f5..89009a021 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -169,7 +169,7 @@ typedef struct { /** * Return the packet header */ -static inline odp_packet_hdr_t *odp_packet_hdr(odp_packet_t pkt) +static inline odp_packet_hdr_t *packet_hdr(odp_packet_t pkt) { return (odp_packet_hdr_t *)(uintptr_t)pkt; } @@ -181,7 +181,7 @@ static inline odp_packet_t packet_handle(odp_packet_hdr_t *pkt_hdr) static inline odp_buffer_hdr_t *packet_to_buf_hdr(odp_packet_t pkt) { - return &odp_packet_hdr(pkt)->buf_hdr; + return &packet_hdr(pkt)->buf_hdr; } static inline odp_packet_t packet_from_buf_hdr(odp_buffer_hdr_t *buf_hdr) @@ -201,12 +201,12 @@ static inline seg_entry_t *seg_entry_last(odp_packet_hdr_t *hdr) static inline odp_event_subtype_t packet_subtype(odp_packet_t pkt) { - return odp_packet_hdr(pkt)->subtype; + return packet_hdr(pkt)->subtype; } static inline void packet_subtype_set(odp_packet_t pkt, int ev) { - odp_packet_hdr(pkt)->subtype = ev; + packet_hdr(pkt)->subtype = ev; } /** diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 8ae484fd8..325a9d066 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -1434,7 +1434,7 @@ odp_event_t odp_crypto_packet_to_event(odp_packet_t pkt) static odp_crypto_packet_result_t *get_op_result_from_packet(odp_packet_t pkt) { - odp_packet_hdr_t *hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *hdr = packet_hdr(pkt); return &hdr->crypto_op_result; } @@ -1520,7 +1520,7 @@ int odp_crypto_int(odp_packet_t pkt_in, (rc_cipher == ODP_CRYPTO_ALG_ERR_NONE) && (rc_auth == ODP_CRYPTO_ALG_ERR_NONE); - pkt_hdr = odp_packet_hdr(out_pkt); + pkt_hdr = packet_hdr(out_pkt); pkt_hdr->p.error_flags.crypto_err = !op_result->ok; /* Synchronous, simply return results */ diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index 521627f1d..586653d4e 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -158,7 +158,7 @@ static odp_ipsec_packet_result_t *ipsec_pkt_result(odp_packet_t packet) ODP_ASSERT(ODP_EVENT_PACKET_IPSEC == odp_event_subtype(odp_packet_to_event(packet))); - return &odp_packet_hdr(packet)->ipsec_ctx; + return &packet_hdr(packet)->ipsec_ctx; } static inline int _odp_ipv4_csum(odp_packet_t pkt, @@ -829,7 +829,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, return ipsec_sa; err: - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); pkt_hdr->p.error_flags.ipsec_err = 1; *pkt_out = pkt; @@ -1404,7 +1404,7 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, return ipsec_sa; err: - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); pkt_hdr->p.error_flags.ipsec_err = 1; @@ -1652,7 +1652,7 @@ int _odp_ipsec_try_inline(odp_packet_t pkt) result->sa = ipsec_sa->ipsec_sa_hdl; result->flag.inline_mode = 1; - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); pkt_hdr->p.input_flags.dst_queue = 1; pkt_hdr->dst_queue = queue_fn->from_ext(ipsec_sa->queue); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 2867e67e9..043e4cb5c 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -49,11 +49,6 @@ const _odp_packet_inline_offset_t ODP_ALIGNED_CACHE _odp_packet_inline = { #include -static inline odp_packet_hdr_t *packet_hdr(odp_packet_t pkt) -{ - return (odp_packet_hdr_t *)(uintptr_t)pkt; -} - static inline odp_buffer_t buffer_handle(odp_packet_hdr_t *pkt_hdr) { return (odp_buffer_t)pkt_hdr; @@ -69,6 +64,11 @@ odp_packet_t _odp_packet_from_buf_hdr(odp_buffer_hdr_t *buf_hdr) return (odp_packet_t)buf_hdr; } +static inline odp_buffer_t packet_to_buffer(odp_packet_t pkt) +{ + return (odp_buffer_t)pkt; +} + static inline seg_entry_t *seg_entry(odp_packet_hdr_t *hdr, uint32_t seg_idx) { diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index 96507c664..2909703f3 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -11,18 +11,18 @@ #include #define retflag(pkt, x) do { \ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \ + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); \ return pkt_hdr->p.x; \ } while (0) #define setflag(pkt, x, v) do { \ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); \ + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); \ pkt_hdr->p.x = (v) & 1; \ } while (0) int odp_packet_has_error(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return pkt_hdr->p.error_flags.all != 0; } @@ -31,7 +31,7 @@ int odp_packet_has_error(odp_packet_t pkt) int odp_packet_has_l2_error(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); /* L2 parsing is always done by default and hence no additional check is required */ return pkt_hdr->p.error_flags.frame_len @@ -46,7 +46,7 @@ int odp_packet_has_l3(odp_packet_t pkt) int odp_packet_has_l3_error(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return pkt_hdr->p.error_flags.ip_err; } @@ -58,7 +58,7 @@ int odp_packet_has_l4(odp_packet_t pkt) int odp_packet_has_l4_error(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return pkt_hdr->p.error_flags.tcp_err | pkt_hdr->p.error_flags.udp_err; } @@ -150,14 +150,14 @@ odp_packet_color_t odp_packet_color(odp_packet_t pkt) void odp_packet_color_set(odp_packet_t pkt, odp_packet_color_t color) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); pkt_hdr->p.input_flags.color = color; } odp_bool_t odp_packet_drop_eligible(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return !pkt_hdr->p.input_flags.nodrop; } @@ -174,7 +174,7 @@ int8_t odp_packet_shaper_len_adjust(odp_packet_t pkt) void odp_packet_shaper_len_adjust_set(odp_packet_t pkt, int8_t adj) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); pkt_hdr->p.output_flags.shaper_len_adj = adj; } @@ -288,14 +288,14 @@ void odp_packet_has_icmp_set(odp_packet_t pkt, int val) void odp_packet_has_flow_hash_clr(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); pkt_hdr->p.input_flags.flow_hash = 0; } void odp_packet_has_ts_clr(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); pkt_hdr->p.input_flags.timestamp = 0; } diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index b8dd7c90d..460891d06 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -570,7 +570,7 @@ static inline int pktin_recv_buf(odp_pktin_queue_t queue, for (i = 0; i < pkts; i++) { pkt = packets[i]; - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); buf_hdr = packet_to_buf_hdr(pkt); if (pkt_hdr->p.input_flags.dst_queue) { @@ -698,7 +698,7 @@ int sched_cb_pktin_poll_one(int pktio_index, num_rx = 0; for (i = 0; i < num_pkts; i++) { pkt = packets[i]; - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); if (odp_unlikely(pkt_hdr->p.input_flags.dst_queue)) { queue = pkt_hdr->dst_queue; buf_hdr = packet_to_buf_hdr(pkt); diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 86d7a4513..bd6920e6a 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -262,7 +262,7 @@ static int pool_dequeue_bulk(struct rte_mempool *mp, void **obj_table, for (i = 0; i < pkts; i++) { odp_packet_t pkt = packet_tbl[i]; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); struct rte_mbuf *mbuf = (struct rte_mbuf *) (uintptr_t)pkt_hdr->extra; if (pkt_hdr->extra_type != PKT_EXTRA_TYPE_DPDK) @@ -468,7 +468,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, } pkt = pkt_table[i]; - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); pull_tail(pkt_hdr, alloc_len - pkt_len); if (_odp_packet_copy_from_mem(pkt, 0, pkt_len, data) != 0) @@ -636,7 +636,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, return 0; } for (i = 0; i < num; i++) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt_table[i]); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt_table[i]); pkt_len = packet_len(pkt_hdr); @@ -697,7 +697,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, pkt_len = rte_pktmbuf_pkt_len(mbuf); pkt = (odp_packet_t)mbuf->userdata; - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); if (pktio_cls_enabled(pktio_entry)) { if (cls_classify_packet(pktio_entry, @@ -754,7 +754,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, for (i = 0; i < num; i++) { odp_packet_t pkt = pkt_table[i]; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); struct rte_mbuf *mbuf = (struct rte_mbuf *) (uintptr_t)pkt_hdr->extra; uint16_t pkt_len = odp_packet_len(pkt); @@ -1606,7 +1606,7 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, for (i = 0; i < mbufs && freed != copy_count; i++) { odp_packet_t pkt = pkt_table[i]; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (pkt_hdr->buf_hdr.segcount > 1) { if (odp_likely(i < tx_pkts)) diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index b6c493ea0..95b526646 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -507,14 +507,14 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, memcpy(pkt_data, rmt_data_ptr, phdr->frame_len); /* Copy packets L2, L3 parsed offsets and size */ - copy_packet_cls_metadata(phdr, odp_packet_hdr(pkt)); + copy_packet_cls_metadata(phdr, packet_hdr(pkt)); - odp_packet_hdr(pkt)->frame_len = phdr->frame_len; - odp_packet_hdr(pkt)->headroom = phdr->headroom; - odp_packet_hdr(pkt)->tailroom = phdr->tailroom; + packet_hdr(pkt)->frame_len = phdr->frame_len; + packet_hdr(pkt)->headroom = phdr->headroom; + packet_hdr(pkt)->tailroom = phdr->tailroom; /* Take classification fields */ - odp_packet_hdr(pkt)->p = phdr->p; + packet_hdr(pkt)->p = phdr->p; pkt_table[i] = pkt; } @@ -604,7 +604,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, odp_packet_hdr_t *pkt_hdr; pool_t *pool; - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); pool = pkt_hdr->buf_hdr.pool_ptr; if (pool->pool_idx != ipc_pool->pool_idx || @@ -626,7 +626,7 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, for (i = 0; i < num; i++) { uint64_t data_pool_off; odp_packet_t pkt = pkt_table_mapped[i]; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); odp_pool_t pool_hdl = odp_packet_pool(pkt); pool_t *pool = pool_entry_from_hdl(pool_hdl); diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index aecb0263a..0cf45acbd 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -101,7 +101,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, pkt = packet_from_buf_hdr(hdr_tbl[i]); pkt_len = odp_packet_len(pkt); - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); packet_parse_reset(pkt_hdr); if (pktio_cls_enabled(pktio_entry)) { diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index c03564f4e..66fe247d3 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -647,7 +647,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, } pkt = pkt_tbl[i]; - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); pull_tail(pkt_hdr, alloc_len - len); /* For now copy the data in the mbuf, diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index 76cbf9eef..889903ddd 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -248,7 +248,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, if (ts != NULL) ts_val = odp_time_global(); - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); if (_odp_packet_copy_from_mem(pkt, 0, hdr->caplen, data) != 0) { ODP_ERR("failed to copy packet data\n"); diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 71980b540..749377c09 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -639,7 +639,7 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, void *base = msgvec[i].msg_hdr.msg_iov->iov_base; struct ethhdr *eth_hdr = base; odp_packet_t pkt = pkt_table[i]; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); uint16_t pkt_len = msgvec[i].msg_len; int ret; diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 2ace1a597..852bc7669 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -243,7 +243,7 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, frame_num = next_frame_num; continue; } - hdr = odp_packet_hdr(pkt_table[nb_rx]); + hdr = packet_hdr(pkt_table[nb_rx]); ret = _odp_packet_copy_from_mem(pkt_table[nb_rx], 0, pkt_len, pkt_buf); if (ret != 0) { diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index ccfa19b25..56f90b31b 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -280,7 +280,7 @@ static odp_packet_t pack_odp_pkt(pktio_entry_t *pktio_entry, const void *data, return ODP_PACKET_INVALID; } - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); if (pktio_cls_enabled(pktio_entry)) copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); From patchwork Wed Jan 31 14:00:06 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: 126335 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp759708ljc; Wed, 31 Jan 2018 06:04:31 -0800 (PST) X-Google-Smtp-Source: AH8x2240BZ3XFCDTsoA9q4UxWtjcR9pSfKLaZ2kJvd5eAQOcPR/segcfWlpbOmDXK+P3yHmYqgzy X-Received: by 10.129.93.139 with SMTP id r133mr9995280ywb.422.1517407471685; Wed, 31 Jan 2018 06:04:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517407471; cv=none; d=google.com; s=arc-20160816; b=fD020wbjoHSe+90cC0AJMs0aNg0yF0WVDdEE2wKXeR/GV6/TzOYAfVt35+8eUrmj3R Ok8N8nIMVx4HDNvwBl2rRlnOdpGL2CksVIBmG2PlDrnMDDoyz46x5fUOU03QxIT9pkUO Y2qZJZ5FjLq0vkez73gSqrM6AFvGY9YDHAUPRjXV9mzKshzoN+ollvtbxOaQcE0T6U1Y pBsnLOAvQEp33Jq8Gp01Kymq7+2w3NnM1ks2oh+dWD/QWGl0UXZ/NmuVA8w+OsHUeoBX 0005q0/h0b4N4cId3Fz+uTP3OvNgh1JLnJyHudpB1+O8V6lu6X40MA/9txFQosbIg95P 9aRA== 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=NwGgkeYBZqPSbysPWKM5nWdVZUHYTC+wgjbY2/7A7qk=; b=WaU/Yehcf01dIUmUB7MM7BnRFAB0QoJIlROxtmW6zquiVHo3ySg7iq4VFZgH/5hQdv QCl/proORy90+Kg/Vy8TDKKtwSOJKRVFIS7H2YFZ+dJSeMZEnQCopmbjfEyYuGx3LZS0 0iWFoQPBkV0D73NkjNZW7KQMg/RTNWDIyRjhbCcMolGce8HgJN9g6HWUvCBa+tEbKF2q Rt+kVLRaUU7WwxmOHUwR6egzIpUakXrXtB6RcBZgTBSbB+b1ceg5AC5/0zWwRbHccbKL 9+oR8aERyKObhmuUM3askiz+6bS0u8P1t/JEwNe242cI9LS4FlAUKaHpp2lH5D8D9ki+ Dfhw== 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 l63si610994ybf.633.2018.01.31.06.04.31; Wed, 31 Jan 2018 06:04:31 -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 4A216617E8; Wed, 31 Jan 2018 14:04:31 +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 6626E61790; Wed, 31 Jan 2018 14:00:42 +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 DF7DF60C4C; Wed, 31 Jan 2018 14:00:29 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id AF9CB60C56 for ; Wed, 31 Jan 2018 14:00:19 +0000 (UTC) Received: from mxback3g.mail.yandex.net (mxback3g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:164]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 3C20D5A04138 for ; Wed, 31 Jan 2018 17:00:17 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback3g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 7gpuqOUPaY-0HDukY6I; Wed, 31 Jan 2018 17:00:17 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0GVKails; Wed, 31 Jan 2018 17:00:16 +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:06 +0300 Message-Id: <1517407211-19105-7-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 6/11] linux-gen: packet: implement packet prefetch 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 For minimal code complexity and negative impact, prefetch only when the requested address is in the first segment and prefetch only one cache line. 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/include/odp/api/plat/packet_inlines.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index dee8f71ce..4c0f88aa2 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -225,7 +225,14 @@ static inline odp_packet_seg_t _odp_packet_next_seg(odp_packet_t pkt, static inline void _odp_packet_prefetch(odp_packet_t pkt, uint32_t offset, uint32_t len) { - (void)pkt; (void)offset; (void)len; + uint32_t seg_len = _odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)_odp_packet_data(pkt); + (void)len; + + if (odp_unlikely(offset >= seg_len)) + return; + + odp_prefetch(data + offset); } static inline int _odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset, From patchwork Wed Jan 31 14:00:07 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: 126337 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp762753ljc; Wed, 31 Jan 2018 06:07:28 -0800 (PST) X-Google-Smtp-Source: AH8x224tIp7D76kGKihBM9NdEC+05zQCEq1vsD767qYzoXGszecohRG3yg7yRVCFNDSVJDwU2WoM X-Received: by 10.37.74.201 with SMTP id x192mr21292663yba.204.1517407647868; Wed, 31 Jan 2018 06:07:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517407647; cv=none; d=google.com; s=arc-20160816; b=tDRJpDyG4FuCR4nmd/CGf9Ee1gUmDC+zoThyW0ddC0LYy/VPRp3m4KWCBqVfBDilsi 7//0InfGQ4ucB3OOy9tUPI1uxvL8022jXF6X9VIBjccp+HAUfvjMWrLgby7b8uLk3ptH 7sJip7iLXLFrqurUBK78Ow4BHa8SjCF5NFP4b52zW9hSo5DCpNjcwDPLHkIyJ6hESVcY tq9WWQ3t06E+Obto6bbPpsCuzomgqQ1/VN7cBB2wIXV5HHTXaWWDuk12vZ3aRClz34Xj iKd+R3/9Ak0uOe7VS4hy/cpo3W1wtvEqcer+hH86bpTILRLwyENHvOQFDjOV32OgK21S v0rg== 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=PcJ/E3M++D9mac8cQmmeX/F/g0UVFOcSEEgTSpsQoW8=; b=jmploXjkFw3eufqU+QJsV0QQbjG9GiR8/6H/VwJwEwoxMLnepJRJA8EzQHeGlYJSXZ zYew9X6MAIAQpi6nb7wcBaB/q7J+S4OGVobkDi9rK3vQOwqhn3ZbRcjsjSOXdLRnbs72 ttmpwsLK16qnWh8QjPCJjRbAXtgDUjbTLsYDgiCuDiWxil8fmCAhniz6acdezjdQ+msX 3Sw24amz8Fswes0ZdSzOuVm3MW1Uy4xmt5nQqz3m/y8jo5LyZLcoUj9GlvxTEGKYLRTA FP3H/1IMQAFFXd5cQ4AVzva8WZ0OdSgDcnErlNzVIrtP3wt5hFlQJWV1lWzQu9X3hn9B qzlA== 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 c141si4383057qke.375.2018.01.31.06.07.27; Wed, 31 Jan 2018 06:07:27 -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 7EDF661817; Wed, 31 Jan 2018 14:07:27 +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 E7B6C617A1; Wed, 31 Jan 2018 14:01:02 +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 6DDEB6176F; Wed, 31 Jan 2018 14:00:32 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id CA75261502 for ; Wed, 31 Jan 2018 14:00:19 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward102o.mail.yandex.net (Yandex) with ESMTP id E78645A0475B for ; Wed, 31 Jan 2018 17:00:17 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 9pK8Np38eF-0HB4XQka; Wed, 31 Jan 2018 17:00:17 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0HVKFw8f; Wed, 31 Jan 2018 17: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: Wed, 31 Jan 2018 17:00:07 +0300 Message-Id: <1517407211-19105-8-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 7/11] linux-gen: packet: inline conversions between packet and event 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 implementation of packet_from_event and packet_to_event functions. 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 **/ include/odp/api/abi-default/buffer.h | 2 +- include/odp/api/abi-default/event.h | 2 +- include/odp/api/abi-default/packet.h | 2 +- .../linux-generic/include-abi/odp/api/abi/buffer.h | 2 +- .../linux-generic/include-abi/odp/api/abi/event.h | 2 +- .../include/odp/api/plat/packet_inlines.h | 29 ++++++++++++ .../include/odp/api/plat/packet_inlines_api.h | 21 +++++++++ platform/linux-generic/odp_packet.c | 51 ++++------------------ 8 files changed, 63 insertions(+), 48 deletions(-) diff --git a/include/odp/api/abi-default/buffer.h b/include/odp/api/abi-default/buffer.h index d8bfc9131..980528ba7 100644 --- a/include/odp/api/abi-default/buffer.h +++ b/include/odp/api/abi-default/buffer.h @@ -20,7 +20,7 @@ typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_buffer_t; typedef _odp_abi_buffer_t *odp_buffer_t; -#define ODP_BUFFER_INVALID ((odp_buffer_t)NULL) +#define ODP_BUFFER_INVALID ((odp_buffer_t)0) /** * @} diff --git a/include/odp/api/abi-default/event.h b/include/odp/api/abi-default/event.h index b52a1a222..0ed6dd094 100644 --- a/include/odp/api/abi-default/event.h +++ b/include/odp/api/abi-default/event.h @@ -22,7 +22,7 @@ typedef struct { char dummy; /**< @internal Dummy */ } _odp_abi_event_t; typedef _odp_abi_event_t *odp_event_t; -#define ODP_EVENT_INVALID ((odp_event_t)NULL) +#define ODP_EVENT_INVALID ((odp_event_t)0) typedef enum odp_event_type_t { ODP_EVENT_BUFFER = 1, diff --git a/include/odp/api/abi-default/packet.h b/include/odp/api/abi-default/packet.h index 15cf081bf..086c4d3bd 100644 --- a/include/odp/api/abi-default/packet.h +++ b/include/odp/api/abi-default/packet.h @@ -26,7 +26,7 @@ typedef struct { char dummy; /**< *internal Dummy */ } _odp_abi_packet_seg_t; typedef _odp_abi_packet_t *odp_packet_t; typedef _odp_abi_packet_seg_t *odp_packet_seg_t; -#define ODP_PACKET_INVALID ((odp_packet_t)0xffffffff) +#define ODP_PACKET_INVALID ((odp_packet_t)0) #define ODP_PACKET_SEG_INVALID ((odp_packet_seg_t)0xffffffff) #define ODP_PACKET_OFFSET_INVALID 0xffff diff --git a/platform/linux-generic/include-abi/odp/api/abi/buffer.h b/platform/linux-generic/include-abi/odp/api/abi/buffer.h index 90b6653a6..879c88afa 100644 --- a/platform/linux-generic/include-abi/odp/api/abi/buffer.h +++ b/platform/linux-generic/include-abi/odp/api/abi/buffer.h @@ -26,7 +26,7 @@ extern "C" { typedef ODP_HANDLE_T(odp_buffer_t); -#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, NULL) +#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, 0) /** * @} diff --git a/platform/linux-generic/include-abi/odp/api/abi/event.h b/platform/linux-generic/include-abi/odp/api/abi/event.h index 802e431f3..49dde956c 100644 --- a/platform/linux-generic/include-abi/odp/api/abi/event.h +++ b/platform/linux-generic/include-abi/odp/api/abi/event.h @@ -26,7 +26,7 @@ extern "C" { typedef ODP_HANDLE_T(odp_event_t); -#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, NULL) +#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, 0) typedef enum odp_event_type_t { ODP_EVENT_BUFFER = 1, diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index 4c0f88aa2..dc7d464f2 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -263,6 +263,35 @@ static inline int _odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, return 0; } +static inline odp_packet_t _odp_packet_from_event(odp_event_t ev) +{ + return (odp_packet_t)ev; +} + +static inline odp_event_t _odp_packet_to_event(odp_packet_t pkt) +{ + return (odp_event_t)pkt; +} + +static inline void _odp_packet_from_event_multi(odp_packet_t pkt[], + const odp_event_t ev[], + int num) +{ + int i; + + for (i = 0; i < num; i++) + pkt[i] = _odp_packet_from_event(ev[i]); +} + +static inline void _odp_packet_to_event_multi(const odp_packet_t pkt[], + odp_event_t ev[], int num) +{ + int i; + + for (i = 0; i < num; i++) + ev[i] = _odp_packet_to_event(pkt[i]); +} + /** @endcond */ #endif diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h index 9b31c923f..95adec66f 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h @@ -152,4 +152,25 @@ _ODP_INLINE int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, return _odp_packet_copy_to_mem(pkt, offset, len, dst); } +_ODP_INLINE odp_packet_t odp_packet_from_event(odp_event_t ev) +{ + return _odp_packet_from_event(ev); +} + +_ODP_INLINE odp_event_t odp_packet_to_event(odp_packet_t pkt) +{ + return _odp_packet_to_event(pkt); +} + +_ODP_INLINE void odp_packet_from_event_multi(odp_packet_t pkt[], + const odp_event_t ev[], int num) +{ + return _odp_packet_from_event_multi(pkt, ev, num); +} + +_ODP_INLINE void odp_packet_to_event_multi(const odp_packet_t pkt[], + odp_event_t ev[], int num) +{ + return _odp_packet_to_event_multi(pkt, ev, num); +} #endif diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 043e4cb5c..488dcbddf 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -49,15 +49,14 @@ const _odp_packet_inline_offset_t ODP_ALIGNED_CACHE _odp_packet_inline = { #include -static inline odp_buffer_t buffer_handle(odp_packet_hdr_t *pkt_hdr) -{ - return (odp_buffer_t)pkt_hdr; -} - -static inline odp_packet_hdr_t *buf_to_packet_hdr(odp_buffer_t buf) -{ - return (odp_packet_hdr_t *)buf_hdl_to_hdr(buf); -} +/* Check that invalid values are the same. Some versions of Clang have trouble + * with the strong type casting, and complain that these invalid values are not + * integral constants. */ +#ifndef __clang__ +ODP_STATIC_ASSERT(ODP_PACKET_INVALID == 0, "Packet invalid not 0"); +ODP_STATIC_ASSERT(ODP_BUFFER_INVALID == 0, "Buffer invalid not 0"); +ODP_STATIC_ASSERT(ODP_EVENT_INVALID == 0, "Event invalid not 0"); +#endif odp_packet_t _odp_packet_from_buf_hdr(odp_buffer_hdr_t *buf_hdr) { @@ -998,40 +997,6 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len) return 0; } -odp_packet_t odp_packet_from_event(odp_event_t ev) -{ - if (odp_unlikely(ev == ODP_EVENT_INVALID)) - return ODP_PACKET_INVALID; - - return (odp_packet_t)buf_to_packet_hdr((odp_buffer_t)ev); -} - -odp_event_t odp_packet_to_event(odp_packet_t pkt) -{ - if (odp_unlikely(pkt == ODP_PACKET_INVALID)) - return ODP_EVENT_INVALID; - - return (odp_event_t)buffer_handle(packet_hdr(pkt)); -} - -void odp_packet_from_event_multi(odp_packet_t pkt[], const odp_event_t ev[], - int num) -{ - int i; - - for (i = 0; i < num; i++) - pkt[i] = odp_packet_from_event(ev[i]); -} - -void odp_packet_to_event_multi(const odp_packet_t pkt[], odp_event_t ev[], - int num) -{ - int i; - - for (i = 0; i < num; i++) - ev[i] = odp_packet_to_event(pkt[i]); -} - int odp_event_filter_packet(const odp_event_t event[], odp_packet_t packet[], odp_event_t remain[], int num) From patchwork Wed Jan 31 14: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: 126354 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp780227ljc; Wed, 31 Jan 2018 06:27:17 -0800 (PST) X-Google-Smtp-Source: AH8x226SjG9xBLCvTLAHFZ2NinsFnaMD92C1hyEOzSyusCvWK70+gwRFQh+nGW7LDQvYWMiK5Uca X-Received: by 10.200.26.69 with SMTP id q5mr49621865qtk.174.1517408837469; Wed, 31 Jan 2018 06:27:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517408837; cv=none; d=google.com; s=arc-20160816; b=tOHhtyX5abFdqh3gOXXEtUQhk1g3Tu/JX1ybMNESs2dz16OdjFpmKtDEo/gwU6/+Zr 1uShRPewtSynMQKA+DZ+qz8LhWzs9c9lq1AXnIuOj5BRWZXRLvQV3N7TVl8MOVertDLV a4x/BzP83E8xhYwAMyOpqWlkw/NZpO0E3jM7xOJsb3o2IpHQy5Vhk4+sQbU3/avFe5mX 4jLUZGPGpv1TlfnubtQQdBm9ZJ4aQdaGXWmzT1j4JneRaseBpbZUk59Bx/LnSE3iVhED 8HecgfHyxruUM8r5+6SF2vVNBJhblNXgcexaan8p+woTuF4rj2LCYrsxUTMEYnWNkKRi 45+g== 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=hfVKnvR/qstaioUOd0AJazfR2OW0781/h4x6Soy1fPs=; b=bCiQ95siPmjYLv5uHYcazf8wRVIxPYjFx/ZQ0hTBKF4C6yHUl+5RRY7p+KuIZeC0hl QauW5Dp+UHZLnPrrIRFQCcjRj+4eX3MucdxI12BqkGQ3qi/u/ZmlbtZymoGEyvKgSCIv B6J0zvOgbN3GlLHgX3i0JV+VCLItr4SQXM0aDS6Xp8OkGkXxCOM4WGyxDtjUr4NoXWXr SaNCqNG5M9u7bxoGugVWIXqX0+dnHduqUHASjBGcI6VYeR9BhY6FeNbu5DanS63/Slwu PuWUSRt1gvfBX5XJbQGLHLHCLDeCCcXbXK7+nm5IirQUW+GpDAZ1tlI/2/43a5IEBMKM SO6A== 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 v33si2614119qtc.225.2018.01.31.06.27.17; Wed, 31 Jan 2018 06:27:17 -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 2C6B7617E2; Wed, 31 Jan 2018 14:27:17 +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 960B5617A1; Wed, 31 Jan 2018 14:07:39 +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 EB248617A5; Wed, 31 Jan 2018 14:07:34 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id 97C18616E5 for ; Wed, 31 Jan 2018 14:01:53 +0000 (UTC) Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 6689144459FB for ; Wed, 31 Jan 2018 17:00:18 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback2o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id dur8H5Zslc-0IwuhjJb; Wed, 31 Jan 2018 17:00:18 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0HVioZFm; Wed, 31 Jan 2018 17:00:18 +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:08 +0300 Message-Id: <1517407211-19105-9-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 8/11] test: l2fwd: use multi conversion functions 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 Use multi versions of packet / event conversion functions. 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 **/ test/performance/odp_l2fwd.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c index 09a12b050..a2b9a9ca0 100644 --- a/test/performance/odp_l2fwd.c +++ b/test/performance/odp_l2fwd.c @@ -270,12 +270,10 @@ static inline int event_queue_send(odp_queue_t queue, odp_packet_t *pkt_tbl, unsigned pkts) { int ret; - unsigned i; unsigned sent = 0; odp_event_t ev_tbl[pkts]; - for (i = 0; i < pkts; i++) - ev_tbl[i] = odp_packet_to_event(pkt_tbl[i]); + odp_packet_to_event_multi(pkt_tbl, ev_tbl, pkts); while (sent < pkts) { ret = odp_queue_enq_multi(queue, &ev_tbl[sent], pkts - sent); @@ -373,8 +371,7 @@ static int run_worker_sched_mode(void *arg) if (pkts <= 0) continue; - for (i = 0; i < pkts; i++) - pkt_tbl[i] = odp_packet_from_event(ev_tbl[i]); + odp_packet_from_event_multi(pkt_tbl, ev_tbl, pkts); if (odp_unlikely(gbl_args->appl.extra_check)) { if (gbl_args->appl.chksum) @@ -499,8 +496,7 @@ static int run_worker_plain_queue_mode(void *arg) if (odp_unlikely(pkts <= 0)) continue; - for (i = 0; i < pkts; i++) - pkt_tbl[i] = odp_packet_from_event(event[i]); + odp_packet_from_event_multi(pkt_tbl, event, pkts); if (odp_unlikely(gbl_args->appl.extra_check)) { if (gbl_args->appl.chksum) From patchwork Wed Jan 31 14:00:09 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: 126357 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp782372ljc; Wed, 31 Jan 2018 06:29:50 -0800 (PST) X-Google-Smtp-Source: AH8x224j3LXjsA5o4q0ss5MPxKOr1nh1ig+unw9s1HalpkVfvm4p6ZDN350MdiPIhuZQIhGBBBxp X-Received: by 10.55.134.193 with SMTP id i184mr46390667qkd.314.1517408990033; Wed, 31 Jan 2018 06:29:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517408990; cv=none; d=google.com; s=arc-20160816; b=fDxDC4adCfZe/6rQ7LOeOie55hBZpp+O8mThvZvbD+x/q6n54pnwrU6Mi0enUG3QIn gDq+22E2BzHNqKG3JfmIcIb3QytqQTktTwn1HZ21ZDzy1kvDihwckr4M8lGR9Pqwyjnj He2d7YXFRIO2E/fcMqpqx+p9jazzW1m2qzBth67QUni5EtpLH2t2/LHrVwgbNbIS9SXw kKmSNkEw/hTRPXZBCn637hz2ObUzct1nv9Ofyi/D7NDv0jruHN5eQQDyYHAlEBdG+8/W 2DXvZICbbOqyy6FnV3+tVGBq9fYquF1blXqsab/YTfZm/zftVGFpalMxn0y6ecJGolJ8 jeHQ== 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=1QVZhiGSWgJENHmgk/fjAP74RGFP+Lr+IpPtWShcqxw=; b=R0QUp7Pb1pmxIfIsnPN8WwWGK8FEBquQ2Zw3t6lYtXTmMdfvn6EJd7TltmLj1qAJ3f Fa6MGja89I9nE9fBu+ck1Jf6+Y0XXN25DsT1HWhu/tRrXcjRPdcPvFmAdEh0+nhfhgkl Bx9LYAM0GablI1doexwiB5/gmCXZwr0gvxDOBckYOkLXccCCzmd/GPuXhnGe7uclDzci h80baSoyyHcuNZPGYTB8/A+s8BI70UCLlOtY0F14VAEF5maiqsn5LTViUjqfN5I/QivP szQN0YzIlWLsiK2vUtSgUuhdXv8isPPdUe+N2lwzvzLXgE1ePLm+lzhB/us6i8dPgz3z pkrQ== 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 t31si2047642qtg.137.2018.01.31.06.29.49; Wed, 31 Jan 2018 06:29: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 61701617E8; Wed, 31 Jan 2018 14:29:49 +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 7C6BC617D2; Wed, 31 Jan 2018 14:08:16 +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 6556C6181C; Wed, 31 Jan 2018 14:07:57 +0000 (UTC) Received: from forward105j.mail.yandex.net (forward105j.mail.yandex.net [5.45.198.248]) by lists.linaro.org (Postfix) with ESMTPS id D0342617D1 for ; Wed, 31 Jan 2018 14:02:18 +0000 (UTC) Received: from mxback5j.mail.yandex.net (mxback5j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10e]) by forward105j.mail.yandex.net (Yandex) with ESMTP id 0DE9918693E for ; Wed, 31 Jan 2018 17:00:19 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback5j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id bAyrhUDfs2-0IZ02bSu; Wed, 31 Jan 2018 17:00:18 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0IV4IEgJ; Wed, 31 Jan 2018 17:00:18 +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:09 +0300 Message-Id: <1517407211-19105-10-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 9/11] validation: pktio: don't pass invalid handle to index conversion 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 Fast path functions cannot be expected to always check against invalid handles. Also a handle that has been closed (or destroyed) must not be passed to any API function. 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 **/ test/validation/api/pktio/pktio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index a23641036..b20272ffc 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -1183,7 +1183,7 @@ void pktio_test_lookup(void) void pktio_test_index(void) { - odp_pktio_t pktio, pktio_inval = ODP_PKTIO_INVALID; + odp_pktio_t pktio; odp_pktio_param_t pktio_param; int ndx; @@ -1195,10 +1195,8 @@ void pktio_test_index(void) ndx = odp_pktio_index(pktio); CU_ASSERT(ndx >= 0); - CU_ASSERT(odp_pktio_index(pktio_inval) < 0); CU_ASSERT(odp_pktio_close(pktio) == 0); - CU_ASSERT(odp_pktio_index(pktio) < 0); } static void pktio_test_print(void) 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 From patchwork Wed Jan 31 14:00:11 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: 126338 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp763977ljc; Wed, 31 Jan 2018 06:08:45 -0800 (PST) X-Google-Smtp-Source: AH8x224lTGOeTFS7H8dpxupfpHHAp53USUy5a0jEPm5m9qeJcCQysdKaoiqS/9WntYWrhNuuDuSO X-Received: by 10.55.138.134 with SMTP id m128mr49825446qkd.72.1517407725626; Wed, 31 Jan 2018 06:08:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517407725; cv=none; d=google.com; s=arc-20160816; b=ppUku7jB/Bcm8svvX6oFPSHtnZ6/CDbZYY3ZsxszIx2vySQ/mNX6MWWEK+WeyJK/SB iW+27tRCB4x5Bg25jGoXd9CbFX3jAY7fnbSKHxzfVTmwwcFL2h6lQRyL74AA3SO36c+i ZYVHjTgonU94bXbc6GFpKLO+Qwr4N4GnDlCtNer+qZxBgOOFajq8MASD43zz1ANAPQzE E7iG50pxDMz5XUxR1I3mOZKUJ5pUZEkGmlo5HWactCsrggCvXwdEzGVxsGwcrojOYf1Y cxUYgI4c0kHs9Pie1odlZOf7BzX+qz/JtftvHO2pFK7fqaC6juY5ZAF67l0c5yiFAGtY P4Fw== 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=/Z6rlnwtFrlt4pLdUYiJNywWvWgbydMUnbVbTSGddpI=; b=Wz7+x7gnzxBAJl9UEm9WY5zr56jElJMAm5mgFFr9/wQhiALxCNHOfTllNZ4MjABeNq zlDMG09m7gfc8p9tCCrq2x0G5jduEXltM9AS23+PNgSNDjQHFpLQ7VAtxlHqmc0LLaDY zSm5w/VsnIQF6p0qyv8QJZXkRxruBmFKXQ3bXyjWaffR/ZAaBJv8BX13LbHK5Z0adqNK BkR6PQvLf5xJ/sTf8JwCRDlehaUzQ4mEkdmJCZjBZCNjyyF0P+FNAygGxmXnFQwoy41h jhlhWJD/REU1d5KEZNZr+XXwihogRdPquQbrGy7stsAC2BR8oGuXoOwCC7Z0bMLVW/ae MKIg== 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 z2si147136qtd.400.2018.01.31.06.08.45; Wed, 31 Jan 2018 06:08:45 -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 36C4D6181C; Wed, 31 Jan 2018 14:08:45 +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 3A17D617AA; Wed, 31 Jan 2018 14:01:13 +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 9D10C6176F; Wed, 31 Jan 2018 14:00:34 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id F3D8A61510 for ; Wed, 31 Jan 2018 14:00:21 +0000 (UTC) Received: from mxback12g.mail.yandex.net (mxback12g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:91]) by forward102o.mail.yandex.net (Yandex) with ESMTP id C643A5A05796 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 mxback12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 1gpaf6IpJM-0KniPnqK; Wed, 31 Jan 2018 17:00:20 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id nmVaH0g7bK-0KV8pwaB; Wed, 31 Jan 2018 17:00:20 +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:11 +0300 Message-Id: <1517407211-19105-12-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 11/11] linux-gen: packet: inline packet input 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 input interface index 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/include/odp/api/plat/packet_inlines.h | 8 ++++++++ platform/linux-generic/include/odp/api/plat/packet_inlines_api.h | 5 +++++ platform/linux-generic/odp_packet.c | 5 ----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index dc7d464f2..0704abb2f 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -22,6 +22,7 @@ #include #include +#include #include @@ -89,6 +90,13 @@ static inline odp_pktio_t _odp_packet_input(odp_packet_t pkt) return _odp_pkt_get(pkt, odp_pktio_t, input); } +static inline int _odp_packet_input_index(odp_packet_t pkt) +{ + odp_pktio_t pktio = _odp_packet_input(pkt); + + return _odp_pktio_index(pktio); +} + static inline int _odp_packet_num_segs(odp_packet_t pkt) { return _odp_pkt_get(pkt, uint8_t, segcount); diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h index 95adec66f..c451c4d6c 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h @@ -48,6 +48,11 @@ _ODP_INLINE odp_pktio_t odp_packet_input(odp_packet_t pkt) return _odp_packet_input(pkt); } +_ODP_INLINE int odp_packet_input_index(odp_packet_t pkt) +{ + return _odp_packet_input_index(pkt); +} + _ODP_INLINE int odp_packet_num_segs(odp_packet_t pkt) { return _odp_packet_num_segs(pkt); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 1909bae25..9c3be1bcc 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1269,11 +1269,6 @@ 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); -} - void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ctx) { packet_hdr(pkt)->buf_hdr.buf_cctx = ctx;