Home | History | Annotate | Line # | Download | only in ic
ath_netbsd.h revision 1.15.18.1
      1  1.15.18.1  pgoyette /*	$NetBSD: ath_netbsd.h,v 1.15.18.1 2017/03/20 06:57:28 pgoyette Exp $ */
      2        1.5   xtraeme 
      3        1.1    dyoung /*-
      4        1.1    dyoung  * Copyright (c) 2003, 2004 David Young
      5        1.1    dyoung  * All rights reserved.
      6        1.1    dyoung  *
      7        1.1    dyoung  * Redistribution and use in source and binary forms, with or without
      8        1.1    dyoung  * modification, are permitted provided that the following conditions
      9        1.1    dyoung  * are met:
     10        1.1    dyoung  * 1. Redistributions of source code must retain the above copyright
     11        1.1    dyoung  *    notice, this list of conditions and the following disclaimer.
     12        1.1    dyoung  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1    dyoung  *    notice, this list of conditions and the following disclaimer in the
     14        1.1    dyoung  *    documentation and/or other materials provided with the distribution.
     15        1.1    dyoung  *
     16        1.1    dyoung  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17        1.1    dyoung  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18        1.1    dyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19        1.1    dyoung  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20        1.1    dyoung  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21        1.1    dyoung  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22        1.1    dyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23        1.1    dyoung  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24        1.1    dyoung  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25        1.1    dyoung  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26        1.1    dyoung  */
     27        1.1    dyoung #ifndef _ATH_NETBSD_H
     28        1.1    dyoung #define _ATH_NETBSD_H
     29        1.1    dyoung 
     30       1.10    dyoung #include <sys/sysctl.h>
     31  1.15.18.1  pgoyette #include <sys/intr.h>
     32       1.10    dyoung 
     33        1.1    dyoung typedef struct ath_task {
     34  1.15.18.1  pgoyette 	void	*t_soft_ih;
     35        1.1    dyoung } ath_task_t;
     36        1.1    dyoung 
     37        1.6        ad #define ATH_CALLOUT_INIT(__ch, __mpsafe) callout_init((__ch), 0)
     38        1.1    dyoung 
     39        1.1    dyoung #define TASK_INIT(__task, __zero, __func, __context)	\
     40        1.1    dyoung 	do {						\
     41  1.15.18.1  pgoyette 		(__task)->t_soft_ih = 			\
     42  1.15.18.1  pgoyette 		    softint_establish(SOFTINT_NET,	\
     43  1.15.18.1  pgoyette 		      __CONCAT(__func, _si),		\
     44  1.15.18.1  pgoyette 		      (__context));			\
     45  1.15.18.1  pgoyette 		KASSERT((__task)->t_soft_ih);		\
     46        1.1    dyoung 	} while (0)
     47        1.1    dyoung 
     48        1.1    dyoung #define TASK_RUN_OR_ENQUEUE(__task)	\
     49  1.15.18.1  pgoyette 	softint_schedule((__task)->t_soft_ih);
     50        1.1    dyoung 
     51       1.12    dyoung typedef kmutex_t ath_txq_lock_t;
     52       1.12    dyoung #define	ATH_TXQ_LOCK_INIT(_sc, _tq)	mutex_init(&(_tq)->axq_lock, MUTEX_DEFAULT, IPL_NET)
     53       1.12    dyoung #define	ATH_TXQ_LOCK_DESTROY(_tq)	mutex_destroy(&(_tq)->axq_lock)
     54       1.12    dyoung #define	ATH_TXQ_LOCK(_tq)		mutex_enter(&(_tq)->axq_lock)
     55       1.12    dyoung #define	ATH_TXQ_UNLOCK(_tq)		mutex_exit(&(_tq)->axq_lock)
     56       1.14    dyoung #define	ATH_TXQ_LOCK_ASSERT(_tq)	do { KASSERTMSG(mutex_owned(&(_tq)->axq_lock), "txq lock unheld"); } while (/*CONSTCOND*/true)
     57       1.12    dyoung 
     58       1.12    dyoung typedef kmutex_t ath_txbuf_lock_t;
     59       1.12    dyoung #define	ATH_TXBUF_LOCK_INIT(_sc)	mutex_init(&(_sc)->sc_txbuflock, MUTEX_DEFAULT, IPL_NET)
     60       1.12    dyoung #define	ATH_TXBUF_LOCK_DESTROY(_sc)	mutex_destroy(&(_sc)->sc_txbuflock)
     61       1.12    dyoung #define	ATH_TXBUF_LOCK(_sc)		mutex_enter(&(_sc)->sc_txbuflock)
     62       1.12    dyoung #define	ATH_TXBUF_UNLOCK(_sc)		mutex_exit(&(_sc)->sc_txbuflock)
     63       1.14    dyoung #define	ATH_TXBUF_LOCK_ASSERT(_sc)	do { KASSERTMSG(mutex_owned(&(_sc)->sc_txbuflock), "txbuf lock unheld"); } while (/*CONSTCOND*/true)
     64        1.1    dyoung 
     65  1.15.18.1  pgoyette #define	NET_LOCK_GIANT_FUNC_INIT()	int s
     66  1.15.18.1  pgoyette #define	NET_LOCK_GIANT()		s = splnet()
     67  1.15.18.1  pgoyette #define	NET_UNLOCK_GIANT()		splx(s)
     68        1.1    dyoung 
     69        1.1    dyoung #define	SYSCTL_INT_SUBR(__rw, __name, __descr)				     \
     70        1.1    dyoung 	sysctl_createv(log, 0, &rnode, &cnode, CTLFLAG_PERMANENT|(__rw),     \
     71        1.1    dyoung 	    CTLTYPE_INT, #__name, SYSCTL_DESCR(__descr), ath_sysctl_##__name,\
     72       1.13       dsl 	    0, (void *)sc, 0, CTL_CREATE, CTL_EOL)
     73        1.1    dyoung 
     74        1.4    dyoung #define	__PFX(__pfx, __name)	__pfx##__name
     75        1.4    dyoung 
     76        1.4    dyoung #define	SYSCTL_PFX_INT(__pfx, __rw, __name, __descr)			\
     77        1.1    dyoung 	sysctl_createv(log, 0, &rnode, &cnode, CTLFLAG_PERMANENT|(__rw),\
     78        1.1    dyoung 	    CTLTYPE_INT, #__name, SYSCTL_DESCR(__descr), NULL, 0,	\
     79        1.4    dyoung 	    __PFX(&__pfx, __name), 0, CTL_CREATE, CTL_EOL)
     80        1.4    dyoung 
     81        1.4    dyoung #define	SYSCTL_INT(__rw, __name, __descr)				\
     82        1.4    dyoung 	SYSCTL_PFX_INT(sc->sc_, __rw, __name, __descr)
     83        1.1    dyoung 
     84        1.1    dyoung #define	SYSCTL_GLOBAL_INT(__rw, __name, __descr, __var)			\
     85        1.1    dyoung 	sysctl_createv(clog, 0, &rnode, &cnode,				\
     86        1.1    dyoung 	    CTLFLAG_PERMANENT|(__rw), CTLTYPE_INT, __name,		\
     87        1.1    dyoung 	    SYSCTL_DESCR(__descr), NULL, 0, &ath_##__var, 0, CTL_CREATE,\
     88        1.1    dyoung 	    CTL_EOL)
     89        1.1    dyoung 
     90        1.1    dyoung const struct sysctlnode *ath_sysctl_treetop(struct sysctllog **);
     91        1.4    dyoung const struct sysctlnode *ath_sysctl_instance(const char *, struct sysctllog **);
     92        1.1    dyoung 
     93        1.1    dyoung #endif /* _ATH_NETBSD_H */
     94