From: Tal Shnaiderman <talshn@nvidia.com>
This commit adds a new glue function query_rt_values to support the new
API mlx5_read_clock().
Signed-off-by: Tal Shnaiderman <talshn@nvidia.com>
---
drivers/common/mlx5/mlx5_prm.h | 1 +
drivers/common/mlx5/windows/mlx5_glue.c | 26 ++++++++++++++++++++++++++
drivers/common/mlx5/windows/mlx5_glue.h | 1 +
drivers/common/mlx5/windows/mlx5_win_ext.h | 6 ++++++
drivers/net/mlx5/windows/mlx5_ethdev_os.c | 30 ++++++++++++++++++++++++++++++
5 files changed, 64 insertions(+)
@@ -578,6 +578,7 @@ struct mlx5_modification_cmd {
};
};
+typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
@@ -283,6 +283,31 @@ mlx5_glue_devx_fs_rule_del(void *flow)
return devx_fs_rule_del(flow);
}
+static int
+mlx5_glue_query_rt_values(void *ctx, void *devx_clock)
+{
+ struct mlx5_context *mlx5_ctx;
+ struct mlx5_devx_clock *clock;
+ int err;
+
+ if (!ctx) {
+ errno = EINVAL;
+ return errno;
+ }
+ mlx5_ctx = (struct mlx5_context *)ctx;
+ clock = (struct mlx5_devx_clock *)devx_clock;
+ err = devx_hca_clock_query(
+ mlx5_ctx->devx_ctx,
+ &clock->p_iseg_internal_timer,
+ &clock->clock_frequency_hz,
+ &clock->is_stable_clock_frequency);
+ if (err) {
+ errno = err;
+ return errno;
+ }
+ return 0;
+}
+
alignas(RTE_CACHE_LINE_SIZE)
const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
.version = MLX5_GLUE_VERSION,
@@ -304,4 +329,5 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
.devx_fs_rule_add = mlx5_glue_devx_fs_rule_add,
.devx_fs_rule_del = mlx5_glue_devx_fs_rule_del,
.devx_query_eqn = mlx5_glue_devx_query_eqn,
+ .query_rt_values = mlx5_glue_query_rt_values,
};
@@ -51,6 +51,7 @@ struct mlx5_glue {
void *(*devx_fs_rule_add)(void *ctx, void *in, uint32_t inlen);
int (*devx_fs_rule_del)(void *flow);
int (*devx_query_eqn)(void *context, uint32_t cpus, uint32_t *eqn);
+ int (*query_rt_values)(void *ctx, void *devx_clock);
};
extern const struct mlx5_glue *mlx5_glue;
@@ -34,6 +34,12 @@ struct mlx5_pd {
devx_device_ctx *devx_ctx;
};
+struct mlx5_devx_clock {
+ void *p_iseg_internal_timer;
+ u64 clock_frequency_hz;
+ int is_stable_clock_frequency;
+};
+
#define GET_DEVX_CTX(ctx) (((mlx5_context_st *)ctx)->devx_ctx)
#define GET_OBJ_CTX(obj) (((mlx5_devx_obj_st *)obj)->devx_ctx)
@@ -14,6 +14,7 @@
#include <mlx5_win_ext.h>
#include <mlx5_malloc.h>
#include <mlx5.h>
+#include <mlx5_utils.h>
/**
* Get MAC address by querying netdevice.
@@ -279,3 +280,32 @@ int mlx5_get_module_eeprom(struct rte_eth_dev *dev,
RTE_SET_USED(info);
return -ENOTSUP;
}
+
+/**
+ * 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)
+{
+ int err;
+ struct mlx5_devx_clock mlx5_clock;
+ struct mlx5_priv *priv = dev->data->dev_private;
+ mlx5_context_st *context_obj = (mlx5_context_st *)priv->sh->ctx;
+
+ err = mlx5_glue->query_rt_values(context_obj, &mlx5_clock);
+ if (err != 0) {
+ DRV_LOG(WARNING, "Could not query the clock !");
+ return err;
+ }
+ *clock = *(u64 volatile *)mlx5_clock.p_iseg_internal_timer;
+ return 0;
+}