80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * This file and its contents are supplied under the terms of the
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Common Development and Distribution License ("CDDL"), version 1.0.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * You may only use this file in accordance with the terms of version
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 1.0 of the CDDL.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * A full copy of the text of the CDDL should have accompanied this
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * source. A copy of the CDDL is also available via the Internet at
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * http://www.illumos.org/license/CDDL.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include <sys/sdt.h>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#include "cpqary3.h"
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Local Functions Definitions
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_tgt_init(dev_info_t *, dev_info_t *, scsi_hba_tran_t *,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct scsi_device *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_tgt_probe(struct scsi_device *, int (*)());
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_transport(struct scsi_address *, struct scsi_pkt *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_reset(struct scsi_address *, int);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_abort(struct scsi_address *, struct scsi_pkt *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_getcap(struct scsi_address *, char *, int);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_setcap(struct scsi_address *, char *, int, int);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_dma_alloc(cpqary3_t *, struct scsi_pkt *,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct buf *, int, int (*)());
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_dma_move(struct scsi_pkt *, struct buf *, cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_handle_flag_nointr(cpqary3_cmdpvt_t *, struct scsi_pkt *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_poll(cpqary3_t *, uint32_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic void cpqary3_dmafree(struct scsi_address *, struct scsi_pkt *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic void cpqary3_dma_sync(struct scsi_address *, struct scsi_pkt *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic void cpqary3_destroy_pkt(struct scsi_address *, struct scsi_pkt *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic struct scsi_pkt *cpqary3_init_pkt(struct scsi_address *,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct scsi_pkt *, struct buf *, int, int, int, int, int (*callback)(),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski caddr_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int cpqary3_additional_cmd(struct scsi_pkt *scsi_pktp, cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid cpqary3_oscmd_complete(cpqary3_cmdpvt_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic uint8_t cpqary3_is_scsi_read_write(struct scsi_pkt *scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * External Variable Declarations
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiextern ddi_dma_attr_t cpqary3_dma_attr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_init_hbatran
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine initializes the transport vector in the
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * SCSA architecture for entry ponts in this driver.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_attach()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per_controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_init_hbatran(cpqary3_t *ctlr)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_hba_tran_t *hba_tran;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(ctlr != NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran = ctlr->hba_tran;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Memory for the transport vector has been allocated by now.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * initialize all the entry points in this vector
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_hba_private = (void *)ctlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Target Driver Instance Initialization */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_tgt_init = cpqary3_tgt_init;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_tgt_probe = cpqary3_tgt_probe;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Resource Allocation */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_init_pkt = cpqary3_init_pkt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_destroy_pkt = cpqary3_destroy_pkt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_sync_pkt = cpqary3_dma_sync;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_dmafree = cpqary3_dmafree;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Command Transport */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_start = cpqary3_transport;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Capability Management */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_getcap = cpqary3_getcap;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_setcap = cpqary3_setcap;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Abort and Reset */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_reset = cpqary3_reset;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski hba_tran->tran_abort = cpqary3_abort;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_tgt_init ()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine validates the target ID.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_init_hbatran()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : HBA-instance, target instance, transport vector,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * scsi-device structure
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_detect_target_geometry(),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_probe4targets()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: DDI_SUCCESS : A Target exists at this ID.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * DDI_FAILURE : No such target exists.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* ARGSUSED */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_tgt_init(dev_info_t *hba_dip, dev_info_t *tgt_dip,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_hba_tran_t *hba_tran, struct scsi_device *sd)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t tid = SD2TGT(sd);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t lun = SD2LUN(sd);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *ctlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr = (cpqary3_t *)hba_tran->tran_hba_private;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* HPQacucli Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski extern int8_t cpqary3_detect_target_geometry(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((CPQARY3_SUCCESS == cpqary3_probe4targets(ctlr)) &&
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (ctlr->num_of_targets > 0)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (void) cpqary3_detect_target_geometry(ctlr);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* HPQacucli Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Validate the Target ID
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Validate Lun --Ver1.10--
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If not a valid target id, return FAILURE.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Derieve the per-controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((tid >= CPQARY3_MAX_TGT) || (lun != 0)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE2(tgt_init_notsup,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *, ctlr, uint32_t, tid);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (DDI_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Check to see if a target structure corrresponding to this
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * target Id exists.(support only for Logical Drives and Controller)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * if target exists, update target flags, return SUCCESS
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * is target does not exist, return FAILURE
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!(ctlr->cpqary3_tgtp[tid])) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (DDI_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[tid]->tgt_dip = tgt_dip;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[tid]->ctlr_flags = CPQARY3_CAP_DISCON_ENABLED |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_CAP_SYNC_ENABLED | CPQARY3_CAP_WIDE_XFER_ENABLED |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_CAP_ARQ_ENABLED;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE1(tgt_init_done, uint32_t, tid);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (DDI_SUCCESS);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_tgt_probe()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine probes into the Target Details.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_init_hbatran()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : scsi-device structure, calling function if any
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: value returned by scsi_hba_probe()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_tgt_probe(struct scsi_device *sd, int (*waitfunc)())
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#ifdef CPQARY3_DEBUG
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int status;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#endif
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Probe for the presence of the target, using the scsi_hba_probe().
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * It inturn issues the SCSI inquiry command that is serviced by our
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * driver
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* HPQacucli Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski extern int8_t cpqary3_detect_target_geometry(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct scsi_hba_tran *hba_tran = sd->sd_address.a_hba_tran;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *ctlr = hba_tran->tran_hba_private;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((CPQARY3_SUCCESS == cpqary3_probe4targets(ctlr)) &&
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (ctlr->num_of_targets > 0)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (void) cpqary3_detect_target_geometry(ctlr);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* HPQacucli Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (scsi_hba_probe(sd, waitfunc));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#ifdef CPQARY3_DEBUG
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Comment the previous line of code */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski status = scsi_hba_probe(sd, waitfunc);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_CONT, "CPQary3 : _tgt_probe : target = %d \n", SD2TGT(sd));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_CONT, "CPQary3 : _tgt_probe : scsi_hba_probe returned %d \n",
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski status);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_CONT, "CPQary3 : _tgt_probe : Leaving \n");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (status);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#endif
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_init_pkt
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine allocates resources for a SCSI packet.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_init_pkt()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : SCSI address, SCSI packet, buffer, CDB length,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * SCB length, driver private length, flags modifier,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * callback function, arguement for the callback function
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_dma_alloc(), cpqary3_dma_move()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: allocated SCSI packet / NULL
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* ARGSUSED */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic struct scsi_pkt *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_init_pkt(struct scsi_address *sa, struct scsi_pkt *scsi_pktp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct buf *bp, int cmdlen, int statuslen, int tgtlen,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int flags, int (*callback)(), caddr_t arg)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *cpqary3p;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dev_info_t *dip;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pkt_t *cpqary3_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct scsi_pkt *new_scsi_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(callback == NULL_FUNC || callback == SLEEP_FUNC);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3p = SA2CTLR(sa);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dip = cpqary3p->dip;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If the SCSI packet is NULL, allocate frresh resources to it.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Else, get the next available resources for the same
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!scsi_pktp) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp = scsi_hba_pkt_alloc(dip, sa, cmdlen, statuslen,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski tgtlen, sizeof (cpqary3_pkt_t), callback, NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!scsi_pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp = (cpqary3_pkt_t *)scsi_pktp->pkt_ha_private;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bzero(cpqary3_pktp, sizeof (cpqary3_pkt_t));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->scsi_cmd_pkt = scsi_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Store the CDB length and sense data length in the
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * pkt private
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cdb_len = cmdlen;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->scb_len = statuslen;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmahandle = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->memp = (cpqary3_cmdpvt_t *)NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Initialize to NULL all the fields of scsi_pktp, except
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * pkt_scbp, pkt_cdbp, pkt_ha_private and pkt_private members.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_address = *sa;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_comp = (void (*) ())NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_flags = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_time = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_resid = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (flags & PKT_CONSISTENT)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_flags |= DDI_DMA_CONSISTENT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (flags & PKT_DMA_PARTIAL)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_flags |= DDI_DMA_PARTIAL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski new_scsi_pktp = scsi_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski new_scsi_pktp = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp = (cpqary3_pkt_t *)scsi_pktp->pkt_ha_private;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->bf = bp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If any I/O is desired, Allocate/Move DMA resources for the SCSI
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * packet
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If first time allocation for this SCSI packet, allocate fresh DMA
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Else, move the already allocated DMA resources
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (bp && bp->b_bcount != 0) { /* I/O is desired */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!cpqary3_pktp->cmd_dmahandle) { /* First time allocation */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_dma_alloc(cpqary3p, scsi_pktp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bp, flags, callback) == CPQARY3_FAILURE) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (new_scsi_pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_hba_pkt_free(sa, new_scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return ((struct scsi_pkt *)NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(new_scsi_pktp == NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (CPQARY3_FAILURE ==
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_dma_move(scsi_pktp, bp, cpqary3p)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return ((struct scsi_pkt *)NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_dma_alloc()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine services requests for memory (dynamic)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * as and when required by the OS.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_init_pkt()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per-controller, SCSI packet, buffer, flag modifier,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * callback function
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: SUCCESS / FAILURE
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_dma_alloc(cpqary3_t *cpqary3p, struct scsi_pkt *scsi_pktp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct buf *bp, int flags, int (*callback)())
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int32_t (*cb)(caddr_t);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int32_t retvalue;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t i = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t dma_flags;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pkt_t *cpqary3_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_attr_t tmp_dma_attr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp = (cpqary3_pkt_t *)scsi_pktp->pkt_ha_private;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(callback == NULL_FUNC || callback == SLEEP_FUNC);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Record the direction of the data transfer, so that it
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * can be used in appropriate synchronization during cpqary3_sync_pkt()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (bp->b_flags & B_READ) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_flags &= ~CFLAG_DMASEND;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dma_flags = DDI_DMA_READ;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_flags |= CFLAG_DMASEND;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dma_flags = DDI_DMA_WRITE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (flags & PKT_CONSISTENT) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_flags |= CFLAG_CMDIOPB;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dma_flags |= DDI_DMA_CONSISTENT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (flags & PKT_DMA_PARTIAL) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dma_flags |= DDI_DMA_PARTIAL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski tmp_dma_attr = cpqary3_dma_attr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski tmp_dma_attr.dma_attr_sgllen = cpqary3p->sg_cnt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cb = (callback == NULL_FUNC) ? DDI_DMA_DONTWAIT : DDI_DMA_SLEEP;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * DMA resources are allocated thru a 2 step protocol :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * - allocate a DMA handle
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * - bind the buffer to the handle
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If both the steps succeed, we have succeeded in allocating resources
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (DDI_SUCCESS != (retvalue = ddi_dma_alloc_handle(cpqary3p->dip,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &tmp_dma_attr, cb, CPQARY3_DMA_NO_CALLBACK,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dmahandle))) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski switch (retvalue) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case DDI_DMA_NORESOURCES:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * No Resources are available to be allocated
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bioerror(bp, CPQARY3_BUFFER_ERROR_CLEAR);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case DDI_DMA_BADATTR:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * The attributes stated in our DMA attribute
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * structure is such that potential DMA resources can
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * not be allocated.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_CONT, "CPQary3: DmaAlloc: "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "AllocHandle Failed BadAttr\n");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bioerror(bp, EFAULT);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski default:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * There is no other possible return value
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_WARN,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "CPQary3: dma_alloc: Unexpected Return Value %x "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "From call to Allocate DMA Handle \n", retvalue);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski retvalue = ddi_dma_buf_bind_handle(cpqary3_pktp->cmd_dmahandle, bp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dma_flags, cb, CPQARY3_DMA_NO_CALLBACK,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dmacookies[0], &cpqary3_pktp->cmd_ncookies);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski switch (retvalue) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case DDI_DMA_PARTIAL_MAP :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case DDI_DMA_MAPPED :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (DDI_DMA_PARTIAL_MAP == retvalue) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ddi_dma_numwin(cpqary3_pktp->cmd_dmahandle,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_nwin) == DDI_FAILURE) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_PANIC, "CPQary3: Retrieval of DMA "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "windows number failed");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ddi_dma_getwin(cpqary3_pktp->cmd_dmahandle,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_curwin,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dma_offset,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dma_len,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dmacookies[0],
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_ncookies) == DDI_FAILURE) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_PANIC, "CPQary3: Activation of New "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "DMA Window Failed");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_nwin = 1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dma_len = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dma_offset = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmacount = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski i = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski for (;;) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmacount +=
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmacookies[i++].dmac_size;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Check Out for Limits */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (i == cpqary3p->sg_cnt ||
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski i == cpqary3_pktp->cmd_ncookies)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_nextcookie(cpqary3_pktp->cmd_dmahandle,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dmacookies[i]);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_cookie = i;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_cookiecnt = i;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_flags |= CFLAG_DMAVALID;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_resid =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bp->b_bcount - cpqary3_pktp->cmd_dmacount;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_SUCCESS);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case DDI_DMA_NORESOURCES:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bioerror(bp, CPQARY3_BUFFER_ERROR_CLEAR);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case DDI_DMA_NOMAPPING:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bioerror(bp, EFAULT);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case DDI_DMA_TOOBIG:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bioerror(bp, EINVAL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case DDI_DMA_INUSE:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_PANIC, "CPQary3: Another I/O transaction "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "is using the DMA handle");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski default:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_PANIC, "CPQary3: Unexpected ERROR "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "returned from Call to Bind Buffer "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "to Handle : 0x%X", i);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_free_handle(&cpqary3_pktp->cmd_dmahandle);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmahandle = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_flags &= ~CFLAG_DMAVALID;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_dma_move()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine gets the next DMA window.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_init_pkt()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per-controller, SCSI packet, buffer
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: SUCCESS / FAILURE
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_dma_move(struct scsi_pkt *scsi_pktp, struct buf *bp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *cpqary3p)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t i = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pkt_t *cpqary3_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp = PKT2PVTPKT(scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If there are no more cookies remaining in this window,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * must move to the next window first.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_pktp->cmd_cookie == cpqary3_pktp->cmd_ncookies) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* For small pkts, leave things where they are */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((cpqary3_pktp->cmd_curwin == cpqary3_pktp->cmd_nwin) &&
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (cpqary3_pktp->cmd_nwin == 1))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_SUCCESS);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Shall not be able to move if last window */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (++cpqary3_pktp->cmd_curwin >= cpqary3_pktp->cmd_nwin)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ddi_dma_getwin(cpqary3_pktp->cmd_dmahandle,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_curwin, &cpqary3_pktp->cmd_dma_offset,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dma_len,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dmacookies[0],
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_ncookies) == DDI_FAILURE)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_cookie = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Still more cookies in this window - get the next one */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_nextcookie(cpqary3_pktp->cmd_dmahandle,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dmacookies[0]);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Get remaining cookies in this window, up to our maximum */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski for (;;) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmacount +=
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmacookies[i++].dmac_size;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_cookie++;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* no. of DATA SEGMENTS */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (i == cpqary3p->sg_cnt ||
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_cookie == cpqary3_pktp->cmd_ncookies)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_nextcookie(cpqary3_pktp->cmd_dmahandle,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &cpqary3_pktp->cmd_dmacookies[i]);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_cookiecnt = i;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_resid = bp->b_bcount - cpqary3_pktp->cmd_dmacount;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_SUCCESS);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_transport()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine services requests from the OS that are
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * directed towards the targets.(any SCSI command)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : kernel
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : SCSI address, SCSI packet, buffer
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_build_iop, cpqary3_add2submitted
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: TRAN_ACCEPT : The driver accepts the command.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * TRAN_BUSY : Required resources not available
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * at the moment.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * TRAN_FATAL_ERROR: A target no longer exists.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_transport(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *ctlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pkt_t *cpqary3_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_tgt_t *tgtp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvt_t *memp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(sa != NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr = SA2CTLR(sa);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp = PKT2PVTPKT(scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski tgtp = ctlr->cpqary3_tgtp[SA2TGT(sa)];
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!tgtp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_FATAL_ERROR);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (tgtp->type == CPQARY3_TARGET_NONE)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_FATAL_ERROR);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_additional_cmd(scsi_pktp, ctlr))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_ACCEPT);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Attempt to occupy a free command memory block
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If not successful, return TRAN_BUSY
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Else, build the Command
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Submit it to the controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If NO_INTR flag is set, wait for the completion of the command and
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * when the command completes, update packet values appropriately and
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * return TRAN_ACCEPT.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Make an entry in the submitted Q
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * return TRAN_ACCEPT
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (NULL == (memp = cpqary3_cmdlist_occupy(ctlr)))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_BUSY);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->memp = memp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->pvt_pkt = cpqary3_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((cpqary3_pktp->cmd_flags & DDI_DMA_CONSISTENT) &&
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmahandle) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (void) ddi_dma_sync(cpqary3_pktp->cmd_dmahandle, 0, 0,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DDI_DMA_SYNC_FORDEV);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(cpqary3_pktp->cmd_cookiecnt <= ctlr->sg_cnt);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* SG */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* PERF */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->complete = cpqary3_oscmd_complete;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* PERF */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski switch (cpqary3_build_cmdlist(memp, SA2TGT(sa))) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CPQARY3_SUCCESS :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (scsi_pktp->pkt_flags & FLAG_NOINTR) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (cpqary3_handle_flag_nointr(memp, scsi_pktp));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_start_time = ddi_get_lbolt();
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&ctlr->hw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* CONTROLLER_LOCKUP */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (EIO == cpqary3_submit(ctlr, memp->cmdlist_phyaddr)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->hw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(memp, CPQARY3_HOLD_SW_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_FATAL_ERROR);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* CONTROLLER_LOCKUP */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->hw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CPQARY3_FAILURE :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(memp, CPQARY3_HOLD_SW_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_FATAL_ERROR);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski default: /* Never occurs */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_NOTE, "CPQary3 : Transport : Unexpected Error");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_FATAL_ERROR);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_ACCEPT);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_dmafree
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine de-allocates previously allocated
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * DMA resources.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : kernel
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : SCSI address, SCSI packet
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* ARGSUSED */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic void
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_dmafree(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pkt_t *cpqary3_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp = PKT2PVTPKT(scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If any DMA was succesfully attempted earlier, free all allocated
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * resources
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_pktp->cmd_flags & CFLAG_DMAVALID) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!cpqary3_pktp->cmd_dmahandle) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE(dmafree_null);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_flags &= ~CFLAG_DMAVALID;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (void) ddi_dma_unbind_handle(cpqary3_pktp->cmd_dmahandle);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_free_handle(&cpqary3_pktp->cmd_dmahandle);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmahandle = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_dma_sync
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine synchronizes the CPU's / HBA's view of
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * the data associated with the pkt, typically by calling
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * ddi_dma_sync().
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : kernel
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : SCSI address, SCSI packet
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* ARGSUSED */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic void
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_dma_sync(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pkt_t *cpqary3_pktp = PKT2PVTPKT(scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Check whether DMA was attempted successfully earlier
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If yes and
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * if the command flags is write, then synchronise the device else
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * synchronise the CPU
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_pktp->cmd_flags & CFLAG_DMAVALID) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (void) ddi_dma_sync(cpqary3_pktp->cmd_dmahandle,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dma_offset, cpqary3_pktp->cmd_dma_len,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (cpqary3_pktp->cmd_flags & CFLAG_DMASEND) ?
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DDI_DMA_SYNC_FORDEV : DDI_DMA_SYNC_FORCPU);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_destroy_pkt
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine de-allocates previously allocated
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * resources for the SCSI packet.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : kernel
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : SCSI address, SCSI packet
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic void
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_destroy_pkt(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pkt_t *cpqary3_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp = PKT2PVTPKT(scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Deallocate DMA Resources, if allocated.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Free the SCSI Packet.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_pktp->cmd_flags & CFLAG_DMAVALID) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!cpqary3_pktp->cmd_dmahandle) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE(dmafree_null);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_flags &= ~CFLAG_DMAVALID;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (void) ddi_dma_unbind_handle(
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmahandle);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_dma_free_handle(&cpqary3_pktp->cmd_dmahandle);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pktp->cmd_dmahandle = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_hba_pkt_free(sa, scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_reset
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine resets a SCSI bus/target.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : kernel
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : SCSI address, reset level required
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: SUCCESS
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* ARGSUSED */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_reset(struct scsi_address *sa, int level)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Fix for Crash seen during RAID 0 Drive removal -
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * just return CPQARY3_SUCCESS on reset request
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_SUCCESS);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_abort()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine aborts a particular command or all commands
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * directed towards a target.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : kernel
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : SCSI address, SCSI packet
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: SUCCESS / FAILURE
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * [ abort of concernd command(s) was a success or
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * a failure. ]
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_abort(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t tid;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *ctlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(sa != NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski tid = SA2TGT(sa);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr = SA2CTLR(sa);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If SCSI packet exists, abort that particular command.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Else, abort all existing commands to the target
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * In either of the cases, we shall have to wait after the abort
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * functions are called to return the status.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!scsi_pktp) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (cpqary3_send_abortcmd(ctlr, tid,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (CommandList_t *)NULL));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (cpqary3_send_abortcmd(ctlr, tid, SP2CMD(scsi_pktp)));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_getcap
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine is called to get the current value of a
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * capability.(SCSI transport capability)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : kernel
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : SCSI address, capability identifier, target(s) affected
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: current value of capability / -1 (if unsupported)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_getcap(struct scsi_address *sa, char *capstr, int tgtonly)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int index;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *ctlr = SA2CTLR(sa);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_tgt_t *tgtp = ctlr->cpqary3_tgtp[SA2TGT(sa)];
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If requested Capability is not supported, return -1.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (DDI_FAILURE == (index = scsi_hba_lookup_capstr(capstr)))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_NOT_DEFINED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Getting capability for a particulat target is supported
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * the generic form of tran_getcap() is unsupported(for all targets)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If directed towards a particular target, return current capability.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (tgtonly == 0) { /* all targets */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE1(getcap_alltgt, int, index);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_NOT_DEFINED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE1(getcap_index, int, index);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski switch (index) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_DMA_MAX:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return ((int)cpqary3_dma_attr.dma_attr_maxxfer);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_DISCONNECT:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (tgtp->ctlr_flags & CPQARY3_CAP_DISCON_ENABLED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_SYNCHRONOUS:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (tgtp->ctlr_flags & CPQARY3_CAP_SYNC_ENABLED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_WIDE_XFER:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (tgtp->ctlr_flags & CPQARY3_CAP_WIDE_XFER_ENABLED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_ARQ:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return ((tgtp->ctlr_flags & CPQARY3_CAP_ARQ_ENABLED) ? 1 : 0);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_INITIATOR_ID:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CTLR_SCSI_ID);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_UNTAGGED_QING:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_TAGGED_QING:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_SECTOR_SIZE:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (cpqary3_dma_attr.dma_attr_granular);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_TOTAL_SECTORS:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_NOT_DEFINED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_GEOMETRY:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (cpqary3_target_geometry(sa));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_RESET_NOTIFICATION:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (0);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski default:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_NOT_DEFINED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_setcap
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine is called to set the current value of a
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * capability.(SCSI transport capability)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : kernel
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : SCSI address, capability identifier,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * new capability value, target(s) affected
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: SUCCESS / FAILURE / -1 (if capability is unsupported)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* ARGSUSED */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_setcap(struct scsi_address *sa, char *capstr, int value, int tgtonly)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int index;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int retstatus = CAP_NOT_DEFINED;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If requested Capability is not supported, return -1.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((index = scsi_hba_lookup_capstr(capstr)) == DDI_FAILURE)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (retstatus);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Setting capability for a particulat target is supported
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * the generic form of tran_setcap() is unsupported(for all targets)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If directed towards a particular target, set & return current
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * capability.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!tgtonly) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE1(setcap_alltgt, int, index);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (retstatus);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE1(setcap_index, int, index);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski switch (index) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_DMA_MAX:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_CHG_NOT_ALLOWED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_DISCONNECT:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_CHG_NOT_ALLOWED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_SYNCHRONOUS:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_CHG_NOT_ALLOWED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_WIDE_XFER:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_CHG_NOT_ALLOWED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_ARQ:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_INITIATOR_ID:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_CHG_NOT_ALLOWED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_UNTAGGED_QING:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_TAGGED_QING:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_SECTOR_SIZE:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_CHG_NOT_ALLOWED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_TOTAL_SECTORS:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_CHG_NOT_ALLOWED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_GEOMETRY:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_CHG_NOT_ALLOWED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_CAP_RESET_NOTIFICATION:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_CHG_NOT_ALLOWED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski default:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CAP_NOT_DEFINED);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_handle_flag_nointr
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine is called to handle submission and
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * subsequently poll for the completion of a command,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * when its FLAG_NOINTR bit is set.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_transport()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : command private structure, SCSI packet
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_intr_onoff, cpqary3_retrieve,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_submit, cpqary3_poll
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: TRAN_ACCEPT
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_handle_flag_nointr(cpqary3_cmdpvt_t *memp, struct scsi_pkt *scsi_pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t tag;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t simple_tag;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t i;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *ctlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvt_t *cpqary3_cmdpvtp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t CmdsOutMax;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t no_cmds;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski RETURN_FAILURE_IF_NULL(memp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski tag = memp->tag.tag_value;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr = memp->ctlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->poll_flag = CPQARY3_FALSE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Before sumitting this command, ensure all commands pending
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * with the controller are completed.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_intr_onoff(ctlr, CPQARY3_INTR_DISABLE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ctlr->host_support & 0x4)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_lockup_intr_onoff(ctlr, CPQARY3_LOCKUP_INTR_DISABLE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski no_cmds = (uint32_t)((ctlr->ctlr_maxcmds / 3) * NO_OF_CMDLIST_IN_A_BLK);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski for (;;) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->poll_flag = CPQARY3_FALSE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski for (i = 0; i < no_cmds; i++) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvtp = &ctlr->cmdmemlistp->pool[i];
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(cpqary3_cmdpvtp != NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((tag != cpqary3_cmdpvtp->tag.tag_value) &&
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (cpqary3_cmdpvtp->occupied == CPQARY3_OCCUPIED)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ctlr->noe_support == 1) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((cpqary3_cmdpvtp->cmdlist_memaddr->
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski Header.Tag.drvinfo_n_err ==
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_NOECMD_SUCCESS) ||
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (cpqary3_cmdpvtp->cmdpvt_flag ==
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_TIMEOUT)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski continue;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_cmdpvtp->cmdpvt_flag ==
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_TIMEOUT) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski continue;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->poll_flag = CPQARY3_TRUE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* NOE */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ctlr->poll_flag == CPQARY3_TRUE) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ctlr->poll_flag == CPQARY3_TRUE) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!(ctlr->bddef->bd_flags & SA_BD_SAS)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski while ((simple_tag =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_get32(ctlr->opq_handle,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (uint32_t *)ctlr->opq)) != 0xFFFFFFFF) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CmdsOutMax = ctlr->ctlr_maxcmds;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((simple_tag >>
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_GET_MEM_TAG) >=
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ((CmdsOutMax / 3) * 3)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_WARN,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "CPQary3 : HBA returned "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "Spurious Tag");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvtp =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &ctlr->cmdmemlistp->pool[
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski simple_tag >> CPQARY3_GET_MEM_TAG];
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvtp->cmdlist_memaddr->
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski Header.Tag.drvinfo_n_err =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (simple_tag & 0xF) >> 1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvtp->complete(
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvtp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (CPQARY3_SUCCESS != cpqary3_retrieve(ctlr)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski drv_usecwait(1000);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&ctlr->sw_mutex); /* Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&ctlr->hw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (EIO == cpqary3_submit(ctlr, memp->cmdlist_phyaddr)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->hw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(memp, CPQARY3_HOLD_SW_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_FATAL_ERROR);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (CPQARY3_FAILURE == cpqary3_poll(ctlr, tag)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_TIMEOUT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics = STAT_TIMEOUT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->hw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(memp, CPQARY3_HOLD_SW_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_intr_onoff(ctlr, CPQARY3_INTR_ENABLE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ctlr->host_support & 0x4)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_lockup_intr_onoff(ctlr,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_LOCKUP_INTR_ENABLE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_ACCEPT);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->hw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_intr_onoff(ctlr, CPQARY3_INTR_ENABLE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ctlr->host_support & 0x4) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_lockup_intr_onoff(ctlr,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_LOCKUP_INTR_ENABLE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (TRAN_ACCEPT);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_poll
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine polls for the completion of a command.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_handle_flag_nointr
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per controller, tag of the command to be polled
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_poll_retrieve
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: TRAN_ACCEPT
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_poll(cpqary3_t *ctlr, uint32_t tag)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t ii = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski RETURN_FAILURE_IF_NULL(ctlr);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * POLL for the completion of the said command
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Since, we had ensured that controller is empty, we need not
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * check for the complete Retrieved Q.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * However, we just check the Retrieved Q and complete all
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * commands in it, inclusive of the polled command.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * if the polled command is completed, send back a success.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski for (;;) { /* this function is called with both the locks held */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (CPQARY3_SUCCESS != cpqary3_poll_retrieve(ctlr, tag)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ii++;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ii > 120000)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski drv_usecwait(500);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski continue;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_SUCCESS);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic int
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_additional_cmd(struct scsi_pkt *scsi_pktp, cpqary3_t *ctlr)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct scsi_arq_status *arqstat;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* LINTED: alignment */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arqstat = (struct scsi_arq_status *)(scsi_pktp->pkt_scbp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski switch (scsi_pktp->pkt_cdbp[0]) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case 0x35: /* Synchronize Cache */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_flush_cache(ctlr);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_CMPLT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_SENT_CMD | STATE_XFERRED_DATA | STATE_GOT_STATUS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (scsi_pktp->pkt_comp) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (*scsi_pktp->pkt_comp)(scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case 0x04: /* Format Unit */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_NOTE, "The FORMAT UNIT is not supported by this "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "device If this option is selected from the format utility "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "do not continue further. Please refer to cpqary3 driver "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "man pages for details.");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (0);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_LOG_SENSE:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_MODE_SELECT:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_PERSISTENT_RESERVE_IN:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arqstat->sts_status.sts_chk = 1; /* CHECK CONDITION */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arqstat->sts_rqpkt_reason = CMD_CMPLT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arqstat->sts_rqpkt_resid = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arqstat->sts_rqpkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_SENT_CMD | STATE_XFERRED_DATA;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arqstat->sts_rqpkt_statistics = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arqstat->sts_sensedata.es_valid = 1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arqstat->sts_sensedata.es_class = CLASS_EXTENDED_SENSE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arqstat->sts_sensedata.es_key = KEY_ILLEGAL_REQUEST;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_SENT_CMD | STATE_XFERRED_DATA;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (scsi_pktp->pkt_comp) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (*scsi_pktp->pkt_comp)(scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (0);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/* PERF */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_oscmd_complete
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine processes the
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * completed OS commands and
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * initiates any callback that is needed.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_transport
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per-command
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_ioctl_send_bmiccmd,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_ioctl_send_scsicmd,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_send_abortcmd, cpqary3_flush_cache,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_probe4LVs,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_probe4Tapes, cpqary3_synccmd_complete,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_detect_target_geometry,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_detect_target_geometry
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_oscmd_complete(cpqary3_cmdpvt_t *cpqary3_cmdpvtp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *cpqary3p;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ErrorInfo_t *errorinfop;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CommandList_t *cmdlistp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct scsi_pkt *scsi_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(cpqary3_cmdpvtp != NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (CPQARY3_TIMEOUT == cpqary3_cmdpvtp->cmdpvt_flag) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(cpqary3_cmdpvtp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_NO_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3p = cpqary3_cmdpvtp->ctlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp = cpqary3_cmdpvtp->cmdlist_memaddr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski errorinfop = cpqary3_cmdpvtp->errorinfop;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cmdlistp->Header.Tag.drvinfo_n_err == CPQARY3_OSCMD_SUCCESS) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp = cpqary3_cmdpvtp->pvt_pkt->scsi_cmd_pkt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_CMPLT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = STATE_GOT_BUS |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_GOT_TARGET | STATE_SENT_CMD |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_XFERRED_DATA | STATE_GOT_STATUS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_cmdpvtp->pvt_pkt->scsi_cmd_pkt->pkt_flags &
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski FLAG_NOINTR) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(cpqary3_cmdpvtp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_NO_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(cpqary3_cmdpvtp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_NO_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (scsi_pktp->pkt_comp) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&cpqary3p->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (*scsi_pktp->pkt_comp)(scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&cpqary3p->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp = cpqary3_cmdpvtp->pvt_pkt->scsi_cmd_pkt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski switch (errorinfop->CommandStatus) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_DATA_OVERRUN :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_DATA_OVR;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_SENT_CMD | STATE_XFERRED_DATA | STATE_GOT_STATUS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_INVALID :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE1(invalid_cmd, struct scsi_pkt *, scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_BADMSG;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = STATE_GOT_BUS |STATE_GOT_TARGET |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_SENT_CMD | STATE_GOT_STATUS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_PROTOCOL_ERR :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_BADMSG;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_SENT_CMD | STATE_GOT_STATUS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_HARDWARE_ERR:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_CONNECTION_LOST:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_INCOMPLETE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_ABORTED:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_UNSOLICITED_ABORT:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_ABORTED;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics = STAT_ABORTED;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_SENT_CMD | STATE_XFERRED_DATA | STATE_GOT_STATUS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_ABORT_FAILED:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_TIMEOUT:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_TIMEOUT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics = STAT_TIMEOUT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_DATA_UNDERRUN: /* Significant ONLY for Read & Write */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_is_scsi_read_write(scsi_pktp)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_CMPLT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_GOT_BUS | STATE_GOT_TARGET | STATE_SENT_CMD |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_XFERRED_DATA | STATE_GOT_STATUS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* FALLTHROUGH */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_SUCCESS:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case CISS_CMD_TARGET_STATUS:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_CMPLT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = STATE_GOT_BUS | STATE_GOT_TARGET |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_SENT_CMD | STATE_XFERRED_DATA | STATE_GOT_STATUS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski default: /* Should never Occur !!! */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_TRAN_ERR;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * if ever a command completes with a CHECK CONDITION or a
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * COMMAND_TERMINATED SCSI status, Update the sense data.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * NOTE : The CISS_CMD_INVALID command status would always result in a
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * CHECK CONDITION and hence reach this part of the code.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((errorinfop->ScsiStatus == SCSI_CHECK_CONDITION) ||
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (errorinfop->ScsiStatus == SCSI_COMMAND_TERMINATED)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (errorinfop->SenseLen) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct scsi_arq_status *arq_statusp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arq_statusp =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* LINTED: alignment */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (struct scsi_arq_status *)scsi_pktp->pkt_scbp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((errorinfop->ScsiStatus == SCSI_CHECK_CONDITION)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arq_statusp->sts_status.sts_chk = (uint8_t)1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arq_statusp->sts_status.sts_chk = (uint8_t)1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arq_statusp->sts_status.sts_scsi2 = (uint8_t)1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bzero((void *)&(arq_statusp->sts_rqpkt_status),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski sizeof (struct scsi_status));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arq_statusp->sts_rqpkt_reason = CMD_CMPLT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arq_statusp->sts_rqpkt_resid = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arq_statusp->sts_rqpkt_state = scsi_pktp->pkt_state;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski arq_statusp->sts_rqpkt_statistics =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bcopy((caddr_t)&errorinfop->SenseInfo[0],
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (caddr_t)(&arq_statusp->sts_sensedata),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_MIN(errorinfop->SenseLen,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvtp->pvt_pkt->scb_len));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state |= STATE_ARQ_DONE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_cmdpvtp->pvt_pkt->scsi_cmd_pkt->pkt_flags & FLAG_NOINTR) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(cpqary3_cmdpvtp, CPQARY3_NO_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(cpqary3_cmdpvtp, CPQARY3_NO_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (scsi_pktp->pkt_comp) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&cpqary3p->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (*scsi_pktp->pkt_comp)(scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&cpqary3p->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskistatic uint8_t
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_is_scsi_read_write(struct scsi_pkt *scsi_pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * In the scsi packet structure, the first byte is the SCSI Command
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * OpCode. We check to see if it is any one of the SCSI Read or Write
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * opcodes.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski switch (scsi_pktp->pkt_cdbp[0]) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_READ_6:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_READ_10:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_READ_12:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_WRITE_6:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_WRITE_10:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski case SCSI_WRITE_12:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski default:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (0);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}