1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) 2019, Vladimir Oltean <olteanv@gmail.com> 3 */ 4 #ifndef _SJA1105_TAS_H 5 #define _SJA1105_TAS_H 6 7 #include <net/pkt_sched.h> 8 9 #if IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS) 10 11 enum sja1105_tas_state { 12 SJA1105_TAS_STATE_DISABLED, 13 SJA1105_TAS_STATE_ENABLED_NOT_RUNNING, 14 SJA1105_TAS_STATE_RUNNING, 15 }; 16 17 enum sja1105_ptp_op { 18 SJA1105_PTP_NONE, 19 SJA1105_PTP_CLOCKSTEP, 20 SJA1105_PTP_ADJUSTFREQ, 21 }; 22 23 struct sja1105_tas_data { 24 struct tc_taprio_qopt_offload *offload[SJA1105_NUM_PORTS]; 25 enum sja1105_tas_state state; 26 enum sja1105_ptp_op last_op; 27 struct work_struct tas_work; 28 s64 earliest_base_time; 29 s64 oper_base_time; 30 u64 max_cycle_time; 31 bool enabled; 32 }; 33 34 int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port, 35 struct tc_taprio_qopt_offload *admin); 36 37 void sja1105_tas_setup(struct dsa_switch *ds); 38 39 void sja1105_tas_teardown(struct dsa_switch *ds); 40 41 void sja1105_tas_clockstep(struct dsa_switch *ds); 42 43 void sja1105_tas_adjfreq(struct dsa_switch *ds); 44 45 #else 46 47 /* C doesn't allow empty structures, bah! */ 48 struct sja1105_tas_data { 49 u8 dummy; 50 }; 51 52 static inline int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port, 53 struct tc_taprio_qopt_offload *admin) 54 { 55 return -EOPNOTSUPP; 56 } 57 58 static inline void sja1105_tas_setup(struct dsa_switch *ds) { } 59 60 static inline void sja1105_tas_teardown(struct dsa_switch *ds) { } 61 62 static inline void sja1105_tas_clockstep(struct dsa_switch *ds) { } 63 64 static inline void sja1105_tas_adjfreq(struct dsa_switch *ds) { } 65 66 #endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS) */ 67 68 #endif /* _SJA1105_TAS_H */ 69