Home | History | Annotate | Line # | Download | only in altq
altq_cbq.h revision 1.1.1.1
      1 /*	$KAME: altq_cbq.h,v 1.5 2000/12/02 13:44:40 kjc Exp $	*/
      2 
      3 /*
      4  * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  *
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  *
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  *
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *      This product includes software developed by the SMCC Technology
     20  *      Development Group at Sun Microsystems, Inc.
     21  *
     22  * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or
     23  *      promote products derived from this software without specific prior
     24  *      written permission.
     25  *
     26  * SUN MICROSYSTEMS DOES NOT CLAIM MERCHANTABILITY OF THIS SOFTWARE OR THE
     27  * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software is
     28  * provided "as is" without express or implied warranty of any kind.
     29  *
     30  * These notices must be retained in any copies of any part of this software.
     31  */
     32 
     33 #ifndef _ALTQ_ALTQ_CBQ_H_
     34 #define	_ALTQ_ALTQ_CBQ_H_
     35 
     36 #include <sys/ioccom.h>
     37 #include <altq/altq.h>
     38 #include <altq/altq_rmclass.h>
     39 #include <altq/altq_red.h>
     40 #include <altq/altq_rio.h>
     41 
     42 /* #pragma ident "@(#)cbq.h  1.18     98/05/13 SMI" */
     43 
     44 #ifdef __cplusplus
     45 extern "C" {
     46 #endif
     47 
     48 /*
     49  * Define a well known class handles
     50  */
     51 #define	NULL_CLASS_HANDLE	0xffffffff
     52 #define	ROOT_CLASS_HANDLE	0xfffffffe
     53 #define	DEFAULT_CLASS_HANDLE	0xfffffffd
     54 #define	CTL_CLASS_HANDLE	0xfffffffc
     55 
     56 /*
     57  * Define structures associated with IOCTLS for cbq.
     58  */
     59 
     60 /*
     61  * Define the CBQ interface structure.  This must be included in all
     62  * IOCTL's such that the CBQ driver may find the appropriate CBQ module
     63  * associated with the network interface to be affected.
     64  */
     65 struct cbq_interface {
     66 	char	cbq_ifacename[IFNAMSIZ];
     67 };
     68 
     69 typedef struct cbq_class_spec {
     70 	u_int		priority;
     71 	u_int		nano_sec_per_byte;
     72 	u_int		maxq;
     73 	u_int		maxidle;
     74 	int		minidle;
     75 	u_int		offtime;
     76 	u_long		parent_class_handle;
     77 	u_long		borrow_class_handle;
     78 
     79 	u_int		pktsize;
     80 	int		flags;
     81 } cbq_class_spec_t;
     82 
     83 /* class flags shoud be same as class flags in rm_class.h */
     84 #define	CBQCLF_RED		0x0001	/* use RED */
     85 #define	CBQCLF_ECN		0x0002  /* use RED/ECN */
     86 #define	CBQCLF_RIO		0x0004  /* use RIO */
     87 #define	CBQCLF_FLOWVALVE	0x0008	/* use flowvalve (aka penalty-box) */
     88 #define	CBQCLF_CLEARDSCP	0x0010  /* clear diffserv codepoint */
     89 
     90 /* class flags only for root class */
     91 #define	CBQCLF_WRR		0x0100	/* weighted-round robin */
     92 #define	CBQCLF_EFFICIENT	0x0200  /* work-conserving */
     93 
     94 /* class flags for special classes */
     95 #define	CBQCLF_ROOTCLASS	0x1000	/* root class */
     96 #define	CBQCLF_DEFCLASS		0x2000	/* default class */
     97 #define	CBQCLF_CTLCLASS		0x4000	/* control class */
     98 #define	CBQCLF_CLASSMASK	0xf000	/* class mask */
     99 
    100 #define	CBQ_MAXQSIZE	200
    101 
    102 struct cbq_add_class {
    103 	struct cbq_interface	cbq_iface;
    104 
    105 	cbq_class_spec_t	cbq_class;
    106 	u_long			cbq_class_handle;
    107 };
    108 
    109 struct cbq_delete_class {
    110 	struct cbq_interface	cbq_iface;
    111 	u_long			cbq_class_handle;
    112 };
    113 
    114 struct cbq_modify_class {
    115 	struct cbq_interface	cbq_iface;
    116 
    117 	cbq_class_spec_t	cbq_class;
    118 	u_long			cbq_class_handle;
    119 };
    120 
    121 struct cbq_add_filter {
    122 	struct cbq_interface		cbq_iface;
    123 	u_long			cbq_class_handle;
    124 	struct flow_filter	cbq_filter;
    125 
    126 	u_long			cbq_filter_handle;
    127 };
    128 
    129 struct cbq_delete_filter {
    130 	struct cbq_interface	cbq_iface;
    131 	u_long			cbq_filter_handle;
    132 };
    133 
    134 typedef struct _cbq_class_stats_ {
    135 	u_int		handle;
    136 	u_int		depth;
    137 
    138 	struct pktcntr	xmit_cnt;	/* packets sent in this class */
    139 	struct pktcntr	drop_cnt;	/* dropped packets */
    140 	u_int		over;		/* # times went over limit */
    141 	u_int		borrows;	/* # times tried to borrow */
    142 	u_int		overactions;	/* # times invoked overlimit action */
    143 	u_int		delays;		/* # times invoked delay actions */
    144 
    145 	/* other static class parameters useful for debugging */
    146 	int		priority;
    147 	int		maxidle;
    148 	int		minidle;
    149 	int		offtime;
    150 	int		qmax;
    151 	int		ns_per_byte;
    152 	int		wrr_allot;
    153 
    154 	int		qcnt;		/* # packets in queue */
    155 	int		avgidle;
    156 
    157 	/* red and rio related info */
    158 	int		qtype;
    159 	struct redstats	red[3];
    160 } class_stats_t;
    161 
    162 /* number of classes are returned in nclasses field */
    163 struct cbq_getstats {
    164 	struct cbq_interface	iface;
    165 	int			nclasses;
    166 	class_stats_t		*stats;
    167 };
    168 
    169 /*
    170  * Define IOCTLs for CBQ.
    171  */
    172 #define	CBQ_IF_ATTACH		_IOW('Q', 1, struct cbq_interface)
    173 #define	CBQ_IF_DETACH		_IOW('Q', 2, struct cbq_interface)
    174 #define	CBQ_ENABLE		_IOW('Q', 3, struct cbq_interface)
    175 #define	CBQ_DISABLE		_IOW('Q', 4, struct cbq_interface)
    176 #define	CBQ_CLEAR_HIERARCHY	_IOW('Q', 5, struct cbq_interface)
    177 #define	CBQ_ADD_CLASS		_IOWR('Q', 7, struct cbq_add_class)
    178 #define	CBQ_DEL_CLASS		_IOW('Q', 8, struct cbq_delete_class)
    179 #define	CBQ_MODIFY_CLASS	_IOWR('Q', 9, struct cbq_modify_class)
    180 #define	CBQ_ADD_FILTER		_IOWR('Q', 10, struct cbq_add_filter)
    181 #define	CBQ_DEL_FILTER		_IOW('Q', 11, struct cbq_delete_filter)
    182 #define	CBQ_GETSTATS		_IOWR('Q', 12, struct cbq_getstats)
    183 
    184 #ifdef _KERNEL
    185 /*
    186  * Define macros only good for kernel drivers and modules.
    187  */
    188 
    189 #define	DISABLE		0x00
    190 #define	ENABLE		0x01
    191 
    192 #define	CBQ_WATCHDOG    	(HZ / 20)
    193 #define	CBQ_TIMEOUT		10
    194 #define	CBQ_LS_TIMEOUT		(20 * hz / 1000)
    195 
    196 #define	CBQ_MAX_CLASSES	256
    197 #define	CBQ_MAX_FILTERS 256
    198 
    199 /*
    200  * Define State structures.
    201  */
    202 typedef struct cbqstate {
    203 	struct cbqstate		*cbq_next;
    204 	int			cbq_qlen;	/* # of packets in cbq */
    205 	struct rm_class		**cbq_class_tbl;
    206 
    207 	struct rm_ifdat		ifnp;
    208 	struct callout		cbq_callout;	/* for timeouts */
    209 
    210 	struct acc_classifier	cbq_classifier;
    211 } cbq_state_t;
    212 
    213 #endif /* _KERNEL */
    214 
    215 #ifdef __cplusplus
    216 }
    217 #endif
    218 
    219 #endif /* !_ALTQ_ALTQ_CBQ_H_ */
    220