summaryrefslogtreecommitdiff
path: root/drivers/net/dsa/sja1105/sja1105_tas.h
blob: b226c3dfd5b16822ae862b7f97b22295987c94e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2019, Vladimir Oltean <olteanv@gmail.com>
 */
#ifndef _SJA1105_TAS_H
#define _SJA1105_TAS_H

#include <net/pkt_sched.h>

#if IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS)

enum sja1105_tas_state {
	SJA1105_TAS_STATE_DISABLED,
	SJA1105_TAS_STATE_ENABLED_NOT_RUNNING,
	SJA1105_TAS_STATE_RUNNING,
};

enum sja1105_ptp_op {
	SJA1105_PTP_NONE,
	SJA1105_PTP_CLOCKSTEP,
	SJA1105_PTP_ADJUSTFREQ,
};

struct sja1105_tas_data {
	struct tc_taprio_qopt_offload *offload[SJA1105_NUM_PORTS];
	enum sja1105_tas_state state;
	enum sja1105_ptp_op last_op;
	struct work_struct tas_work;
	s64 earliest_base_time;
	s64 oper_base_time;
	u64 max_cycle_time;
	bool enabled;
};

int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
			    struct tc_taprio_qopt_offload *admin);

void sja1105_tas_setup(struct dsa_switch *ds);

void sja1105_tas_teardown(struct dsa_switch *ds);

void sja1105_tas_clockstep(struct dsa_switch *ds);

void sja1105_tas_adjfreq(struct dsa_switch *ds);

#else

/* C doesn't allow empty structures, bah! */
struct sja1105_tas_data {
	u8 dummy;
};

static inline int sja1105_setup_tc_taprio(struct dsa_switch *ds, int port,
					  struct tc_taprio_qopt_offload *admin)
{
	return -EOPNOTSUPP;
}

static inline void sja1105_tas_setup(struct dsa_switch *ds) { }

static inline void sja1105_tas_teardown(struct dsa_switch *ds) { }

static inline void sja1105_tas_clockstep(struct dsa_switch *ds) { }

static inline void sja1105_tas_adjfreq(struct dsa_switch *ds) { }

#endif /* IS_ENABLED(CONFIG_NET_DSA_SJA1105_TAS) */

#endif /* _SJA1105_TAS_H */