Implement the read_clock operation in eth_dev_ops. The function calls the AdminQ command to fetch the current NIC timestamp synchronously, updates the cached timestamp used for reconstruction, and returns the full 64-bit value.
Signed-off-by: Mark Blasko <[email protected]> Reviewed-by: Joshua Washington <[email protected]> Reviewed-by: Jasper Tran O'Leary <[email protected]> --- v2: - Scoped read_clock ethdev operation strictly to DQO queues. --- drivers/net/gve/gve_ethdev.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c index ee21fb3ec4..c600062faf 100644 --- a/drivers/net/gve/gve_ethdev.c +++ b/drivers/net/gve/gve_ethdev.c @@ -1271,6 +1271,34 @@ gve_flow_ops_get(struct rte_eth_dev *dev, const struct rte_flow_ops **ops) return 0; } +static int +gve_read_clock(struct rte_eth_dev *dev, uint64_t *clock) +{ + struct gve_priv *priv = dev->data->dev_private; + uint64_t ts; + int err; + + if (!priv->nic_timestamp_supported) + return -EOPNOTSUPP; + + if (!priv->nic_ts_report_mz) + return -EIO; + + err = gve_adminq_report_nic_timestamp(priv, priv->nic_ts_report_mz->iova); + if (err != 0) + return err; + + ts = be64_to_cpu(priv->nic_ts_report->nic_timestamp); + *clock = ts; + + /* Update the cached value */ + rte_atomic_store_explicit(&priv->last_read_nic_timestamp, ts, rte_memory_order_relaxed); + rte_atomic_store_explicit(&priv->nic_ts_read_fails, 0, rte_memory_order_relaxed); + rte_atomic_store_explicit(&priv->nic_ts_stale, 0, rte_memory_order_release); + + return 0; +} + static const struct eth_dev_ops gve_eth_dev_ops = { .dev_configure = gve_dev_configure, .dev_start = gve_dev_start, -- 2.54.0.563.g4f69b47b94-goog

