[[PATCH,v3,2/4] ethdev: add API to query device frequency
Checks
Commit Message
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(+)
@@ -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)
{
@@ -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.
@@ -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. */
@@ -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 {