Since this drive supports receive timestamping, provide a callback
so that the application can determine the clock rate for timestamp.

Signed-off-by: Stephen Hemminger <[email protected]>
---
 drivers/net/pcap/pcap_ethdev.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index e283fb3787..3eb313ebb8 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -1103,6 +1103,16 @@ eth_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
        return 0;
 }
 
+/* Timestamp values in receive packets from libpcap are in UTC */
+static int
+eth_rx_clock(struct rte_eth_dev *dev __rte_unused, uint64_t *timestamp)
+{
+       struct timespec cur_time;
+
+       timespec_get(&cur_time, TIME_UTC);
+       *timestamp = rte_timespec_to_ns(&cur_time);
+       return 0;
+}
 
 static const struct eth_dev_ops ops = {
        .dev_start = eth_dev_start,
@@ -1120,6 +1130,7 @@ static const struct eth_dev_ops ops = {
        .mtu_set = eth_mtu_set,
        .stats_get = eth_stats_get,
        .stats_reset = eth_stats_reset,
+       .read_clock = eth_rx_clock,
 };
 
 static int
-- 
2.51.0

Reply via email to