From patchwork Thu Apr 21 00:14:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 66261 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2741812qge; Wed, 20 Apr 2016 17:15:36 -0700 (PDT) X-Received: by 10.55.80.131 with SMTP id e125mr15557393qkb.62.1461197736867; Wed, 20 Apr 2016 17:15:36 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 10si27751310qgt.111.2016.04.20.17.15.36; Wed, 20 Apr 2016 17:15:36 -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=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 89A3568A46; Thu, 21 Apr 2016 00:15:36 +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, 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 DDE8D68A49; Thu, 21 Apr 2016 00:14:33 +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 3BDCD669E4; Thu, 21 Apr 2016 00:14:23 +0000 (UTC) Received: from mail-oi0-f44.google.com (mail-oi0-f44.google.com [209.85.218.44]) by lists.linaro.org (Postfix) with ESMTPS id 5D1D7669E4 for ; Thu, 21 Apr 2016 00:14:21 +0000 (UTC) Received: by mail-oi0-f44.google.com with SMTP id x201so60922553oif.3 for ; Wed, 20 Apr 2016 17:14:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lK8Ih0uxGszKF7O8opyOgTFkolsTDrH0RyOCVmoaHQA=; b=bapP4t9av26fMnJmX36k0IZFB0XK9FpMeG+KPjuj3aLMDvykXeqplJ55QQI4HNX/8h frn2wnVw/MsbIO6vqGCinDlA1CBu3WaqY818zdu0MvfWhIpN7stbMAtI80Ve6zZIN99G P1iRUtF34pM5V7nU9qVO5YM1zIIDDVMvM9yE/K0hM6U+w3uawe/hf0FNCQZqydGTOnpx zG7irPN93S1ubUPUYlgCYAEARExoFF8h9knNqNKuKa95Px4Ui4nunnWj/P00x99aQT4W N0bSGwC4UdQPNbxQdM1iFmlBlI8Hs2UtjFGmLk5vrYxzCuStabSzcUi95KMZz4BGq8pG QS7w== X-Gm-Message-State: AOPr4FWI/1XxooqWCRLB9sxo92JT6D03nlsjf2T5S9mlVFgv/0O5NSMh1IFRNoZPG4CdCW12rPY= X-Received: by 10.202.87.203 with SMTP id l194mr1611204oib.89.1461197660935; Wed, 20 Apr 2016 17:14:20 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id a34sm335otb.1.2016.04.20.17.14.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Apr 2016 17:14:20 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 20 Apr 2016 19:14:06 -0500 Message-Id: <1461197655-23743-3-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461197655-23743-1-git-send-email-bill.fischofer@linaro.org> References: <1461197655-23743-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 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" From: Matias Elo Implements support for packet timestamps and adds related validation tests. Signed-off-by: Matias Elo Reviewed-and-tested-by: Bill Fischofer --- 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)