sja1105_tas.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2019, Vladimir Oltean <[email protected]>
  3. */
  4. #ifndef _SJA1105_TAS_H
  5. #define _SJA1105_TAS_H
  6. #include <net/pkt_sched.h>
  7. #define SJA1105_TAS_MAX_DELTA BIT(18)
  8. struct sja1105_private;
  9. #if IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS)
  10. enum sja1105_tas_state {
  11. SJA1105_TAS_STATE_DISABLED,
  12. SJA1105_TAS_STATE_ENABLED_NOT_RUNNING,
  13. SJA1105_TAS_STATE_RUNNING,
  14. };
  15. enum sja1105_ptp_op {
  16. SJA1105_PTP_NONE,
  17. SJA1105_PTP_CLOCKSTEP,
  18. SJA1105_PTP_ADJUSTFREQ,
  19. };
  20. struct sja1105_gate_entry {
  21. struct list_head list;
  22. struct sja1105_rule *rule;
  23. s64 interval;
  24. u8 gate_state;
  25. };
  26. struct sja1105_gating_config {
  27. u64 cycle_time;
  28. s64 base_time;
  29. int num_entries;
  30. struct list_head entries;
  31. };
  32. struct sja1105_tas_data {
  33. struct tc_taprio_qopt_offload *offload[SJA1105_MAX_NUM_PORTS];
  34. struct sja1105_gating_config gating_cfg;
  35. enum sja1105_tas_state state;
  36. enum sja1105_ptp_op last_op;
  37. struct work_struct tas_work;
  38. s64 earliest_base_time;
  39. s64 oper_base_time;
  40. u64 max_cycle_time;
  41. bool enabled;
  42. };
  43. int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
  44. struct tc_taprio_qopt_offload *admin);
  45. void sja1105_tas_setup(struct dsa_switch *ds);
  46. void sja1105_tas_teardown(struct dsa_switch *ds);
  47. void sja1105_tas_clockstep(struct dsa_switch *ds);
  48. void sja1105_tas_adjfreq(struct dsa_switch *ds);
  49. bool sja1105_gating_check_conflicts(struct sja1105_private *priv, int port,
  50. struct netlink_ext_ack *extack);
  51. int sja1105_init_scheduling(struct sja1105_private *priv);
  52. #else
  53. /* C doesn't allow empty structures, bah! */
  54. struct sja1105_tas_data {
  55. u8 dummy;
  56. };
  57. static inline int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
  58. struct tc_taprio_qopt_offload *admin)
  59. {
  60. return -EOPNOTSUPP;
  61. }
  62. static inline void sja1105_tas_setup(struct dsa_switch *ds) { }
  63. static inline void sja1105_tas_teardown(struct dsa_switch *ds) { }
  64. static inline void sja1105_tas_clockstep(struct dsa_switch *ds) { }
  65. static inline void sja1105_tas_adjfreq(struct dsa_switch *ds) { }
  66. static inline bool
  67. sja1105_gating_check_conflicts(struct dsa_switch *ds, int port,
  68. struct netlink_ext_ack *extack)
  69. {
  70. return true;
  71. }
  72. static inline int sja1105_init_scheduling(struct sja1105_private *priv)
  73. {
  74. return 0;
  75. }
  76. #endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS) */
  77. #endif /* _SJA1105_TAS_H */