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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #include <sys/types.h>
27 #include <sys/isa_defs.h>
28 #include <sys/systeminfo.h>
29 #include <sys/scsi/generic/commands.h>
30 #include <sys/scsi/impl/commands.h>
31 #include <sys/scsi/impl/uscsi.h>
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <stddef.h>
36 #include <string.h>
37 #include <dlfcn.h>
38 #include <limits.h>
39
40 #include <scsi/libscsi.h>
41 #include "libscsi_impl.h"
42
43 static const libscsi_engine_t *
181 if ((private = ep->lse_ops->lseo_open(hp, target)) == NULL) {
182 libscsi_free(hp, tp);
183 return (NULL);
184 }
185
186 scsi_parse_mtbf("LIBSCSI_MTBF_CDB", &tp->lst_mtbf_cdb);
187 scsi_parse_mtbf("LIBSCSI_MTBF_READ", &tp->lst_mtbf_read);
188 scsi_parse_mtbf("LIBSCSI_MTBF_WRITE", &tp->lst_mtbf_write);
189
190 tp->lst_hdl = hp;
191 tp->lst_engine = ep;
192 tp->lst_priv = private;
193
194 ++hp->lsh_targets;
195
196 if (libscsi_get_inquiry(hp, tp) != 0) {
197 libscsi_close(hp, tp);
198 return (NULL);
199 }
200
201 return (tp);
202 }
203
204 libscsi_hdl_t *
205 libscsi_get_handle(libscsi_target_t *tp)
206 {
207 return (tp->lst_hdl);
208 }
209
210 void
211 libscsi_close(libscsi_hdl_t *hp, libscsi_target_t *tp)
212 {
213 tp->lst_engine->lse_ops->lseo_close(hp, tp->lst_priv);
214 libscsi_free(hp, tp->lst_vendor);
215 libscsi_free(hp, tp->lst_product);
216 libscsi_free(hp, tp->lst_revision);
217 libscsi_free(hp, tp);
218 --hp->lsh_targets;
219 }
220
221 sam4_status_t
222 libscsi_action_get_status(const libscsi_action_t *ap)
223 {
224 const libscsi_action_impl_t *aip = (const libscsi_action_impl_t *)ap;
225
226 return (aip->lsai_status);
227 }
228
229 /*
230 * Set the timeout in seconds for this action. If no timeout is specified
231 * or if the timeout is set to 0, an implementation-specific timeout will be
232 * used (which may vary based on the target, command or other variables).
233 * Not all engines support all timeout values. Setting the timeout to a value
234 * not supported by the engine will cause engine-defined behavior when the
235 * action is executed.
236 */
|
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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
25 */
26
27 #include <sys/types.h>
28 #include <sys/isa_defs.h>
29 #include <sys/systeminfo.h>
30 #include <sys/scsi/generic/commands.h>
31 #include <sys/scsi/impl/commands.h>
32 #include <sys/scsi/impl/uscsi.h>
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <stddef.h>
37 #include <string.h>
38 #include <dlfcn.h>
39 #include <limits.h>
40
41 #include <scsi/libscsi.h>
42 #include "libscsi_impl.h"
43
44 static const libscsi_engine_t *
182 if ((private = ep->lse_ops->lseo_open(hp, target)) == NULL) {
183 libscsi_free(hp, tp);
184 return (NULL);
185 }
186
187 scsi_parse_mtbf("LIBSCSI_MTBF_CDB", &tp->lst_mtbf_cdb);
188 scsi_parse_mtbf("LIBSCSI_MTBF_READ", &tp->lst_mtbf_read);
189 scsi_parse_mtbf("LIBSCSI_MTBF_WRITE", &tp->lst_mtbf_write);
190
191 tp->lst_hdl = hp;
192 tp->lst_engine = ep;
193 tp->lst_priv = private;
194
195 ++hp->lsh_targets;
196
197 if (libscsi_get_inquiry(hp, tp) != 0) {
198 libscsi_close(hp, tp);
199 return (NULL);
200 }
201
202 if (libscsi_get_inquiry_dev_id(hp, tp) != 0)
203 tp->lst_lid = NULL;
204 if (libscsi_get_inquiry_usn(hp, tp) != 0)
205 tp->lst_usn = NULL;
206
207 return (tp);
208 }
209
210 libscsi_hdl_t *
211 libscsi_get_handle(libscsi_target_t *tp)
212 {
213 return (tp->lst_hdl);
214 }
215
216 void
217 libscsi_close(libscsi_hdl_t *hp, libscsi_target_t *tp)
218 {
219 tp->lst_engine->lse_ops->lseo_close(hp, tp->lst_priv);
220 libscsi_free(hp, tp->lst_vendor);
221 libscsi_free(hp, tp->lst_product);
222 libscsi_free(hp, tp->lst_revision);
223 if (tp->lst_lid != NULL)
224 libscsi_free(hp, tp->lst_lid);
225 if (tp->lst_usn != NULL)
226 libscsi_free(hp, tp->lst_usn);
227 libscsi_free(hp, tp);
228 --hp->lsh_targets;
229 }
230
231 sam4_status_t
232 libscsi_action_get_status(const libscsi_action_t *ap)
233 {
234 const libscsi_action_impl_t *aip = (const libscsi_action_impl_t *)ap;
235
236 return (aip->lsai_status);
237 }
238
239 /*
240 * Set the timeout in seconds for this action. If no timeout is specified
241 * or if the timeout is set to 0, an implementation-specific timeout will be
242 * used (which may vary based on the target, command or other variables).
243 * Not all engines support all timeout values. Setting the timeout to a value
244 * not supported by the engine will cause engine-defined behavior when the
245 * action is executed.
246 */
|