Print this page
NEX-3705 Need to update libses with LID/USN code from sesctld
Reviewed by: Dan Fields <dan.fields@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/lib/scsi/libscsi/common/libscsi.h
+++ new/usr/src/lib/scsi/libscsi/common/libscsi.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 + * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24 25 */
25 26
26 27 #ifndef _LIBSCSI_H
27 28 #define _LIBSCSI_H
28 29
29 30 #ifdef __cplusplus
30 31 extern "C" {
31 32 #endif
32 33
33 34 #include <sys/types.h>
34 35 #include <sys/sysmacros.h>
35 36 #include <sys/scsi/impl/spc3_types.h>
36 37 #include <stdarg.h>
37 38
38 39 #define LIBSCSI_VERSION 1
39 40 #define LIBSCSI_STATUS_INVALID ((sam4_status_t)-1)
40 41 #define LIBSCSI_DEFAULT_ENGINE_PATH "/usr/lib/scsi/plugins/scsi/engines"
41 42 #define LIBSCSI_DEFAULT_ENGINE "uscsi"
42 43
43 44 /*
44 45 * Flags for action creation. Selected to avoid overlap with the uscsi
45 46 * flags with similar or identical meaning.
46 47 */
47 48 #define LIBSCSI_AF_READ 0x80000000
48 49 #define LIBSCSI_AF_WRITE 0x40000000
49 50 #define LIBSCSI_AF_SILENT 0x20000000
50 51 #define LIBSCSI_AF_DIAGNOSE 0x10000000
51 52 #define LIBSCSI_AF_ISOLATE 0x08000000
52 53 #define LIBSCSI_AF_RQSENSE 0x04000000
53 54
54 55 typedef enum libscsi_errno {
55 56 ESCSI_NONE, /* no error */
56 57 ESCSI_NOMEM, /* no memory */
57 58 ESCSI_ZERO_LENGTH, /* zero-length allocation requested */
58 59 ESCSI_VERSION, /* library version mismatch */
59 60 ESCSI_BADTARGET, /* invalid target specification */
60 61 ESCSI_BADCMD, /* invalid SCSI command */
61 62 ESCSI_BADENGINE, /* engine library corrupt */
62 63 ESCSI_NOENGINE, /* engine library not found */
63 64 ESCSI_ENGINE_INIT, /* engine initialization failed */
64 65 ESCSI_ENGINE_VER, /* engine version mismatch */
65 66 ESCSI_ENGINE_BADPATH, /* engine path contains no usable components */
66 67 ESCSI_BADFLAGS, /* incorrect action flags */
67 68 ESCSI_BOGUSFLAGS, /* unknown flag value */
68 69 ESCSI_BADLENGTH, /* buffer length overflow */
69 70 ESCSI_NEEDBUF, /* missing required buffer */
70 71 ESCSI_IO, /* I/O operation failed */
71 72 ESCSI_SYS, /* system call failed */
72 73 ESCSI_PERM, /* insufficient permissions */
73 74 ESCSI_RANGE, /* parameter outside valid range */
74 75 ESCSI_NOTSUP, /* operation not supported */
75 76 ESCSI_UNKNOWN, /* error of unknown type */
76 77 ESCSI_INQUIRY_FAILED, /* initial inquiry command failed */
77 78 ESCSI_MAX /* maximum libscsi errno value */
78 79 } libscsi_errno_t;
79 80
80 81 struct libscsi_hdl;
81 82 typedef struct libscsi_hdl libscsi_hdl_t;
82 83
83 84 struct libscsi_target;
84 85 typedef struct libscsi_target libscsi_target_t;
85 86
86 87 typedef struct libscsi_status {
87 88 uint64_t lss_status; /* SCSI status of this command */
88 89 size_t lss_sense_len; /* Length in bytes of sense data */
89 90 uint8_t *lss_sense_data; /* Pointer to sense data */
90 91 } libscsi_status_t;
91 92
92 93 struct libscsi_action;
93 94 typedef struct libscsi_action libscsi_action_t;
94 95
95 96 typedef struct libscsi_engine_ops {
96 97 void *(*lseo_open)(libscsi_hdl_t *, const void *);
97 98 void (*lseo_close)(libscsi_hdl_t *, void *);
98 99 int (*lseo_exec)(libscsi_hdl_t *, void *, libscsi_action_t *);
99 100 void (*lseo_target_name)(libscsi_hdl_t *, void *, char *, size_t);
100 101 } libscsi_engine_ops_t;
101 102
102 103 typedef struct libscsi_engine {
103 104 const char *lse_name;
104 105 uint_t lse_libversion;
105 106 const libscsi_engine_ops_t *lse_ops;
106 107 } libscsi_engine_t;
107 108
108 109 extern libscsi_hdl_t *libscsi_init(uint_t, libscsi_errno_t *);
|
↓ open down ↓ |
75 lines elided |
↑ open up ↑ |
109 110 extern void libscsi_fini(libscsi_hdl_t *);
110 111
111 112 extern libscsi_target_t *libscsi_open(libscsi_hdl_t *, const char *,
112 113 const void *);
113 114 extern void libscsi_close(libscsi_hdl_t *, libscsi_target_t *);
114 115 extern libscsi_hdl_t *libscsi_get_handle(libscsi_target_t *);
115 116
116 117 extern const char *libscsi_vendor(libscsi_target_t *);
117 118 extern const char *libscsi_product(libscsi_target_t *);
118 119 extern const char *libscsi_revision(libscsi_target_t *);
120 +extern const char *libscsi_lid(libscsi_target_t *);
121 +extern const char *libscsi_usn(libscsi_target_t *);
119 122
120 123 extern libscsi_errno_t libscsi_errno(libscsi_hdl_t *);
121 124 extern const char *libscsi_errmsg(libscsi_hdl_t *);
122 125 extern const char *libscsi_strerror(libscsi_errno_t);
123 126 extern const char *libscsi_errname(libscsi_errno_t);
124 127 extern libscsi_errno_t libscsi_errcode(const char *);
125 128
126 129 extern libscsi_action_t *libscsi_action_alloc(libscsi_hdl_t *, spc3_cmd_t,
127 130 uint_t, void *, size_t);
128 131 extern sam4_status_t libscsi_action_get_status(const libscsi_action_t *);
129 132 extern void libscsi_action_set_timeout(libscsi_action_t *, uint32_t);
130 133 extern uint32_t libscsi_action_get_timeout(const libscsi_action_t *);
131 134 extern uint_t libscsi_action_get_flags(const libscsi_action_t *);
132 135 extern uint8_t *libscsi_action_get_cdb(const libscsi_action_t *);
133 136 extern int libscsi_action_get_buffer(const libscsi_action_t *,
134 137 uint8_t **, size_t *, size_t *);
135 138 extern int libscsi_action_get_sense(const libscsi_action_t *,
136 139 uint8_t **, size_t *, size_t *);
137 140 extern int libscsi_action_parse_sense(const libscsi_action_t *, uint64_t *,
138 141 uint64_t *, uint64_t *, diskaddr_t *);
139 142 extern void libscsi_action_set_status(libscsi_action_t *, sam4_status_t);
140 143 extern int libscsi_action_set_datalen(libscsi_action_t *, size_t);
141 144 extern int libscsi_action_set_senselen(libscsi_action_t *, size_t);
142 145 extern int libscsi_exec(libscsi_action_t *, libscsi_target_t *);
143 146 extern void libscsi_action_free(libscsi_action_t *);
144 147
145 148 extern const char *libscsi_sense_key_name(uint64_t);
146 149 extern const char *libscsi_sense_code_name(uint64_t, uint64_t);
147 150
148 151 /*
149 152 * Interfaces for engine providers
150 153 */
151 154 extern void *libscsi_alloc(libscsi_hdl_t *, size_t);
152 155 extern void *libscsi_zalloc(libscsi_hdl_t *, size_t);
153 156 extern char *libscsi_strdup(libscsi_hdl_t *, const char *);
154 157 extern void libscsi_free(libscsi_hdl_t *, void *);
155 158 extern libscsi_status_t *libscsi_status_alloc(libscsi_hdl_t *, size_t);
156 159 extern int libscsi_status_fill(libscsi_hdl_t *, libscsi_status_t *,
157 160 uint16_t, size_t);
158 161 extern void libscsi_status_free(libscsi_hdl_t *, libscsi_status_t *);
159 162
160 163 extern int libscsi_set_errno(libscsi_hdl_t *, libscsi_errno_t);
161 164 extern int libscsi_verror(libscsi_hdl_t *, libscsi_errno_t, const char *,
162 165 va_list);
163 166 extern int libscsi_error(libscsi_hdl_t *, libscsi_errno_t, const char *, ...);
164 167
165 168 typedef const libscsi_engine_t *(*libscsi_engine_init_f)(libscsi_hdl_t *);
166 169
167 170 /*
168 171 * Generic SCSI utility functions.
169 172 */
170 173 extern size_t libscsi_cmd_cdblen(libscsi_hdl_t *, uint8_t);
171 174
172 175 #ifdef __cplusplus
173 176 }
174 177 #endif
175 178
176 179 #endif /* _LIBSCSI_H */
|
↓ open down ↓ |
48 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX