xref: /onnv-gate/usr/src/lib/scsi/libsmp/common/libsmp.h (revision 13094:efddb0166961)
112126SHyon.Kim@Sun.COM /*
212126SHyon.Kim@Sun.COM  * CDDL HEADER START
312126SHyon.Kim@Sun.COM  *
412126SHyon.Kim@Sun.COM  * The contents of this file are subject to the terms of the
512126SHyon.Kim@Sun.COM  * Common Development and Distribution License (the "License").
612126SHyon.Kim@Sun.COM  * You may not use this file except in compliance with the License.
712126SHyon.Kim@Sun.COM  *
812126SHyon.Kim@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
912126SHyon.Kim@Sun.COM  * or http://www.opensolaris.org/os/licensing.
1012126SHyon.Kim@Sun.COM  * See the License for the specific language governing permissions
1112126SHyon.Kim@Sun.COM  * and limitations under the License.
1212126SHyon.Kim@Sun.COM  *
1312126SHyon.Kim@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
1412126SHyon.Kim@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1512126SHyon.Kim@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
1612126SHyon.Kim@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
1712126SHyon.Kim@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
1812126SHyon.Kim@Sun.COM  *
1912126SHyon.Kim@Sun.COM  * CDDL HEADER END
2012126SHyon.Kim@Sun.COM  */
2112126SHyon.Kim@Sun.COM 
2212126SHyon.Kim@Sun.COM /*
2312126SHyon.Kim@Sun.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2412126SHyon.Kim@Sun.COM  */
2512126SHyon.Kim@Sun.COM 
2612126SHyon.Kim@Sun.COM #ifndef	_LIBSMP_H
2712126SHyon.Kim@Sun.COM #define	_LIBSMP_H
2812126SHyon.Kim@Sun.COM 
2912126SHyon.Kim@Sun.COM #ifdef	__cplusplus
3012126SHyon.Kim@Sun.COM extern "C" {
3112126SHyon.Kim@Sun.COM #endif
3212126SHyon.Kim@Sun.COM 
3312126SHyon.Kim@Sun.COM #include <sys/types.h>
3412126SHyon.Kim@Sun.COM #include <sys/sysmacros.h>
3512126SHyon.Kim@Sun.COM #include <sys/scsi/impl/usmp.h>
3612126SHyon.Kim@Sun.COM #include <sys/scsi/generic/smp_frames.h>
3712126SHyon.Kim@Sun.COM #include <libnvpair.h>
3812126SHyon.Kim@Sun.COM #include <stdarg.h>
3912126SHyon.Kim@Sun.COM 
4012126SHyon.Kim@Sun.COM #define	LIBSMP_VERSION		1
4112126SHyon.Kim@Sun.COM 
4212126SHyon.Kim@Sun.COM #define	SMP_TARGET_C_LONG_RESP	0x01	/* Long response (SAS-2 10.4.3.4) */
4312126SHyon.Kim@Sun.COM #define	SMP_TARGET_C_ZONING	0x02	/* Zoning supported */
4412126SHyon.Kim@Sun.COM #define	SMP_TARGET_C_ZG_256	0x04	/* 256 zone groups supported */
4512126SHyon.Kim@Sun.COM 
4612126SHyon.Kim@Sun.COM typedef enum smp_errno {
4712126SHyon.Kim@Sun.COM 	ESMP_NONE,		/* no error */
4812126SHyon.Kim@Sun.COM 	ESMP_NOMEM,		/* no memory */
4912126SHyon.Kim@Sun.COM 	ESMP_ZERO_LENGTH,	/* zero-length allocation requested */
5012126SHyon.Kim@Sun.COM 	ESMP_VERSION,		/* library version mismatch */
5112126SHyon.Kim@Sun.COM 	ESMP_BADTARGET,		/* invalid target specification */
5212126SHyon.Kim@Sun.COM 	ESMP_BADFUNC,		/* invalid SMP function */
5312126SHyon.Kim@Sun.COM 	ESMP_BADENGINE,		/* engine library corrupt */
5412126SHyon.Kim@Sun.COM 	ESMP_NOENGINE,		/* engine library not found */
5512126SHyon.Kim@Sun.COM 	ESMP_ENGINE_INIT,	/* engine initialization failed */
5612126SHyon.Kim@Sun.COM 	ESMP_ENGINE_VER,	/* engine version mismatch */
5712126SHyon.Kim@Sun.COM 	ESMP_ENGINE_BADPATH,	/* engine path contains no usable components */
5812126SHyon.Kim@Sun.COM 	ESMP_BADLENGTH,		/* buffer length overflow or size error */
5912126SHyon.Kim@Sun.COM 	ESMP_NEEDBUF,		/* missing required buffer */
6012126SHyon.Kim@Sun.COM 	ESMP_PLUGIN,		/* no plugins found */
6112126SHyon.Kim@Sun.COM 	ESMP_IO,		/* I/O operation failed */
6212126SHyon.Kim@Sun.COM 	ESMP_SYS,		/* system call failed */
6312126SHyon.Kim@Sun.COM 	ESMP_PERM,		/* insufficient permissions */
6412126SHyon.Kim@Sun.COM 	ESMP_RANGE,		/* parameter outside valid range */
6512126SHyon.Kim@Sun.COM 	ESMP_NOTSUP,		/* operation not supported */
6612126SHyon.Kim@Sun.COM 	ESMP_UNKNOWN,		/* error of unknown type */
6712126SHyon.Kim@Sun.COM 	ESMP_REPGEN_FAILED,	/* initial report general command failed */
6812126SHyon.Kim@Sun.COM 	ESMP_MAX		/* maximum libsmp errno value */
6912126SHyon.Kim@Sun.COM } smp_errno_t;
7012126SHyon.Kim@Sun.COM 
7112126SHyon.Kim@Sun.COM typedef struct smp_target_def {
7212126SHyon.Kim@Sun.COM 	const char *std_engine;
7312126SHyon.Kim@Sun.COM 	const void *std_def;
7412126SHyon.Kim@Sun.COM } smp_target_def_t;
7512126SHyon.Kim@Sun.COM 
7612126SHyon.Kim@Sun.COM struct smp_target;
7712126SHyon.Kim@Sun.COM typedef struct smp_target smp_target_t;
7812126SHyon.Kim@Sun.COM 
7912126SHyon.Kim@Sun.COM struct smp_action;
8012126SHyon.Kim@Sun.COM typedef struct smp_action smp_action_t;
8112126SHyon.Kim@Sun.COM 
8212126SHyon.Kim@Sun.COM extern int smp_init(int);
8312126SHyon.Kim@Sun.COM extern void smp_fini(void);
8412126SHyon.Kim@Sun.COM 
8512126SHyon.Kim@Sun.COM extern smp_target_t *smp_open(const smp_target_def_t *);
8612126SHyon.Kim@Sun.COM extern uint_t smp_target_getcap(const smp_target_t *);
8712126SHyon.Kim@Sun.COM extern uint16_t smp_target_get_change_count(const smp_target_t *);
8812126SHyon.Kim@Sun.COM extern void smp_target_set_change_count(smp_target_t *, uint16_t);
89*13094Sdavid.hollister@oracle.com extern uint8_t smp_target_get_number_of_phys(const smp_target_t *);
90*13094Sdavid.hollister@oracle.com extern uint16_t smp_target_get_exp_route_indexes(const smp_target_t *);
9112126SHyon.Kim@Sun.COM extern const char *smp_target_vendor(const smp_target_t *);
9212126SHyon.Kim@Sun.COM extern const char *smp_target_product(const smp_target_t *);
9312126SHyon.Kim@Sun.COM extern const char *smp_target_revision(const smp_target_t *);
9412126SHyon.Kim@Sun.COM extern const char *smp_target_component_vendor(const smp_target_t *);
9512126SHyon.Kim@Sun.COM extern uint16_t smp_target_component_id(const smp_target_t *);
9612126SHyon.Kim@Sun.COM extern uint8_t smp_target_component_revision(const smp_target_t *);
9712126SHyon.Kim@Sun.COM extern void smp_target_name(const smp_target_t *, char *, size_t);
9812126SHyon.Kim@Sun.COM extern uint64_t smp_target_addr(const smp_target_t *);
9912126SHyon.Kim@Sun.COM extern void smp_close(smp_target_t *);
10012126SHyon.Kim@Sun.COM 
10112126SHyon.Kim@Sun.COM extern smp_errno_t smp_errno(void);
10212126SHyon.Kim@Sun.COM extern smp_errno_t smp_errcode(const char *);
10312126SHyon.Kim@Sun.COM extern const char *smp_errmsg(void);
10412126SHyon.Kim@Sun.COM extern const char *smp_strerror(smp_errno_t);
10512126SHyon.Kim@Sun.COM extern const char *smp_errname(smp_errno_t);
10612126SHyon.Kim@Sun.COM 
10712126SHyon.Kim@Sun.COM extern char *smp_trim_strdup(const char *, size_t);
10812126SHyon.Kim@Sun.COM 
10912126SHyon.Kim@Sun.COM extern smp_action_t *smp_action_alloc(smp_function_t, smp_target_t *, size_t);
11012126SHyon.Kim@Sun.COM extern smp_action_t *smp_action_xalloc(smp_function_t, smp_target_t *,
11112126SHyon.Kim@Sun.COM     void *, size_t, void *, size_t);
11212126SHyon.Kim@Sun.COM extern uint32_t smp_action_get_timeout(const smp_action_t *);
11312126SHyon.Kim@Sun.COM extern void smp_action_set_timeout(smp_action_t *, uint32_t);
11412126SHyon.Kim@Sun.COM extern void smp_action_get_request(const smp_action_t *, void **, size_t *);
11512126SHyon.Kim@Sun.COM extern void smp_action_get_response(const smp_action_t *,
11612126SHyon.Kim@Sun.COM     smp_result_t *, void **, size_t *);
11712126SHyon.Kim@Sun.COM extern int smp_exec(smp_action_t *, smp_target_t *);
11812126SHyon.Kim@Sun.COM extern void smp_action_free(smp_action_t *);
11912126SHyon.Kim@Sun.COM 
12012126SHyon.Kim@Sun.COM extern nvlist_t *smp_discover(const smp_target_def_t **, size_t);
12112126SHyon.Kim@Sun.COM extern nvlist_t *smp_discover_targets(smp_target_t **, size_t);
12212126SHyon.Kim@Sun.COM 
12312126SHyon.Kim@Sun.COM #ifdef	__cplusplus
12412126SHyon.Kim@Sun.COM }
12512126SHyon.Kim@Sun.COM #endif
12612126SHyon.Kim@Sun.COM 
12712126SHyon.Kim@Sun.COM #endif	/* _LIBSMP_H */
128