]>
Commit | Line | Data |
---|---|---|
39037602 | 1 | /* |
cb323159 | 2 | * Copyright (c) 2016-2018 Apple Inc. All rights reserved. |
39037602 A |
3 | * |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | ||
29 | #ifndef _NET_CLASSQ_CLASSQ_FQ_CODEL_H | |
0a7de745 | 30 | #define _NET_CLASSQ_CLASSQ_FQ_CODEL_H |
39037602 A |
31 | #ifdef PRIVATE |
32 | #ifdef BSD_KERNEL_PRIVATE | |
33 | #include <stdbool.h> | |
34 | #include <sys/time.h> | |
35 | #include <net/flowadv.h> | |
36 | #include <net/classq/if_classq.h> | |
37 | ||
38 | #ifdef __cplusplus | |
39 | extern "C" { | |
40 | #endif | |
41 | ||
0a7de745 A |
42 | #define FQ_MIN_FC_THRESHOLD_BYTES 7500 |
43 | #define FQ_IS_DELAYHIGH(_fq_) ((_fq_)->fq_flags & FQF_DELAY_HIGH) | |
44 | #define FQ_SET_DELAY_HIGH(_fq_) do { \ | |
39037602 A |
45 | (_fq_)->fq_flags |= FQF_DELAY_HIGH; \ |
46 | } while (0) | |
0a7de745 | 47 | #define FQ_CLEAR_DELAY_HIGH(_fq_) do { \ |
39037602 A |
48 | (_fq_)->fq_flags &= ~FQF_DELAY_HIGH; \ |
49 | } while (0) | |
50 | ||
51 | typedef struct flowq { | |
5ba3f43e A |
52 | union { |
53 | MBUFQ_HEAD(mbufq_head) __mbufq; /* mbuf packet queue */ | |
54 | } __fq_pktq_u; | |
0a7de745 A |
55 | #define FQF_FLOWCTL_CAPABLE 0x01 /* Use flow control instead of drop */ |
56 | #define FQF_DELAY_HIGH 0x02 /* Min delay is greater than target */ | |
57 | #define FQF_NEW_FLOW 0x04 /* Currently on new flows queue */ | |
58 | #define FQF_OLD_FLOW 0x08 /* Currently on old flows queue */ | |
59 | #define FQF_FLOWCTL_ON 0x10 /* Currently flow controlled */ | |
60 | u_int8_t fq_flags; /* flags */ | |
61 | u_int8_t fq_sc_index; /* service_class index */ | |
62 | int16_t fq_deficit; /* Deficit for scheduling */ | |
63 | u_int32_t fq_bytes; /* Number of bytes in the queue */ | |
64 | u_int64_t fq_min_qdelay; /* min queue delay for Codel */ | |
65 | u_int64_t fq_updatetime; /* next update interval */ | |
66 | u_int64_t fq_getqtime; /* last dequeue time */ | |
39037602 A |
67 | SLIST_ENTRY(flowq) fq_hashlink; /* for flow queue hash table */ |
68 | STAILQ_ENTRY(flowq) fq_actlink; /* for new/old flow queues */ | |
0a7de745 A |
69 | u_int32_t fq_flowhash; /* Flow hash */ |
70 | classq_pkt_type_t fq_ptype; /* Packet type */ | |
39037602 A |
71 | } fq_t; |
72 | ||
0a7de745 | 73 | #define fq_mbufq __fq_pktq_u.__mbufq |
5ba3f43e | 74 | |
0a7de745 | 75 | #define fq_empty(_q) MBUFQ_EMPTY(&(_q)->fq_mbufq) |
5ba3f43e | 76 | |
cb323159 | 77 | #define fq_enqueue(_q, _p) MBUFQ_ENQUEUE(&(_q)->fq_mbufq, _p.cp_mbuf) |
5ba3f43e | 78 | |
0a7de745 | 79 | #define fq_dequeue(_q, _p) do { \ |
cb323159 A |
80 | MBUFQ_DEQUEUE(&(_q)->fq_mbufq, (_p)->cp_mbuf); \ |
81 | if (__probable((_p)->cp_mbuf != NULL)) { \ | |
82 | CLASSQ_PKT_INIT_MBUF((_p), (_p)->cp_mbuf); \ | |
83 | } \ | |
5ba3f43e A |
84 | } while (0) |
85 | ||
39037602 A |
86 | struct fq_codel_sched_data; |
87 | struct fq_if_classq; | |
88 | ||
89 | /* Function definitions */ | |
90 | extern void fq_codel_init(void); | |
a39ff7e2 | 91 | extern void fq_codel_reap_caches(boolean_t); |
5ba3f43e | 92 | extern fq_t *fq_alloc(classq_pkt_type_t); |
39037602 | 93 | extern void fq_destroy(fq_t *); |
5ba3f43e | 94 | extern int fq_addq(struct fq_codel_sched_data *, pktsched_pkt_t *, |
39037602 | 95 | struct fq_if_classq *); |
cb323159 | 96 | extern void fq_getq_flow(struct fq_codel_sched_data *, fq_t *, |
5ba3f43e | 97 | pktsched_pkt_t *); |
cb323159 | 98 | extern void fq_getq_flow_internal(struct fq_codel_sched_data *, |
5ba3f43e | 99 | fq_t *, pktsched_pkt_t *); |
39037602 A |
100 | extern void fq_head_drop(struct fq_codel_sched_data *, fq_t *); |
101 | ||
102 | #ifdef __cplusplus | |
103 | } | |
104 | #endif | |
105 | #endif /* BSD_KERNEL_PRIVATE */ | |
106 | #endif /* PRIVATE */ | |
107 | #endif /* _NET_CLASSQ_CLASSQ_FQ_CODEL_H */ |