1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2019, Vladimir Oltean <olteanv@gmail.com>
7 #include <net/pkt_sched.h>
9 #define SJA1105_TAS_MAX_DELTA BIT(18)
11 struct sja1105_private
;
13 #if IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS)
15 enum sja1105_tas_state
{
16 SJA1105_TAS_STATE_DISABLED
,
17 SJA1105_TAS_STATE_ENABLED_NOT_RUNNING
,
18 SJA1105_TAS_STATE_RUNNING
,
23 SJA1105_PTP_CLOCKSTEP
,
24 SJA1105_PTP_ADJUSTFREQ
,
27 struct sja1105_gate_entry
{
28 struct list_head list
;
29 struct sja1105_rule
*rule
;
34 struct sja1105_gating_config
{
38 struct list_head entries
;
41 struct sja1105_tas_data
{
42 struct tc_taprio_qopt_offload
*offload
[SJA1105_MAX_NUM_PORTS
];
43 struct sja1105_gating_config gating_cfg
;
44 enum sja1105_tas_state state
;
45 enum sja1105_ptp_op last_op
;
46 struct work_struct tas_work
;
47 s64 earliest_base_time
;
53 int sja1105_setup_tc_taprio(struct dsa_switch
*ds
, int port
,
54 struct tc_taprio_qopt_offload
*admin
);
56 void sja1105_tas_setup(struct dsa_switch
*ds
);
58 void sja1105_tas_teardown(struct dsa_switch
*ds
);
60 void sja1105_tas_clockstep(struct dsa_switch
*ds
);
62 void sja1105_tas_adjfreq(struct dsa_switch
*ds
);
64 bool sja1105_gating_check_conflicts(struct sja1105_private
*priv
, int port
,
65 struct netlink_ext_ack
*extack
);
67 int sja1105_init_scheduling(struct sja1105_private
*priv
);
71 /* C doesn't allow empty structures, bah! */
72 struct sja1105_tas_data
{
76 static inline int sja1105_setup_tc_taprio(struct dsa_switch
*ds
, int port
,
77 struct tc_taprio_qopt_offload
*admin
)
82 static inline void sja1105_tas_setup(struct dsa_switch
*ds
) { }
84 static inline void sja1105_tas_teardown(struct dsa_switch
*ds
) { }
86 static inline void sja1105_tas_clockstep(struct dsa_switch
*ds
) { }
88 static inline void sja1105_tas_adjfreq(struct dsa_switch
*ds
) { }
91 sja1105_gating_check_conflicts(struct dsa_switch
*ds
, int port
,
92 struct netlink_ext_ack
*extack
)
97 static inline int sja1105_init_scheduling(struct sja1105_private
*priv
)
102 #endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS) */
104 #endif /* _SJA1105_TAS_H */