xref: /illumos-gate/usr/src/uts/common/io/scsi/impl/scsi_control.c (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1996-2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * Generic Abort, Reset and Misc Routines
31  */
32 
33 #include <sys/scsi/scsi.h>
34 
35 
36 #define	A_TO_TRAN(ap)	(ap->a_hba_tran)
37 
38 int
39 scsi_abort(struct scsi_address *ap, struct scsi_pkt *pkt)
40 {
41 	return (*A_TO_TRAN(ap)->tran_abort)(ap, pkt);
42 }
43 
44 int
45 scsi_reset(struct scsi_address *ap, int level)
46 {
47 	ASSERT((level == RESET_LUN) || (level == RESET_TARGET) ||
48 	    (level == RESET_ALL));
49 	if ((level == RESET_LUN) &&
50 	    ((*A_TO_TRAN(ap)->tran_getcap)(ap, "lun-reset", 1) != 1)) {
51 		return (0);
52 	}
53 	return (*A_TO_TRAN(ap)->tran_reset)(ap, level);
54 }
55 
56 int
57 scsi_reset_notify(struct scsi_address *ap, int flag,
58 	void (*callback)(caddr_t), caddr_t arg)
59 {
60 	if ((A_TO_TRAN(ap)->tran_reset_notify) == NULL) {
61 		return (DDI_FAILURE);
62 	}
63 	return (*A_TO_TRAN(ap)->tran_reset_notify)(ap, flag, callback, arg);
64 }
65 
66 int
67 scsi_clear_task_set(struct scsi_address *ap)
68 {
69 	if ((A_TO_TRAN(ap)->tran_clear_task_set) == NULL) {
70 		return (-1);
71 	}
72 	return (*A_TO_TRAN(ap)->tran_clear_task_set)(ap);
73 }
74 
75 int
76 scsi_terminate_task(struct scsi_address *ap, struct scsi_pkt *pkt)
77 {
78 	if ((A_TO_TRAN(ap)->tran_terminate_task) == NULL) {
79 		return (-1);
80 	}
81 	return (*A_TO_TRAN(ap)->tran_terminate_task)(ap, pkt);
82 }
83 
84 /*
85  * Other Misc Routines
86  */
87 
88 int
89 scsi_clear_aca(struct scsi_address *ap)
90 {
91 	if ((A_TO_TRAN(ap)->tran_clear_aca) == NULL) {
92 		return (-1);
93 	}
94 	return (*A_TO_TRAN(ap)->tran_clear_aca)(ap);
95 }
96