]> git.proxmox.com Git - mirror_spl-debian.git/blame - include/linux-kstat.h
Initial commit. All spl source written up to this point wrapped
[mirror_spl-debian.git] / include / linux-kstat.h
CommitLineData
f1ca4da6 1#ifndef _SYS_LINUX_KSTAT_H
2#define _SYS_LINUX_KSTAT_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <sys/linux-types.h>
9
10/* XXX - The minimum functionality here is stubbed out but nothing works. */
11
12#define KSTAT_STRLEN 31 /* 30 chars + NULL; must be 16 * n - 1 */
13
14#define KSTAT_TYPE_RAW 0 /* can be anything */
15 /* ks_ndata >= 1 */
16#define KSTAT_TYPE_NAMED 1 /* name/value pair */
17 /* ks_ndata >= 1 */
18#define KSTAT_TYPE_INTR 2 /* interrupt statistics */
19 /* ks_ndata == 1 */
20#define KSTAT_TYPE_IO 3 /* I/O statistics */
21 /* ks_ndata == 1 */
22#define KSTAT_TYPE_TIMER 4 /* event timer */
23 /* ks_ndata >= 1 */
24
25#define KSTAT_NUM_TYPES 5
26
27
28#define KSTAT_DATA_CHAR 0
29#define KSTAT_DATA_INT32 1
30#define KSTAT_DATA_UINT32 2
31#define KSTAT_DATA_INT64 3
32#define KSTAT_DATA_UINT64 4
33
34
35#define KSTAT_FLAG_VIRTUAL 0x01
36#define KSTAT_FLAG_VAR_SIZE 0x02
37#define KSTAT_FLAG_WRITABLE 0x04
38#define KSTAT_FLAG_PERSISTENT 0x08
39#define KSTAT_FLAG_DORMANT 0x10
40#define KSTAT_FLAG_INVALID 0x2
41
42
43typedef int kid_t; /* unique kstat id */
44
45typedef struct kstat_s {
46 /*
47 * Fields relevant to both kernel and user
48 */
49 hrtime_t ks_crtime; /* creation time (from gethrtime()) */
50 struct kstat_s *ks_next; /* kstat chain linkage */
51 kid_t ks_kid; /* unique kstat ID */
52 char ks_module[KSTAT_STRLEN]; /* provider module name */
53 uchar_t ks_resv; /* reserved, currently just padding */
54 int ks_instance; /* provider module's instance */
55 char ks_name[KSTAT_STRLEN]; /* kstat name */
56 uchar_t ks_type; /* kstat data type */
57 char ks_class[KSTAT_STRLEN]; /* kstat class */
58 uchar_t ks_flags; /* kstat flags */
59 void *ks_data; /* kstat type-specific data */
60 uint_t ks_ndata; /* # of type-specific data records */
61 size_t ks_data_size; /* total size of kstat data section */
62 hrtime_t ks_snaptime; /* time of last data shapshot */
63 /*
64 * Fields relevant to kernel only
65 */
66 int (*ks_update)(struct kstat *, int); /* dynamic update */
67 void *ks_private; /* arbitrary provider-private data */
68 int (*ks_snapshot)(struct kstat *, void *, int);
69 void *ks_lock; /* protects this kstat's data */
70} kstat_t;
71
72typedef struct kstat_named_s {
73 char name[KSTAT_STRLEN]; /* name of counter */
74 uchar_t data_type; /* data type */
75 union {
76 char c[16]; /* enough for 128-bit ints */
77 int32_t i32;
78 uint32_t ui32;
79 struct {
80 union {
81 char *ptr; /* NULL-term string */
82 char __pad[8]; /* 64-bit padding */
83 } addr;
84 uint32_t len; /* # bytes for strlen + '\0' */
85 } str;
86/*
87 * The int64_t and uint64_t types are not valid for a maximally conformant
88 * 32-bit compilation environment (cc -Xc) using compilers prior to the
89 * introduction of C99 conforming compiler (reference ISO/IEC 9899:1990).
90 * In these cases, the visibility of i64 and ui64 is only permitted for
91 * 64-bit compilation environments or 32-bit non-maximally conformant
92 * C89 or C90 ANSI C compilation environments (cc -Xt and cc -Xa). In the
93 * C99 ANSI C compilation environment, the long long type is supported.
94 * The _INT64_TYPE is defined by the implementation (see sys/int_types.h).
95 */
96 int64_t i64;
97 uint64_t ui64;
98 long l;
99 ulong_t ul;
100
101 /* These structure members are obsolete */
102
103 longlong_t ll;
104 u_longlong_t ull;
105 float f;
106 double d;
107 } value; /* value of counter */
108} kstat_named_t;
109
110
111static __inline__ kstat_t *
112kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
113 const char *ks_class, uchar_t ks_type, uint_t ks_ndata,
114 uchar_t ks_flags)
115{
116 return NULL;
117}
118
119static __inline__ void
120kstat_install(kstat_t *ksp)
121{
122 return;
123}
124
125static __inline__ void
126kstat_delete(kstat_t *ksp)
127{
128 return;
129}
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif /* _SYS_LINUX_KSTAT_H */
136