]>
git.saurik.com Git - apple/xnu.git/blob - bsd/net/pktsched/pktsched_tcq.h
2 * Copyright (c) 2011-2016 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _NET_PKTSCHED_PKTSCHED_TCQ_H_
30 #define _NET_PKTSCHED_PKTSCHED_TCQ_H_
33 #include <net/pktsched/pktsched.h>
34 #include <net/classq/classq.h>
35 #include <net/classq/classq_red.h>
36 #include <net/classq/classq_rio.h>
37 #include <net/classq/classq_blue.h>
38 #include <net/classq/classq_sfb.h>
44 #define TCQ_MAXPRI 4 /* upper limit of the number of priorities */
47 #define TQCF_RED 0x0001 /* use RED */
48 #define TQCF_ECN 0x0002 /* use ECN with RED/BLUE/SFB */
49 #define TQCF_RIO 0x0004 /* use RIO */
50 #define TQCF_CLEARDSCP 0x0010 /* clear diffserv codepoint */
51 #define TQCF_BLUE 0x0100 /* use BLUE */
52 #define TQCF_SFB 0x0200 /* use SFB */
53 #define TQCF_FLOWCTL 0x0400 /* enable flow control advisories */
54 #define TQCF_DEFAULTCLASS 0x1000 /* default class */
55 #define TQCF_DELAYBASED 0x2000 /* queue sizing is delay based */
56 #ifdef BSD_KERNEL_PRIVATE
57 #define TQCF_LAZY 0x10000000 /* on-demand resource allocation */
58 #endif /* BSD_KERNEL_PRIVATE */
60 #define TQCF_USERFLAGS \
61 (TQCF_RED | TQCF_ECN | TQCF_RIO | TQCF_CLEARDSCP | TQCF_BLUE | \
62 TQCF_SFB | TQCF_FLOWCTL | TQCF_DEFAULTCLASS)
64 #ifdef BSD_KERNEL_PRIVATE
66 "\020\1RED\2ECN\3RIO\5CLEARDSCP\11BLUE\12SFB\13FLOWCTL\15DEFAULT" \
70 "\020\1RED\2ECN\3RIO\5CLEARDSCP\11BLUE\12SFB\13FLOWCTL"
71 #endif /* !BSD_KERNEL_PRIVATE */
73 struct tcq_classstats
{
74 u_int32_t class_handle
;
80 struct pktcntr xmitcnt
; /* transmitted packet counter */
81 struct pktcntr dropcnt
; /* dropped packet counter */
83 /* RED, RIO, BLUE, SFB related info */
86 /* RIO has 3 red stats */
87 struct red_stats red
[RIO_NDROPPREC
];
88 struct blue_stats blue
;
91 classq_state_t qstate
;
94 #ifdef BSD_KERNEL_PRIVATE
96 u_int32_t cl_handle
; /* class handle */
97 class_queue_t cl_q
; /* class queue structure */
98 u_int32_t cl_qflags
; /* class queue flags */
101 struct sfb
*sfb
; /* SFB state */
103 int32_t cl_pri
; /* priority */
104 u_int32_t cl_flags
; /* class flags */
105 struct tcq_if
*cl_tif
; /* back pointer to tif */
108 u_int32_t cl_period
; /* backlog period */
109 struct pktcntr cl_xmitcnt
; /* transmitted packet counter */
110 struct pktcntr cl_dropcnt
; /* dropped packet counter */
113 #define cl_sfb cl_qalg.sfb
116 * tcq interface state
119 struct ifclassq
*tif_ifq
; /* backpointer to ifclassq */
120 int tif_maxpri
; /* max priority in use */
121 u_int32_t tif_throttle
; /* throttling level */
122 struct tcq_class
*tif_default
; /* default class */
123 struct tcq_class
*tif_classes
[TCQ_MAXPRI
]; /* classes */
126 #define TCQIF_IFP(_tif) ((_tif)->tif_ifq->ifcq_ifp)
128 struct if_ifclassq_stats
;
130 extern void tcq_init(void);
131 extern struct tcq_if
*tcq_alloc(struct ifnet
*, int);
132 extern int tcq_destroy(struct tcq_if
*);
133 extern void tcq_purge(struct tcq_if
*);
134 extern void tcq_event(struct tcq_if
*, cqev_t
);
135 extern int tcq_add_queue(struct tcq_if
*, int, u_int32_t
, int, u_int32_t
,
136 struct tcq_class
**, classq_pkt_type_t
);
137 extern int tcq_remove_queue(struct tcq_if
*, u_int32_t
);
138 extern int tcq_get_class_stats(struct tcq_if
*, u_int32_t
,
139 struct tcq_classstats
*);
140 extern int tcq_enqueue(struct tcq_if
*, struct tcq_class
*, pktsched_pkt_t
*,
142 extern void tcq_dequeue_tc(struct tcq_if
*, mbuf_svc_class_t
, pktsched_pkt_t
*);
143 extern int tcq_setup_ifclassq(struct ifclassq
*, u_int32_t
, classq_pkt_type_t
);
144 extern int tcq_teardown_ifclassq(struct ifclassq
*ifq
);
145 extern int tcq_getqstats_ifclassq(struct ifclassq
*, u_int32_t qid
,
146 struct if_ifclassq_stats
*);
147 #endif /* BSD_KERNEL_PRIVATE */
152 #endif /* _NET_PKTSCHED_PKTSCHED_TCQ_H_ */