]> git.saurik.com Git - apple/xnu.git/blame - bsd/net/classq/classq_fq_codel.h
xnu-3789.51.2.tar.gz
[apple/xnu.git] / bsd / net / classq / classq_fq_codel.h
CommitLineData
39037602
A
1/*
2 * Copyright (c) 2016 Apple Inc. All rights reserved.
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
30#define _NET_CLASSQ_CLASSQ_FQ_CODEL_H
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
39extern "C" {
40#endif
41
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 { \
45 (_fq_)->fq_flags |= FQF_DELAY_HIGH; \
46} while (0)
47#define FQ_CLEAR_DELAY_HIGH(_fq_) do { \
48 (_fq_)->fq_flags &= ~FQF_DELAY_HIGH; \
49} while (0)
50
51typedef struct flowq {
52 MBUFQ_HEAD(pktq_head) fq_mbufq; /* Packet queue */
53#define FQF_FLOWCTL_CAPABLE 0x01 /* Use flow control instead of drop */
54#define FQF_DELAY_HIGH 0x02 /* Min delay is greater than target */
55#define FQF_NEW_FLOW 0x04 /* Currently on new flows queue */
56#define FQF_OLD_FLOW 0x08 /* Currently on old flows queue */
57#define FQF_FLOWCTL_ON 0x10 /* Currently flow controlled */
58 u_int8_t fq_flags; /* flags */
59 u_int8_t fq_sc_index; /* service_class index */
60 int16_t fq_deficit; /* Deficit for scheduling */
61 u_int32_t fq_bytes; /* Number of bytes in the queue */
62 u_int64_t fq_min_qdelay; /* min queue delay for Codel */
63 u_int64_t fq_updatetime; /* next update interval */
64 u_int64_t fq_getqtime; /* last dequeue time */
65 SLIST_ENTRY(flowq) fq_hashlink; /* for flow queue hash table */
66 STAILQ_ENTRY(flowq) fq_actlink; /* for new/old flow queues */
67 u_int32_t fq_flowhash; /* Flow hash */
68 u_int32_t fq_dequeue_seq; /* Last dequeue seq */
69} fq_t;
70
71struct fq_codel_sched_data;
72struct fq_if_classq;
73
74/* Function definitions */
75extern void fq_codel_init(void);
76extern fq_t *fq_alloc(int);
77extern void fq_destroy(fq_t *);
78extern int fq_addq(struct fq_codel_sched_data *, struct mbuf *,
79 struct fq_if_classq *);
80extern struct mbuf *fq_getq_flow(struct fq_codel_sched_data *, fq_t *);
81extern void fq_head_drop(struct fq_codel_sched_data *, fq_t *);
82
83#ifdef __cplusplus
84}
85#endif
86#endif /* BSD_KERNEL_PRIVATE */
87#endif /* PRIVATE */
88#endif /* _NET_CLASSQ_CLASSQ_FQ_CODEL_H */