Home | History | Annotate | Line # | Download | only in altq
altq_cbq.h revision 1.7.22.1
      1  1.7.22.1     yamt /*	$NetBSD: altq_cbq.h,v 1.7.22.1 2006/10/22 06:04:30 yamt Exp $	*/
      2  1.7.22.1     yamt /*	$KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 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.6    perry  *
     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 <altq/altq.h>
     38       1.1  thorpej #include <altq/altq_rmclass.h>
     39       1.1  thorpej #include <altq/altq_red.h>
     40       1.1  thorpej #include <altq/altq_rio.h>
     41       1.1  thorpej 
     42       1.1  thorpej #ifdef __cplusplus
     43       1.1  thorpej extern "C" {
     44       1.6    perry #endif
     45       1.1  thorpej 
     46  1.7.22.1     yamt #define	NULL_CLASS_HANDLE	0
     47  1.7.22.1     yamt 
     48  1.7.22.1     yamt /* class flags should be same as class flags in rm_class.h */
     49  1.7.22.1     yamt #define	CBQCLF_RED		0x0001	/* use RED */
     50  1.7.22.1     yamt #define	CBQCLF_ECN		0x0002  /* use RED/ECN */
     51  1.7.22.1     yamt #define	CBQCLF_RIO		0x0004  /* use RIO */
     52  1.7.22.1     yamt #define	CBQCLF_FLOWVALVE	0x0008	/* use flowvalve (aka penalty-box) */
     53  1.7.22.1     yamt #define	CBQCLF_CLEARDSCP	0x0010  /* clear diffserv codepoint */
     54  1.7.22.1     yamt #define	CBQCLF_BORROW		0x0020  /* borrow from parent */
     55  1.7.22.1     yamt 
     56  1.7.22.1     yamt /* class flags only for root class */
     57  1.7.22.1     yamt #define	CBQCLF_WRR		0x0100	/* weighted-round robin */
     58  1.7.22.1     yamt #define	CBQCLF_EFFICIENT	0x0200  /* work-conserving */
     59       1.1  thorpej 
     60  1.7.22.1     yamt /* class flags for special classes */
     61  1.7.22.1     yamt #define	CBQCLF_ROOTCLASS	0x1000	/* root class */
     62  1.7.22.1     yamt #define	CBQCLF_DEFCLASS		0x2000	/* default class */
     63  1.7.22.1     yamt #ifdef ALTQ3_COMPAT
     64  1.7.22.1     yamt #define	CBQCLF_CTLCLASS		0x4000	/* control class */
     65  1.7.22.1     yamt #endif
     66  1.7.22.1     yamt #define	CBQCLF_CLASSMASK	0xf000	/* class mask */
     67  1.7.22.1     yamt 
     68  1.7.22.1     yamt #define	CBQ_MAXQSIZE		200
     69  1.7.22.1     yamt #define	CBQ_MAXPRI		RM_MAXPRIO
     70  1.7.22.1     yamt 
     71  1.7.22.1     yamt typedef struct _cbq_class_stats_ {
     72  1.7.22.1     yamt 	u_int32_t	handle;
     73  1.7.22.1     yamt 	u_int		depth;
     74  1.7.22.1     yamt 
     75  1.7.22.1     yamt 	struct pktcntr	xmit_cnt;	/* packets sent in this class */
     76  1.7.22.1     yamt 	struct pktcntr	drop_cnt;	/* dropped packets */
     77  1.7.22.1     yamt 	u_int		over;		/* # times went over limit */
     78  1.7.22.1     yamt 	u_int		borrows;	/* # times tried to borrow */
     79  1.7.22.1     yamt 	u_int		overactions;	/* # times invoked overlimit action */
     80  1.7.22.1     yamt 	u_int		delays;		/* # times invoked delay actions */
     81  1.7.22.1     yamt 
     82  1.7.22.1     yamt 	/* other static class parameters useful for debugging */
     83  1.7.22.1     yamt 	int		priority;
     84  1.7.22.1     yamt 	int		maxidle;
     85  1.7.22.1     yamt 	int		minidle;
     86  1.7.22.1     yamt 	int		offtime;
     87  1.7.22.1     yamt 	int		qmax;
     88  1.7.22.1     yamt 	int		ns_per_byte;
     89  1.7.22.1     yamt 	int		wrr_allot;
     90  1.7.22.1     yamt 
     91  1.7.22.1     yamt 	int		qcnt;		/* # packets in queue */
     92  1.7.22.1     yamt 	int		avgidle;
     93  1.7.22.1     yamt 
     94  1.7.22.1     yamt 	/* red and rio related info */
     95  1.7.22.1     yamt 	int		qtype;
     96  1.7.22.1     yamt 	struct redstats	red[3];
     97  1.7.22.1     yamt } class_stats_t;
     98  1.7.22.1     yamt 
     99  1.7.22.1     yamt #ifdef ALTQ3_COMPAT
    100       1.1  thorpej /*
    101       1.1  thorpej  * Define structures associated with IOCTLS for cbq.
    102       1.1  thorpej  */
    103       1.1  thorpej 
    104       1.1  thorpej /*
    105       1.1  thorpej  * Define the CBQ interface structure.  This must be included in all
    106       1.1  thorpej  * IOCTL's such that the CBQ driver may find the appropriate CBQ module
    107       1.1  thorpej  * associated with the network interface to be affected.
    108       1.1  thorpej  */
    109       1.1  thorpej struct cbq_interface {
    110       1.1  thorpej 	char	cbq_ifacename[IFNAMSIZ];
    111       1.1  thorpej };
    112       1.1  thorpej 
    113       1.1  thorpej typedef struct cbq_class_spec {
    114       1.1  thorpej 	u_int		priority;
    115       1.1  thorpej 	u_int		nano_sec_per_byte;
    116       1.1  thorpej 	u_int		maxq;
    117       1.1  thorpej 	u_int		maxidle;
    118       1.6    perry 	int		minidle;
    119       1.1  thorpej 	u_int		offtime;
    120  1.7.22.1     yamt 	u_int32_t	parent_class_handle;
    121  1.7.22.1     yamt 	u_int32_t	borrow_class_handle;
    122       1.1  thorpej 
    123       1.1  thorpej 	u_int		pktsize;
    124       1.1  thorpej 	int		flags;
    125       1.1  thorpej } cbq_class_spec_t;
    126       1.1  thorpej 
    127       1.1  thorpej struct cbq_add_class {
    128       1.1  thorpej 	struct cbq_interface	cbq_iface;
    129       1.1  thorpej 
    130       1.6    perry 	cbq_class_spec_t	cbq_class;
    131  1.7.22.1     yamt 	u_int32_t		cbq_class_handle;
    132       1.1  thorpej };
    133       1.1  thorpej 
    134       1.1  thorpej struct cbq_delete_class {
    135       1.1  thorpej 	struct cbq_interface	cbq_iface;
    136  1.7.22.1     yamt 	u_int32_t		cbq_class_handle;
    137       1.1  thorpej };
    138       1.1  thorpej 
    139       1.1  thorpej struct cbq_modify_class {
    140       1.1  thorpej 	struct cbq_interface	cbq_iface;
    141       1.1  thorpej 
    142       1.6    perry 	cbq_class_spec_t	cbq_class;
    143  1.7.22.1     yamt 	u_int32_t		cbq_class_handle;
    144       1.1  thorpej };
    145       1.1  thorpej 
    146       1.1  thorpej struct cbq_add_filter {
    147       1.1  thorpej 	struct cbq_interface		cbq_iface;
    148  1.7.22.1     yamt 	u_int32_t		cbq_class_handle;
    149       1.1  thorpej 	struct flow_filter	cbq_filter;
    150       1.1  thorpej 
    151       1.1  thorpej 	u_long			cbq_filter_handle;
    152       1.1  thorpej };
    153       1.1  thorpej 
    154       1.1  thorpej struct cbq_delete_filter {
    155       1.1  thorpej 	struct cbq_interface	cbq_iface;
    156       1.1  thorpej 	u_long			cbq_filter_handle;
    157       1.1  thorpej };
    158       1.1  thorpej 
    159       1.1  thorpej /* number of classes are returned in nclasses field */
    160       1.1  thorpej struct cbq_getstats {
    161       1.1  thorpej 	struct cbq_interface	iface;
    162       1.1  thorpej 	int			nclasses;
    163       1.1  thorpej 	class_stats_t		*stats;
    164       1.1  thorpej };
    165       1.1  thorpej 
    166       1.6    perry /*
    167       1.1  thorpej  * Define IOCTLs for CBQ.
    168       1.1  thorpej  */
    169       1.1  thorpej #define	CBQ_IF_ATTACH		_IOW('Q', 1, struct cbq_interface)
    170       1.1  thorpej #define	CBQ_IF_DETACH		_IOW('Q', 2, struct cbq_interface)
    171       1.1  thorpej #define	CBQ_ENABLE		_IOW('Q', 3, struct cbq_interface)
    172       1.1  thorpej #define	CBQ_DISABLE		_IOW('Q', 4, struct cbq_interface)
    173       1.1  thorpej #define	CBQ_CLEAR_HIERARCHY	_IOW('Q', 5, struct cbq_interface)
    174       1.1  thorpej #define	CBQ_ADD_CLASS		_IOWR('Q', 7, struct cbq_add_class)
    175       1.1  thorpej #define	CBQ_DEL_CLASS		_IOW('Q', 8, struct cbq_delete_class)
    176       1.1  thorpej #define	CBQ_MODIFY_CLASS	_IOWR('Q', 9, struct cbq_modify_class)
    177       1.1  thorpej #define	CBQ_ADD_FILTER		_IOWR('Q', 10, struct cbq_add_filter)
    178       1.1  thorpej #define	CBQ_DEL_FILTER		_IOW('Q', 11, struct cbq_delete_filter)
    179       1.1  thorpej #define	CBQ_GETSTATS		_IOWR('Q', 12, struct cbq_getstats)
    180  1.7.22.1     yamt #endif /* ALTQ3_COMPAT */
    181       1.1  thorpej 
    182       1.1  thorpej #ifdef _KERNEL
    183       1.1  thorpej /*
    184       1.1  thorpej  * Define macros only good for kernel drivers and modules.
    185       1.1  thorpej  */
    186  1.7.22.1     yamt #define	CBQ_WATCHDOG		(hz / 20)
    187       1.1  thorpej #define	CBQ_TIMEOUT		10
    188       1.1  thorpej #define	CBQ_LS_TIMEOUT		(20 * hz / 1000)
    189       1.1  thorpej 
    190       1.1  thorpej #define	CBQ_MAX_CLASSES	256
    191  1.7.22.1     yamt 
    192  1.7.22.1     yamt #ifdef ALTQ3_COMPAT
    193       1.1  thorpej #define	CBQ_MAX_FILTERS 256
    194       1.1  thorpej 
    195  1.7.22.1     yamt #define	DISABLE		0x00
    196  1.7.22.1     yamt #define	ENABLE		0x01
    197  1.7.22.1     yamt #endif /* ALTQ3_COMPAT */
    198  1.7.22.1     yamt 
    199       1.1  thorpej /*
    200       1.1  thorpej  * Define State structures.
    201       1.1  thorpej  */
    202       1.1  thorpej typedef struct cbqstate {
    203  1.7.22.1     yamt #ifdef ALTQ3_COMPAT
    204       1.1  thorpej 	struct cbqstate		*cbq_next;
    205  1.7.22.1     yamt #endif
    206  1.7.22.1     yamt 	int			 cbq_qlen;	/* # of packets in cbq */
    207  1.7.22.1     yamt 	struct rm_class		*cbq_class_tbl[CBQ_MAX_CLASSES];
    208       1.1  thorpej 
    209  1.7.22.1     yamt 	struct rm_ifdat		 ifnp;
    210  1.7.22.1     yamt 	struct callout		 cbq_callout;	/* for timeouts */
    211  1.7.22.1     yamt #ifdef ALTQ3_CLFIER_COMPAT
    212       1.1  thorpej 	struct acc_classifier	cbq_classifier;
    213  1.7.22.1     yamt #endif
    214       1.1  thorpej } cbq_state_t;
    215       1.1  thorpej 
    216       1.1  thorpej #endif /* _KERNEL */
    217       1.1  thorpej 
    218       1.1  thorpej #ifdef __cplusplus
    219       1.1  thorpej }
    220       1.6    perry #endif
    221       1.1  thorpej 
    222       1.1  thorpej #endif /* !_ALTQ_ALTQ_CBQ_H_ */
    223