1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* Aquantia Corporation Network Driver 3 * Copyright (C) 2014-2019 Aquantia Corporation. All rights reserved 4 */ 5 6 /* File aq_ptp.h: Declaration of PTP functions. 7 */ 8 #ifndef AQ_PTP_H 9 #define AQ_PTP_H 10 11 #include <linux/net_tstamp.h> 12 13 #if IS_REACHABLE(CONFIG_PTP_1588_CLOCK) 14 15 /* Common functions */ 16 int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec); 17 18 void aq_ptp_unregister(struct aq_nic_s *aq_nic); 19 void aq_ptp_free(struct aq_nic_s *aq_nic); 20 21 int aq_ptp_irq_alloc(struct aq_nic_s *aq_nic); 22 void aq_ptp_irq_free(struct aq_nic_s *aq_nic); 23 24 int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic); 25 void aq_ptp_ring_free(struct aq_nic_s *aq_nic); 26 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); 31 32 void aq_ptp_service_task(struct aq_nic_s *aq_nic); 33 34 void aq_ptp_tm_offset_set(struct aq_nic_s *aq_nic, unsigned int mbps); 35 36 void aq_ptp_clock_init(struct aq_nic_s *aq_nic); 37 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); 41 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); 47 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); 50 51 u16 aq_ptp_extract_ts(struct aq_nic_s *aq_nic, struct sk_buff *skb, u8 *p, 52 unsigned int len); 53 54 struct ptp_clock *aq_ptp_get_ptp_clock(struct aq_ptp_s *aq_ptp); 55 56 int aq_ptp_link_change(struct aq_nic_s *aq_nic); 57 58 #else 59 60 static inline int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec) 61 { 62 return 0; 63 } 64 65 static inline void aq_ptp_unregister(struct aq_nic_s *aq_nic) {} 66 67 static inline void aq_ptp_free(struct aq_nic_s *aq_nic) 68 { 69 } 70 71 static inline int aq_ptp_irq_alloc(struct aq_nic_s *aq_nic) 72 { 73 return 0; 74 } 75 76 static inline void aq_ptp_irq_free(struct aq_nic_s *aq_nic) 77 { 78 } 79 80 static inline int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic) 81 { 82 return 0; 83 } 84 85 static inline void aq_ptp_ring_free(struct aq_nic_s *aq_nic) {} 86 87 static inline int aq_ptp_ring_init(struct aq_nic_s *aq_nic) 88 { 89 return 0; 90 } 91 92 static inline int aq_ptp_ring_start(struct aq_nic_s *aq_nic) 93 { 94 return 0; 95 } 96 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) 104 { 105 return -EOPNOTSUPP; 106 } 107 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) 113 { 114 return 0; 115 } 116 117 static inline bool aq_ptp_ring(struct aq_nic_s *aq_nic, struct aq_ring_s *ring) 118 { 119 return false; 120 } 121 122 static inline u16 aq_ptp_extract_ts(struct aq_nic_s *aq_nic, 123 struct sk_buff *skb, u8 *p, 124 unsigned int len) 125 { 126 return 0; 127 } 128 129 static inline struct ptp_clock *aq_ptp_get_ptp_clock(struct aq_ptp_s *aq_ptp) 130 { 131 return NULL; 132 } 133 134 static inline int aq_ptp_link_change(struct aq_nic_s *aq_nic) 135 { 136 return 0; 137 } 138 #endif 139 140 #endif /* AQ_PTP_H */ 141