]>
git.saurik.com Git - apple/xnu.git/blob - bsd/net/pktsched/pktsched_tcq.h
2 * Copyright (c) 2011-2012 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 #ifdef BSD_KERNEL_PRIVATE
56 #define TQCF_LAZY 0x10000000 /* on-demand resource allocation */
57 #endif /* BSD_KERNEL_PRIVATE */
59 #define TQCF_USERFLAGS \
60 (TQCF_RED | TQCF_ECN | TQCF_RIO | TQCF_CLEARDSCP | TQCF_BLUE | \
61 TQCF_SFB | TQCF_FLOWCTL | TQCF_DEFAULTCLASS)
63 #ifdef BSD_KERNEL_PRIVATE
65 "\020\1RED\2ECN\3RIO\5CLEARDSCP\11BLUE\12SFB\13FLOWCTL\15DEFAULT" \
69 "\020\1RED\2ECN\3RIO\5CLEARDSCP\11BLUE\12SFB\13FLOWCTL"
70 #endif /* !BSD_KERNEL_PRIVATE */
72 struct tcq_classstats
{
73 u_int32_t class_handle
;
79 struct pktcntr xmitcnt
; /* transmitted packet counter */
80 struct pktcntr dropcnt
; /* dropped packet counter */
82 /* RED, RIO, BLUE, SFB related info */
85 /* RIO has 3 red stats */
86 struct red_stats red
[RIO_NDROPPREC
];
87 struct blue_stats blue
;
90 classq_state_t qstate
;
93 #ifdef BSD_KERNEL_PRIVATE
95 u_int32_t cl_handle
; /* class handle */
96 class_queue_t cl_q
; /* class queue structure */
97 u_int32_t cl_qflags
; /* class queue flags */
100 struct red
*red
; /* RED state */
101 struct rio
*rio
; /* RIO state */
102 struct blue
*blue
; /* BLUE state */
103 struct sfb
*sfb
; /* SFB state */
105 int32_t cl_pri
; /* priority */
106 u_int32_t cl_flags
; /* class flags */
107 struct tcq_if
*cl_tif
; /* back pointer to tif */
110 u_int32_t cl_period
; /* backlog period */
111 struct pktcntr cl_xmitcnt
; /* transmitted packet counter */
112 struct pktcntr cl_dropcnt
; /* dropped packet counter */
115 #define cl_red cl_qalg.red
116 #define cl_rio cl_qalg.rio
117 #define cl_blue cl_qalg.blue
118 #define cl_sfb cl_qalg.sfb
121 #define TCQIFF_ALTQ 0x1 /* configured via PF/ALTQ */
124 * tcq interface state
127 struct ifclassq
*tif_ifq
; /* backpointer to ifclassq */
128 int tif_maxpri
; /* max priority in use */
129 u_int32_t tif_flags
; /* flags */
130 u_int32_t tif_throttle
; /* throttling level */
131 struct tcq_class
*tif_default
; /* default class */
132 struct tcq_class
*tif_classes
[TCQ_MAXPRI
]; /* classes */
135 #define TCQIF_IFP(_tif) ((_tif)->tif_ifq->ifcq_ifp)
137 struct if_ifclassq_stats
;
139 extern void tcq_init(void);
140 extern struct tcq_if
*tcq_alloc(struct ifnet
*, int, boolean_t
);
141 extern int tcq_destroy(struct tcq_if
*);
142 extern void tcq_purge(struct tcq_if
*);
143 extern void tcq_event(struct tcq_if
*, cqev_t
);
144 extern int tcq_add_queue(struct tcq_if
*, int, u_int32_t
, int, u_int32_t
,
145 struct tcq_class
**);
146 extern int tcq_remove_queue(struct tcq_if
*, u_int32_t
);
147 extern int tcq_get_class_stats(struct tcq_if
*, u_int32_t
,
148 struct tcq_classstats
*);
149 extern int tcq_enqueue(struct tcq_if
*, struct tcq_class
*, struct mbuf
*,
151 extern struct mbuf
*tcq_dequeue_tc(struct tcq_if
*, mbuf_svc_class_t
,
153 extern int tcq_setup_ifclassq(struct ifclassq
*, u_int32_t
);
154 extern int tcq_teardown_ifclassq(struct ifclassq
*ifq
);
155 extern int tcq_getqstats_ifclassq(struct ifclassq
*, u_int32_t qid
,
156 struct if_ifclassq_stats
*);
157 #endif /* BSD_KERNEL_PRIVATE */
162 #endif /* _NET_PKTSCHED_PKTSCHED_TCQ_H_ */