DPDK patches and discussions
 help / color / mirror / Atom feed
From: Patrick Keroulas <patrick.keroulas@radio-canada.ca>
To: dev@dpdk.org
Cc: Patrick Keroulas <patrick.keroulas@radio-canada.ca>
Subject: [dpdk-dev] [[PATCH v3 2/4] ethdev: add API to query device frequency
Date: Fri, 24 Jul 2020 16:23:13 -0400	[thread overview]
Message-ID: <20200724202315.19533-3-patrick.keroulas@radio-canada.ca> (raw)
In-Reply-To: <20200724202315.19533-1-patrick.keroulas@radio-canada.ca>

Signed-off-by: Patrick Keroulas <patrick.keroulas@radio-canada.ca>
---
 lib/librte_ethdev/rte_ethdev.c           | 12 ++++++++++++
 lib/librte_ethdev/rte_ethdev.h           | 17 +++++++++++++++++
 lib/librte_ethdev/rte_ethdev_core.h      |  5 +++++
 lib/librte_ethdev/rte_ethdev_version.map |  2 ++
 4 files changed, 36 insertions(+)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 7858ad5f11..8e8812782f 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -4882,6 +4882,18 @@ rte_eth_read_clock(uint16_t port_id, uint64_t *clock)
 	return eth_err(port_id, (*dev->dev_ops->read_clock)(dev, clock));
 }
 
+int
+rte_eth_get_clock_freq(uint16_t port_id, uint64_t *freq)
+{
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+	dev = &rte_eth_devices[port_id];
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_clock_freq, -ENOTSUP);
+	return eth_err(port_id, (*dev->dev_ops->get_clock_freq)(dev, freq));
+}
+
 int
 rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info)
 {
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 57e4a6ca58..d17838e66f 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -4264,6 +4264,23 @@ __rte_experimental
 int
 rte_eth_read_clock(uint16_t port_id, uint64_t *clock);
 
+/**
+ * Get the clock frequency of ethernet device, in Hz
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param[out] freq
+ *   Pointer to the device clock frequency.
+ *
+ * @return
+ *   - 0: Success.
+ *   - -ENODEV: The port ID is invalid.
+ *   - -ENOTSUP: The function is not supported by the Ethernet driver.
+ */
+__rte_experimental
+int
+rte_eth_get_clock_freq(uint16_t port_id, uint64_t *freq);
+
 /**
  * Config l2 tunnel ether type of an Ethernet device for filtering specific
  * tunnel packets by ether type.
diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h
index 32407dd418..ac64961e6f 100644
--- a/lib/librte_ethdev/rte_ethdev_core.h
+++ b/lib/librte_ethdev/rte_ethdev_core.h
@@ -468,6 +468,10 @@ typedef int (*eth_read_clock)(struct rte_eth_dev *dev,
 				      uint64_t *timestamp);
 /**< @internal Function used to get the current value of the device clock. */
 
+typedef int (*eth_get_clock_freq)(struct rte_eth_dev *dev,
+				      uint64_t *freq);
+/**< @internal Function used to frequency from device clock */
+
 typedef int (*eth_get_reg_t)(struct rte_eth_dev *dev,
 				struct rte_dev_reg_info *info);
 /**< @internal Retrieve registers  */
@@ -731,6 +735,7 @@ struct eth_dev_ops {
 	eth_timesync_write_time    timesync_write_time; /** Set the device clock time. */
 
 	eth_read_clock             read_clock;
+	eth_get_clock_freq         get_clock_freq;
 
 	eth_xstats_get_by_id_t     xstats_get_by_id;
 	/**< Get extended device statistic values by ID. */
diff --git a/lib/librte_ethdev/rte_ethdev_version.map b/lib/librte_ethdev/rte_ethdev_version.map
index 1212a17d32..ffc00bf94f 100644
--- a/lib/librte_ethdev/rte_ethdev_version.map
+++ b/lib/librte_ethdev/rte_ethdev_version.map
@@ -241,6 +241,8 @@ EXPERIMENTAL {
 	__rte_ethdev_trace_rx_burst;
 	__rte_ethdev_trace_tx_burst;
 	rte_flow_get_aged_flows;
+
+	rte_eth_get_clock_freq;
 };
 
 INTERNAL {
-- 
2.17.1


  parent reply	other threads:[~2020-07-24 20:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 20:23 [dpdk-dev] [[PATCH v3 0/4] pdump HW Rx timestamps for mlx5 Patrick Keroulas
2020-07-24 20:23 ` [dpdk-dev] [[PATCH v3 1/4] net/mlx5: query device frequency Patrick Keroulas
2020-07-24 20:23 ` Patrick Keroulas [this message]
2020-07-24 20:23 ` [dpdk-dev] [[PATCH v3 3/4] pdump: convert timestamp to nanoseconds on Rx path Patrick Keroulas
2020-09-02 15:41   ` Pattan, Reshma
2020-07-24 20:23 ` [dpdk-dev] [[PATCH v3 4/4] net/pcap: support hardware Tx timestamps Patrick Keroulas
2020-07-25  8:35   ` Tom Barbette
2020-07-25 11:51     ` Stephen Hemminger
2020-07-26 22:17   ` Stephen Hemminger
2020-10-06 16:25 ` [dpdk-dev] [[PATCH v3 0/4] pdump HW Rx timestamps for mlx5 Ferruh Yigit
2020-10-07  6:59   ` Morten Brørup

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=20200724202315.19533-3-patrick.keroulas@radio-canada.ca \
    --to=patrick.keroulas@radio-canada.ca \
    --cc=dev@dpdk.org \
    /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).