This source file includes following definitions.
- mlx5_clock_get_ptp_index
- mlx5_timecounter_cyc2time
- mlx5_init_clock
- mlx5_cleanup_clock
- mlx5_clock_get_ptp_index
- mlx5_timecounter_cyc2time
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #ifndef __LIB_CLOCK_H__
34 #define __LIB_CLOCK_H__
35
36 #if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
37 void mlx5_init_clock(struct mlx5_core_dev *mdev);
38 void mlx5_cleanup_clock(struct mlx5_core_dev *mdev);
39
40 static inline int mlx5_clock_get_ptp_index(struct mlx5_core_dev *mdev)
41 {
42 return mdev->clock.ptp ? ptp_clock_index(mdev->clock.ptp) : -1;
43 }
44
45 static inline ktime_t mlx5_timecounter_cyc2time(struct mlx5_clock *clock,
46 u64 timestamp)
47 {
48 unsigned int seq;
49 u64 nsec;
50
51 do {
52 seq = read_seqbegin(&clock->lock);
53 nsec = timecounter_cyc2time(&clock->tc, timestamp);
54 } while (read_seqretry(&clock->lock, seq));
55
56 return ns_to_ktime(nsec);
57 }
58
59 #else
60 static inline void mlx5_init_clock(struct mlx5_core_dev *mdev) {}
61 static inline void mlx5_cleanup_clock(struct mlx5_core_dev *mdev) {}
62 static inline int mlx5_clock_get_ptp_index(struct mlx5_core_dev *mdev)
63 {
64 return -1;
65 }
66
67 static inline ktime_t mlx5_timecounter_cyc2time(struct mlx5_clock *clock,
68 u64 timestamp)
69 {
70 return 0;
71 }
72 #endif
73
74 #endif