]>
git.proxmox.com Git - mirror_spl.git/blob - include/sys/kstat.h
0b6ce0583e3c12e86d987aa6762c551a2b445e6e
8 #include <linux/module.h>
12 /* XXX - The minimum functionality here is stubbed out but nothing works. */
14 #define KSTAT_STRLEN 31 /* 30 chars + NULL; must be 16 * n - 1 */
16 #define KSTAT_TYPE_RAW 0 /* can be anything */
18 #define KSTAT_TYPE_NAMED 1 /* name/value pair */
20 #define KSTAT_TYPE_INTR 2 /* interrupt statistics */
22 #define KSTAT_TYPE_IO 3 /* I/O statistics */
24 #define KSTAT_TYPE_TIMER 4 /* event timer */
27 #define KSTAT_NUM_TYPES 5
30 #define KSTAT_DATA_CHAR 0
31 #define KSTAT_DATA_INT32 1
32 #define KSTAT_DATA_UINT32 2
33 #define KSTAT_DATA_INT64 3
34 #define KSTAT_DATA_UINT64 4
37 #define KSTAT_FLAG_VIRTUAL 0x01
38 #define KSTAT_FLAG_VAR_SIZE 0x02
39 #define KSTAT_FLAG_WRITABLE 0x04
40 #define KSTAT_FLAG_PERSISTENT 0x08
41 #define KSTAT_FLAG_DORMANT 0x10
42 #define KSTAT_FLAG_INVALID 0x2
45 typedef int kid_t
; /* unique kstat id */
47 typedef struct kstat_s
{
49 * Fields relevant to both kernel and user
51 hrtime_t ks_crtime
; /* creation time (from gethrtime()) */
52 struct kstat_s
*ks_next
; /* kstat chain linkage */
53 kid_t ks_kid
; /* unique kstat ID */
54 char ks_module
[KSTAT_STRLEN
]; /* provider module name */
55 uchar_t ks_resv
; /* reserved, currently just padding */
56 int ks_instance
; /* provider module's instance */
57 char ks_name
[KSTAT_STRLEN
]; /* kstat name */
58 uchar_t ks_type
; /* kstat data type */
59 char ks_class
[KSTAT_STRLEN
]; /* kstat class */
60 uchar_t ks_flags
; /* kstat flags */
61 void *ks_data
; /* kstat type-specific data */
62 uint_t ks_ndata
; /* # of type-specific data records */
63 size_t ks_data_size
; /* total size of kstat data section */
64 hrtime_t ks_snaptime
; /* time of last data shapshot */
66 * Fields relevant to kernel only
68 int (*ks_update
)(struct kstat
*, int); /* dynamic update */
69 void *ks_private
; /* arbitrary provider-private data */
70 int (*ks_snapshot
)(struct kstat
*, void *, int);
71 void *ks_lock
; /* protects this kstat's data */
74 typedef struct kstat_named_s
{
75 char name
[KSTAT_STRLEN
]; /* name of counter */
76 uchar_t data_type
; /* data type */
78 char c
[16]; /* enough for 128-bit ints */
83 char *ptr
; /* NULL-term string */
84 char __pad
[8]; /* 64-bit padding */
86 uint32_t len
; /* # bytes for strlen + '\0' */
89 * The int64_t and uint64_t types are not valid for a maximally conformant
90 * 32-bit compilation environment (cc -Xc) using compilers prior to the
91 * introduction of C99 conforming compiler (reference ISO/IEC 9899:1990).
92 * In these cases, the visibility of i64 and ui64 is only permitted for
93 * 64-bit compilation environments or 32-bit non-maximally conformant
94 * C89 or C90 ANSI C compilation environments (cc -Xt and cc -Xa). In the
95 * C99 ANSI C compilation environment, the long long type is supported.
96 * The _INT64_TYPE is defined by the implementation (see sys/int_types.h).
103 /* These structure members are obsolete */
109 } value
; /* value of counter */
113 static __inline__ kstat_t
*
114 kstat_create(const char *ks_module
, int ks_instance
, const char *ks_name
,
115 const char *ks_class
, uchar_t ks_type
, uint_t ks_ndata
,
121 static __inline__
void
122 kstat_install(kstat_t
*ksp
)
127 static __inline__
void
128 kstat_delete(kstat_t
*ksp
)
133 /* FIXME - NONE OF THIS IS ATOMIC, IT SHOULD BE. For the moment this is
134 * OK since it is only used for the noncritical kstat counters, and we
135 * are only doing testing on x86_86 platform where the entire counter
136 * will be updated with one instruction. */
137 static __inline__
void
138 atomic_inc_64(volatile uint64_t *target
)
143 static __inline__
void
144 atomic_dec_64(volatile uint64_t *target
)
149 static __inline__
uint64_t
150 atomic_add_64(volatile uint64_t *target
, uint64_t delta
)
152 uint64_t rc
= *target
;
157 static __inline__
uint64_t
158 atomic_add_64_nv(volatile uint64_t *target
, uint64_t delta
)
164 static __inline__
uint64_t
165 atomic_cas_64(volatile uint64_t *target
, uint64_t cmp
,
168 uint64_t rc
= *target
;
180 #endif /* _SPL_KSTAT_H */