From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A7AF3A0526; Fri, 24 Jul 2020 22:24:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 88B4D1C0AC; Fri, 24 Jul 2020 22:23:41 +0200 (CEST) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by dpdk.org (Postfix) with ESMTP id 16F681C036 for ; Fri, 24 Jul 2020 22:23:35 +0200 (CEST) Received: by mail-qk1-f195.google.com with SMTP id h7so9833436qkk.7 for ; Fri, 24 Jul 2020 13:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=radio-canada-ca.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d4J8GL2P60emupUK6J06ILs+5iZkXAkCw+Y77iftfbc=; b=Vl0FVSnCwuekofc0OTXaRjOOmOwcSR+BHZrK7kwP2paHA7UDkCFXUmNoKvc1yU9gRw 1IhoMaJCuv3n1cv9ovi+GqQuFtbGW1tM6v0ZzbGCGR8d3L58WLyA/wMw7tkCsOj/ysGb CCmgoBEWbeHh23zfuhVKbiva+Z3vvITpNXF3w/+Rx93v0gw6EggZlFH1V7iK8lJeWJZe IH6yJYw4NYZsZ0znvK4/AKoIejW9R3qvnveLAIvQSF/UqG7O88+iUoA+6CtNrSm2qqvY nD+VafGWxPumVc/wG+kAP6xyJX2dpU+B3egJHy8P14pKvbAFkx1fQIRBTuLH0mDgTkK7 0BaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=d4J8GL2P60emupUK6J06ILs+5iZkXAkCw+Y77iftfbc=; b=XYdXey8oq/8PtoPoDGmwINEs8awgpFkl1zfaDEpO+gJdCYAcEdfHLpOO0wFrlhDBUw ywtdoSW5AQzgEIJLKxaFN09ZXymN82q5xg4Ax6t/t5eAxgtkgBT6CMIaGQFc2GUV7NBH BYDg6EFS9Rc7caAz5FkCYn2vJHWgg4i91Im2JSLVZqFAO3/f7mzP1pB4KTPXbGnOsv8+ y1arOd1hB39/hsBuotqyUp1dm+kXmcLOBUKV6XLBDDuSUqn4Xrg2fBQRT2+kAB/dc/YS K2HprtoSL81/vmb5XLkd+YcdNM6bX5h/Z2KB3+d0+UQ4LQGQkxTtaJNI3PFnQu5BkTpK Ui0A== X-Gm-Message-State: AOAM531IMV60M13lXUngM+/QKL2f2Cn+WFUZssX0vBaGJyga+y+Or1er aj+LGitfiRhe23tqq+mDCDwT3BcH5kQ= X-Google-Smtp-Source: ABdhPJw5Sa2sWoE2/ab5lBJB0Pd1aAd8tGdRnnCkWgWsAIQY78FzJza9DAoMK7ybMT3KJnYPsbsd2w== X-Received: by 2002:a37:a4c2:: with SMTP id n185mr12931878qke.373.1595622214392; Fri, 24 Jul 2020 13:23:34 -0700 (PDT) Received: from localhost.localdomain (modemcable246.10-73-45.static.videotron.ca. [45.73.10.246]) by smtp.gmail.com with ESMTPSA id f7sm5216089qkj.32.2020.07.24.13.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 13:23:34 -0700 (PDT) From: Patrick Keroulas To: dev@dpdk.org Cc: Patrick Keroulas Date: Fri, 24 Jul 2020 16:23:14 -0400 Message-Id: <20200724202315.19533-4-patrick.keroulas@radio-canada.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200724202315.19533-1-patrick.keroulas@radio-canada.ca> References: <20200724202315.19533-1-patrick.keroulas@radio-canada.ca> Subject: [dpdk-dev] [[PATCH v3 3/4] pdump: convert timestamp to nanoseconds on Rx path X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Use start time and device frequency to translate raw Rx hardware timestamps into nanoseconds. Signed-off-by: Patrick Keroulas --- lib/librte_pdump/rte_pdump.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c index b3c8d5ce43..8fd7e13af5 100644 --- a/lib/librte_pdump/rte_pdump.c +++ b/lib/librte_pdump/rte_pdump.c @@ -2,6 +2,8 @@ * Copyright(c) 2016-2018 Intel Corporation */ +#include + #include #include #include @@ -69,6 +71,21 @@ static struct pdump_rxtx_cbs { } rx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT], tx_cbs[RTE_MAX_ETHPORTS][RTE_MAX_QUEUES_PER_PORT]; +static uint64_t hz; +static uint64_t start_time; +static uint64_t start_cycles; + +static inline void +pdump_ts_to_ns(struct rte_mbuf **pkts, uint16_t nb_pkts) +{ + unsigned int i; + + for (i = 0; i < nb_pkts; i++) { + if ((pkts[i]->ol_flags & PKT_RX_TIMESTAMP) && hz) + pkts[i]->timestamp = start_time + + (pkts[i]->timestamp - start_cycles) * NS_PER_S / hz; + } +} static inline void pdump_copy(struct rte_mbuf **pkts, uint16_t nb_pkts, void *user_params) @@ -107,6 +124,7 @@ pdump_rx(uint16_t port __rte_unused, uint16_t qidx __rte_unused, uint16_t max_pkts __rte_unused, void *user_params) { + pdump_ts_to_ns(pkts, nb_pkts); pdump_copy(pkts, nb_pkts, user_params); return nb_pkts; } @@ -131,6 +149,13 @@ pdump_register_rx_callbacks(uint16_t end_q, uint16_t port, uint16_t queue, for (; qid < end_q; qid++) { cbs = &rx_cbs[port][qid]; if (cbs && operation == ENABLE) { + struct timeval now; + + rte_eth_read_clock(port, &start_cycles); + rte_eth_get_clock_freq(port, &hz); + gettimeofday(&now, NULL); + start_time = now.tv_sec * NS_PER_S + now.tv_usec * 1000; + if (cbs->cb) { PDUMP_LOG(ERR, "failed to add rx callback for port=%d " -- 2.17.1