1*768cf841SOleksij Rempel /* SPDX-License-Identifier: GPL-2.0 */
2*768cf841SOleksij Rempel /* Copyright (c) 2024 Pengutronix, Oleksij Rempel <kernel@pengutronix.de> */
3*768cf841SOleksij Rempel
4*768cf841SOleksij Rempel #ifndef _NET_IEEE8021Q_H
5*768cf841SOleksij Rempel #define _NET_IEEE8021Q_H
6*768cf841SOleksij Rempel
7*768cf841SOleksij Rempel #include <linux/errno.h>
8*768cf841SOleksij Rempel
9*768cf841SOleksij Rempel /**
10*768cf841SOleksij Rempel * enum ieee8021q_traffic_type - 802.1Q traffic type priority values (802.1Q-2022)
11*768cf841SOleksij Rempel *
12*768cf841SOleksij Rempel * @IEEE8021Q_TT_BK: Background
13*768cf841SOleksij Rempel * @IEEE8021Q_TT_BE: Best Effort (default). According to 802.1Q-2022, BE is 0
14*768cf841SOleksij Rempel * but has higher priority than BK which is 1.
15*768cf841SOleksij Rempel * @IEEE8021Q_TT_EE: Excellent Effort
16*768cf841SOleksij Rempel * @IEEE8021Q_TT_CA: Critical Applications
17*768cf841SOleksij Rempel * @IEEE8021Q_TT_VI: Video, < 100 ms latency and jitter
18*768cf841SOleksij Rempel * @IEEE8021Q_TT_VO: Voice, < 10 ms latency and jitter
19*768cf841SOleksij Rempel * @IEEE8021Q_TT_IC: Internetwork Control
20*768cf841SOleksij Rempel * @IEEE8021Q_TT_NC: Network Control
21*768cf841SOleksij Rempel */
22*768cf841SOleksij Rempel enum ieee8021q_traffic_type {
23*768cf841SOleksij Rempel IEEE8021Q_TT_BK = 0,
24*768cf841SOleksij Rempel IEEE8021Q_TT_BE = 1,
25*768cf841SOleksij Rempel IEEE8021Q_TT_EE = 2,
26*768cf841SOleksij Rempel IEEE8021Q_TT_CA = 3,
27*768cf841SOleksij Rempel IEEE8021Q_TT_VI = 4,
28*768cf841SOleksij Rempel IEEE8021Q_TT_VO = 5,
29*768cf841SOleksij Rempel IEEE8021Q_TT_IC = 6,
30*768cf841SOleksij Rempel IEEE8021Q_TT_NC = 7,
31*768cf841SOleksij Rempel
32*768cf841SOleksij Rempel /* private: */
33*768cf841SOleksij Rempel IEEE8021Q_TT_MAX,
34*768cf841SOleksij Rempel };
35*768cf841SOleksij Rempel
36*768cf841SOleksij Rempel #define SIMPLE_IETF_DSCP_TO_IEEE8021Q_TT(dscp) ((dscp >> 3) & 0x7)
37*768cf841SOleksij Rempel
38*768cf841SOleksij Rempel #if IS_ENABLED(CONFIG_NET_IEEE8021Q_HELPERS)
39*768cf841SOleksij Rempel
40*768cf841SOleksij Rempel int ietf_dscp_to_ieee8021q_tt(u8 dscp);
41*768cf841SOleksij Rempel int ieee8021q_tt_to_tc(enum ieee8021q_traffic_type tt, unsigned int num_queues);
42*768cf841SOleksij Rempel
43*768cf841SOleksij Rempel #else
44*768cf841SOleksij Rempel
ietf_dscp_to_ieee8021q_tt(u8 dscp)45*768cf841SOleksij Rempel static inline int ietf_dscp_to_ieee8021q_tt(u8 dscp)
46*768cf841SOleksij Rempel {
47*768cf841SOleksij Rempel return -EOPNOTSUPP;
48*768cf841SOleksij Rempel }
49*768cf841SOleksij Rempel
ieee8021q_tt_to_tc(enum ieee8021q_traffic_type tt,unsigned int num_queues)50*768cf841SOleksij Rempel static inline int ieee8021q_tt_to_tc(enum ieee8021q_traffic_type tt,
51*768cf841SOleksij Rempel unsigned int num_queues)
52*768cf841SOleksij Rempel {
53*768cf841SOleksij Rempel return -EOPNOTSUPP;
54*768cf841SOleksij Rempel }
55*768cf841SOleksij Rempel
56*768cf841SOleksij Rempel #endif
57*768cf841SOleksij Rempel #endif /* _NET_IEEE8021Q_H */
58