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