From: Tom Barbette <barbette@kth.se>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com, john.mcnamara@intel.com,
Thomas Monjalon <thomas@monjalon.net>,
Ferruh Yigit <ferruh.yigit@intel.com>,
Andrew Rybchenko <arybchenko@solarflare.com>,
Shahaf Shuler <shahafs@mellanox.com>,
Yongseok Koh <yskoh@mellanox.com>, Tom Barbette <barbette@kth.se>
Subject: [dpdk-dev] [RFC PATCH 2/3] mlx5: Implement support for read_clock
Date: Wed, 28 Nov 2018 10:52:11 +0100 [thread overview]
Message-ID: <1543398732-79439-3-git-send-email-barbette@kth.se> (raw)
In-Reply-To: <1543398732-79439-1-git-send-email-barbette@kth.se>
Signed-off-by: Tom Barbette <barbette@kth.se>
---
drivers/net/mlx5/mlx5.c | 1 +
drivers/net/mlx5/mlx5.h | 1 +
drivers/net/mlx5/mlx5_ethdev.c | 31 +++++++++++++++++++++++++++++++
drivers/net/mlx5/mlx5_glue.c | 8 ++++++++
drivers/net/mlx5/mlx5_glue.h | 2 ++
5 files changed, 43 insertions(+)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 9e5cab169..ed799ab5a 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -372,6 +372,7 @@ const struct eth_dev_ops mlx5_dev_ops = {
.xstats_reset = mlx5_xstats_reset,
.xstats_get_names = mlx5_xstats_get_names,
.dev_infos_get = mlx5_dev_infos_get,
+ .read_clock = mlx5_read_clock,
.dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
.vlan_filter_set = mlx5_vlan_filter_set,
.rx_queue_setup = mlx5_rx_queue_setup,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index bc500b2bc..3972debf5 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -258,6 +258,7 @@ int mlx5_set_flags(struct rte_eth_dev *dev, unsigned int keep,
unsigned int flags);
int mlx5_dev_configure(struct rte_eth_dev *dev);
void mlx5_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info);
+int mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *time);
const uint32_t *mlx5_dev_supported_ptypes_get(struct rte_eth_dev *dev);
int mlx5_link_update(struct rte_eth_dev *dev, int wait_to_complete);
int mlx5_force_link_status_change(struct rte_eth_dev *dev, int status);
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index d178ed6a1..eb97ab27e 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -557,6 +557,37 @@ 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
+ */
+int
+mlx5_read_clock(struct rte_eth_dev *dev, uint64_t *clock)
+{
+ struct priv *priv = dev->data->dev_private;
+ struct ibv_values_ex values;
+ int err = 0;
+
+ values.comp_mask = IBV_VALUES_MASK_RAW_CLOCK;
+ err = mlx5_glue->query_rt_values_ex(priv->ctx, &values);
+ if (err != 0) {
+ DRV_LOG(WARNING, "Could not query the clock !");
+ return err;
+ }
+
+ *clock = values.raw_clock.tv_nsec;
+ return 0;
+}
+
+
/**
* Get supported packet types.
*
diff --git a/drivers/net/mlx5/mlx5_glue.c b/drivers/net/mlx5/mlx5_glue.c
index dd10ad6de..e23296519 100644
--- a/drivers/net/mlx5/mlx5_glue.c
+++ b/drivers/net/mlx5/mlx5_glue.c
@@ -86,6 +86,13 @@ mlx5_glue_query_device_ex(struct ibv_context *context,
return ibv_query_device_ex(context, input, attr);
}
+static int
+mlx5_glue_query_rt_values_ex(struct ibv_context *context,
+ struct ibv_values_ex *values)
+{
+ return ibv_query_rt_values_ex(context, values);
+}
+
static int
mlx5_glue_query_port(struct ibv_context *context, uint8_t port_num,
struct ibv_port_attr *port_attr)
@@ -491,6 +498,7 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){
.close_device = mlx5_glue_close_device,
.query_device = mlx5_glue_query_device,
.query_device_ex = mlx5_glue_query_device_ex,
+ .query_rt_values_ex = mlx5_glue_query_rt_values_ex,
.query_port = mlx5_glue_query_port,
.create_comp_channel = mlx5_glue_create_comp_channel,
.destroy_comp_channel = mlx5_glue_destroy_comp_channel,
diff --git a/drivers/net/mlx5/mlx5_glue.h b/drivers/net/mlx5/mlx5_glue.h
index 2d92ba8bc..31ebee72a 100644
--- a/drivers/net/mlx5/mlx5_glue.h
+++ b/drivers/net/mlx5/mlx5_glue.h
@@ -70,6 +70,8 @@ struct mlx5_glue {
int (*query_device_ex)(struct ibv_context *context,
const struct ibv_query_device_ex_input *input,
struct ibv_device_attr_ex *attr);
+ int (*query_rt_values_ex)(struct ibv_context *context,
+ struct ibv_values_ex *values);
int (*query_port)(struct ibv_context *context, uint8_t port_num,
struct ibv_port_attr *port_attr);
struct ibv_comp_channel *(*create_comp_channel)
--
2.17.1
next prev parent reply other threads:[~2018-11-28 9:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-28 9:52 [dpdk-dev] [RFC PATCH 0/3] Add rte_eth_read_clock API Tom Barbette
2018-11-28 9:52 ` [dpdk-dev] [RFC PATCH 1/3] rte_ethdev: Add API function to read dev clock Tom Barbette
2018-12-05 16:33 ` [dpdk-dev] [RFC PATCH 0/3] Add rte_eth_read_clock API zr
2018-12-08 12:07 ` Tom Barbette
2018-12-09 6:00 ` [dpdk-dev] [RFC PATCH 1/3] rte_ethdev: Add API function to read dev clock Shahaf Shuler
2018-11-28 9:52 ` Tom Barbette [this message]
2018-12-09 6:03 ` [dpdk-dev] [RFC PATCH 2/3] mlx5: Implement support for read_clock Shahaf Shuler
2018-11-28 9:52 ` [dpdk-dev] [RFC PATCH 3/3] rxtx_callbacks: Add support for HW timestamp Tom Barbette
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1543398732-79439-3-git-send-email-barbette@kth.se \
--to=barbette@kth.se \
--cc=arybchenko@solarflare.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=john.mcnamara@intel.com \
--cc=shahafs@mellanox.com \
--cc=thomas@monjalon.net \
--cc=yskoh@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).