cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

sja1105_tas.h (2351B)


      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#define SJA1105_TAS_MAX_DELTA		BIT(18)
     10
     11struct sja1105_private;
     12
     13#if IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS)
     14
     15enum sja1105_tas_state {
     16	SJA1105_TAS_STATE_DISABLED,
     17	SJA1105_TAS_STATE_ENABLED_NOT_RUNNING,
     18	SJA1105_TAS_STATE_RUNNING,
     19};
     20
     21enum sja1105_ptp_op {
     22	SJA1105_PTP_NONE,
     23	SJA1105_PTP_CLOCKSTEP,
     24	SJA1105_PTP_ADJUSTFREQ,
     25};
     26
     27struct sja1105_gate_entry {
     28	struct list_head list;
     29	struct sja1105_rule *rule;
     30	s64 interval;
     31	u8 gate_state;
     32};
     33
     34struct sja1105_gating_config {
     35	u64 cycle_time;
     36	s64 base_time;
     37	int num_entries;
     38	struct list_head entries;
     39};
     40
     41struct 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;
     48	s64 oper_base_time;
     49	u64 max_cycle_time;
     50	bool enabled;
     51};
     52
     53int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
     54			    struct tc_taprio_qopt_offload *admin);
     55
     56void sja1105_tas_setup(struct dsa_switch *ds);
     57
     58void sja1105_tas_teardown(struct dsa_switch *ds);
     59
     60void sja1105_tas_clockstep(struct dsa_switch *ds);
     61
     62void sja1105_tas_adjfreq(struct dsa_switch *ds);
     63
     64bool sja1105_gating_check_conflicts(struct sja1105_private *priv, int port,
     65				    struct netlink_ext_ack *extack);
     66
     67int sja1105_init_scheduling(struct sja1105_private *priv);
     68
     69#else
     70
     71/* C doesn't allow empty structures, bah! */
     72struct sja1105_tas_data {
     73	u8 dummy;
     74};
     75
     76static inline int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
     77					  struct tc_taprio_qopt_offload *admin)
     78{
     79	return -EOPNOTSUPP;
     80}
     81
     82static inline void sja1105_tas_setup(struct dsa_switch *ds) { }
     83
     84static inline void sja1105_tas_teardown(struct dsa_switch *ds) { }
     85
     86static inline void sja1105_tas_clockstep(struct dsa_switch *ds) { }
     87
     88static inline void sja1105_tas_adjfreq(struct dsa_switch *ds) { }
     89
     90static inline bool
     91sja1105_gating_check_conflicts(struct dsa_switch *ds, int port,
     92			       struct netlink_ext_ack *extack)
     93{
     94	return true;
     95}
     96
     97static inline int sja1105_init_scheduling(struct sja1105_private *priv)
     98{
     99	return 0;
    100}
    101
    102#endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS) */
    103
    104#endif /* _SJA1105_TAS_H */