10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*10696SDavid.Hollister@Sun.COM * Common Development and Distribution License (the "License").
6*10696SDavid.Hollister@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*10696SDavid.Hollister@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate /*
270Sstevel@tonic-gate * Generic Abort, Reset and Misc Routines
280Sstevel@tonic-gate */
290Sstevel@tonic-gate
300Sstevel@tonic-gate #include <sys/scsi/scsi.h>
310Sstevel@tonic-gate
320Sstevel@tonic-gate
330Sstevel@tonic-gate #define A_TO_TRAN(ap) (ap->a_hba_tran)
340Sstevel@tonic-gate
350Sstevel@tonic-gate int
scsi_abort(struct scsi_address * ap,struct scsi_pkt * pkt)360Sstevel@tonic-gate scsi_abort(struct scsi_address *ap, struct scsi_pkt *pkt)
370Sstevel@tonic-gate {
380Sstevel@tonic-gate return (*A_TO_TRAN(ap)->tran_abort)(ap, pkt);
390Sstevel@tonic-gate }
400Sstevel@tonic-gate
410Sstevel@tonic-gate int
scsi_reset(struct scsi_address * ap,int level)420Sstevel@tonic-gate scsi_reset(struct scsi_address *ap, int level)
430Sstevel@tonic-gate {
440Sstevel@tonic-gate ASSERT((level == RESET_LUN) || (level == RESET_TARGET) ||
450Sstevel@tonic-gate (level == RESET_ALL));
460Sstevel@tonic-gate if ((level == RESET_LUN) &&
470Sstevel@tonic-gate ((*A_TO_TRAN(ap)->tran_getcap)(ap, "lun-reset", 1) != 1)) {
480Sstevel@tonic-gate return (0);
490Sstevel@tonic-gate }
50*10696SDavid.Hollister@Sun.COM if ((A_TO_TRAN(ap)->tran_reset) == NULL) {
51*10696SDavid.Hollister@Sun.COM return (0);
52*10696SDavid.Hollister@Sun.COM }
530Sstevel@tonic-gate return (*A_TO_TRAN(ap)->tran_reset)(ap, level);
540Sstevel@tonic-gate }
550Sstevel@tonic-gate
560Sstevel@tonic-gate int
scsi_reset_notify(struct scsi_address * ap,int flag,void (* callback)(caddr_t),caddr_t arg)570Sstevel@tonic-gate scsi_reset_notify(struct scsi_address *ap, int flag,
580Sstevel@tonic-gate void (*callback)(caddr_t), caddr_t arg)
590Sstevel@tonic-gate {
600Sstevel@tonic-gate if ((A_TO_TRAN(ap)->tran_reset_notify) == NULL) {
610Sstevel@tonic-gate return (DDI_FAILURE);
620Sstevel@tonic-gate }
630Sstevel@tonic-gate return (*A_TO_TRAN(ap)->tran_reset_notify)(ap, flag, callback, arg);
640Sstevel@tonic-gate }
650Sstevel@tonic-gate
660Sstevel@tonic-gate int
scsi_clear_task_set(struct scsi_address * ap)670Sstevel@tonic-gate scsi_clear_task_set(struct scsi_address *ap)
680Sstevel@tonic-gate {
690Sstevel@tonic-gate if ((A_TO_TRAN(ap)->tran_clear_task_set) == NULL) {
700Sstevel@tonic-gate return (-1);
710Sstevel@tonic-gate }
720Sstevel@tonic-gate return (*A_TO_TRAN(ap)->tran_clear_task_set)(ap);
730Sstevel@tonic-gate }
740Sstevel@tonic-gate
750Sstevel@tonic-gate int
scsi_terminate_task(struct scsi_address * ap,struct scsi_pkt * pkt)760Sstevel@tonic-gate scsi_terminate_task(struct scsi_address *ap, struct scsi_pkt *pkt)
770Sstevel@tonic-gate {
780Sstevel@tonic-gate if ((A_TO_TRAN(ap)->tran_terminate_task) == NULL) {
790Sstevel@tonic-gate return (-1);
800Sstevel@tonic-gate }
810Sstevel@tonic-gate return (*A_TO_TRAN(ap)->tran_terminate_task)(ap, pkt);
820Sstevel@tonic-gate }
830Sstevel@tonic-gate
840Sstevel@tonic-gate /*
850Sstevel@tonic-gate * Other Misc Routines
860Sstevel@tonic-gate */
870Sstevel@tonic-gate
880Sstevel@tonic-gate int
scsi_clear_aca(struct scsi_address * ap)890Sstevel@tonic-gate scsi_clear_aca(struct scsi_address *ap)
900Sstevel@tonic-gate {
910Sstevel@tonic-gate if ((A_TO_TRAN(ap)->tran_clear_aca) == NULL) {
920Sstevel@tonic-gate return (-1);
930Sstevel@tonic-gate }
940Sstevel@tonic-gate return (*A_TO_TRAN(ap)->tran_clear_aca)(ap);
950Sstevel@tonic-gate }
96