-#ifndef _SYS_KZT_H
-#define _SYS_KZT_H
-
-#ifdef _KERNEL
-#include <asm/ioctls.h>
-#include <asm/uaccess.h>
-#include <linux/list.h>
-#endif /* _KERNEL */
-
-#define KZT_VERSION "v1.0"
-#define KZT_VERSION_SIZE 64
-
-#define KZT_MAJOR 229 /* XXX - Arbitrary */
-#define KZT_MINORS 1
-#define KZT_DEV "/dev/kztctl"
-
-#define KZT_NAME_SIZE 12
-#define KZT_DESC_SIZE 60
-
-typedef struct kzt_user {
- char name[KZT_NAME_SIZE]; /* short name */
- char desc[KZT_DESC_SIZE]; /* short description */
- int id; /* unique numeric id */
-} kzt_user_t;
-
-#define KZT_CFG_MAGIC 0x15263748U
-typedef struct kzt_cfg {
- unsigned int cfg_magic; /* Unique magic */
- int cfg_cmd; /* Config command */
- int cfg_arg1; /* Config command arg 1 */
- int cfg_rc1; /* Config response 1 */
+/*****************************************************************************\
+ * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
+ * Copyright (C) 2007 The Regents of the University of California.
+ * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
+ * UCRL-CODE-235197
+ *
+ * This file is part of the SPL, Solaris Porting Layer.
+ * For details, see <http://zfsonlinux.org/>.
+ *
+ * The SPL is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * The SPL is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with the SPL. If not, see <http://www.gnu.org/licenses/>.
+\*****************************************************************************/
+
+#ifndef _SPLAT_CTL_H
+#define _SPLAT_CTL_H
+
+#include <linux/types.h>
+
+/*
+ * Contains shared definitions for both user space and kernel space. To
+ * ensure 32-bit/64-bit interoperability over ioctl()'s only types with
+ * fixed sizes can be used.
+ */
+#define SPLAT_NAME "splatctl"
+#define SPLAT_DEV "/dev/splatctl"
+
+#define SPLAT_NAME_SIZE 20
+#define SPLAT_DESC_SIZE 60
+
+typedef struct splat_user {
+ char name[SPLAT_NAME_SIZE]; /* Short name */
+ char desc[SPLAT_DESC_SIZE]; /* Short description */
+ __u32 id; /* Unique numeric id */
+} splat_user_t;
+
+#define SPLAT_CFG_MAGIC 0x15263748U
+typedef struct splat_cfg {
+ __u32 cfg_magic; /* Unique magic */
+ __u32 cfg_cmd; /* Configure command */
+ __s32 cfg_arg1; /* Configure command arg 1 */
+ __s32 cfg_rc1; /* Configure response 1 */
union {
struct {
- int size;
- kzt_user_t descs[0];
- } kzt_subsystems;
+ __u32 size;
+ splat_user_t descs[0];
+ } splat_subsystems;
struct {
- int size;
- kzt_user_t descs[0];
- } kzt_tests;
+ __u32 size;
+ splat_user_t descs[0];
+ } splat_tests;
} cfg_data;
-} kzt_cfg_t;
-
-#define KZT_CMD_MAGIC 0x9daebfc0U
-typedef struct kzt_cmd {
- unsigned int cmd_magic; /* Unique magic */
- int cmd_subsystem; /* Target subsystem */
- int cmd_test; /* Subsystem test */
- int cmd_data_size; /* Extra opaque data */
+} splat_cfg_t;
+
+#define SPLAT_CMD_MAGIC 0x9daebfc0U
+typedef struct splat_cmd {
+ __u32 cmd_magic; /* Unique magic */
+ __u32 cmd_subsystem; /* Target subsystem */
+ __u32 cmd_test; /* Subsystem test */
+ __u32 cmd_data_size; /* Opaque data size */
char cmd_data_str[0]; /* Opaque data region */
-} kzt_cmd_t;
+} splat_cmd_t;
/* Valid ioctls */
-#define KZT_CFG _IOWR('f', 101, long)
-#define KZT_CMD _IOWR('f', 102, long)
+#define SPLAT_CFG _IOWR('f', 101, splat_cfg_t)
+#define SPLAT_CMD _IOWR('f', 102, splat_cmd_t)
/* Valid configuration commands */
-#define KZT_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */
-#define KZT_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */
-#define KZT_CFG_SUBSYSTEM_COUNT 0x101 /* Number of subsystem */
-#define KZT_CFG_SUBSYSTEM_LIST 0x102 /* List of N subsystems */
-#define KZT_CFG_TEST_COUNT 0x201 /* Number of tests */
-#define KZT_CFG_TEST_LIST 0x202 /* List of N tests */
-
-/* Valid subsystem and test commands defined in each subsystem, we do
- * need to be careful to avoid colisions. That alone may argue to define
- * them all here, for now we just define the global error codes.
+#define SPLAT_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */
+#define SPLAT_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */
+#define SPLAT_CFG_SUBSYSTEM_COUNT 0x101 /* Number of subsystem */
+#define SPLAT_CFG_SUBSYSTEM_LIST 0x102 /* List of N subsystems */
+#define SPLAT_CFG_TEST_COUNT 0x201 /* Number of tests */
+#define SPLAT_CFG_TEST_LIST 0x202 /* List of N tests */
+
+/*
+ * Valid subsystem and test commands are defined in each subsystem as
+ * SPLAT_SUBSYSTEM_*. We do need to be careful to avoid collisions, the
+ * currently defined subsystems are as follows:
*/
-#define KZT_SUBSYSTEM_UNKNOWN 0xF00
-#define KZT_TEST_UNKNOWN 0xFFF
-
-
-#ifdef _KERNEL
-#define KZT_SUBSYSTEM_INIT(type) \
-({ kzt_subsystem_t *_sub_; \
- \
- _sub_ = (kzt_subsystem_t *)kzt_##type##_init(); \
- if (_sub_ == NULL) { \
- printk(KERN_ERR "Error initializing: " #type "\n"); \
- } else { \
- spin_lock(&kzt_module_lock); \
- list_add_tail(&(_sub_->subsystem_list), \
- &kzt_module_list); \
- spin_unlock(&kzt_module_lock); \
- } \
-})
-
-#define KZT_SUBSYSTEM_FINI(type) \
-({ kzt_subsystem_t *_sub_, *_tmp_; \
- int _id_, _flag_ = 0; \
- \
- _id_ = kzt_##type##_id(); \
- spin_lock(&kzt_module_lock); \
- list_for_each_entry_safe(_sub_, _tmp_, &kzt_module_list, \
- subsystem_list) { \
- if (_sub_->desc.id == _id_) { \
- list_del_init(&(_sub_->subsystem_list)); \
- spin_unlock(&kzt_module_lock); \
- kzt_##type##_fini(_sub_); \
- spin_lock(&kzt_module_lock); \
- _flag_ = 1; \
- } \
- } \
- spin_unlock(&kzt_module_lock); \
- \
- if (!_flag_) \
- printk(KERN_ERR "Error finalizing: " #type "\n"); \
-})
-
-#define KZT_TEST_INIT(sub, n, d, tid, func) \
-({ kzt_test_t *_test_; \
- \
- _test_ = (kzt_test_t *)kmalloc(sizeof(*_test_), GFP_KERNEL); \
- if (_test_ == NULL) { \
- printk(KERN_ERR "Error initializing: " n "/" #tid" \n");\
- } else { \
- memset(_test_, 0, sizeof(*_test_)); \
- strncpy(_test_->desc.name, n, KZT_NAME_SIZE); \
- strncpy(_test_->desc.desc, d, KZT_DESC_SIZE); \
- _test_->desc.id = tid; \
- _test_->test = func; \
- INIT_LIST_HEAD(&(_test_->test_list)); \
- spin_lock(&((sub)->test_lock)); \
- list_add_tail(&(_test_->test_list),&((sub)->test_list));\
- spin_unlock(&((sub)->test_lock)); \
- } \
-})
-
-#define KZT_TEST_FINI(sub, tid) \
-({ kzt_test_t *_test_, *_tmp_; \
- int _flag_ = 0; \
- \
- spin_lock(&((sub)->test_lock)); \
- list_for_each_entry_safe(_test_, _tmp_, \
- &((sub)->test_list), test_list) { \
- if (_test_->desc.id == tid) { \
- list_del_init(&(_test_->test_list)); \
- _flag_ = 1; \
- } \
- } \
- spin_unlock(&((sub)->test_lock)); \
- \
- if (!_flag_) \
- printk(KERN_ERR "Error finalizing: " #tid "\n"); \
-})
-
-typedef int (*kzt_test_func_t)(struct file *, void *);
-
-typedef struct kzt_test {
- struct list_head test_list;
- kzt_user_t desc;
- kzt_test_func_t test;
-} kzt_test_t;
-
-typedef struct kzt_subsystem {
- struct list_head subsystem_list;/* List had to chain entries */
- kzt_user_t desc;
- spinlock_t test_lock;
- struct list_head test_list;
-} kzt_subsystem_t;
-
-#define KZT_INFO_BUFFER_SIZE 65536
-#define KZT_INFO_BUFFER_REDZONE 256
-
-typedef struct kzt_info {
- spinlock_t info_lock;
- int info_size;
- char *info_buffer;
- char *info_head; /* Internal kernel use only */
-} kzt_info_t;
-
-#define sym2str(sym) (char *)(#sym)
-
-#define kzt_print(file, format, args...) \
-({ kzt_info_t *_info_ = (kzt_info_t *)file->private_data; \
- int _rc_; \
- \
- ASSERT(_info_); \
- ASSERT(_info_->info_buffer); \
- \
- spin_lock(&_info_->info_lock); \
- \
- /* Don't allow the kernel to start a write in the red zone */ \
- if ((int)(_info_->info_head - _info_->info_buffer) > \
- (KZT_INFO_BUFFER_SIZE -KZT_INFO_BUFFER_REDZONE)) { \
- _rc_ = -EOVERFLOW; \
- } else { \
- _rc_ = sprintf(_info_->info_head, format, args); \
- if (_rc_ >= 0) \
- _info_->info_head += _rc_; \
- } \
- \
- spin_unlock(&_info_->info_lock); \
- _rc_; \
-})
-
-#define kzt_vprint(file, test, format, args...) \
- kzt_print(file, "%*s: " format, KZT_NAME_SIZE, test, args)
-
-kzt_subsystem_t * kzt_condvar_init(void);
-kzt_subsystem_t * kzt_kmem_init(void);
-kzt_subsystem_t * kzt_mutex_init(void);
-kzt_subsystem_t * kzt_krng_init(void);
-kzt_subsystem_t * kzt_rwlock_init(void);
-kzt_subsystem_t * kzt_taskq_init(void);
-kzt_subsystem_t * kzt_thread_init(void);
-kzt_subsystem_t * kzt_time_init(void);
-
-#endif /* _KERNEL */
-
-#endif /* _SYS_KZT_H */
+#define SPLAT_SUBSYSTEM_KMEM 0x0100
+#define SPLAT_SUBSYSTEM_TASKQ 0x0200
+#define SPLAT_SUBSYSTEM_KRNG 0x0300
+#define SPLAT_SUBSYSTEM_MUTEX 0x0400
+#define SPLAT_SUBSYSTEM_CONDVAR 0x0500
+#define SPLAT_SUBSYSTEM_THREAD 0x0600
+#define SPLAT_SUBSYSTEM_RWLOCK 0x0700
+#define SPLAT_SUBSYSTEM_TIME 0x0800
+#define SPLAT_SUBSYSTEM_VNODE 0x0900
+#define SPLAT_SUBSYSTEM_KOBJ 0x0a00
+#define SPLAT_SUBSYSTEM_ATOMIC 0x0b00
+#define SPLAT_SUBSYSTEM_LIST 0x0c00
+#define SPLAT_SUBSYSTEM_GENERIC 0x0d00
+#define SPLAT_SUBSYSTEM_CRED 0x0e00
+#define SPLAT_SUBSYSTEM_ZLIB 0x0f00
+#define SPLAT_SUBSYSTEM_LINUX 0x1000
+#define SPLAT_SUBSYSTEM_UNKNOWN 0xff00
+
+#endif /* _SPLAT_CTL_H */