From patchwork Thu Apr 21 07:59:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elo, Matias \(Nokia - FI/Espoo\)" X-Patchwork-Id: 66318 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2898534qge; Thu, 21 Apr 2016 01:02:38 -0700 (PDT) X-Received: by 10.107.149.7 with SMTP id x7mr14451113iod.141.1461225758107; Thu, 21 Apr 2016 01:02:38 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id mx2si1146412igb.13.2016.04.21.01.02.37; Thu, 21 Apr 2016 01:02:38 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE dis=NONE) header.from=nokia.com Received: by lists.linaro.org (Postfix, from userid 109) id 9150568A8B; Thu, 21 Apr 2016 08:02:37 +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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 D30A968A94; Thu, 21 Apr 2016 07:59:53 +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 7EBF168A96; Thu, 21 Apr 2016 07:59:44 +0000 (UTC) Received: from demumfd002.nsn-inter.net (demumfd002.nsn-inter.net [93.183.12.31]) by lists.linaro.org (Postfix) with ESMTPS id 2F35468A88 for ; Thu, 21 Apr 2016 07:59:37 +0000 (UTC) Received: from demuprx016.emea.nsn-intra.net ([10.150.129.55]) by demumfd002.nsn-inter.net (8.15.2/8.15.2) with ESMTPS id u3L7xZxp006231 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 21 Apr 2016 07:59:35 GMT Received: from 10.144.19.15 ([10.144.104.109]) by demuprx016.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id u3L7xWW0018712 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Thu, 21 Apr 2016 09:59:33 +0200 From: Matias Elo To: lng-odp@lists.linaro.org Date: Thu, 21 Apr 2016 10:59:23 +0300 Message-Id: <1461225572-18238-3-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461225572-18238-1-git-send-email-matias.elo@nokia.com> References: <1461225572-18238-1-git-send-email-matias.elo@nokia.com> X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-size: 3894 X-purgate-ID: 151667::1461225575-00002418-CCF50D5A/0/0 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v5 02/11] linux-generic: packet: implement timestamp support 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Implements support for packet timestamps and adds related validation tests. Signed-off-by: Matias Elo --- platform/linux-generic/include/odp_packet_internal.h | 2 ++ platform/linux-generic/odp_packet.c | 15 +++++++++++++++ platform/linux-generic/odp_packet_flags.c | 14 ++++++++++++++ test/validation/packet/packet.c | 8 ++++++++ 4 files changed, 39 insertions(+) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index edff533..1005535 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -42,6 +42,7 @@ typedef union { uint32_t parsed_all:1;/**< Parsing complete */ uint32_t flow_hash:1; /**< Flow hash present */ + uint32_t timestamp:1; /**< Timestamp present */ uint32_t l2:1; /**< known L2 protocol present */ uint32_t l3:1; /**< known L3 protocol present */ @@ -152,6 +153,7 @@ typedef struct { odp_pktio_t input; uint32_t flow_hash; /**< Flow hash value */ + odp_time_t timestamp; /**< Timestamp value */ odp_crypto_generic_op_result_t op_result; /**< Result for crypto */ } odp_packet_hdr_t; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 2c06e97..fe4f819 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -456,6 +456,21 @@ void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash) pkt_hdr->input_flags.flow_hash = 1; } +odp_time_t odp_packet_ts(odp_packet_t pkt) +{ + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->timestamp; +} + +void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp) +{ + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + pkt_hdr->timestamp = timestamp; + pkt_hdr->input_flags.timestamp = 1; +} + int odp_packet_is_segmented(odp_packet_t pkt) { return odp_packet_hdr(pkt)->buf_hdr.segcount > 1; diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index 5d93f57..3acdc53 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -179,6 +179,13 @@ int odp_packet_has_flow_hash(odp_packet_t pkt) return pkt_hdr->input_flags.flow_hash; } +int odp_packet_has_ts(odp_packet_t pkt) +{ + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return pkt_hdr->input_flags.timestamp; +} + odp_packet_color_t odp_packet_color(odp_packet_t pkt) { retflag(pkt, input_flags.color); @@ -337,3 +344,10 @@ void odp_packet_has_flow_hash_clr(odp_packet_t pkt) pkt_hdr->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); + + pkt_hdr->input_flags.timestamp = 0; +} diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c index bac5f1d..63c4085 100644 --- a/test/validation/packet/packet.c +++ b/test/validation/packet/packet.c @@ -245,6 +245,7 @@ void packet_test_event_conversion(void) void packet_test_basic_metadata(void) { odp_packet_t pkt = test_packet; + odp_time_t ts; CU_ASSERT_PTR_NOT_NULL(odp_packet_head(pkt)); CU_ASSERT_PTR_NOT_NULL(odp_packet_data(pkt)); @@ -259,6 +260,13 @@ void packet_test_basic_metadata(void) CU_ASSERT(odp_packet_flow_hash(pkt) == UINT32_MAX); odp_packet_has_flow_hash_clr(pkt); CU_ASSERT(!odp_packet_has_flow_hash(pkt)); + + ts = odp_time_global(); + odp_packet_ts_set(pkt, ts); + CU_ASSERT_FATAL(odp_packet_has_ts(pkt)); + CU_ASSERT(!odp_time_cmp(ts, odp_packet_ts(pkt))); + odp_packet_has_ts_clr(pkt); + CU_ASSERT(!odp_packet_has_ts(pkt)); } void packet_test_length(void)