DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vivien Didelot <vivien.didelot@gmail.com>
To: dev@dpdk.org
Cc: patrick.keroulas@radio-canada.ca, thomas@monjalon.net,
	Vivien Didelot <vivien.didelot@gmail.com>
Subject: [dpdk-dev] [PATCH 2/2] net/pcap: add TODO for writing Tx HW timestamp
Date: Sat, 23 May 2020 13:21:30 -0400	[thread overview]
Message-ID: <20200523172130.2285380-2-vivien.didelot@gmail.com> (raw)
In-Reply-To: <20200523172130.2285380-1-vivien.didelot@gmail.com>

In order to write a packet with hardware timestamp enabled into a
PCAP file, we need to convert its device specific raw timestamp first.

This might not be trivial since querying the raw clock value from
the device is still experimental, and derivating the frequency would
ideally require an additional alarm thread.

As a first step, pass the mbuf to the timestamp calculation function
since mbuf->port and mbuf->timestamp would be needed, and add a TODO
note. No functional changes.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 68588c3d7..f205a28e0 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -290,10 +290,16 @@ eth_null_rx(void *queue __rte_unused,
 #define NSEC_PER_SEC	1e9
 
 static inline void
-calculate_timestamp(struct timeval *ts) {
+calculate_timestamp(const struct rte_mbuf *mbuf, struct timeval *ts) {
 	uint64_t cycles;
 	struct timeval cur_time;
 
+	if (mbuf->ol_flags & PKT_RX_TIMESTAMP) {
+		/* TODO: convert mbuf->timestamp into nanoseconds instead.
+                 * See rte_eth_read_clock().
+                 */
+	}
+
 	cycles = rte_get_timer_cycles() - start_cycles;
 	cur_time.tv_sec = cycles / hz;
 	cur_time.tv_usec = (cycles % hz) * NSEC_PER_SEC / hz;
@@ -339,7 +345,7 @@ eth_pcap_tx_dumper(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			caplen = sizeof(temp_data);
 		}
 
-		calculate_timestamp(&header.ts);
+		calculate_timestamp(mbuf, &header.ts);
 		header.len = len;
 		header.caplen = caplen;
 		/* rte_pktmbuf_read() returns a pointer to the data directly
-- 
2.26.2


  reply	other threads:[~2020-05-23 20:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-23 17:21 [dpdk-dev] [PATCH 1/2] net/pcap: support software Tx nanosecond timestamp Vivien Didelot
2020-05-23 17:21 ` Vivien Didelot [this message]
2020-05-24  1:38   ` [dpdk-dev] [PATCH 2/2] net/pcap: add TODO for writing Tx HW timestamp Stephen Hemminger
2020-06-03 17:31     ` Ferruh Yigit
2020-05-24  1:39 ` [dpdk-dev] [PATCH 1/2] net/pcap: support software Tx nanosecond timestamp Stephen Hemminger
2020-06-03 17:50 ` Ferruh Yigit
2020-06-03 20:11   ` Stephen Hemminger
     [not found]     ` <20200603162652.GB13716@t480s.localdomain>
2020-06-03 21:59       ` Stephen Hemminger
2020-06-04 10:52       ` Ferruh Yigit
2020-06-04 11:16         ` Ferruh Yigit
2020-06-04 10:55     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200523172130.2285380-2-vivien.didelot@gmail.com \
    --to=vivien.didelot@gmail.com \
    --cc=dev@dpdk.org \
    --cc=patrick.keroulas@radio-canada.ca \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).