summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/sys/kstat.h213
-rw-r--r--include/sys/proc.h17
2 files changed, 134 insertions, 96 deletions
diff --git a/include/sys/kstat.h b/include/sys/kstat.h
index 0b79a41c0..1ce084729 100644
--- a/include/sys/kstat.h
+++ b/include/sys/kstat.h
@@ -5,130 +5,151 @@
extern "C" {
#endif
+#define DEBUG_KSTAT
+
#include <linux/module.h>
#include <sys/types.h>
#include <sys/time.h>
+#include <sys/kmem.h>
+#include <sys/proc.h>
-/* XXX - The minimum functionality here is stubbed out but nothing works. */
-
-#define KSTAT_STRLEN 31 /* 30 chars + NULL; must be 16 * n - 1 */
+#define KSTAT_STRLEN 31
-#define KSTAT_TYPE_RAW 0 /* can be anything */
- /* ks_ndata >= 1 */
-#define KSTAT_TYPE_NAMED 1 /* name/value pair */
- /* ks_ndata >= 1 */
-#define KSTAT_TYPE_INTR 2 /* interrupt statistics */
- /* ks_ndata == 1 */
-#define KSTAT_TYPE_IO 3 /* I/O statistics */
- /* ks_ndata == 1 */
-#define KSTAT_TYPE_TIMER 4 /* event timer */
- /* ks_ndata >= 1 */
+/* For reference valid classes are:
+ * disk, tape, net, controller, vm, kvm, hat, streams, kstat, misc
+ */
+#define KSTAT_TYPE_RAW 0 /* can be anything; ks_ndata >= 1 */
+#define KSTAT_TYPE_NAMED 1 /* name/value pair; ks_ndata >= 1 */
+#define KSTAT_TYPE_INTR 2 /* interrupt stats; ks_ndata == 1 */
+#define KSTAT_TYPE_IO 3 /* I/O stats; ks_ndata == 1 */
+#define KSTAT_TYPE_TIMER 4 /* event timer; ks_ndata >= 1 */
#define KSTAT_NUM_TYPES 5
-
#define KSTAT_DATA_CHAR 0
#define KSTAT_DATA_INT32 1
#define KSTAT_DATA_UINT32 2
#define KSTAT_DATA_INT64 3
#define KSTAT_DATA_UINT64 4
+#define KSTAT_DATA_LONG 5
+#define KSTAT_DATA_ULONG 6
+#define KSTAT_DATA_STRING 7
+#define KSTAT_NUM_DATAS 8
+
+#define KSTAT_INTR_HARD 0
+#define KSTAT_INTR_SOFT 1
+#define KSTAT_INTR_WATCHDOG 2
+#define KSTAT_INTR_SPURIOUS 3
+#define KSTAT_INTR_MULTSVC 4
+#define KSTAT_NUM_INTRS 5
+#define KSTAT_FLAG_VIRTUAL 0x01
+#define KSTAT_FLAG_VAR_SIZE 0x02
+#define KSTAT_FLAG_WRITABLE 0x04
+#define KSTAT_FLAG_PERSISTENT 0x08
+#define KSTAT_FLAG_DORMANT 0x10
+#define KSTAT_FLAG_UNSUPPORTED (KSTAT_FLAG_VAR_SIZE | KSTAT_FLAG_WRITABLE | \
+ KSTAT_FLAG_PERSISTENT | KSTAT_FLAG_DORMANT)
-#define KSTAT_FLAG_VIRTUAL 0x01
-#define KSTAT_FLAG_VAR_SIZE 0x02
-#define KSTAT_FLAG_WRITABLE 0x04
-#define KSTAT_FLAG_PERSISTENT 0x08
-#define KSTAT_FLAG_DORMANT 0x10
-#define KSTAT_FLAG_INVALID 0x2
+#define KS_MAGIC 0x9d9d9d9d
-typedef int kid_t; /* unique kstat id */
+typedef int kid_t; /* unique kstat id */
typedef struct kstat_s {
- /*
- * Fields relevant to both kernel and user
- */
- hrtime_t ks_crtime; /* creation time (from gethrtime()) */
- struct kstat_s *ks_next; /* kstat chain linkage */
- kid_t ks_kid; /* unique kstat ID */
- char ks_module[KSTAT_STRLEN]; /* provider module name */
- uchar_t ks_resv; /* reserved, currently just padding */
- int ks_instance; /* provider module's instance */
- char ks_name[KSTAT_STRLEN]; /* kstat name */
- uchar_t ks_type; /* kstat data type */
- char ks_class[KSTAT_STRLEN]; /* kstat class */
- uchar_t ks_flags; /* kstat flags */
- void *ks_data; /* kstat type-specific data */
- uint_t ks_ndata; /* # of type-specific data records */
- size_t ks_data_size; /* total size of kstat data section */
- hrtime_t ks_snaptime; /* time of last data shapshot */
- /*
- * Fields relevant to kernel only
- */
- int (*ks_update)(struct kstat *, int); /* dynamic update */
- void *ks_private; /* arbitrary provider-private data */
- int (*ks_snapshot)(struct kstat *, void *, int);
- void *ks_lock; /* protects this kstat's data */
+ int ks_magic; /* magic value */
+ kid_t ks_kid; /* unique kstat ID */
+ hrtime_t ks_crtime; /* creation time */
+ hrtime_t ks_snaptime; /* last access time */
+ char ks_module[KSTAT_STRLEN+1]; /* provider module name */
+ int ks_instance; /* provider module instance */
+ char ks_name[KSTAT_STRLEN+1]; /* kstat name */
+ char ks_class[KSTAT_STRLEN+1]; /* kstat class */
+ uchar_t ks_type; /* kstat data type */
+ uchar_t ks_flags; /* kstat flags */
+ void *ks_data; /* kstat type-specific data */
+ uint_t ks_ndata; /* # of type-specific data records */
+ size_t ks_data_size; /* size of kstat data section */
+ struct proc_dir_entry *ks_proc; /* proc linkage */
+ spinlock_t ks_lock; /* kstat data lock */
+ struct list_head ks_list; /* kstat linkage */
} kstat_t;
typedef struct kstat_named_s {
- char name[KSTAT_STRLEN]; /* name of counter */
- uchar_t data_type; /* data type */
+ char name[KSTAT_STRLEN]; /* name of counter */
+ uchar_t data_type; /* data type */
union {
- char c[16]; /* enough for 128-bit ints */
- int32_t i32;
- uint32_t ui32;
+ char c[16]; /* 128-bit int */
+ int32_t i32; /* 32-bit signed int */
+ uint32_t ui32; /* 32-bit unsigned int */
+ int64_t i64; /* 64-bit signed int */
+ uint64_t ui64; /* 64-bit unsigned int */
+ long l; /* native signed long */
+ ulong_t ul; /* native unsigned long */
struct {
union {
- char *ptr; /* NULL-term string */
- char __pad[8]; /* 64-bit padding */
+ char *ptr; /* NULL-term string */
+ char __pad[8]; /* 64-bit padding */
} addr;
- uint32_t len; /* # bytes for strlen + '\0' */
- } str;
-/*
- * The int64_t and uint64_t types are not valid for a maximally conformant
- * 32-bit compilation environment (cc -Xc) using compilers prior to the
- * introduction of C99 conforming compiler (reference ISO/IEC 9899:1990).
- * In these cases, the visibility of i64 and ui64 is only permitted for
- * 64-bit compilation environments or 32-bit non-maximally conformant
- * C89 or C90 ANSI C compilation environments (cc -Xt and cc -Xa). In the
- * C99 ANSI C compilation environment, the long long type is supported.
- * The _INT64_TYPE is defined by the implementation (see sys/int_types.h).
- */
- int64_t i64;
- uint64_t ui64;
- long l;
- ulong_t ul;
-
- /* These structure members are obsolete */
-
- longlong_t ll;
- u_longlong_t ull;
- float f;
- double d;
- } value; /* value of counter */
+ uint32_t len; /* # bytes for strlen + '\0' */
+ } string;
+ } value;
} kstat_named_t;
-
-static __inline__ kstat_t *
-kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
- const char *ks_class, uchar_t ks_type, uint_t ks_ndata,
- uchar_t ks_flags)
-{
- return NULL;
-}
-
-static __inline__ void
-kstat_install(kstat_t *ksp)
-{
- return;
-}
-
-static __inline__ void
-kstat_delete(kstat_t *ksp)
-{
- return;
-}
+#define KSTAT_NAMED_STR_PTR(knptr) ((knptr)->value.string.addr.ptr)
+#define KSTAT_NAMED_STR_BUFLEN(knptr) ((knptr)->value.string.len)
+
+typedef struct kstat_intr {
+ uint_t intrs[KSTAT_NUM_INTRS];
+} kstat_intr_t;
+
+typedef struct kstat_io {
+ u_longlong_t nread; /* number of bytes read */
+ u_longlong_t nwritten; /* number of bytes written */
+ uint_t reads; /* number of read operations */
+ uint_t writes; /* number of write operations */
+ hrtime_t wtime; /* cumulative wait (pre-service) time */
+ hrtime_t wlentime; /* cumulative wait length*time product*/
+ hrtime_t wlastupdate; /* last time wait queue changed */
+ hrtime_t rtime; /* cumulative run (service) time */
+ hrtime_t rlentime; /* cumulative run length*time product */
+ hrtime_t rlastupdate; /* last time run queue changed */
+ uint_t wcnt; /* count of elements in wait state */
+ uint_t rcnt; /* count of elements in run state */
+} kstat_io_t;
+
+typedef struct kstat_timer {
+ char name[KSTAT_STRLEN+1]; /* event name */
+ u_longlong_t num_events; /* number of events */
+ hrtime_t elapsed_time; /* cumulative elapsed time */
+ hrtime_t min_time; /* shortest event duration */
+ hrtime_t max_time; /* longest event duration */
+ hrtime_t start_time; /* previous event start time */
+ hrtime_t stop_time; /* previous event stop time */
+} kstat_timer_t;
+
+int kstat_init(void);
+void kstat_fini(void);
+
+#ifdef DEBUG_KSTAT
+extern kstat_t *__kstat_create(const char *ks_module, int ks_instance,
+ const char *ks_name, const char *ks_class,
+ uchar_t ks_type, uint_t ks_ndata,
+ uchar_t ks_flags);
+extern void __kstat_install(kstat_t *ksp);
+extern void __kstat_delete(kstat_t *ksp);
+
+#define kstat_create(m,i,n,c,t,s,f) __kstat_create(m,i,n,c,t,s,f)
+#define kstat_install(k) __kstat_install(k)
+#define kstat_delete(k) __kstat_delete(k)
+
+#else
+
+#define kstat_create(m,i,n,c,t,s,f) (NULL)
+#define kstat_install(k) ((void)0)
+#define kstat_delete(k) ((void)0)
+
+#endif /* DEBUG_KSTAT */
#ifdef __cplusplus
}
diff --git a/include/sys/proc.h b/include/sys/proc.h
index e77ea5fb2..e76e4dbfa 100644
--- a/include/sys/proc.h
+++ b/include/sys/proc.h
@@ -2,6 +2,23 @@
#define _SPL_PROC_H
#include <linux/proc_fs.h>
+#include <linux/kmod.h>
+#include <linux/uaccess.h>
+#include <linux/ctype.h>
+#include <linux/sysctl.h>
+#include <linux/seq_file.h>
+#include <sys/sysmacros.h>
+#include <sys/kmem.h>
+#include <sys/mutex.h>
+#include <sys/kstat.h>
+#include <sys/debug.h>
+
+#ifdef DEBUG_KSTAT
+extern struct proc_dir_entry *proc_sys_spl_kstat;
+struct proc_dir_entry *proc_dir_entry_find(struct proc_dir_entry *root,
+ const char *str);
+int proc_dir_entries(struct proc_dir_entry *root);
+#endif
int proc_init(void);
void proc_fini(void);