bpf: refactor code to support explicit opt-in for bulk+prio detection
[project/qosify.git] / qosify-bpf.h
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright (C) 2021 Felix Fietkau <nbd@nbd.name>
4 */
5 #ifndef __BPF_QOSIFY_H
6 #define __BPF_QOSIFY_H
7
8 #ifndef QOSIFY_FLOW_BUCKET_SHIFT
9 #define QOSIFY_FLOW_BUCKET_SHIFT 13
10 #endif
11
12 #define QOSIFY_FLOW_BUCKETS (1 << QOSIFY_FLOW_BUCKET_SHIFT)
13
14 /* rodata per-instance flags */
15 #define QOSIFY_INGRESS (1 << 0)
16 #define QOSIFY_IP_ONLY (1 << 1)
17
18 #define QOSIFY_DSCP_FALLBACK_FLAG (1 << 6)
19
20 #define QOSIFY_VAL_FLAG_PRIO_CHECK (1 << 0)
21 #define QOSIFY_VAL_FLAG_BULK_CHECK (1 << 1)
22
23 struct qosify_dscp_val {
24 uint8_t ingress;
25 uint8_t egress;
26 uint8_t flags;
27 } __attribute__((packed));
28
29 /* global config data */
30 struct qosify_config {
31 struct qosify_dscp_val dscp_prio;
32 struct qosify_dscp_val dscp_bulk;
33 struct qosify_dscp_val dscp_icmp;
34
35 uint8_t bulk_trigger_timeout;
36 uint16_t bulk_trigger_pps;
37
38 uint16_t prio_max_avg_pkt_len;
39 };
40
41 struct qosify_ip_map_val {
42 struct qosify_dscp_val dscp; /* must be first */
43 uint8_t seen;
44 };
45
46 #endif