net/cnxk: support Rx/Tx timestamp read
authorSunil Kumar Kori <skori@marvell.com>
Wed, 23 Jun 2021 04:46:57 +0000 (10:16 +0530)
committerJerin Jacob <jerinj@marvell.com>
Wed, 30 Jun 2021 01:06:25 +0000 (03:06 +0200)
Patch implements Rx/Tx timestamp read operations for cn9k
and cn10k platforms.

Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
drivers/net/cnxk/cnxk_ethdev.c
drivers/net/cnxk/cnxk_ethdev.h
drivers/net/cnxk/cnxk_ptp.c

index fc91346..cb583b4 100644 (file)
@@ -1260,6 +1260,8 @@ struct eth_dev_ops cnxk_eth_dev_ops = {
        .tx_done_cleanup = cnxk_nix_tx_done_cleanup,
        .flow_ops_get = cnxk_nix_flow_ops_get,
        .get_reg = cnxk_nix_dev_get_reg,
+       .timesync_read_rx_timestamp = cnxk_nix_timesync_read_rx_timestamp,
+       .timesync_read_tx_timestamp = cnxk_nix_timesync_read_tx_timestamp,
 };
 
 static int
index de6d533..76df84a 100644 (file)
@@ -312,6 +312,11 @@ int cnxk_nix_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t qid);
 int cnxk_nix_dev_start(struct rte_eth_dev *eth_dev);
 int cnxk_nix_timesync_enable(struct rte_eth_dev *eth_dev);
 int cnxk_nix_timesync_disable(struct rte_eth_dev *eth_dev);
+int cnxk_nix_timesync_read_rx_timestamp(struct rte_eth_dev *eth_dev,
+                                       struct timespec *timestamp,
+                                       uint32_t flags);
+int cnxk_nix_timesync_read_tx_timestamp(struct rte_eth_dev *eth_dev,
+                                       struct timespec *timestamp);
 int cnxk_nix_tsc_convert(struct cnxk_eth_dev *dev);
 
 uint64_t cnxk_nix_rxq_mbuf_setup(struct cnxk_eth_dev *dev);
index fc31796..7b00f87 100644 (file)
@@ -55,6 +55,44 @@ fail:
        return rc;
 }
 
+int
+cnxk_nix_timesync_read_rx_timestamp(struct rte_eth_dev *eth_dev,
+                                   struct timespec *timestamp, uint32_t flags)
+{
+       struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+       struct cnxk_timesync_info *tstamp = &dev->tstamp;
+       uint64_t ns;
+
+       PLT_SET_USED(flags);
+
+       if (!tstamp->rx_ready)
+               return -EINVAL;
+
+       ns = rte_timecounter_update(&dev->rx_tstamp_tc, tstamp->rx_tstamp);
+       *timestamp = rte_ns_to_timespec(ns);
+       tstamp->rx_ready = 0;
+       return 0;
+}
+
+int
+cnxk_nix_timesync_read_tx_timestamp(struct rte_eth_dev *eth_dev,
+                                   struct timespec *timestamp)
+{
+       struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
+       struct cnxk_timesync_info *tstamp = &dev->tstamp;
+       uint64_t ns;
+
+       if (*tstamp->tx_tstamp == 0)
+               return -EINVAL;
+
+       ns = rte_timecounter_update(&dev->tx_tstamp_tc, *tstamp->tx_tstamp);
+       *timestamp = rte_ns_to_timespec(ns);
+       *tstamp->tx_tstamp = 0;
+       rte_wmb();
+
+       return 0;
+}
+
 int
 cnxk_nix_timesync_enable(struct rte_eth_dev *eth_dev)
 {