Signed-off-by: Patrick Keroulas <patrick.kerou...@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