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