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