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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
33 #include <sys/types.h>
36 #include <libnvpair.h>
39 #include <scsi/libscsi.h>
40 #include <scsi/plugins/ses/framework/ses2.h>
41 #include <scsi/plugins/ses/framework/libses.h>
43 #define LIBSES_VERSION 1
46 * element type prop can be created by any plugin. The ses2 plugin created
47 * SES-2 defined element types and SUN plugin defines vendor specific types.
49 #define SES_PROP_ELEMENT_TYPE "ses-element-type"
51 typedef enum ses_node_type
{
53 SES_NODE_TARGET
= 0x1,
54 SES_NODE_ENCLOSURE
= 0x2,
55 SES_NODE_AGGREGATE
= 0x4,
56 SES_NODE_ELEMENT
= 0x8
59 typedef enum ses_errno
{
60 ESES_NONE
, /* no error */
61 ESES_NOMEM
, /* no memory */
62 ESES_ZERO_LENGTH
, /* zero-length allocation requested */
63 ESES_VERSION
, /* library version mismatch */
64 ESES_NVL
, /* nvlist manipulation error */
65 ESES_BAD_NODE
, /* bad node */
66 ESES_INVALID_OP
, /* invalid operation */
67 ESES_RANGE
, /* value out of range */
68 ESES_INVALID_PROP
, /* nonexistent or immutable property */
69 ESES_BAD_TYPE
, /* incorrect property type */
70 ESES_BAD_PAGE
, /* bad page number */
71 ESES_BAD_RESPONSE
, /* bad response from target */
72 ESES_BUSY
, /* target busy */
73 ESES_TOOMUCHCHANGE
, /* target configuration changing too rapidly */
74 ESES_LIBSCSI
, /* SCSI error */
75 ESES_NOTSUP
, /* operation not supported */
76 ESES_UNKNOWN
, /* error of unknown type */
77 ESES_CHANGED
, /* generation count has changed */
78 ESES_PLUGIN
, /* invalid or missing plugin */
79 ESES_MAX
/* maximum libses errno value */
83 typedef struct ses_target ses_target_t
;
86 typedef struct ses_snap ses_snap_t
;
89 typedef struct ses_node ses_node_t
;
91 extern ses_target_t
*ses_open(uint_t
, const char *);
92 extern ses_target_t
*ses_open_scsi(uint_t
, libscsi_target_t
*);
93 extern void ses_close(ses_target_t
*);
95 extern libscsi_target_t
*ses_scsi_target(ses_target_t
*);
97 typedef enum ses_walk_action
{
98 SES_WALK_ACTION_CONTINUE
,
99 SES_WALK_ACTION_PRUNE
,
100 SES_WALK_ACTION_TERMINATE
103 typedef ses_walk_action_t (*ses_walk_f
)(ses_node_t
*, void *);
105 extern uint64_t ses_node_id(ses_node_t
*);
106 extern ses_node_t
*ses_node_lookup(ses_snap_t
*, uint64_t);
108 extern ses_node_t
*ses_root_node(ses_snap_t
*);
109 extern ses_node_t
*ses_node_sibling(ses_node_t
*);
110 extern ses_node_t
*ses_node_prev_sibling(ses_node_t
*);
111 extern ses_node_t
*ses_node_child(ses_node_t
*);
112 extern ses_node_t
*ses_node_parent(ses_node_t
*);
113 extern int ses_walk(ses_snap_t
*, ses_walk_f
, void *);
115 extern ses_snap_t
*ses_snap_hold(ses_target_t
*);
116 extern void ses_snap_rele(ses_snap_t
*);
117 extern ses_snap_t
*ses_snap_new(ses_target_t
*);
118 extern uint32_t ses_snap_generation(ses_snap_t
*);
120 extern ses_node_type_t
ses_node_type(ses_node_t
*);
121 extern nvlist_t
*ses_node_props(ses_node_t
*);
122 extern int ses_node_ctl(ses_node_t
*, const char *, nvlist_t
*);
123 extern ses_snap_t
*ses_node_snapshot(ses_node_t
*);
124 extern ses_target_t
*ses_node_target(ses_node_t
*);
126 extern ses_errno_t
ses_errno(void);
127 extern const char *ses_errmsg(void);
128 extern const char *ses_strerror(ses_errno_t
);
129 extern const char *ses_nv_error_member(void);
131 extern ses_node_t
*ses_snap_primary_enclosure(ses_snap_t
*);
137 #endif /* _LIBSES_H */