From patchwork Thu Dec 21 16:00:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 122577 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1076185qgn; Thu, 21 Dec 2017 08:02:57 -0800 (PST) X-Google-Smtp-Source: ACJfBouuu2Dra8l39bQptEqKUjCAFPxzTRvmLNzkMLVO6zHB1qR9rORrPJdtXbioZ2knOMXHrJrc X-Received: by 10.13.219.66 with SMTP id d63mr7538978ywe.347.1513872177296; Thu, 21 Dec 2017 08:02:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513872177; cv=none; d=google.com; s=arc-20160816; b=jY5qODyePPLoVuU7sV1KAdk+p/8HBX8LnJSb8tlup/MAVvqUNVZq1D7YwJFukF40u6 lekndz1DQdvEYrMu+9GYzJGMUwINd98C9S1fnyVRCM7y5VAuCb+83OGMc6RWkC6YFhZZ pza8T3yvTnQ+ML2uJqi8K4ep+0SKKJxeY5pyIhgfnLsmOHXciKwOWDB2Z9XxidUOUdy1 Sg+2FmElRojpy5JsPCh14FWAWHHQNagtDI8mB9aJ7VkoUWTvldKJCJ4zo3MnCjlDu3I1 Fy+iZcnb+xldXNmRwjG49KYU7RiqGt2uRybgYmpcU658lOWqJrI8lcwJlaPK64KNEIJf jjjg== 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=zwGnFImIHIiV2SIsE/4p2dK7DVPvTGZjC9FAO4fAKUY=; b=EW4rdsNJ6YbOwOQ+jhEbMqOY8oDcDgJqTv/KF7n2OFfZLCJcEZuhqtU5273DjC8k+D 80i4JiE+Gq08PoEW4z63P0wcmuvs6sQGGURJCpuGJDO9A22nAsJxza1G0EhnJ7EsNs98 6K1O9pQundNY534I4USuiZWUVBN4kEtfTOG2IvzjoDxolc5cHuLKMZbY4uQAHW2jUYz5 MxjKrUPq8T+u3Wp25IAVdFodaSZJvh81/1mrUUejUs/nuuLO1/nld0JWVLM0PsBMJ+Gd 4krdauZMQEd7IGkUqjybkweD3k0CG8JNXS2OLv29WSd00egjYvoiqanvHF9DPCJYocF9 3PGg== 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 b82si6420673qkc.477.2017.12.21.08.02.54; Thu, 21 Dec 2017 08:02:57 -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 74E3460975; Thu, 21 Dec 2017 16:02:54 +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, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 7E3E860B11; Thu, 21 Dec 2017 16:01: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 6B0556099A; Thu, 21 Dec 2017 16:01:07 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id 37BAB609A2 for ; Thu, 21 Dec 2017 16:00:14 +0000 (UTC) Received: from mxback15g.mail.yandex.net (mxback15g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:94]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 9B146444278B for ; Thu, 21 Dec 2017 19:00:12 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback15g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id fImQtcFDb1-0CSSuVOI; Thu, 21 Dec 2017 19:00:12 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 9thSdAwhh7-0B7mGamn; Thu, 21 Dec 2017 19:00:11 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 21 Dec 2017 19:00:09 +0300 Message-Id: <1513872010-2747-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513872010-2747-1-git-send-email-odpbot@yandex.ru> References: <1513872010-2747-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 360 Subject: [lng-odp] [PATCH v1 1/2] linux-gen: packet: inline layer offsets 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 L2/L3/L4 offset read functions. Always use the inlined version within the implementation itself. Signed-off-by: Petri Savolainen --- /** Email created from pull request 360 (psavol:master-packet-offset-inline) ** https://github.com/Linaro/odp/pull/360 ** Patch: https://github.com/Linaro/odp/pull/360.patch ** Base sha: 3c02836d9d9ca16b1277bdd30e523779b9fe8374 ** Merge commit sha: 8a43dcccb105ee32ad867e39b8763d77c37b331e **/ .../include/odp/api/plat/packet_inlines.h | 18 +++++++++++++++ .../include/odp/api/plat/packet_inlines_api.h | 15 +++++++++++++ .../include/odp/api/plat/packet_types.h | 6 +++++ platform/linux-generic/odp_packet.c | 26 +++------------------- platform/linux-generic/odp_traffic_mngr.c | 5 +++-- 5 files changed, 45 insertions(+), 25 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 c808f2d6f..aa9ba812f 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -108,6 +108,24 @@ 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 @return */ static inline uint32_t _odp_packet_flow_hash(odp_packet_t pkt) { 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 233bc8761..84b4f08ab 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 @@ -68,6 +68,21 @@ _ODP_INLINE uint32_t odp_packet_user_area_size(odp_packet_t pkt) return _odp_packet_user_area_size(pkt); } +_ODP_INLINE uint32_t odp_packet_l2_offset(odp_packet_t pkt) +{ + return _odp_packet_l2_offset(pkt); +} + +_ODP_INLINE uint32_t odp_packet_l3_offset(odp_packet_t pkt) +{ + return _odp_packet_l3_offset(pkt); +} + +_ODP_INLINE uint32_t odp_packet_l4_offset(odp_packet_t pkt) +{ + return _odp_packet_l4_offset(pkt); +} + _ODP_INLINE uint32_t odp_packet_flow_hash(odp_packet_t pkt) { return _odp_packet_flow_hash(pkt); diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h b/platform/linux-generic/include/odp/api/plat/packet_types.h index 009a3aa7c..5b44c09c8 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_types.h @@ -94,6 +94,12 @@ typedef struct _odp_packet_inline_offset_t { /** @internal field offset */ uint16_t user_area; /** @internal field offset */ + uint16_t l2_offset; + /** @internal field offset */ + uint16_t l3_offset; + /** @internal field offset */ + uint16_t l4_offset; + /** @internal field offset */ uint16_t flow_hash; /** @internal field offset */ uint16_t timestamp; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 04f1f33bb..3f0d764f6 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -37,6 +37,9 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = { .segcount = offsetof(odp_packet_hdr_t, buf_hdr.segcount), .user_ptr = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx), .user_area = offsetof(odp_packet_hdr_t, buf_hdr.uarea_addr), + .l2_offset = offsetof(odp_packet_hdr_t, p.l2_offset), + .l3_offset = offsetof(odp_packet_hdr_t, p.l3_offset), + .l4_offset = offsetof(odp_packet_hdr_t, p.l4_offset), .flow_hash = offsetof(odp_packet_hdr_t, flow_hash), .timestamp = offsetof(odp_packet_hdr_t, timestamp), .input_flags = offsetof(odp_packet_hdr_t, p.input_flags) @@ -1213,15 +1216,6 @@ void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) return packet_map(pkt_hdr, pkt_hdr->p.l2_offset, len, NULL); } -uint32_t odp_packet_l2_offset(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - if (!packet_hdr_has_l2(pkt_hdr)) - return ODP_PACKET_OFFSET_INVALID; - return pkt_hdr->p.l2_offset; -} - int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1241,13 +1235,6 @@ void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) return packet_map(pkt_hdr, pkt_hdr->p.l3_offset, len, NULL); } -uint32_t odp_packet_l3_offset(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return pkt_hdr->p.l3_offset; -} - int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1266,13 +1253,6 @@ void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) return packet_map(pkt_hdr, pkt_hdr->p.l4_offset, len, NULL); } -uint32_t odp_packet_l4_offset(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return pkt_hdr->p.l4_offset; -} - int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index ab06b3c0d..e22a33f29 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -26,6 +26,7 @@ #include #include #include +#include /* Local vars */ static const @@ -1966,7 +1967,7 @@ static void egress_ipv4_tos_marking(tm_tos_marking_t *tos_marking, uint32_t hdr_len, l3_offset, old_chksum, ones_compl_sum, tos_diff; uint8_t old_tos, new_tos, ecn; - l3_offset = odp_packet_l3_offset(odp_pkt); + l3_offset = _odp_packet_l3_offset(odp_pkt); ipv4_hdr_ptr = odp_packet_l3_ptr(odp_pkt, &hdr_len); /* If the split_hdr variable below is TRUE, then this indicates that @@ -2032,7 +2033,7 @@ static void egress_ipv6_tc_marking(tm_tos_marking_t *tos_marking, uint32_t hdr_len, old_ver_tc_flow, new_ver_tc_flow, l3_offset; uint8_t old_tc, new_tc, ecn; - l3_offset = odp_packet_l3_offset(odp_pkt); + l3_offset = _odp_packet_l3_offset(odp_pkt); ipv6_hdr_ptr = odp_packet_l3_ptr(odp_pkt, &hdr_len); /* If the split_hdr variable below is TRUE, then this indicates that