]>
git.proxmox.com Git - mirror_spl-debian.git/blob - include/sys/kstat.h
1ce084729fa15cb41f7b0609d6e26f172d92ae37
10 #include <linux/module.h>
11 #include <sys/types.h>
16 #define KSTAT_STRLEN 31
18 /* For reference valid classes are:
19 * disk, tape, net, controller, vm, kvm, hat, streams, kstat, misc
22 #define KSTAT_TYPE_RAW 0 /* can be anything; ks_ndata >= 1 */
23 #define KSTAT_TYPE_NAMED 1 /* name/value pair; ks_ndata >= 1 */
24 #define KSTAT_TYPE_INTR 2 /* interrupt stats; ks_ndata == 1 */
25 #define KSTAT_TYPE_IO 3 /* I/O stats; ks_ndata == 1 */
26 #define KSTAT_TYPE_TIMER 4 /* event timer; ks_ndata >= 1 */
27 #define KSTAT_NUM_TYPES 5
29 #define KSTAT_DATA_CHAR 0
30 #define KSTAT_DATA_INT32 1
31 #define KSTAT_DATA_UINT32 2
32 #define KSTAT_DATA_INT64 3
33 #define KSTAT_DATA_UINT64 4
34 #define KSTAT_DATA_LONG 5
35 #define KSTAT_DATA_ULONG 6
36 #define KSTAT_DATA_STRING 7
37 #define KSTAT_NUM_DATAS 8
39 #define KSTAT_INTR_HARD 0
40 #define KSTAT_INTR_SOFT 1
41 #define KSTAT_INTR_WATCHDOG 2
42 #define KSTAT_INTR_SPURIOUS 3
43 #define KSTAT_INTR_MULTSVC 4
44 #define KSTAT_NUM_INTRS 5
46 #define KSTAT_FLAG_VIRTUAL 0x01
47 #define KSTAT_FLAG_VAR_SIZE 0x02
48 #define KSTAT_FLAG_WRITABLE 0x04
49 #define KSTAT_FLAG_PERSISTENT 0x08
50 #define KSTAT_FLAG_DORMANT 0x10
51 #define KSTAT_FLAG_UNSUPPORTED (KSTAT_FLAG_VAR_SIZE | KSTAT_FLAG_WRITABLE | \
52 KSTAT_FLAG_PERSISTENT | KSTAT_FLAG_DORMANT)
55 #define KS_MAGIC 0x9d9d9d9d
57 typedef int kid_t
; /* unique kstat id */
59 typedef struct kstat_s
{
60 int ks_magic
; /* magic value */
61 kid_t ks_kid
; /* unique kstat ID */
62 hrtime_t ks_crtime
; /* creation time */
63 hrtime_t ks_snaptime
; /* last access time */
64 char ks_module
[KSTAT_STRLEN
+1]; /* provider module name */
65 int ks_instance
; /* provider module instance */
66 char ks_name
[KSTAT_STRLEN
+1]; /* kstat name */
67 char ks_class
[KSTAT_STRLEN
+1]; /* kstat class */
68 uchar_t ks_type
; /* kstat data type */
69 uchar_t ks_flags
; /* kstat flags */
70 void *ks_data
; /* kstat type-specific data */
71 uint_t ks_ndata
; /* # of type-specific data records */
72 size_t ks_data_size
; /* size of kstat data section */
73 struct proc_dir_entry
*ks_proc
; /* proc linkage */
74 spinlock_t ks_lock
; /* kstat data lock */
75 struct list_head ks_list
; /* kstat linkage */
78 typedef struct kstat_named_s
{
79 char name
[KSTAT_STRLEN
]; /* name of counter */
80 uchar_t data_type
; /* data type */
82 char c
[16]; /* 128-bit int */
83 int32_t i32
; /* 32-bit signed int */
84 uint32_t ui32
; /* 32-bit unsigned int */
85 int64_t i64
; /* 64-bit signed int */
86 uint64_t ui64
; /* 64-bit unsigned int */
87 long l
; /* native signed long */
88 ulong_t ul
; /* native unsigned long */
91 char *ptr
; /* NULL-term string */
92 char __pad
[8]; /* 64-bit padding */
94 uint32_t len
; /* # bytes for strlen + '\0' */
99 #define KSTAT_NAMED_STR_PTR(knptr) ((knptr)->value.string.addr.ptr)
100 #define KSTAT_NAMED_STR_BUFLEN(knptr) ((knptr)->value.string.len)
102 typedef struct kstat_intr
{
103 uint_t intrs
[KSTAT_NUM_INTRS
];
106 typedef struct kstat_io
{
107 u_longlong_t nread
; /* number of bytes read */
108 u_longlong_t nwritten
; /* number of bytes written */
109 uint_t reads
; /* number of read operations */
110 uint_t writes
; /* number of write operations */
111 hrtime_t wtime
; /* cumulative wait (pre-service) time */
112 hrtime_t wlentime
; /* cumulative wait length*time product*/
113 hrtime_t wlastupdate
; /* last time wait queue changed */
114 hrtime_t rtime
; /* cumulative run (service) time */
115 hrtime_t rlentime
; /* cumulative run length*time product */
116 hrtime_t rlastupdate
; /* last time run queue changed */
117 uint_t wcnt
; /* count of elements in wait state */
118 uint_t rcnt
; /* count of elements in run state */
121 typedef struct kstat_timer
{
122 char name
[KSTAT_STRLEN
+1]; /* event name */
123 u_longlong_t num_events
; /* number of events */
124 hrtime_t elapsed_time
; /* cumulative elapsed time */
125 hrtime_t min_time
; /* shortest event duration */
126 hrtime_t max_time
; /* longest event duration */
127 hrtime_t start_time
; /* previous event start time */
128 hrtime_t stop_time
; /* previous event stop time */
131 int kstat_init(void);
132 void kstat_fini(void);
135 extern kstat_t
*__kstat_create(const char *ks_module
, int ks_instance
,
136 const char *ks_name
, const char *ks_class
,
137 uchar_t ks_type
, uint_t ks_ndata
,
139 extern void __kstat_install(kstat_t
*ksp
);
140 extern void __kstat_delete(kstat_t
*ksp
);
142 #define kstat_create(m,i,n,c,t,s,f) __kstat_create(m,i,n,c,t,s,f)
143 #define kstat_install(k) __kstat_install(k)
144 #define kstat_delete(k) __kstat_delete(k)
148 #define kstat_create(m,i,n,c,t,s,f) (NULL)
149 #define kstat_install(k) ((void)0)
150 #define kstat_delete(k) ((void)0)
152 #endif /* DEBUG_KSTAT */
158 #endif /* _SPL_KSTAT_H */