xref: /onnv-gate/usr/src/lib/scsi/libsmp/common/smp_impl.h (revision 12126:60364f3f65c7)
1*12126SHyon.Kim@Sun.COM /*
2*12126SHyon.Kim@Sun.COM  * CDDL HEADER START
3*12126SHyon.Kim@Sun.COM  *
4*12126SHyon.Kim@Sun.COM  * The contents of this file are subject to the terms of the
5*12126SHyon.Kim@Sun.COM  * Common Development and Distribution License (the "License").
6*12126SHyon.Kim@Sun.COM  * You may not use this file except in compliance with the License.
7*12126SHyon.Kim@Sun.COM  *
8*12126SHyon.Kim@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*12126SHyon.Kim@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*12126SHyon.Kim@Sun.COM  * See the License for the specific language governing permissions
11*12126SHyon.Kim@Sun.COM  * and limitations under the License.
12*12126SHyon.Kim@Sun.COM  *
13*12126SHyon.Kim@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*12126SHyon.Kim@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*12126SHyon.Kim@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*12126SHyon.Kim@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*12126SHyon.Kim@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*12126SHyon.Kim@Sun.COM  *
19*12126SHyon.Kim@Sun.COM  * CDDL HEADER END
20*12126SHyon.Kim@Sun.COM  */
21*12126SHyon.Kim@Sun.COM 
22*12126SHyon.Kim@Sun.COM /*
23*12126SHyon.Kim@Sun.COM  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24*12126SHyon.Kim@Sun.COM  */
25*12126SHyon.Kim@Sun.COM 
26*12126SHyon.Kim@Sun.COM #ifndef	_SMP_IMPL_H
27*12126SHyon.Kim@Sun.COM #define	_SMP_IMPL_H
28*12126SHyon.Kim@Sun.COM 
29*12126SHyon.Kim@Sun.COM #ifdef	__cplusplus
30*12126SHyon.Kim@Sun.COM extern "C" {
31*12126SHyon.Kim@Sun.COM #endif
32*12126SHyon.Kim@Sun.COM 
33*12126SHyon.Kim@Sun.COM #include <sys/scsi/generic/smp_frames.h>
34*12126SHyon.Kim@Sun.COM 
35*12126SHyon.Kim@Sun.COM #include <scsi/libsmp.h>
36*12126SHyon.Kim@Sun.COM #include <scsi/libsmp_plugin.h>
37*12126SHyon.Kim@Sun.COM 
38*12126SHyon.Kim@Sun.COM #include <pthread.h>
39*12126SHyon.Kim@Sun.COM 
40*12126SHyon.Kim@Sun.COM #define	LIBSMP_ERRMSGLEN	512
41*12126SHyon.Kim@Sun.COM 
42*12126SHyon.Kim@Sun.COM #define	LIBSMP_DEFAULT_PLUGINDIR	"/usr/lib/scsi/plugins/smp"
43*12126SHyon.Kim@Sun.COM #define	LIBSMP_PLUGIN_ENGINE		"engine"
44*12126SHyon.Kim@Sun.COM #define	LIBSMP_PLUGIN_FRAMEWORK		"framework"
45*12126SHyon.Kim@Sun.COM #define	LIBSMP_PLUGIN_VENDOR		"vendor"
46*12126SHyon.Kim@Sun.COM 
47*12126SHyon.Kim@Sun.COM #define	LIBSMP_PLUGIN_EXT		".so"
48*12126SHyon.Kim@Sun.COM 
49*12126SHyon.Kim@Sun.COM #define	LIBSMP_DEFAULT_ENGINE		"usmp"
50*12126SHyon.Kim@Sun.COM 
51*12126SHyon.Kim@Sun.COM struct smp_engine {
52*12126SHyon.Kim@Sun.COM 	char *se_name;
53*12126SHyon.Kim@Sun.COM 	const smp_engine_ops_t *se_ops;
54*12126SHyon.Kim@Sun.COM 	void *se_object;
55*12126SHyon.Kim@Sun.COM 	int (*se_init)(struct smp_engine *);
56*12126SHyon.Kim@Sun.COM 	void (*se_fini)(struct smp_engine *);
57*12126SHyon.Kim@Sun.COM 	uint_t se_refcnt;
58*12126SHyon.Kim@Sun.COM 	struct smp_engine *se_next;
59*12126SHyon.Kim@Sun.COM };
60*12126SHyon.Kim@Sun.COM 
61*12126SHyon.Kim@Sun.COM struct smp_plugin {
62*12126SHyon.Kim@Sun.COM 	struct smp_plugin *sp_next;
63*12126SHyon.Kim@Sun.COM 	struct smp_plugin *sp_prev;
64*12126SHyon.Kim@Sun.COM 	smp_target_t *sp_target;
65*12126SHyon.Kim@Sun.COM 	uint64_t sp_priority;
66*12126SHyon.Kim@Sun.COM 	void *sp_object;
67*12126SHyon.Kim@Sun.COM 	void *sp_data;
68*12126SHyon.Kim@Sun.COM 	boolean_t sp_initialized;
69*12126SHyon.Kim@Sun.COM 	const smp_function_def_t *sp_functions;
70*12126SHyon.Kim@Sun.COM 	int (*sp_init)(smp_plugin_t *);
71*12126SHyon.Kim@Sun.COM 	void (*sp_fini)(smp_plugin_t *);
72*12126SHyon.Kim@Sun.COM };
73*12126SHyon.Kim@Sun.COM 
74*12126SHyon.Kim@Sun.COM #define	SMP_ACTION_F_OFFSET		0x01
75*12126SHyon.Kim@Sun.COM #define	SMP_ACTION_F_EXEC		0x02
76*12126SHyon.Kim@Sun.COM #define	SMP_ACTION_F_DECODE		0x04
77*12126SHyon.Kim@Sun.COM 
78*12126SHyon.Kim@Sun.COM struct smp_action {
79*12126SHyon.Kim@Sun.COM 	uint32_t sa_timeout;
80*12126SHyon.Kim@Sun.COM 	const smp_function_def_t *sa_def;
81*12126SHyon.Kim@Sun.COM 	uint8_t *sa_request;
82*12126SHyon.Kim@Sun.COM 	size_t sa_request_rqsd;
83*12126SHyon.Kim@Sun.COM 	size_t sa_request_alloc_len;
84*12126SHyon.Kim@Sun.COM 	off_t sa_request_data_off;
85*12126SHyon.Kim@Sun.COM 	uint8_t *sa_response;
86*12126SHyon.Kim@Sun.COM 	size_t sa_response_alloc_len;
87*12126SHyon.Kim@Sun.COM 	size_t sa_response_engine_len;
88*12126SHyon.Kim@Sun.COM 	size_t sa_response_data_len;
89*12126SHyon.Kim@Sun.COM 	off_t sa_response_data_off;
90*12126SHyon.Kim@Sun.COM 	smp_result_t sa_result;
91*12126SHyon.Kim@Sun.COM 	uint_t sa_flags;
92*12126SHyon.Kim@Sun.COM 	uint_t sa_cap;
93*12126SHyon.Kim@Sun.COM 	uint8_t sa_buf[1];
94*12126SHyon.Kim@Sun.COM };
95*12126SHyon.Kim@Sun.COM 
96*12126SHyon.Kim@Sun.COM struct smp_target {
97*12126SHyon.Kim@Sun.COM 	smp_engine_t *st_engine;
98*12126SHyon.Kim@Sun.COM 	void *st_priv;
99*12126SHyon.Kim@Sun.COM 	uint_t st_mtbf_request;
100*12126SHyon.Kim@Sun.COM 	uint_t st_mtbf_response;
101*12126SHyon.Kim@Sun.COM 	uint16_t st_change_count;
102*12126SHyon.Kim@Sun.COM 	smp_plugin_t *st_plugin_first;
103*12126SHyon.Kim@Sun.COM 	smp_plugin_t *st_plugin_last;
104*12126SHyon.Kim@Sun.COM 	char *st_vendor;
105*12126SHyon.Kim@Sun.COM 	char *st_product;
106*12126SHyon.Kim@Sun.COM 	char *st_revision;
107*12126SHyon.Kim@Sun.COM 	char *st_component_vendor;
108*12126SHyon.Kim@Sun.COM 	uint16_t st_component_id;
109*12126SHyon.Kim@Sun.COM 	uint8_t st_component_revision;
110*12126SHyon.Kim@Sun.COM 	smp_report_general_resp_t st_repgen;
111*12126SHyon.Kim@Sun.COM };
112*12126SHyon.Kim@Sun.COM 
113*12126SHyon.Kim@Sun.COM extern void smp_engine_init(void);
114*12126SHyon.Kim@Sun.COM extern void smp_engine_fini(void);
115*12126SHyon.Kim@Sun.COM 
116*12126SHyon.Kim@Sun.COM extern int smp_plugin_load(smp_target_t *);
117*12126SHyon.Kim@Sun.COM extern void smp_plugin_unload(smp_target_t *);
118*12126SHyon.Kim@Sun.COM 
119*12126SHyon.Kim@Sun.COM #ifdef	__cplusplus
120*12126SHyon.Kim@Sun.COM }
121*12126SHyon.Kim@Sun.COM #endif
122*12126SHyon.Kim@Sun.COM 
123*12126SHyon.Kim@Sun.COM #endif	/* _SMP_IMPL_H */
124