mirror of
https://github.com/corundum/corundum.git
synced 2025-01-30 08:32:52 +08:00
lib/mqnic: Added helper methods for converting cycle counts to/from time
Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
parent
66f305c46c
commit
dc50705d01
@ -227,6 +227,10 @@ uint32_t mqnic_get_core_clk_nom_freq_hz(struct mqnic *dev);
|
||||
uint32_t mqnic_get_ref_clk_nom_freq_hz(struct mqnic *dev);
|
||||
uint32_t mqnic_get_core_clk_freq_hz(struct mqnic *dev);
|
||||
uint32_t mqnic_get_clk_freq_hz(struct mqnic *dev, int ch);
|
||||
uint64_t mqnic_core_clk_cycles_to_ns(struct mqnic *dev, uint64_t cycles);
|
||||
uint64_t mqnic_core_clk_ns_to_cycles(struct mqnic *dev, uint64_t ns);
|
||||
uint64_t mqnic_ref_clk_cycles_to_ns(struct mqnic *dev, uint64_t cycles);
|
||||
uint64_t mqnic_ref_clk_ns_to_cycles(struct mqnic *dev, uint64_t ns);
|
||||
|
||||
// mqnic_stats.c
|
||||
void mqnic_stats_init(struct mqnic *dev);
|
||||
|
@ -80,3 +80,35 @@ uint32_t mqnic_get_clk_freq_hz(struct mqnic *dev, int ch)
|
||||
|
||||
return mqnic_reg_read32(dev->clk_info_rb->regs, MQNIC_RB_CLK_INFO_FREQ_BASE + ch*4);
|
||||
}
|
||||
|
||||
uint64_t mqnic_core_clk_cycles_to_ns(struct mqnic *dev, uint64_t cycles)
|
||||
{
|
||||
if (!dev->clk_info_rb || !dev->core_clk_nom_per_ns_denom)
|
||||
return 0;
|
||||
|
||||
return (cycles * (uint64_t)dev->core_clk_nom_per_ns_num) / (uint64_t)dev->core_clk_nom_per_ns_denom;
|
||||
}
|
||||
|
||||
uint64_t mqnic_core_clk_ns_to_cycles(struct mqnic *dev, uint64_t ns)
|
||||
{
|
||||
if (!dev->clk_info_rb || !dev->core_clk_nom_per_ns_num)
|
||||
return 0;
|
||||
|
||||
return (ns * (uint64_t)dev->core_clk_nom_per_ns_denom) / (uint64_t)dev->core_clk_nom_per_ns_num;
|
||||
}
|
||||
|
||||
uint64_t mqnic_ref_clk_cycles_to_ns(struct mqnic *dev, uint64_t cycles)
|
||||
{
|
||||
if (!dev->clk_info_rb || !dev->ref_clk_nom_per_ns_denom)
|
||||
return 0;
|
||||
|
||||
return (cycles * (uint64_t)dev->ref_clk_nom_per_ns_num) / (uint64_t)dev->ref_clk_nom_per_ns_denom;
|
||||
}
|
||||
|
||||
uint64_t mqnic_ref_clk_ns_to_cycles(struct mqnic *dev, uint64_t ns)
|
||||
{
|
||||
if (!dev->clk_info_rb || !dev->ref_clk_nom_per_ns_num)
|
||||
return 0;
|
||||
|
||||
return (ns * (uint64_t)dev->ref_clk_nom_per_ns_denom) / (uint64_t)dev->ref_clk_nom_per_ns_num;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user