1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Aquantia Corporation Network Driver
3 * Copyright (C) 2014-2019 Aquantia Corporation. All rights reserved
6 /* File aq_ptp.h: Declaration of PTP functions.
11 #include <linux/net_tstamp.h>
13 #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
15 /* Common functions */
16 int aq_ptp_init(struct aq_nic_s
*aq_nic
, unsigned int idx_vec
);
18 void aq_ptp_unregister(struct aq_nic_s
*aq_nic
);
19 void aq_ptp_free(struct aq_nic_s
*aq_nic
);
21 int aq_ptp_irq_alloc(struct aq_nic_s
*aq_nic
);
22 void aq_ptp_irq_free(struct aq_nic_s
*aq_nic
);
24 int aq_ptp_ring_alloc(struct aq_nic_s
*aq_nic
);
25 void aq_ptp_ring_free(struct aq_nic_s
*aq_nic
);
27 int aq_ptp_ring_init(struct aq_nic_s
*aq_nic
);
28 int aq_ptp_ring_start(struct aq_nic_s
*aq_nic
);
29 void aq_ptp_ring_stop(struct aq_nic_s
*aq_nic
);
30 void aq_ptp_ring_deinit(struct aq_nic_s
*aq_nic
);
32 void aq_ptp_service_task(struct aq_nic_s
*aq_nic
);
34 void aq_ptp_tm_offset_set(struct aq_nic_s
*aq_nic
, unsigned int mbps
);
36 void aq_ptp_clock_init(struct aq_nic_s
*aq_nic
);
38 /* Traffic processing functions */
39 int aq_ptp_xmit(struct aq_nic_s
*aq_nic
, struct sk_buff
*skb
);
40 void aq_ptp_tx_hwtstamp(struct aq_nic_s
*aq_nic
, u64 timestamp
);
42 /* Must be to check available of PTP before call */
43 void aq_ptp_hwtstamp_config_get(struct aq_ptp_s
*aq_ptp
,
44 struct hwtstamp_config
*config
);
45 int aq_ptp_hwtstamp_config_set(struct aq_ptp_s
*aq_ptp
,
46 struct hwtstamp_config
*config
);
48 /* Return either ring is belong to PTP or not*/
49 bool aq_ptp_ring(struct aq_nic_s
*aq_nic
, struct aq_ring_s
*ring
);
51 u16
aq_ptp_extract_ts(struct aq_nic_s
*aq_nic
, struct sk_buff
*skb
, u8
*p
,
54 struct ptp_clock
*aq_ptp_get_ptp_clock(struct aq_ptp_s
*aq_ptp
);
56 int aq_ptp_link_change(struct aq_nic_s
*aq_nic
);
60 static inline int aq_ptp_init(struct aq_nic_s
*aq_nic
, unsigned int idx_vec
)
65 static inline void aq_ptp_unregister(struct aq_nic_s
*aq_nic
) {}
67 static inline void aq_ptp_free(struct aq_nic_s
*aq_nic
)
71 static inline int aq_ptp_irq_alloc(struct aq_nic_s
*aq_nic
)
76 static inline void aq_ptp_irq_free(struct aq_nic_s
*aq_nic
)
80 static inline int aq_ptp_ring_alloc(struct aq_nic_s
*aq_nic
)
85 static inline void aq_ptp_ring_free(struct aq_nic_s
*aq_nic
) {}
87 static inline int aq_ptp_ring_init(struct aq_nic_s
*aq_nic
)
92 static inline int aq_ptp_ring_start(struct aq_nic_s
*aq_nic
)
97 static inline void aq_ptp_ring_stop(struct aq_nic_s
*aq_nic
) {}
98 static inline void aq_ptp_ring_deinit(struct aq_nic_s
*aq_nic
) {}
99 static inline void aq_ptp_service_task(struct aq_nic_s
*aq_nic
) {}
100 static inline void aq_ptp_tm_offset_set(struct aq_nic_s
*aq_nic
,
101 unsigned int mbps
) {}
102 static inline void aq_ptp_clock_init(struct aq_nic_s
*aq_nic
) {}
103 static inline int aq_ptp_xmit(struct aq_nic_s
*aq_nic
, struct sk_buff
*skb
)
108 static inline void aq_ptp_tx_hwtstamp(struct aq_nic_s
*aq_nic
, u64 timestamp
) {}
109 static inline void aq_ptp_hwtstamp_config_get(struct aq_ptp_s
*aq_ptp
,
110 struct hwtstamp_config
*config
) {}
111 static inline int aq_ptp_hwtstamp_config_set(struct aq_ptp_s
*aq_ptp
,
112 struct hwtstamp_config
*config
)
117 static inline bool aq_ptp_ring(struct aq_nic_s
*aq_nic
, struct aq_ring_s
*ring
)
122 static inline u16
aq_ptp_extract_ts(struct aq_nic_s
*aq_nic
,
123 struct sk_buff
*skb
, u8
*p
,
129 static inline struct ptp_clock
*aq_ptp_get_ptp_clock(struct aq_ptp_s
*aq_ptp
)
134 static inline int aq_ptp_link_change(struct aq_nic_s
*aq_nic
)
140 #endif /* AQ_PTP_H */