summaryrefslogtreecommitdiff
path: root/drivers/net/mlx5/mlx5_ethdev.c
diff options
context:
space:
mode:
authorTom Barbette <barbette@kth.se>2019-05-02 14:11:34 +0200
committerFerruh Yigit <ferruh.yigit@intel.com>2019-06-06 20:21:20 +0900
commite571ad5541457e5741d84babb7d2301f2cd18c2f (patch)
tree09bcb93caa0b75283e22048f7395e717fc1b0028 /drivers/net/mlx5/mlx5_ethdev.c
parent5e741377657c8fce28037e025ea2f12371400476 (diff)
downloaddpdk-next-eventdev-e571ad5541457e5741d84babb7d2301f2cd18c2f.zip
dpdk-next-eventdev-e571ad5541457e5741d84babb7d2301f2cd18c2f.tar.gz
dpdk-next-eventdev-e571ad5541457e5741d84babb7d2301f2cd18c2f.tar.xz
net/mlx5: support reading clock
Implements support for read_clock for the mlx5 driver. mlx5 supports hardware timestamp offload, setting packets timestamp field to the device clock. rte_eth_read_clock allows to read the device's current clock value and therefore compare values on similar time base. See rxtx_callbacks for an example. Signed-off-by: Tom Barbette <barbette@kth.se> Acked-by: Shahaf Shuler <shahafs@mellanox.com>
Diffstat (limited to 'drivers/net/mlx5/mlx5_ethdev.c')
-rw-r--r--drivers/net/mlx5/mlx5_ethdev.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index a8a7ece..7785341 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -569,6 +569,36 @@ mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info)
}
/**
+ * Get device current raw clock counter
+ *
+ * @param dev
+ * Pointer to Ethernet device structure.
+ * @param[out] time
+ * Current raw clock counter of the device.
+ *
+ * @return
+ * 0 if the clock has correctly been read
+ * The value of errno in case of error
+ */
+int
+mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock)
+{
+ struct mlx5_priv *priv = dev->data->dev_private;
+ struct ibv_context *ctx = priv->sh->ctx;
+ struct ibv_values_ex values;
+ int err = 0;
+
+ values.comp_mask = IBV_VALUES_MASK_RAW_CLOCK;
+ err = mlx5_glue->query_rt_values_ex(ctx, &values);
+ if (err != 0) {
+ DRV_LOG(WARNING, "Could not query the clock !");
+ return err;
+ }
+ *clock = values.raw_clock.tv_nsec;
+ return 0;
+}
+
+/**
* Get firmware version of a device.
*
* @param dev