Sync usage with man page.
[netbsd-mini2440.git] / sys / dev / ic / ath_netbsd.h
blob8d912edd92ea00d899eded2055d2d73d8205289f
1 /* $NetBSD: ath_netbsd.h,v 1.8 2007/11/26 23:52:40 dyoung Exp $ */
3 /*-
4 * Copyright (c) 2003, 2004 David Young
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef _ATH_NETBSD_H
28 #define _ATH_NETBSD_H
30 #undef KASSERT
31 #define KASSERT(__cond, __complaint) if (!(__cond)) panic __complaint
33 typedef struct ath_task {
34 void (*t_func)(void*, int);
35 void *t_context;
36 } ath_task_t;
38 #define ATH_CALLOUT_INIT(__ch, __mpsafe) callout_init((__ch), 0)
40 #define TASK_INIT(__task, __zero, __func, __context) \
41 do { \
42 (__task)->t_func = (__func); \
43 (__task)->t_context = (__context); \
44 } while (0)
46 #define TASK_RUN_OR_ENQUEUE(__task) \
47 ((*(__task)->t_func)((__task)->t_context, 1))
49 struct ath_lock {
50 int count;
51 int ipl;
54 #define ATH_LOCK_INIT_IMPL(_obj, _member) \
55 do { (_obj)->_member.count = 0; } while (0)
56 #define ATH_LOCK_IMPL(_obj, _member) \
57 do { \
58 int __s = splnet(); \
59 if ((_obj)->_member.count++ == 0) \
60 (_obj)->_member.ipl = __s; \
61 } while (0)
62 #define ATH_UNLOCK_IMPL(_obj, _member) \
63 do { \
64 if (--(_obj)->_member.count == 0) \
65 splx((_obj)->_member.ipl); \
66 else { \
67 KASSERT((_obj)->_member.count >= 0, \
68 ("%s: no ATH_LOCK holders", __func__)); \
69 } \
70 } while (0)
72 typedef struct ath_lock ath_lock_t;
73 #define ATH_LOCK_INIT(_sc) ATH_LOCK_INIT_IMPL(_sc, sc_mtx)
74 #define ATH_LOCK_DESTROY(_sc)
75 #define ATH_LOCK(_sc) ATH_LOCK_IMPL(_sc, sc_mtx)
76 #define ATH_UNLOCK(_sc) ATH_UNLOCK_IMPL(_sc, sc_mtx)
77 #define ATH_LOCK_ASSERT(_sc)
79 typedef struct ath_lock ath_txq_lock_t;
80 #define ATH_TXQ_LOCK_INIT(_sc, _tq) ATH_LOCK_INIT_IMPL(_tq, axq_lock)
81 #define ATH_TXQ_LOCK_DESTROY(_tq)
82 #define ATH_TXQ_LOCK(_tq) ATH_LOCK_IMPL(_tq, axq_lock)
83 #define ATH_TXQ_UNLOCK(_tq) ATH_UNLOCK_IMPL(_tq, axq_lock)
84 #define ATH_TXQ_LOCK_ASSERT(_tq)
86 typedef struct ath_lock ath_txbuf_lock_t;
87 #define ATH_TXBUF_LOCK_INIT(_sc) ATH_LOCK_INIT_IMPL(_sc, sc_txbuflock)
88 #define ATH_TXBUF_LOCK_DESTROY(_sc)
89 #define ATH_TXBUF_LOCK(_sc) ATH_LOCK_IMPL(_sc, sc_txbuflock)
90 #define ATH_TXBUF_UNLOCK(_sc) ATH_UNLOCK_IMPL(_sc, sc_txbuflock)
91 #define ATH_TXBUF_LOCK_ASSERT(_sc)
93 #define NET_LOCK_GIANT()
94 #define NET_UNLOCK_GIANT()
96 #define IF_LOCK(__q)
97 #define IF_UNLOCK(__q)
99 #define SYSCTL_INT_SUBR(__rw, __name, __descr) \
100 sysctl_createv(log, 0, &rnode, &cnode, CTLFLAG_PERMANENT|(__rw), \
101 CTLTYPE_INT, #__name, SYSCTL_DESCR(__descr), ath_sysctl_##__name,\
102 0, sc, 0, CTL_CREATE, CTL_EOL)
104 #define __PFX(__pfx, __name) __pfx##__name
106 #define SYSCTL_PFX_INT(__pfx, __rw, __name, __descr) \
107 sysctl_createv(log, 0, &rnode, &cnode, CTLFLAG_PERMANENT|(__rw),\
108 CTLTYPE_INT, #__name, SYSCTL_DESCR(__descr), NULL, 0, \
109 __PFX(&__pfx, __name), 0, CTL_CREATE, CTL_EOL)
111 #define SYSCTL_INT(__rw, __name, __descr) \
112 SYSCTL_PFX_INT(sc->sc_, __rw, __name, __descr)
114 #define SYSCTL_GLOBAL_INT(__rw, __name, __descr, __var) \
115 sysctl_createv(clog, 0, &rnode, &cnode, \
116 CTLFLAG_PERMANENT|(__rw), CTLTYPE_INT, __name, \
117 SYSCTL_DESCR(__descr), NULL, 0, &ath_##__var, 0, CTL_CREATE,\
118 CTL_EOL)
120 extern void device_printf(device_t, const char *fmt, ...)
121 __attribute__((__format__(__printf__,2,3)));
122 const struct sysctlnode *ath_sysctl_treetop(struct sysctllog **);
123 const struct sysctlnode *ath_sysctl_instance(const char *, struct sysctllog **);
125 #endif /* _ATH_NETBSD_H */