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.
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.
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]
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
26 #ifndef _LIBSMP_PLUGIN_H
27 #define _LIBSMP_PLUGIN_H
33 #include <sys/scsi/generic/smp_frames.h>
34 #include <scsi/libsmp.h>
38 #define LIBSMP_PLUGIN_VERSION 1
39 #define LIBSMP_ENGINE_VERSION 1
41 #ifndef SMP_REQ_MINLEN
42 #define SMP_REQ_MINLEN \
43 (offsetof(smp_request_frame_t, srf_data[0]) + sizeof (smp_crc_t))
45 #ifndef SMP_RESP_MINLEN
46 #define SMP_RESP_MINLEN \
47 (offsetof(smp_response_frame_t, srf_data[0]) + sizeof (smp_crc_t))
50 #define VERIFY(x) ((void)((x) || smp_assert(#x, __FILE__, __LINE__)))
53 #define ASSERT(x) VERIFY(x)
59 typedef struct smp_engine smp_engine_t
;
62 typedef struct smp_plugin smp_plugin_t
;
64 typedef struct smp_engine_ops
{
65 void *(*seo_open
)(const void *);
66 void (*seo_close
)(void *);
67 int (*seo_exec
)(void *, smp_action_t
*);
68 void (*seo_target_name
)(void *, char *, size_t);
69 uint64_t (*seo_target_addr
)(void *);
72 typedef struct smp_engine_config
{
74 const smp_engine_ops_t
*sec_ops
;
75 } smp_engine_config_t
;
77 #define SMP_FD_F_NEEDS_CHANGE_COUNT 0x0001
78 #define SMP_FD_F_PROVIDES_CHANGE_COUNT 0x0002
79 #define SMP_FD_F_READ 0x0004
80 #define SMP_FD_F_WRITE 0x0008
82 typedef struct smp_function_def
{
83 smp_function_t sfd_function
;
87 size_t (*sfd_rq_len
)(size_t, smp_target_t
*);
88 off_t (*sfd_rq_dataoff
)(smp_action_t
*, smp_target_t
*);
89 void (*sfd_rq_setframe
)(smp_action_t
*, smp_target_t
*);
90 size_t (*sfd_rs_datalen
)(smp_action_t
*, smp_target_t
*);
91 off_t (*sfd_rs_dataoff
)(smp_action_t
*, smp_target_t
*);
92 void (*sfd_rs_getparams
)(smp_action_t
*, smp_target_t
*);
95 typedef struct smp_plugin_config
{
97 smp_function_def_t
*spc_functions
;
98 } smp_plugin_config_t
;
100 extern int smp_assert(const char *, const char *, int);
102 extern void *smp_alloc(size_t);
103 extern void *smp_zalloc(size_t);
104 extern char *smp_strdup(const char *);
105 extern void smp_free(void *);
107 extern int smp_set_errno(smp_errno_t
);
108 extern int smp_verror(smp_errno_t
, const char *, va_list);
109 extern int smp_error(smp_errno_t
, const char *, ...);
111 extern void smp_action_get_request_frame(const smp_action_t
*,
113 extern void smp_action_get_response_frame(const smp_action_t
*,
115 extern void smp_action_set_response_len(smp_action_t
*, size_t);
116 extern void smp_action_set_result(smp_action_t
*, smp_result_t
);
117 extern const smp_function_def_t
*smp_action_get_function_def(
118 const smp_action_t
*);
120 extern int smp_engine_register(smp_engine_t
*, int,
121 const smp_engine_config_t
*);
123 extern int smp_plugin_register(smp_plugin_t
*, int,
124 const smp_plugin_config_t
*);
125 extern void smp_plugin_setspecific(smp_plugin_t
*, void *);
126 extern void *smp_plugin_getspecific(smp_plugin_t
*);
132 #endif /* _LIBSMP_PLUGIN_H */