nsctl.h revision fcf3ce441efd61da9bb2884968af01cb7c1452cc
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#if (defined(lint) || defined(OSDEBUG)) && defined(_KERNEL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nsctl multi-terabyte volume support
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * To build a multi-terabyte stack, '#define NSC_MULTI_TERABYTE'.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef uint64_t nsc_off_t; /* positions, offsets */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#else /* max 1TB volume size */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Generic parameter definition.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct nsc_def_s {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_decode_param(nsc_def_t *, nsc_def_t *, long *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ID and Type flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_DEVICE 0x00000200 /* Device interface */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_FILE 0x00000400 /* File vnode interface */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_CACHE 0x00000800 /* Cache interface */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_ANON 0x00001000 /* Supports anonymous buffers */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_VCHR 0x00002000 /* VCHR vnode device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_NCALL 0x00004000 /* ncall-io interface */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_FILE_ID NSC_MKID(40) /* File vnode device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_FREEZE_ID NSC_MKID(41) /* Frozen raw device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_VCHR_ID NSC_MKID(42) /* VCHR vnode device */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_SDBC_ID NSC_MKID(80) /* Block based cache */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_RDCLR_ID NSC_MKID(94) /* RDC (low, raw) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_RDCL_ID NSC_MKID(95) /* RDC (low, cache) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_IIR_ID NSC_MKID(96) /* Instant Image (raw) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_II_ID NSC_MKID(98) /* Instant Image */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_RDCHR_ID NSC_MKID(99) /* RDC (high, raw) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_RDCH_ID NSC_MKID(100) /* RDC (high, cache) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* with timeleft (rideout) minutes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Power_OK, /* Power OK or restored before death */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* be shutdown, save any state */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Module Flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_REFCNT 0x00000001 /* Counts references */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_FILTER 0x00000002 /* Uses lower level driver */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nsc_io_t *nsc_register_io(char *, int, nsc_def_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nsc_path_t *nsc_register_path(char *, int, nsc_io_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_unregister_path(nsc_path_t *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_cache_sizes(int *, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_node_hints(unsigned int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_node_hints_set(unsigned int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern blind_t nsc_register_power(char *, nsc_def_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Strategy function interface
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Block sizes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FBA_SIZE(x) ((x) << FBA_SHFT) /* fba to bytes */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FBA_OFF(x) ((x) & FBA_MASK) /* byte offset */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FBA_LEN(x) FBA_NUM((x) + FBA_MASK) /* len to fba */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define FBA_NUM(x) ((nsc_size_t)((uint64_t)(x) >> FBA_SHFT))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* bytes to fba */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Return values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * External file descriptor.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL || _KMEMUSER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_TRY (1<<24) /* Conditional operation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_NOWAIT (1<<28) /* Don't wait if busy */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nsc_fd_t *nsc_open(char *, int, nsc_def_t *, blind_t, int *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_fdpathcmp(nsc_fd_t *, uint64_t, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_set_trksize(nsc_fd_t *, nsc_size_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_discard_pinned(nsc_fd_t *, nsc_off_t, nsc_size_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_partsize(nsc_fd_t *, nsc_size_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_maxfbas(nsc_fd_t *, int, nsc_size_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_max_devices(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_control(nsc_fd_t *, int, void *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * I/O device structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct nsc_iodev_s { int x; } nsc_iodev_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_set_owner(nsc_fd_t *, nsc_iodev_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_pinned_data(nsc_iodev_t *, nsc_off_t, nsc_size_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_unpinned_data(nsc_iodev_t *, nsc_off_t, nsc_size_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Data structures used by I/O interface.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct nsc_vec_s { /* Scatter gather element */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *sv_addr; /* Virtual address of data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nsc_size_t sb_len; /* Length of data in blocks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL || _KMEMUSER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Allocate flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Other flags */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_CACHEBLK 0x0008 /* nsc_maxfbas: size of cache block in fbas */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_HALLOCATED 0x0010 /* handle allocated (IO provider internals) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_HACTIVE 0x0020 /* handle active (IO provider internals) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_BCOPY 0x0040 /* bcopy, don't DMA when moving data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_PAGEIO 0x0080 /* client will use handle for pageio */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_ABUF 0x0100 /* anonymous buffer handle */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_MIXED 0x0200 /* data from 2 devs is mixed in this buffer */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_NODATA 0x0400 /* allocate without data buffer (sb_vec) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_ANON_CD ((blind_t)(-1)) /* used for IO provider alloc buf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_alloc_buf(nsc_fd_t *, nsc_off_t, nsc_size_t, int, nsc_buf_t **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_alloc_abuf(nsc_off_t, nsc_size_t, int, nsc_buf_t **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_read(nsc_buf_t *, nsc_off_t, nsc_size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_write(nsc_buf_t *, nsc_off_t, nsc_size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_zero(nsc_buf_t *, nsc_off_t, nsc_size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_copy(nsc_buf_t *, nsc_buf_t *, nsc_off_t, nsc_off_t, nsc_size_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_copy_direct(nsc_buf_t *, nsc_buf_t *, nsc_off_t,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_uncommit(nsc_buf_t *, nsc_off_t, nsc_size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte void (*)(), void (*)(), void (*)());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_uwrite(nsc_fd_t *, void *, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Performance hints.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * node hint actions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reflective memory spinlocks.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef struct nsc_rmlock_s { int x; } nsc_rmlock_t;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nsc_rmlock_t *nsc_rm_lock_alloc(char *, int, void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Memory allocation routines.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nsc_mem_t *nsc_register_mem(char *, int, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void *nsc_kmem_alloc(size_t, int, nsc_mem_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void *nsc_kmem_zalloc(size_t, int, nsc_mem_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_mem_sizes(nsc_mem_t *, size_t *, size_t *, size_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* nvmem suppport */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortetypedef void (*nsc_mem_err_cb) (void *, void *, size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_commit_mem(void *, void *, size_t, nsc_mem_err_cb);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_cm_errhdlr(void *, void *, size_t, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Max pathname
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Note: Currently defined both here and in nsc_dev.h
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Inter-module function (callback) services
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern nsc_svc_t *nsc_register_svc(char *, void (*)(intptr_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * String manipulation functions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* sun */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *nsc_strdup(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_strfree(char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_strmatch(char *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_sprintf(char *, char *, ...);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Macro definitions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * External definitions.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_node_id(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern char *nsc_node_name(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_node_up(int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_yield(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_membar_stld(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_create_process(void (*)(void *), void *, boolean_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_power_init(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_power_deinit(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern int nsc_nodeid_data(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define NSC_ALERT_DOWN 3 /* System or Module down */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void nsc_do_sysevent(char *, char *, int, int, char *, dev_info_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Missing DDI/DKI definition.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern void *nsc_threadp(void);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _KERNEL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common defines
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * kstat definition
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define KSTAT_DATA_CHAR_LEN (sizeof (((kstat_named_t *)0)->value.c))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#endif /* _SYS_NSCTL_H */