Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (c) 2019, Vladimir Oltean <olteanv@gmail.com>
0003  */
0004 #ifndef _SJA1105_TAS_H
0005 #define _SJA1105_TAS_H
0006 
0007 #include <net/pkt_sched.h>
0008 
0009 #define SJA1105_TAS_MAX_DELTA       BIT(18)
0010 
0011 struct sja1105_private;
0012 
0013 #if IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS)
0014 
0015 enum sja1105_tas_state {
0016     SJA1105_TAS_STATE_DISABLED,
0017     SJA1105_TAS_STATE_ENABLED_NOT_RUNNING,
0018     SJA1105_TAS_STATE_RUNNING,
0019 };
0020 
0021 enum sja1105_ptp_op {
0022     SJA1105_PTP_NONE,
0023     SJA1105_PTP_CLOCKSTEP,
0024     SJA1105_PTP_ADJUSTFREQ,
0025 };
0026 
0027 struct sja1105_gate_entry {
0028     struct list_head list;
0029     struct sja1105_rule *rule;
0030     s64 interval;
0031     u8 gate_state;
0032 };
0033 
0034 struct sja1105_gating_config {
0035     u64 cycle_time;
0036     s64 base_time;
0037     int num_entries;
0038     struct list_head entries;
0039 };
0040 
0041 struct sja1105_tas_data {
0042     struct tc_taprio_qopt_offload *offload[SJA1105_MAX_NUM_PORTS];
0043     struct sja1105_gating_config gating_cfg;
0044     enum sja1105_tas_state state;
0045     enum sja1105_ptp_op last_op;
0046     struct work_struct tas_work;
0047     s64 earliest_base_time;
0048     s64 oper_base_time;
0049     u64 max_cycle_time;
0050     bool enabled;
0051 };
0052 
0053 int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
0054                 struct tc_taprio_qopt_offload *admin);
0055 
0056 void sja1105_tas_setup(struct dsa_switch *ds);
0057 
0058 void sja1105_tas_teardown(struct dsa_switch *ds);
0059 
0060 void sja1105_tas_clockstep(struct dsa_switch *ds);
0061 
0062 void sja1105_tas_adjfreq(struct dsa_switch *ds);
0063 
0064 bool sja1105_gating_check_conflicts(struct sja1105_private *priv, int port,
0065                     struct netlink_ext_ack *extack);
0066 
0067 int sja1105_init_scheduling(struct sja1105_private *priv);
0068 
0069 #else
0070 
0071 /* C doesn't allow empty structures, bah! */
0072 struct sja1105_tas_data {
0073     u8 dummy;
0074 };
0075 
0076 static inline int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
0077                       struct tc_taprio_qopt_offload *admin)
0078 {
0079     return -EOPNOTSUPP;
0080 }
0081 
0082 static inline void sja1105_tas_setup(struct dsa_switch *ds) { }
0083 
0084 static inline void sja1105_tas_teardown(struct dsa_switch *ds) { }
0085 
0086 static inline void sja1105_tas_clockstep(struct dsa_switch *ds) { }
0087 
0088 static inline void sja1105_tas_adjfreq(struct dsa_switch *ds) { }
0089 
0090 static inline bool
0091 sja1105_gating_check_conflicts(struct dsa_switch *ds, int port,
0092                    struct netlink_ext_ack *extack)
0093 {
0094     return true;
0095 }
0096 
0097 static inline int sja1105_init_scheduling(struct sja1105_private *priv)
0098 {
0099     return 0;
0100 }
0101 
0102 #endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS) */
0103 
0104 #endif /* _SJA1105_TAS_H */