]> git.proxmox.com Git - mirror_frr.git/blame - lib/tc.h
Merge pull request #13659 from donaldsharp/increase_mgmt_time
[mirror_frr.git] / lib / tc.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
c317d3f2
SY
2/*
3 * Traffic Control (TC) main header
4 * Copyright (C) 2022 Shichu Yang
c317d3f2
SY
5 */
6
7#ifndef _TC_H
8#define _TC_H
9
10#include <zebra.h>
11#include "stream.h"
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#define TC_STR "Traffic Control\n"
18
19/* qdisc definitions */
20
21/* qdisc kind (same as class kinds) */
22enum tc_qdisc_kind {
23 TC_QDISC_UNSPEC,
24 TC_QDISC_HTB,
25 TC_QDISC_NOQUEUE,
26};
27
28struct tc_qdisc_htb {
29 /* currently no members */
30};
31
32struct tc_qdisc {
33 ifindex_t ifindex;
34
35 enum tc_qdisc_kind kind;
36 union {
37 struct tc_qdisc_htb htb;
38 } u;
39};
40
41/* class definitions */
42
43/* since classes share the same kinds of qdisc, duplicates omitted */
44struct tc_class_htb {
45 uint64_t rate;
46 uint64_t ceil;
47};
48
49struct tc_class {
50 ifindex_t ifindex;
51 uint32_t handle;
52
53 enum tc_qdisc_kind kind;
54 union {
55 struct tc_class_htb htb;
56 } u;
57};
58
59/* filter definitions */
60
61/* filter kinds */
62enum tc_filter_kind {
63 TC_FILTER_UNSPEC,
64 TC_FILTER_BPF,
65 TC_FILTER_FLOW,
66 TC_FILTER_FLOWER,
67 TC_FILTER_U32,
68};
69
70struct tc_bpf {
71 /* TODO: fill in */
72};
73
74struct tc_flow {
75 /* TODO: fill in */
76};
77
78struct tc_flower {
79 uint32_t classid;
80
81#define TC_FLOWER_IP_PROTOCOL (1 << 0)
82#define TC_FLOWER_SRC_IP (1 << 1)
83#define TC_FLOWER_DST_IP (1 << 2)
84#define TC_FLOWER_SRC_PORT (1 << 3)
85#define TC_FLOWER_DST_PORT (1 << 4)
86#define TC_FLOWER_DSFIELD (1 << 5)
87
88 uint32_t filter_bm;
89
90 uint8_t ip_proto;
91
92 struct prefix src_ip;
93 struct prefix dst_ip;
94
95 uint16_t src_port_min;
96 uint16_t src_port_max;
97 uint16_t dst_port_min;
98 uint16_t dst_port_max;
99
100 uint8_t dsfield;
101 uint8_t dsfield_mask;
102};
103
104struct tc_u32 {
105 /* TODO: fill in */
106};
107
108struct tc_filter {
109 ifindex_t ifindex;
110 uint32_t handle;
111
112 uint32_t priority;
113 uint16_t protocol;
114
115 enum tc_filter_kind kind;
116
117 union {
118 struct tc_bpf bpf;
119 struct tc_flow flow;
120 struct tc_flower flower;
121 struct tc_u32 u32;
122 } u;
123};
124
125extern int tc_getrate(const char *str, uint64_t *rate);
126
127extern int zapi_tc_qdisc_encode(uint8_t cmd, struct stream *s,
128 struct tc_qdisc *qdisc);
129extern int zapi_tc_class_encode(uint8_t cmd, struct stream *s,
130 struct tc_class *class);
131extern int zapi_tc_filter_encode(uint8_t cmd, struct stream *s,
132 struct tc_filter *filter);
133
134#ifdef __cplusplus
135}
136#endif
137
138#endif /* _TC_H */