From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5F27CA09F6; Thu, 17 Dec 2020 18:35:24 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EA329CA86; Thu, 17 Dec 2020 18:33:22 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 41751CA40 for ; Thu, 17 Dec 2020 18:33:10 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from talshn@nvidia.com) with SMTP; 17 Dec 2020 19:33:05 +0200 Received: from nvidia.com (l-wincomp04-vm.mtl.labs.mlnx [10.237.1.5]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0BHHX45W021771; Thu, 17 Dec 2020 19:33:05 +0200 From: Tal Shnaiderman To: dev@dpdk.org Cc: thomas@monjalon.net, matan@nvidia.com, rasland@nvidia.com, ophirmu@nvidia.com Date: Thu, 17 Dec 2020 19:30:13 +0200 Message-Id: <20201217173037.11396-12-talshn@nvidia.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20201217173037.11396-1-talshn@nvidia.com> References: <20201217173037.11396-1-talshn@nvidia.com> Subject: [dpdk-dev] [PATCH 11/35] net/mlx5/windows: support read clock X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This commit adds a new glue function query_rt_values to support the new API mlx5_read_clock(). Signed-off-by: Tal Shnaiderman Acked-by: Matan Azrad --- 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(+) diff --git a/drivers/common/mlx5/mlx5_prm.h b/drivers/common/mlx5/mlx5_prm.h index d62d2558eb..ac42238d30 100644 --- a/drivers/common/mlx5/mlx5_prm.h +++ b/drivers/common/mlx5/mlx5_prm.h @@ -594,6 +594,7 @@ struct mlx5_modification_cmd { }; }; +typedef uint64_t u64; typedef uint32_t u32; typedef uint16_t u16; typedef uint8_t u8; diff --git a/drivers/common/mlx5/windows/mlx5_glue.c b/drivers/common/mlx5/windows/mlx5_glue.c index 3896cf0932..167531823b 100644 --- a/drivers/common/mlx5/windows/mlx5_glue.c +++ b/drivers/common/mlx5/windows/mlx5_glue.c @@ -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, }; diff --git a/drivers/common/mlx5/windows/mlx5_glue.h b/drivers/common/mlx5/windows/mlx5_glue.h index f2261ec7ac..bfaaa2a493 100644 --- a/drivers/common/mlx5/windows/mlx5_glue.h +++ b/drivers/common/mlx5/windows/mlx5_glue.h @@ -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; diff --git a/drivers/common/mlx5/windows/mlx5_win_ext.h b/drivers/common/mlx5/windows/mlx5_win_ext.h index 8e697b30c1..a14a6ccc3d 100644 --- a/drivers/common/mlx5/windows/mlx5_win_ext.h +++ b/drivers/common/mlx5/windows/mlx5_win_ext.h @@ -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) diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c index c99eac9868..1b68a7b6e8 100644 --- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c @@ -14,6 +14,7 @@ #include #include #include +#include /** * Get MAC address by querying netdevice. @@ -284,3 +285,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 = *(uint64_t volatile *)mlx5_clock.p_iseg_internal_timer; + return 0; +} -- 2.16.1.windows.4