]> git.proxmox.com Git - mirror_spl.git/blob - include/linux-taskq.h
Initial commit. All spl source written up to this point wrapped
[mirror_spl.git] / include / linux-taskq.h
1 #ifndef _SYS_LINUX_TASKQ_H
2 #define _SYS_LINUX_TASKQ_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 /*
9 * Task Queues - As of linux 2.6.x task queues have been replaced by a
10 * similar construct called work queues. The big difference on the linux
11 * side is that functions called from work queues run in process context
12 * and not interrupt context.
13 *
14 * One nice feature of Solaris which does not exist in linux work
15 * queues in the notion of a dynamic work queue. Rather than implementing
16 * this in the shim layer I'm hardcoding one-thread per work queue.
17 *
18 * XXX - This may end up being a significant performance penalty which
19 * forces us to implement dynamic workqueues. Which is all very doable
20 * with a little effort.
21 */
22 #include <linux/workqueue.h>
23 #include <linux/gfp.h>
24 #include <linux/slab.h>
25 #include <linux/interrupt.h>
26 #include <sys/linux-types.h>
27
28 #undef DEBUG_TASKQ_UNIMPLEMENTED
29
30 #define TASKQ_NAMELEN 31
31 #define taskq_t workq_t
32
33 typedef struct workqueue_struct workq_t;
34 typedef unsigned long taskqid_t;
35 typedef void (*task_func_t)(void *);
36
37 /*
38 * Public flags for taskq_create(): bit range 0-15
39 */
40 #define TASKQ_PREPOPULATE 0x0000 /* XXX - Workqueues fully populate */
41 #define TASKQ_CPR_SAFE 0x0000 /* XXX - No analog */
42 #define TASKQ_DYNAMIC 0x0000 /* XXX - Worksqueues not dynamic */
43
44 /*
45 * Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as
46 * KM_SLEEP/KM_NOSLEEP.
47 */
48 #define TQ_SLEEP 0x00 /* XXX - Workqueues don't support */
49 #define TQ_NOSLEEP 0x00 /* these sorts of flags. They */
50 #define TQ_NOQUEUE 0x00 /* always run in application */
51 #define TQ_NOALLOC 0x00 /* context and can sleep. */
52
53
54 #ifdef DEBUG_TASKQ_UNIMPLEMENTED
55 static __inline__ void taskq_init(void) {
56 #error "taskq_init() not implemented"
57 }
58
59 static __inline__ taskq_t *
60 taskq_create_instance(const char *, int, int, pri_t, int, int, uint_t) {
61 #error "taskq_create_instance() not implemented"
62 }
63
64 extern void nulltask(void *);
65 extern void taskq_suspend(taskq_t *);
66 extern int taskq_suspended(taskq_t *);
67 extern void taskq_resume(taskq_t *);
68
69 #endif /* DEBUG_TASKQ_UNIMPLEMENTED */
70
71 extern taskqid_t __taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
72 extern taskq_t *__taskq_create(const char *, int, pri_t, int, int, uint_t);
73
74 #define taskq_create(name, thr, pri, min, max, flags) \
75 __taskq_create(name, thr, pri, min, max, flags)
76 #define taskq_dispatch(tq, func, priv, flags) \
77 __taskq_dispatch(tq, func, priv, flags)
78 #define taskq_destory(tq) destroy_workqueue(tq)
79 #define taskq_wait(tq) flush_workqueue(tq)
80 #define taskq_member(tq, kthr) 1 /* XXX -Just be true */
81
82 #ifdef __cplusplus
83 }
84 #endif
85
86 #endif /* _SYS_LINUX_TASKQ_H */