1700 Add SCSI UNMAP support
[unleashed.git] / usr / src / uts / common / sys / ddi_periodic.h
blob0af46e5c01d2d7d3520e3769fecffc32a8570642
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
12 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
15 #ifndef _SYS_DDI_PERIODIC_H
16 #define _SYS_DDI_PERIODIC_H
18 #include <sys/list.h>
19 #include <sys/taskq_impl.h>
20 #include <sys/cyclic.h>
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
26 #ifdef _KERNEL
29 * Opaque handle type for i_timeout() and i_untimeout().
31 typedef struct __timeout *timeout_t;
33 typedef enum ddi_periodic_flags {
34 DPF_DISPATCHED = 0x01,
35 DPF_EXECUTING = 0x02,
36 DPF_CANCELLED = 0x04
37 } ddi_periodic_flags_t;
40 * Each instance of this structure represents a single periodic handler
41 * registered through ddi_periodic_add(9F).
43 typedef struct ddi_periodic_impl {
44 struct list_node dpr_link; /* protected by periodics_lock */
45 struct list_node dpr_softint_link; /* only used when DPF_DISPATCHED */
46 id_t dpr_id;
47 hrtime_t dpr_interval;
49 kmutex_t dpr_lock;
50 kcondvar_t dpr_cv;
51 ddi_periodic_flags_t dpr_flags;
52 uint_t dpr_level; /* 0 <= dpr_level <= 10 */
53 taskq_ent_t dpr_taskq_ent; /* only used for level of 0 */
54 uint64_t dpr_fire_count;
55 kthread_t *dpr_thread;
57 cyclic_id_t dpr_cyclic_id;
59 void (*dpr_handler)(void *);
60 void *dpr_arg;
61 } ddi_periodic_impl_t;
64 * Internal implementation functions for the DDI periodic interface.
66 void ddi_periodic_init(void);
67 void ddi_periodic_fini(void);
68 void ddi_periodic_softintr(int level);
69 timeout_t i_timeout(void (*)(void *), void *, hrtime_t, int);
70 void i_untimeout(timeout_t);
72 #endif /* _KERNEL */
74 #ifdef __cplusplus
76 #endif
78 #endif /* _SYS_DDI_PERIODIC_H */