[v2] net/pcap: propagate timestamp from pcap_pkthdr to mbuf

Message ID 1564736244-5906-2-git-send-email-s.rodon@mail.nexatech.local (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [v2] net/pcap: propagate timestamp from pcap_pkthdr to mbuf |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-Compile-Testing success Compile Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS

Commit Message

Sylvain Rodon Aug. 2, 2019, 8:57 a.m. UTC
  From: Sylvain Rodon <srn@nexatech.fr>

Timestamp is always set in PCAP header, whether it reads a file or
listen on an interface. This information can be important for some
applications and it cannot be obtained otherwise (especially when
reading a PCAP file, where the timestamp is not the current time).
Timestamp here is the number of microseconds since epoch.

Signed-off-by: Sylvain Rodon <srn@nexatech.fr>
---
 drivers/net/pcap/rte_eth_pcap.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Ferruh Yigit Aug. 27, 2019, 11:54 a.m. UTC | #1
On 8/2/2019 9:57 AM, Sylvain Rodon wrote:
> From: Sylvain Rodon <srn@nexatech.fr>
> 
> Timestamp is always set in PCAP header, whether it reads a file or
> listen on an interface. This information can be important for some
> applications and it cannot be obtained otherwise (especially when
> reading a PCAP file, where the timestamp is not the current time).
> Timestamp here is the number of microseconds since epoch.
> 
> Signed-off-by: Sylvain Rodon <srn@nexatech.fr>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 95d4b5b..5489010 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -265,6 +265,9 @@  struct pmd_devargs_all {
 		}
 
 		mbuf->pkt_len = (uint16_t)header.caplen;
+		mbuf->timestamp = (uint64_t)header.ts.tv_sec * 1000000
+							+ header.ts.tv_usec;
+		mbuf->ol_flags |= PKT_RX_TIMESTAMP;
 		mbuf->port = pcap_q->port_id;
 		bufs[num_rx] = mbuf;
 		num_rx++;