Home | History | Annotate | Line # | Download | only in altq
altq_conf.h revision 1.9
      1  1.9    peter /*	$NetBSD: altq_conf.h,v 1.9 2006/10/12 19:59:08 peter Exp $	*/
      2  1.9    peter /*	$KAME: altq_conf.h,v 1.10 2005/04/13 03:44:24 suz Exp $	*/
      3  1.1  thorpej 
      4  1.1  thorpej /*
      5  1.9    peter  * Copyright (C) 1998-2002
      6  1.1  thorpej  *	Sony Computer Science Laboratories Inc.  All rights reserved.
      7  1.1  thorpej  *
      8  1.1  thorpej  * Redistribution and use in source and binary forms, with or without
      9  1.1  thorpej  * modification, are permitted provided that the following conditions
     10  1.1  thorpej  * are met:
     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  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     16  1.1  thorpej  *
     17  1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY SONY CSL AND CONTRIBUTORS ``AS IS'' AND
     18  1.1  thorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     19  1.1  thorpej  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     20  1.1  thorpej  * ARE DISCLAIMED.  IN NO EVENT SHALL SONY CSL OR CONTRIBUTORS BE LIABLE
     21  1.1  thorpej  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22  1.1  thorpej  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     23  1.1  thorpej  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24  1.1  thorpej  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     25  1.1  thorpej  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     26  1.1  thorpej  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     27  1.1  thorpej  * SUCH DAMAGE.
     28  1.1  thorpej  */
     29  1.1  thorpej #ifndef _ALTQ_ALTQ_CONF_H_
     30  1.1  thorpej #define	_ALTQ_ALTQ_CONF_H_
     31  1.9    peter #ifdef ALTQ3_COMPAT
     32  1.1  thorpej 
     33  1.1  thorpej #ifdef _KERNEL
     34  1.1  thorpej 
     35  1.1  thorpej #include <sys/param.h>
     36  1.1  thorpej #include <sys/conf.h>
     37  1.1  thorpej #include <sys/kernel.h>
     38  1.1  thorpej 
     39  1.1  thorpej #if (__FreeBSD_version > 300000)
     40  1.1  thorpej #define	ALTQ_KLD
     41  1.1  thorpej #endif
     42  1.1  thorpej 
     43  1.1  thorpej #ifdef ALTQ_KLD
     44  1.1  thorpej #include <sys/module.h>
     45  1.1  thorpej #endif
     46  1.1  thorpej 
     47  1.1  thorpej #ifndef dev_decl
     48  1.1  thorpej #ifdef __STDC__
     49  1.1  thorpej #define	dev_decl(n,t)	d_ ## t ## _t n ## t
     50  1.1  thorpej #else
     51  1.1  thorpej #define	dev_decl(n,t)	d_/**/t/**/_t n/**/t
     52  1.1  thorpej #endif
     53  1.1  thorpej #endif
     54  1.1  thorpej 
     55  1.9    peter #if defined(__NetBSD__)
     56  1.9    peter typedef int d_open_t(dev_t, int, int, struct lwp *);
     57  1.9    peter typedef int d_close_t(dev_t, int, int, struct lwp *);
     58  1.9    peter typedef int d_ioctl_t(dev_t, u_long, caddr_t, int, struct lwp *);
     59  1.9    peter #endif /* __NetBSD__ */
     60  1.1  thorpej 
     61  1.4  gehenna #if defined(__OpenBSD__)
     62  1.9    peter typedef int d_open_t(dev_t, int, int, struct proc *);
     63  1.9    peter typedef int d_close_t(dev_t, int, int, struct proc *);
     64  1.9    peter typedef int d_ioctl_t(dev_t, u_long, caddr_t, int, struct proc *);
     65  1.9    peter 
     66  1.1  thorpej #define	noopen	(dev_type_open((*))) enodev
     67  1.1  thorpej #define	noclose	(dev_type_close((*))) enodev
     68  1.1  thorpej #define	noioctl	(dev_type_ioctl((*))) enodev
     69  1.1  thorpej 
     70  1.9    peter int altqopen(dev_t, int, int, struct proc *);
     71  1.9    peter int altqclose(dev_t, int, int, struct proc *);
     72  1.9    peter int altqioctl(dev_t, u_long, caddr_t, int, struct proc *);
     73  1.1  thorpej #endif
     74  1.1  thorpej 
     75  1.1  thorpej /*
     76  1.1  thorpej  * altq queueing discipline switch structure
     77  1.1  thorpej  */
     78  1.1  thorpej struct altqsw {
     79  1.9    peter 	const char	*d_name;
     80  1.1  thorpej 	d_open_t	*d_open;
     81  1.1  thorpej 	d_close_t	*d_close;
     82  1.1  thorpej 	d_ioctl_t	*d_ioctl;
     83  1.9    peter #ifdef __FreeBSD__
     84  1.9    peter 	dev_t		 dev;	/* make_dev result for later destroy_dev */
     85  1.9    peter #endif
     86  1.1  thorpej };
     87  1.1  thorpej 
     88  1.1  thorpej #define	altqdev_decl(n) \
     89  1.1  thorpej 	dev_decl(n,open); dev_decl(n,close); dev_decl(n,ioctl)
     90  1.1  thorpej 
     91  1.1  thorpej #ifdef ALTQ_KLD
     92  1.1  thorpej 
     93  1.1  thorpej struct altq_module_data {
     94  1.1  thorpej 	int	type;		/* discipline type */
     95  1.1  thorpej 	int	ref;		/* reference count */
     96  1.1  thorpej 	struct	altqsw *altqsw; /* discipline functions */
     97  1.1  thorpej };
     98  1.1  thorpej 
     99  1.1  thorpej #define	ALTQ_MODULE(name, type, devsw)					\
    100  1.1  thorpej static struct altq_module_data name##_moddata = { type, 0, devsw };	\
    101  1.1  thorpej 									\
    102  1.1  thorpej moduledata_t name##_mod = {						\
    103  1.1  thorpej     #name,								\
    104  1.1  thorpej     altq_module_handler,						\
    105  1.1  thorpej     &name##_moddata							\
    106  1.1  thorpej };									\
    107  1.1  thorpej DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+96)
    108  1.1  thorpej 
    109  1.9    peter void altq_module_incref(int);
    110  1.9    peter void altq_module_declref(int);
    111  1.9    peter int altq_module_handler(module_t, int, void *);
    112  1.1  thorpej 
    113  1.1  thorpej #endif /* ALTQ_KLD */
    114  1.1  thorpej 
    115  1.1  thorpej #endif /* _KERNEL */
    116  1.9    peter #endif /* ALTQ3_COMPAT */
    117  1.1  thorpej #endif /* _ALTQ_ALTQ_CONF_H_ */
    118