xref: /titanic_51/usr/src/lib/scsi/libscsi/common/libscsi_impl.h (revision 275c9da86e89f8abf71135cf63d9fc23671b2e60)
1*275c9da8Seschrock /*
2*275c9da8Seschrock  * CDDL HEADER START
3*275c9da8Seschrock  *
4*275c9da8Seschrock  * The contents of this file are subject to the terms of the
5*275c9da8Seschrock  * Common Development and Distribution License (the "License").
6*275c9da8Seschrock  * You may not use this file except in compliance with the License.
7*275c9da8Seschrock  *
8*275c9da8Seschrock  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*275c9da8Seschrock  * or http://www.opensolaris.org/os/licensing.
10*275c9da8Seschrock  * See the License for the specific language governing permissions
11*275c9da8Seschrock  * and limitations under the License.
12*275c9da8Seschrock  *
13*275c9da8Seschrock  * When distributing Covered Code, include this CDDL HEADER in each
14*275c9da8Seschrock  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*275c9da8Seschrock  * If applicable, add the following below this CDDL HEADER, with the
16*275c9da8Seschrock  * fields enclosed by brackets "[]" replaced with your own identifying
17*275c9da8Seschrock  * information: Portions Copyright [yyyy] [name of copyright owner]
18*275c9da8Seschrock  *
19*275c9da8Seschrock  * CDDL HEADER END
20*275c9da8Seschrock  */
21*275c9da8Seschrock 
22*275c9da8Seschrock /*
23*275c9da8Seschrock  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*275c9da8Seschrock  * Use is subject to license terms.
25*275c9da8Seschrock  */
26*275c9da8Seschrock 
27*275c9da8Seschrock #ifndef	_LIBSCSI_IMPL_H
28*275c9da8Seschrock #define	_LIBSCSI_IMPL_H
29*275c9da8Seschrock 
30*275c9da8Seschrock #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*275c9da8Seschrock 
32*275c9da8Seschrock #ifdef	__cplusplus
33*275c9da8Seschrock extern "C" {
34*275c9da8Seschrock #endif
35*275c9da8Seschrock 
36*275c9da8Seschrock #include <libscsi.h>
37*275c9da8Seschrock 
38*275c9da8Seschrock #define	LIBSCSI_ENGINE_EXT	".so"
39*275c9da8Seschrock 
40*275c9da8Seschrock #define	LIBSCSI_ERRMSGLEN	512
41*275c9da8Seschrock 
42*275c9da8Seschrock typedef struct libscsi_engine_impl {
43*275c9da8Seschrock 	const libscsi_engine_t *lsei_engine;
44*275c9da8Seschrock 	void *lsei_dl_hdl;
45*275c9da8Seschrock 	struct libscsi_engine_impl *lsei_next;
46*275c9da8Seschrock } libscsi_engine_impl_t;
47*275c9da8Seschrock 
48*275c9da8Seschrock typedef struct libscsi_action_impl {
49*275c9da8Seschrock 	libscsi_hdl_t *lsai_hdl;
50*275c9da8Seschrock 	uint_t lsai_flags;
51*275c9da8Seschrock 	uint32_t lsai_timeout;
52*275c9da8Seschrock 	uint8_t *lsai_cdb;
53*275c9da8Seschrock 	size_t lsai_cdb_len;
54*275c9da8Seschrock 	size_t lsai_data_len;
55*275c9da8Seschrock 	size_t lsai_data_alloc;
56*275c9da8Seschrock 	uint8_t *lsai_data;
57*275c9da8Seschrock 	sam4_status_t lsai_status;
58*275c9da8Seschrock 	size_t lsai_sense_len;
59*275c9da8Seschrock 	uint8_t *lsai_sense_data;
60*275c9da8Seschrock 	uint8_t lsai_buf[1];
61*275c9da8Seschrock } libscsi_action_impl_t;
62*275c9da8Seschrock 
63*275c9da8Seschrock struct libscsi_hdl {
64*275c9da8Seschrock 	uint_t lsh_version;
65*275c9da8Seschrock 	libscsi_errno_t lsh_errno;
66*275c9da8Seschrock 	char lsh_errmsg[LIBSCSI_ERRMSGLEN];
67*275c9da8Seschrock 	libscsi_engine_impl_t *lsh_engines;
68*275c9da8Seschrock 	uint_t lsh_targets;
69*275c9da8Seschrock };
70*275c9da8Seschrock 
71*275c9da8Seschrock struct libscsi_target {
72*275c9da8Seschrock 	const libscsi_engine_t *lst_engine;
73*275c9da8Seschrock 	char *lst_vendor;
74*275c9da8Seschrock 	char *lst_product;
75*275c9da8Seschrock 	char *lst_revision;
76*275c9da8Seschrock 	void *lst_priv;
77*275c9da8Seschrock 	uint_t lst_mtbf_cdb;
78*275c9da8Seschrock 	uint_t lst_mtbf_read;
79*275c9da8Seschrock 	uint_t lst_mtbf_write;
80*275c9da8Seschrock 	struct libscsi_hdl *lst_hdl;
81*275c9da8Seschrock };
82*275c9da8Seschrock 
83*275c9da8Seschrock #define	VERIFY(x)	((void)((x) || libscsi_assert(#x, __FILE__, __LINE__)))
84*275c9da8Seschrock 
85*275c9da8Seschrock #ifdef DEBUG
86*275c9da8Seschrock #define	ASSERT(x)	VERIFY(x)
87*275c9da8Seschrock #else
88*275c9da8Seschrock #define	ASSERT(x)
89*275c9da8Seschrock #endif
90*275c9da8Seschrock 
91*275c9da8Seschrock #define	LXOR(l, r)	(((l) != 0) ^ ((r) != 0))
92*275c9da8Seschrock 
93*275c9da8Seschrock extern int libscsi_assert(const char *, const char *, int);
94*275c9da8Seschrock extern int libscsi_get_inquiry(struct libscsi_hdl *, struct libscsi_target *);
95*275c9da8Seschrock 
96*275c9da8Seschrock #ifdef	__cplusplus
97*275c9da8Seschrock }
98*275c9da8Seschrock #endif
99*275c9da8Seschrock 
100*275c9da8Seschrock #endif	/* _LIBSCSI_IMPL_H */
101