summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJoshua M. Clulow <jmc@joyent.com>2016-03-04 08:39:03 +0000
committerJoshua M. Clulow <jmc@joyent.com>2016-07-06 16:25:27 +0000
commit931639d8f0cf57f6328750c97540c11d71d26a89 (patch)
tree200f467e1b85ea6cc04b4009cd90e1c1d94c683e /usr/src
parent0e2422b4b98c00ad10ff1594813b9b07a1a3b88e (diff)
downloadillumos-joyent-931639d8f0cf57f6328750c97540c11d71d26a89.tar.gz
XXX mostly moved to new-style SCSA hooks; compiled, testing;
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3.c24
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3.h109
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3_ciss.c30
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3_hba.c376
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3_logvol.c65
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3_scsi.c124
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3_transport.c794
-rw-r--r--usr/src/uts/common/io/cpqary3/cpqary3_util.c8
8 files changed, 522 insertions, 1008 deletions
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3.c b/usr/src/uts/common/io/cpqary3/cpqary3.c
index 6df5d368ee..363520b758 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3.c
+++ b/usr/src/uts/common/io/cpqary3/cpqary3.c
@@ -248,14 +248,13 @@ cpqary3_attach(dev_info_t *dip, ddi_attach_cmd_t attach_cmd)
offsetof(cpqary3_command_t, cpcm_link));
list_create(&cpq->cpq_finishq, sizeof (cpqary3_command_t),
offsetof(cpqary3_command_t, cpcm_link_finish));
+ list_create(&cpq->cpq_volumes, sizeof (cpqary3_volume_t),
+ offsetof(cpqary3_volume_t, cplv_link));
avl_create(&cpq->cpq_inflight, cpqary3_command_comparator,
sizeof (cpqary3_command_t), offsetof(cpqary3_command_t,
cpcm_node));
mutex_init(&cpq->cpq_mutex, NULL, MUTEX_DRIVER, NULL);
cv_init(&cpq->cpq_cv_finishq, NULL, CV_DRIVER, NULL);
- cpq->cpq_targets[CTLR_SCSI_ID] = kmem_zalloc(sizeof (cpqary3_tgt_t),
- KM_SLEEP);
- cpq->cpq_targets[CTLR_SCSI_ID]->type = CPQARY3_TARGET_CTLR;
cpq->cpq_init_level |= CPQARY3_INITLEVEL_BASIC;
@@ -298,11 +297,10 @@ cpqary3_attach(dev_info_t *dip, ddi_attach_cmd_t attach_cmd)
cpq->cpq_init_level |= CPQARY3_INITLEVEL_HBA_ALLOC;
/*
- * Set private field for the HBA tran structure.
- * Initialise the HBA tran entry points.
- * Attach the controller to HBA.
+ * XXX This function should do _all_ of the SCSA HBA driver
+ * init work.
*/
- cpqary3_init_hbatran(cpq);
+ cpqary3_hba_setup(cpq);
tmp_dma_attr = cpqary3_dma_attr;
tmp_dma_attr.dma_attr_sgllen = cpq->cpq_sg_cnt;
@@ -432,15 +430,9 @@ cpqary3_cleanup(cpqary3_t *cpq)
cv_destroy(&cpq->cpq_cv_finishq);
- for (int targ = 0; targ < CPQARY3_MAX_TGT; targ++) {
- if (cpq->cpq_targets[targ] == NULL) {
- continue;
- }
-
- kmem_free(cpq->cpq_targets[targ],
- sizeof (cpqary3_tgt_t));
- cpq->cpq_targets[targ] = NULL;
- }
+ /*
+ * XXX cleanup volumes, targets, etc!
+ */
/*
* XXX avl_destroy, list_destroy, etc
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3.h b/usr/src/uts/common/io/cpqary3/cpqary3.h
index b815380225..93520bd493 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3.h
+++ b/usr/src/uts/common/io/cpqary3/cpqary3.h
@@ -190,40 +190,6 @@ typedef enum cpqary3_ctlr_mode {
#include "cpqary3_mem.h"
#include "cpqary3_scsi.h"
-/*
- * Logical Volume Structure
- */
-typedef enum cpqary3_volume_flags {
- CPQARY3_VOL_FLAG_WWN = (0x1 << 0),
-} cpqary3_volume_flags_t;
-typedef struct cpqary3_volume {
- LogDevAddr_t cplv_addr;
- cpqary3_volume_flags_t cplv_flags;
-
- uint8_t cplv_wwn[16];
-
- cpqary3_t *cplv_ctlr;
- list_node_t cplv_link;
-
- /*
- * List of SCSA targets currently attached to this Logical Volume:
- */
- list_t cplv_targets;
-} cpqary3_volume_t;
-
-/*
- * Per-Target Structure
- */
-typedef struct cpqary3_target {
- struct scsi_device *cptg_scsi_dev;
-
- /*
- * Linkage back to the Logical Volume that this target represents:
- */
- cpqary3_volume_t *cptg_volume;
- list_node_t cptg_link_volume;
-} cpqary3_target_t;
-
#if 0
/*
* Per Target Structure
@@ -338,14 +304,7 @@ struct cpqary3 {
kmutex_t cpq_mutex;
kcondvar_t cpq_cv_finishq;
- /*
- * Controller target tracking. Note that "cpq_ntargets" refers to the
- * current number of visible LUNs, as reported by the controller. The
- * "cpq_targets" array is a sparse mapping from target ID number to
- * the relevant target object.
- */
- cpqary3_tgt_t *cpq_targets[CPQARY3_MAX_TGT];
- unsigned cpq_ntargets;
+ list_t cpq_volumes;
/*
* Controller Heartbeat Tracking
@@ -388,8 +347,44 @@ struct cpqary3 {
ddi_acc_handle_t cpq_ct_handle;
};
+/*
+ * Logical Volume Structure
+ */
+typedef enum cpqary3_volume_flags {
+ CPQARY3_VOL_FLAG_WWN = (0x1 << 0),
+} cpqary3_volume_flags_t;
+typedef struct cpqary3_volume {
+ LogDevAddr_t cplv_addr;
+ cpqary3_volume_flags_t cplv_flags;
+
+ uint8_t cplv_wwn[16];
+
+ cpqary3_t *cplv_ctlr;
+ list_node_t cplv_link;
+
+ /*
+ * List of SCSA targets currently attached to this Logical Volume:
+ */
+ list_t cplv_targets;
+} cpqary3_volume_t;
+
+/*
+ * Per-Target Structure
+ */
+typedef struct cpqary3_target {
+ struct scsi_device *cptg_scsi_dev;
+
+ /*
+ * Linkage back to the Logical Volume that this target represents:
+ */
+ cpqary3_volume_t *cptg_volume;
+ list_node_t cptg_link_volume;
+} cpqary3_target_t;
+
+
typedef struct cpqary3_command cpqary3_command_t;
typedef struct cpqary3_command_internal cpqary3_command_internal_t;
+typedef struct cpqary3_command_scsa cpqary3_command_scsa_t;
typedef struct cpqary3_pkt cpqary3_pkt_t;
typedef enum cpqary3_command_status {
@@ -415,6 +410,7 @@ struct cpqary3_command {
cpqary3_command_type_t cpcm_type;
cpqary3_t *cpcm_ctlr;
+ cpqary3_target_t *cpcm_target;
list_node_t cpcm_link; /* Linkage for allocated list. */
list_node_t cpcm_link_finish; /* Linkage for completion list. */
@@ -425,7 +421,7 @@ struct cpqary3_command {
cpqary3_command_status_t cpcm_status;
- cpqary3_pkt_t *cpcm_private;
+ cpqary3_command_scsa_t *cpcm_scsa;
cpqary3_command_internal_t *cpcm_internal;
/*
@@ -454,7 +450,18 @@ struct cpqary3_command_internal {
size_t cpcmi_len;
};
+/*
+ * Commands issued via the SCSI framework have a number of additional
+ * properties.
+ */
+struct cpqary3_command_scsa {
+ struct scsi_pkt *cpcms_pkt;
+ int cpcms_flags;
+ cpqary3_command_t *cpcms_command;
+};
+
+#if 0
/* cmd_flags */
#define CFLAG_DMASEND 0x01
#define CFLAG_CMDIOPB 0x02
@@ -484,10 +491,10 @@ struct cpqary3_pkt {
uint32_t scb_len;
cpqary3_command_t *cmd_command;
};
+#endif
/* Driver function definitions */
-void cpqary3_init_hbatran(cpqary3_t *);
void cpqary3_periodic(void *);
int cpqary3_flush_cache(cpqary3_t *);
uint16_t cpqary3_init_ctlr_resource(cpqary3_t *);
@@ -498,11 +505,11 @@ int cpqary3_retrieve(cpqary3_t *);
void cpqary3_retrieve_simple(cpqary3_t *);
int cpqary3_target_geometry(struct scsi_address *);
int8_t cpqary3_detect_target_geometry(cpqary3_t *);
-uint8_t cpqary3_send_abortcmd(cpqary3_t *, cpqary3_tgt_t *, cpqary3_command_t *);
+uint8_t cpqary3_send_abortcmd(cpqary3_t *, cpqary3_target_t *, cpqary3_command_t *);
void cpqary3_memfini(cpqary3_t *, uint8_t);
int16_t cpqary3_meminit(cpqary3_t *);
void cpqary3_build_cmdlist(cpqary3_command_t *cpqary3_cmdpvtp,
- cpqary3_tgt_t *);
+ cpqary3_target_t *);
void cpqary3_lockup_check(cpqary3_t *);
void cpqary3_oscmd_complete(cpqary3_command_t *);
@@ -555,8 +562,14 @@ cpqary3_volume_t *cpqary3_lookup_volume_by_id(cpqary3_t *, unsigned);
cpqary3_volume_t *cpqary3_lookup_volume_by_addr(cpqary3_t *,
struct scsi_address *);
-cpqary3_tgt_t *cpqary3_target_from_id(cpqary3_t *, unsigned);
-cpqary3_tgt_t *cpqary3_target_from_addr(cpqary3_t *, struct scsi_address *);
+#if 0
+cpqary3_target_t *cpqary3_target_from_id(cpqary3_t *, unsigned);
+cpqary3_target_t *cpqary3_target_from_addr(cpqary3_t *, struct scsi_address *);
+#endif
+int cpqary3_setcap(struct scsi_address *, char *, int, int);
+int cpqary3_getcap(struct scsi_address *, char *, int);
+
+void cpqary3_hba_setup(cpqary3_t *);
void cpqary3_process_finishq(cpqary3_t *);
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3_ciss.c b/usr/src/uts/common/io/cpqary3/cpqary3_ciss.c
index 539558d296..0f601cc605 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3_ciss.c
+++ b/usr/src/uts/common/io/cpqary3/cpqary3_ciss.c
@@ -47,7 +47,7 @@ cpqary3_periodic(void *arg)
now = ddi_get_lbolt();
for (cpcm = avl_first(&cpq->cpq_inflight); cpcm != NULL;
cpcm = cpcm_next) {
- cpqary3_pkt_t *privp;
+ cpqary3_command_scsa_t *cpcms;
struct scsi_pkt *pkt;
clock_t exp;
@@ -62,8 +62,8 @@ cpqary3_periodic(void *arg)
* issued on behalf of SCSA.
*/
if (cpcm->cpcm_type != CPQARY3_CMDTYPE_OS ||
- (privp = cpcm->cpcm_private) == NULL ||
- (pkt = privp->scsi_cmd_pkt) == NULL) {
+ (cpcms = cpcm->cpcm_scsa) == NULL ||
+ (pkt = cpcms->cpcms_pkt) == NULL) {
continue;
}
@@ -138,6 +138,16 @@ cpqary3_submit(cpqary3_t *cpq, cpqary3_command_t *cpcm)
}
/*
+ * XXX Synchronise the Command Block DMA resources to ensure that the
+ * device has a consistent view before we pass it the address.
+ */
+ if (ddi_dma_sync(cpcm->cpcm_phyctg.cpqary3_dmahandle, 0,
+ sizeof (CommandList_t), DDI_DMA_SYNC_FORDEV) != DDI_SUCCESS) {
+ dev_err(cpq->dip, CE_WARN, "DMA sync failure");
+ return (EIO);
+ }
+
+ /*
* Ensure that this command is not re-used without issuing a new
* tag number and performing any appropriate cleanup.
*/
@@ -211,6 +221,20 @@ cpqary3_process_finishq(cpqary3_t *cpq)
continue;
}
+ /*
+ * XXX Synchronise the Command Block before we read things
+ * from it?
+ */
+ if (ddi_dma_sync(cpcm->cpcm_phyctg.cpqary3_dmahandle, 0,
+ cpcm->cpcm_phyctg.real_size,
+ DDI_DMA_SYNC_FORKERNEL) != DDI_SUCCESS) {
+ dev_err(cpq->dip, CE_WARN,
+ "finishq DMA sync failure");
+ /*
+ * XXX what to do about this?!
+ */
+ }
+
if (cpcm->cpcm_status & CPQARY3_CMD_STATUS_POLLED) {
/*
* This command will be picked up and processed
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3_hba.c b/usr/src/uts/common/io/cpqary3/cpqary3_hba.c
index ad3e5b6054..2e216c7cc0 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3_hba.c
+++ b/usr/src/uts/common/io/cpqary3/cpqary3_hba.c
@@ -41,8 +41,9 @@ cpqary3_tran_tgt_init(dev_info_t *hba_dip, dev_info_t *tgt_dip,
* Look for a logical volume for the SCSI address of this target.
*/
mutex_enter(&cpq->cpq_mutex);
- if ((cplv = cpqary3_lookup_volume_by_addr(cpq, sd)) == NULL) {
- mutex_exit(&cpq_mutex);
+ if ((cplv = cpqary3_lookup_volume_by_addr(cpq, &sd->sd_address)) ==
+ NULL) {
+ mutex_exit(&cpq->cpq_mutex);
kmem_free(cptg, sizeof (*cptg));
return (DDI_FAILURE);
}
@@ -61,7 +62,16 @@ cpqary3_tran_tgt_init(dev_info_t *hba_dip, dev_info_t *tgt_dip,
*/
hba_tran->tran_tgt_private = cptg;
- mutex_exit(&cpq_mutex);
+ /*
+ * XXX
+ * Note that we used to turn on these caps:
+ * CPQARY3_CAP_DISCON_ENABLED
+ * CPQARY3_CAP_SYNC_ENABLED
+ * CPQARY3_CAP_WIDE_XFER_ENABLED
+ * CPQARY3_CAP_ARQ_ENABLED
+ */
+
+ mutex_exit(&cpq->cpq_mutex);
return (DDI_SUCCESS);
}
@@ -69,21 +79,352 @@ static void
cpqary3_tran_tgt_free(dev_info_t *hba_dip, dev_info_t *tgt_dip,
scsi_hba_tran_t *hba_tran, struct scsi_device *sd)
{
+ cpqary3_t *cpq = (cpqary3_t *)hba_tran->tran_hba_private;
cpqary3_target_t *cptg = (cpqary3_target_t *)hba_tran->tran_tgt_private;
cpqary3_volume_t *cplv = cptg->cptg_volume;
+ VERIFY(cptg->cptg_scsi_dev == sd);
+
/*
* XXX Make sure that there are no outstanding commands for this
* target.
*/
mutex_enter(&cpq->cpq_mutex);
- list_insert_remove(&cplv->cplv_targets, cptg);
- mutex_exit(&cpq_mutex);
+ list_remove(&cplv->cplv_targets, cptg);
+ mutex_exit(&cpq->cpq_mutex);
kmem_free(cptg, sizeof (*cptg));
}
+#if 0
+static int
+cpqary3_tran_pkt_constructor(struct scsi_pkt *pkt, scsi_hba_tran_t *tran,
+ int kmflags)
+{
+ cpqary3_t *cpq = tran->tran_hba_private;
+ cpqary3_command_scsa_t *cpcms =
+ (cpqary3_command_scsa_t *)pkt->pkt_hba_private;
+}
+#endif
+
+static int
+cpqary3_tran_setup_pkt(struct scsi_pkt *pkt, int (*callback)(caddr_t),
+ caddr_t arg)
+{
+ scsi_hba_tran_t *tran = pkt->pkt_address.a_hba_tran;
+ cpqary3_t *cpq = (cpqary3_t *)tran->tran_hba_private;
+ cpqary3_target_t *cptg = (cpqary3_target_t *)tran->tran_tgt_private;
+ cpqary3_command_scsa_t *cpcms = (cpqary3_command_scsa_t *)
+ pkt->pkt_ha_private;
+ cpqary3_command_t *cpcm;
+
+ /*
+ * The SCSI framework has allocated a packet, and our private
+ * per-packet object.
+ *
+ * We choose not to have the framework pre-allocate memory
+ * for the command (CDB) and status (SCB) blocks. Instead, we
+ * will make available the memory in the command block itself.
+ */
+
+ /*
+ * Check that we have enough space in the command object for the
+ * request from the target driver:
+ */
+ if (pkt->pkt_cdblen > 16) {
+ /*
+ * The CDB member of the Request Block of a controller
+ * command is fixed at 16 bytes.
+ */
+ return (-1);
+ }
+ if (pkt->pkt_scblen > CISS_SENSEINFOBYTES) {
+ /*
+ * The SCB is the "SenseInfo[]" member of the "ErrorInfo_t".
+ * This is statically allocated; make sure it is big enough.
+ */
+ return (-1);
+ }
+
+ /*
+ * Allocate our command block:
+ * XXX should be passing through the SLEEP_FUCN/NULL_FUNC here
+ * as kmflags...
+ */
+ if ((cpcm = cpqary3_command_alloc(cpq, CPQARY3_CMDTYPE_OS)) == NULL) {
+ return (-1);
+ }
+ cpcm->cpcm_scsa = cpcms;
+ cpcms->cpcms_command = cpcm;
+
+ pkt->pkt_cdbp = &cpcm->cpcm_va_cmd->Request.CDB[16];
+ cpcm->cpcm_va_cmd->Request.CDBLen = pkt->pkt_cdblen;
+
+ pkt->pkt_scbp = (uchar_t *)&cpcm->cpcm_va_err->SenseInfo;
+ /*
+ * XXX we should enable/disable AUTOMATIC REQUEST SENSE?
+ * (see: tran_setup_pkt(9E))
+ */
+
+ cpcm->cpcm_target = cptg;
+ /*
+ * XXX We should link our command into the target_t via some list
+ */
+
+ return (0);
+}
+
+static void
+cpqary3_tran_teardown_pkt(struct scsi_pkt *pkt)
+{
+ scsi_hba_tran_t *tran = pkt->pkt_address.a_hba_tran;
+ cpqary3_t *cpq = (cpqary3_t *)tran->tran_hba_private;
+ cpqary3_command_scsa_t *cpcms = (cpqary3_command_scsa_t *)
+ pkt->pkt_ha_private;
+ cpqary3_command_t *cpcm = cpcms->cpcms_command;
+
+ /*
+ * XXX We should remove ourselves from the target_t list...
+ */
+
+ cpqary3_command_free(cpcm);
+
+ pkt->pkt_cdbp = NULL;
+ pkt->pkt_scbp = NULL;
+}
+
+static int
+cpqary3_tran_start(struct scsi_address *sa, struct scsi_pkt *pkt)
+{
+ scsi_hba_tran_t *tran = pkt->pkt_address.a_hba_tran;
+ cpqary3_t *cpq = (cpqary3_t *)tran->tran_hba_private;
+ cpqary3_command_scsa_t *cpcms = (cpqary3_command_scsa_t *)
+ pkt->pkt_ha_private;
+ cpqary3_command_t *cpcm = cpcms->cpcms_command;
+ int r;
+
+ if (pkt->pkt_flags & FLAG_NOINTR) {
+ /*
+ * We must sleep and wait for the completion of this command.
+ */
+ cpcm->cpcm_status |= CPQARY3_CMD_STATUS_POLLED;
+ }
+
+ /*
+ * Because we provide a tran_setup_pkt(9E) entrypoint, we must now
+ * set up the Scatter/Gather List in the Command to reflect any
+ * DMA resources passed to us by the framework.
+ */
+ if (pkt->pkt_numcookies > cpq->cpq_sg_cnt) {
+ /*
+ * More DMA cookies than we are prepared to handle.
+ */
+ return (TRAN_BADPKT);
+ }
+ cpcm->cpcm_va_cmd->Header.SGList = pkt->pkt_numcookies;
+ cpcm->cpcm_va_cmd->Header.SGTotal = pkt->pkt_numcookies;
+ for (unsigned i = 0; i < pkt->pkt_numcookies; i++) {
+ cpcm->cpcm_va_cmd->SG[i].Addr =
+ pkt->pkt_cookies[i].dmac_laddress;
+ cpcm->cpcm_va_cmd->SG[i].Len =
+ pkt->pkt_cookies[i].dmac_size;
+ }
+
+ /*
+ * Copy logical volume address from the target object:
+ */
+ cpcm->cpcm_va_cmd->Header.LUN.LogDev = cpcm->cpcm_target->
+ cptg_volume->cplv_addr;
+
+ /*
+ * Initialise the command block.
+ */
+ cpcm->cpcm_va_cmd->Request.CDBLen = pkt->pkt_cdblen;
+ cpcm->cpcm_va_cmd->Request.Type.Type = CISS_TYPE_CMD;
+ cpcm->cpcm_va_cmd->Request.Type.Attribute = CISS_ATTR_ORDERED;
+ cpcm->cpcm_va_cmd->Request.Timeout = pkt->pkt_time;
+ if (pkt->pkt_numcookies > 0) {
+ /*
+ * There are DMA resources; set the transfer direction
+ * appropriately:
+ */
+ if (pkt->pkt_dma_flags & DDI_DMA_READ) {
+ cpcm->cpcm_va_cmd->Request.Type.Direction =
+ CISS_XFER_READ;
+ } else if (pkt->pkt_dma_flags & DDI_DMA_WRITE) {
+ cpcm->cpcm_va_cmd->Request.Type.Direction =
+ CISS_XFER_WRITE;
+ } else {
+ cpcm->cpcm_va_cmd->Request.Type.Direction =
+ CISS_XFER_NONE;
+ }
+ } else {
+ /*
+ * No DMA resources means no transfer.
+ */
+ cpcm->cpcm_va_cmd->Request.Type.Direction = CISS_XFER_NONE;
+ }
+
+ /*
+ * Initialise the SCSI packet as described in tran_start(9E). We will
+ * progressively update these fields as the command moves through the
+ * submission and completion states.
+ */
+ pkt->pkt_resid = 0;
+ pkt->pkt_reason = CMD_CMPLT;
+ pkt->pkt_statistics = 0;
+ pkt->pkt_state = 0;
+
+ /*
+ * XXX Synchronise DMA for device to see changes to the command
+ * block...? XXX this is being done in cpqary3_submit() now ...
+ */
+#if 0
+ if (ddi_dma_sync(cpcm->cpcm_phyctg->cpqary3_dmahandle, 0,
+ sizeof (CommandList_t), DDI_DMA_SYNC_FORDEV) != DDI_SUCCESS) {
+ dev_err(cpq->cpq, CE_WARN, "DMA sync failure");
+ return (TRAN_FATAL_ERROR);
+ }
+#endif
+
+ /*
+ * XXX I don't _think_ we need to synchronise the DMA stuff we
+ * were _passed_ (in the SCSI packet). Need to make sure, though.
+ * I think the documentation could be clearer about this...
+ */
+
+ /*
+ * Submit the command to the controller!
+ */
+ mutex_enter(&cpq->cpq_mutex);
+ if ((r = cpqary3_submit(cpq, cpcm)) != 0) {
+ mutex_exit(&cpq->cpq_mutex);
+
+ /*
+ * Inform the SCSI framework that we could not submit
+ * the command.
+ */
+ return (r == EAGAIN ? TRAN_BUSY : TRAN_FATAL_ERROR);
+ }
+
+ /*
+ * Update the SCSI packet to reflect submission of the command.
+ */
+ pkt->pkt_state |= STATE_GOT_BUS | STATE_GOT_TARGET | STATE_SENT_CMD;
+
+ if (pkt->pkt_flags & FLAG_NOINTR) {
+ /*
+ * Poll the controller for completion of the command we
+ * submitted. Once this routine has returned, the completion
+ * callback will have been fired with either an active response
+ * (success or error) or a timeout. The command is freed by
+ * the completion callback, so it may not be referenced again
+ * after this call returns.
+ */
+ cpqary3_poll_for(cpq, cpcm);
+ }
+
+ mutex_exit(&cpq->cpq_mutex);
+ return (TRAN_ACCEPT);
+}
+
+
+#if 0
+static struct scsi_pkt *
+cpqary3_tran_init_pkt(struct scsi_address *sa, struct scsi_pkt *pkt,
+ struct buf *bp, int cmdlen, int statuslen, int tgtlen,
+ int flags, int (*callback)(), caddr_t arg)
+{
+ cpqary3_t *cpq = (cpqary3_t *)sa->a_hba_tran->tran_hba_private;
+ cpqary3_target_t *cptg = (cpqary3_target_t *)sa->a_hba_tran->
+ tran_tgt_private;
+ boolean_t allocated_packet = B_FALSE;
+ cpqary3_command_scsa_t *cpcms;
+
+ if (pkt == NULL) {
+ /*
+ * The framework requires we allocate a new packet
+ * structure via scsi_hba_pkt_alloc(9F).
+ */
+ if ((pkt = scsi_hba_pkt_alloc(cpq->dip, sa, cmdlen, statuslen,
+ tgtlen, sizeof (*cpcms), callback, arg)) == NULL) {
+ return (NULL);
+ }
+ allocated_packet = B_TRUE;
+ }
+ cpcms = (cpqary3_command_scsa_t *)pkt->pkt_ha_private;
+
+ if (allocated_packet) {
+ /*
+ * Our private SCSI packet object was just allocated by
+ * scsi_hba_pkt_alloc(9F). Initialise it:
+ */
+ cpcms->cpcms_pkt = pkt;
+ }
+
+ if (bp != NULL && allocated_packet) {
+ /*
+ * This is a new packet with an associated buffer. The
+ * framework requires us to allocate appropriate DMA
+ * resources.
+ */
+ if (cpqary3_dma_alloc(cpq, pkt, bp, flags, callback) !=
+ DDI_SUCCESS) {
+ scsi_hba_pkt_free(sa, scsi_pktp);
+ return (NULL);
+ }
+ } else if (bp != NULL && !allocated_packet &&
+ (flags & PKT_DMA_PARTIAL) != 0) {
+ /*
+ * This is not a new packet, but a buffer was passed in and we
+ * had previously allocated DMA resources. This is a request
+ * from the framework to move the DMA resources.
+ */
+ if (cpqary3_dma_move(scsi_pktp, bp, cpq) != DDI_SUCCESS) {
+ return (NULL);
+ }
+ }
+
+ return (scsi_pktp);
+}
+#endif
+
+static int
+cpqary3_tran_reset(struct scsi_address *sa, int level)
+{
+ /*
+ * We currently have no earthly idea how to reset the controller.
+ * Signal our universal, abject failure to the SCSI framework.
+ */
+ return (0);
+}
+
+static int
+cpqary3_tran_abort(struct scsi_address *sa, struct scsi_pkt *pkt)
+{
+ scsi_hba_tran_t *tran = sa->a_hba_tran;
+ cpqary3_t *cpq = (cpqary3_t *)tran->tran_hba_private;
+ cpqary3_target_t *cptg = (cpqary3_target_t *)tran->tran_tgt_private;
+ cpqary3_command_t *cpcm = NULL;
+ int r;
+
+ if (pkt != NULL) {
+ cpqary3_command_scsa_t *cpcms = (cpqary3_command_scsa_t *)
+ pkt->pkt_ha_private;
+ cpcm = cpcms->cpcms_command;
+ }
+
+ mutex_enter(&cpq->cpq_mutex);
+ /*
+ * XXX
+ */
+ r = cpqary3_send_abortcmd(cpq, cptg, cpcm);
+ mutex_exit(&cpq->cpq_mutex);
+
+ return (r == 0 ? 1 : 0);
+}
+
void
cpqary3_hba_setup(cpqary3_t *cpq)
{
@@ -95,17 +436,32 @@ cpqary3_hba_setup(cpqary3_t *cpq)
tran->tran_tgt_probe = scsi_hba_probe;
tran->tran_tgt_free = cpqary3_tran_tgt_free;
- tran->tran_start = XXX;
- tran->tran_reset = XXX;
- tran->tran_abort = XXX;
+ tran->tran_start = cpqary3_tran_start;
+ tran->tran_reset = cpqary3_tran_reset;
+ tran->tran_abort = cpqary3_tran_abort;
- tran->tran_getcap = XXX;
- tran->tran_setcap = XXX;
+ /*
+ * XXX these are still the old ones
+ */
+ tran->tran_getcap = cpqary3_getcap;
+ tran->tran_setcap = cpqary3_setcap;
+#if 0
+ /*
+ * XXX Old style:
+ */
tran->tran_init_pkt = XXX;
tran->tran_destroy_pkt = XXX;
tran->tran_dmafree = XXX;
tran->tran_sync_pkt = XXX;
+#else
+ /*
+ * XXX New style:
+ */
+ tran->tran_setup_pkt = cpqary3_tran_setup_pkt;
+ tran->tran_teardown_pkt = cpqary3_tran_teardown_pkt;
+ tran->tran_hba_len = sizeof (cpqary3_command_scsa_t);
+#endif
/*
* XXX We should set "tran_interconnect_type" appropriately.
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3_logvol.c b/usr/src/uts/common/io/cpqary3/cpqary3_logvol.c
index 54418df81e..e2654a6fa1 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3_logvol.c
+++ b/usr/src/uts/common/io/cpqary3/cpqary3_logvol.c
@@ -35,11 +35,11 @@ cpqary3_lookup_volume_by_addr(cpqary3_t *cpq, struct scsi_address *sa)
{
VERIFY(MUTEX_HELD(&cpq->cpq_mutex));
- if (sa->sa_lun != 0) {
+ if (sa->a_lun != 0) {
return (NULL);
}
- return (cpqary3_lookup_volume_by_id(cpq, sa->sa_target));
+ return (cpqary3_lookup_volume_by_id(cpq, sa->a_target));
}
static void
@@ -58,8 +58,7 @@ cpqary3_write_lun_addr_phys(LUNAddr_t *lun, boolean_t masked, unsigned bus,
static int
cpqary3_read_logvols(cpqary3_t *cpq, cpqary3_report_logical_lun_t *cprll)
{
- cpqary3_report_logical_lun_extent_t *ents =
- cprll->cprll_data.ents;
+ cpqary3_report_logical_lun_ent_t *ents = cprll->cprll_data.ents;
uint32_t count = ntohl(cprll->cprll_datasize) /
sizeof (cpqary3_report_logical_lun_ent_t);
@@ -71,15 +70,15 @@ cpqary3_read_logvols(cpqary3_t *cpq, cpqary3_report_logical_lun_t *cprll)
cpqary3_volume_t *cplv;
if ((cplv = cpqary3_lookup_volume_by_id(cpq,
- ents[i]->cprle_addr.VolId)) != NULL) {
+ ents[i].cprle_addr.VolId)) != NULL) {
continue;
}
dev_err(cpq->dip, CE_WARN, "NEW LOGVOL[%u]: mode %x "
"volid %x attr %x", i,
- ents[i]->cprle_addr.Mode,
- ents[i]->cprle_addr.VolId,
- *((uint32_t *)ents[i]->cprle_addr.reserved));
+ ents[i].cprle_addr.Mode,
+ ents[i].cprle_addr.VolId,
+ *((uint32_t *)ents[i].cprle_addr.reserved));
/*
* This is a new Logical Volume, so add it the the list.
@@ -88,13 +87,13 @@ cpqary3_read_logvols(cpqary3_t *cpq, cpqary3_report_logical_lun_t *cprll)
NULL) {
return (ENOMEM);
- cplv->cplv_addr = ents[i]->cprle_addr;
+ cplv->cplv_addr = ents[i].cprle_addr;
list_create(&cplv->cplv_targets,
sizeof (cpqary3_target_t),
offsetof(cpqary3_target_t, cptg_link_volume));
- cplv->cplv_ctrl = cpq;
+ cplv->cplv_ctlr = cpq;
list_insert_tail(&cpq->cpq_volumes, cplv);
}
}
@@ -118,7 +117,7 @@ cpqary3_read_logvols_ext(cpqary3_t *cpq, cpqary3_report_logical_lun_t *cprll)
cpqary3_volume_t *cplv;
if ((cplv = cpqary3_lookup_volume_by_id(cpq,
- ents[i]->cprle_addr.VolId)) != NULL) {
+ extents[i].cprle_addr.VolId)) != NULL) {
/*
* XXX compare previous WWN with current WWN...
*/
@@ -127,28 +126,28 @@ cpqary3_read_logvols_ext(cpqary3_t *cpq, cpqary3_report_logical_lun_t *cprll)
dev_err(cpq->dip, CE_WARN, "NEW EXT LOGVOL[%u]: mode %x "
"volid %x attr %x", i,
- extents[i]->cprle_addr.Mode,
- extents[i]->cprle_addr.VolId,
- *((uint32_t *)extents[i]->cprle_addr.reserved));
+ extents[i].cprle_addr.Mode,
+ extents[i].cprle_addr.VolId,
+ *((uint32_t *)extents[i].cprle_addr.reserved));
dev_err(cpq->dip, CE_WARN, "-- id %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x %02x "
"%02x %02x %02x %02x",
- (uint32_t)extents[i]->cprle_wwn[0],
- (uint32_t)extents[i]->cprle_wwn[1],
- (uint32_t)extents[i]->cprle_wwn[2],
- (uint32_t)extents[i]->cprle_wwn[3],
- (uint32_t)extents[i]->cprle_wwn[4],
- (uint32_t)extents[i]->cprle_wwn[5],
- (uint32_t)extents[i]->cprle_wwn[6],
- (uint32_t)extents[i]->cprle_wwn[7],
- (uint32_t)extents[i]->cprle_wwn[8],
- (uint32_t)extents[i]->cprle_wwn[9],
- (uint32_t)extents[i]->cprle_wwn[10],
- (uint32_t)extents[i]->cprle_wwn[11],
- (uint32_t)extents[i]->cprle_wwn[12],
- (uint32_t)extents[i]->cprle_wwn[13],
- (uint32_t)extents[i]->cprle_wwn[14],
- (uint32_t)extents[i]->cprle_wwn[15]);
+ (uint32_t)extents[i].cprle_wwn[0],
+ (uint32_t)extents[i].cprle_wwn[1],
+ (uint32_t)extents[i].cprle_wwn[2],
+ (uint32_t)extents[i].cprle_wwn[3],
+ (uint32_t)extents[i].cprle_wwn[4],
+ (uint32_t)extents[i].cprle_wwn[5],
+ (uint32_t)extents[i].cprle_wwn[6],
+ (uint32_t)extents[i].cprle_wwn[7],
+ (uint32_t)extents[i].cprle_wwn[8],
+ (uint32_t)extents[i].cprle_wwn[9],
+ (uint32_t)extents[i].cprle_wwn[10],
+ (uint32_t)extents[i].cprle_wwn[11],
+ (uint32_t)extents[i].cprle_wwn[12],
+ (uint32_t)extents[i].cprle_wwn[13],
+ (uint32_t)extents[i].cprle_wwn[14],
+ (uint32_t)extents[i].cprle_wwn[15]);
/*
* This is a new Logical Volume, so add it the the list.
@@ -157,16 +156,16 @@ cpqary3_read_logvols_ext(cpqary3_t *cpq, cpqary3_report_logical_lun_t *cprll)
NULL) {
return (ENOMEM);
- cplv->cplv_addr = ents[i]->cprle_addr;
+ cplv->cplv_addr = extents[i].cprle_addr;
- bcopy(extents[i]->cprle_wwn, cplv->cplv_addr, 16);
+ bcopy(extents[i].cprle_wwn, cplv->cplv_wwn, 16);
cplv->cplv_flags |= CPQARY3_VOL_FLAG_WWN;
list_create(&cplv->cplv_targets,
sizeof (cpqary3_target_t),
offsetof(cpqary3_target_t, cptg_link_volume));
- cplv->cplv_ctrl = cpq;
+ cplv->cplv_ctlr = cpq;
list_insert_tail(&cpq->cpq_volumes, cplv);
}
}
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3_scsi.c b/usr/src/uts/common/io/cpqary3/cpqary3_scsi.c
index 3f7d7509db..933ec085da 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3_scsi.c
+++ b/usr/src/uts/common/io/cpqary3/cpqary3_scsi.c
@@ -21,6 +21,7 @@
* Local Functions Definitions
*/
+#if 0
static uint8_t cpqary3_probe4LVs(cpqary3_t *);
static uint8_t cpqary3_probe4Tapes(cpqary3_t *);
@@ -51,95 +52,7 @@ cpqary3_probe4targets(cpqary3_t *cpqary3p)
return (CPQARY3_SUCCESS);
}
-
-/*
- * Function : cpqary3_build_cmdlist
- * Description : This routine builds the command list for the specific
- * opcode.
- * Called By : cpqary3_transport()
- * Parameters : cmdlist pvt struct, target id as received by SA.
- * Calls : None
- * Return Values: SUCCESS : Build is successful
- * FAILURE : Build has Failed
- */
-void
-cpqary3_build_cmdlist(cpqary3_command_t *cpcm, cpqary3_tgt_t *tgtp)
-{
- int cntr;
- cpqary3_t *cpq = cpcm->cpcm_ctlr;
- CommandList_t *cmdlistp = cpcm->cpcm_va_cmd;
- cpqary3_pkt_t *pkt = cpcm->cpcm_private;
- struct buf *bfp = pkt->bf;
-
- /* Update Cmd Header */
- cmdlistp->Header.SGList = pkt->cmd_cookiecnt;
- cmdlistp->Header.SGTotal = pkt->cmd_cookiecnt;
-
- if (tgtp->type == CPQARY3_TARGET_CTLR) {
- cmdlistp->Header.LUN.PhysDev.TargetId = 0;
- cmdlistp->Header.LUN.PhysDev.Bus = 0;
- cmdlistp->Header.LUN.PhysDev.Mode = MASK_PERIPHERIAL_DEV_ADDR;
- } else if (tgtp->type == CPQARY3_TARGET_LOG_VOL) {
- cmdlistp->Header.LUN.LogDev.VolId = tgtp->logical_id;
- cmdlistp->Header.LUN.LogDev.Mode = LOGICAL_VOL_ADDR;
- } else if (tgtp->type == CPQARY3_TARGET_TAPE) {
- bcopy(&(tgtp->PhysID), &(cmdlistp->Header.LUN.PhysDev),
- sizeof (PhysDevAddr_t));
-
- DTRACE_PROBE1(build_cmdlist_tape, CommandList_t *, cmdlistp);
- } else {
- dev_err(cpq->dip, CE_PANIC, "unexpected target type: %x",
- tgtp->type);
- }
-
- /* Cmd Request */
- cmdlistp->Request.CDBLen = pkt->cdb_len;
-
- bcopy(pkt->scsi_cmd_pkt->pkt_cdbp, cmdlistp->Request.CDB, pkt->cdb_len);
-
- cmdlistp->Request.Type.Type = CISS_TYPE_CMD;
- cmdlistp->Request.Type.Attribute = CISS_ATTR_ORDERED;
-
- DTRACE_PROBE2(build_cmdlist_buf, struct buf *, bfp,
- CommandList_t *, cmdlistp);
-
- if (bfp && (bfp->b_flags & B_READ))
- cmdlistp->Request.Type.Direction = CISS_XFER_READ;
- else if (bfp && (bfp->b_flags & B_WRITE))
- cmdlistp->Request.Type.Direction = CISS_XFER_WRITE;
- else
- cmdlistp->Request.Type.Direction = CISS_XFER_NONE;
- /*
- * Looks like the above Direction is going for a toss in case of
- * MSA20(perticularly for 0x0a-write) connected to SMART Array.
- * If the above check fails, the below switch should take care.
- */
-
- switch (cmdlistp->Request.CDB[0]) {
- case 0x08: /* XXX ? */
- case 0x28: /* XXX ? */
- cmdlistp->Request.Type.Direction = CISS_XFER_READ;
- break;
- case 0x0A: /* XXX ? */
- case 0x2A: /* XXX ? */
- cmdlistp->Request.Type.Direction = CISS_XFER_WRITE;
- break;
- }
-
- /*
- * NEED to increase this TimeOut value when the concerned
- * targets are tape devices(i.e., we need to do it here manually).
- */
- cmdlistp->Request.Timeout = 2 * pkt->scsi_cmd_pkt->pkt_time;
-
- for (cntr = 0; cntr < pkt->cmd_cookiecnt; cntr++) {
- cmdlistp->SG[cntr].Addr =
- pkt->cmd_dmacookies[cntr].dmac_laddress;
- cmdlistp->SG[cntr].Len = (uint32_t)
- pkt->cmd_dmacookies[cntr].dmac_size;
- }
-}
-
+#endif
/*
* Function : cpqary3_send_abortcmd
@@ -153,7 +66,7 @@ cpqary3_build_cmdlist(cpqary3_command_t *cpcm, cpqary3_tgt_t *tgtp)
* FAILURE - Could not submit the abort cmd.
*/
uint8_t
-cpqary3_send_abortcmd(cpqary3_t *cpq, cpqary3_tgt_t *tgtp,
+cpqary3_send_abortcmd(cpqary3_t *cpq, cpqary3_target_t *tgtp,
cpqary3_command_t *abort_cpcm)
{
CommandList_t *cmdlistp;
@@ -162,15 +75,6 @@ cpqary3_send_abortcmd(cpqary3_t *cpq, cpqary3_tgt_t *tgtp,
VERIFY(MUTEX_HELD(&cpq->cpq_mutex));
- switch (tgtp->type) {
- case CPQARY3_TARGET_TAPE:
- case CPQARY3_TARGET_LOG_VOL:
- break;
-
- default:
- return (EINVAL);
- }
-
/*
* Occupy the Command List
* Update the Command List accordingly
@@ -215,21 +119,11 @@ cpqary3_send_abortcmd(cpqary3_t *cpq, cpqary3_tgt_t *tgtp,
*/
cmdlistp->Request.CDB[1] = CISS_ABORT_TASKSET;
- switch (tgtp->type) {
- case CPQARY3_TARGET_LOG_VOL:
- cmdlistp->Header.LUN.LogDev.Mode = LOGICAL_VOL_ADDR;
- cmdlistp->Header.LUN.LogDev.VolId = tgtp->logical_id;
- break;
-
- case CPQARY3_TARGET_TAPE:
- bcopy(&(tgtp->PhysID), &(cmdlistp->Header.LUN.PhysDev),
- sizeof (PhysDevAddr_t));
- break;
-
- default:
- panic("unexpected target type");
- break;
- }
+ cmdlistp->Header.LUN.LogDev = tgtp->cptg_volume->cplv_addr;
+#if 0
+ cmdlistp->Header.LUN.LogDev.Mode = LOGICAL_VOL_ADDR;
+ cmdlistp->Header.LUN.LogDev.VolId = tgtp->logical_id;
+#endif
}
if (cpqary3_synccmd_send(cpq, cpcm, 30000,
@@ -287,6 +181,7 @@ cpqary3_flush_cache(cpqary3_t *cpqary3p)
return (0);
}
+#if 0
/*
* Function : cpqary3_probe4LVs
* Description : This routine probes for the logical drives
@@ -606,3 +501,4 @@ cpqary3_probe4Tapes(cpqary3_t *cpqary3p)
return (CPQARY3_SUCCESS);
}
+#endif
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3_transport.c b/usr/src/uts/common/io/cpqary3/cpqary3_transport.c
index 1e3865acc4..39a4a41dc5 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3_transport.c
+++ b/usr/src/uts/common/io/cpqary3/cpqary3_transport.c
@@ -21,26 +21,6 @@
* Local Functions Definitions
*/
-static int cpqary3_tgt_init(dev_info_t *, dev_info_t *, scsi_hba_tran_t *,
- struct scsi_device *);
-static int cpqary3_tgt_probe(struct scsi_device *, int (*)());
-static int cpqary3_tran_start(struct scsi_address *, struct scsi_pkt *);
-static int cpqary3_tran_reset(struct scsi_address *, int);
-static int cpqary3_tran_abort(struct scsi_address *, struct scsi_pkt *);
-static int cpqary3_getcap(struct scsi_address *, char *, int);
-static int cpqary3_setcap(struct scsi_address *, char *, int, int);
-static int cpqary3_dma_alloc(cpqary3_t *, struct scsi_pkt *,
- struct buf *, int, int (*)());
-static int cpqary3_dma_move(struct scsi_pkt *, struct buf *, cpqary3_t *);
-static int cpqary3_handle_flag_nointr(cpqary3_command_t *, struct scsi_pkt *);
-static void cpqary3_dmafree(struct scsi_address *, struct scsi_pkt *);
-static void cpqary3_dma_sync(struct scsi_address *, struct scsi_pkt *);
-static void cpqary3_tran_destroy_pkt(struct scsi_address *,
- struct scsi_pkt *);
-static struct scsi_pkt *cpqary3_tran_init_pkt(struct scsi_address *,
- struct scsi_pkt *, struct buf *, int, int, int, int, int (*callback)(),
- caddr_t);
-static int cpqary3_additional_cmd(struct scsi_pkt *scsi_pktp, cpqary3_t *);
static boolean_t cpqary3_is_scsi_read_write(struct scsi_pkt *scsi_pktp);
/*
@@ -49,451 +29,6 @@ static boolean_t cpqary3_is_scsi_read_write(struct scsi_pkt *scsi_pktp);
extern ddi_dma_attr_t cpqary3_dma_attr;
-void
-cpqary3_init_hbatran(cpqary3_t *cpq)
-{
- scsi_hba_tran_t *hba_tran = cpq->cpq_hba_tran;
-
- /*
- * Memory for the transport vector has been allocated by now.
- * initialize all the entry points in this vector
- */
-
- hba_tran->tran_hba_private = cpq;
-
- /* Target Driver Instance Initialization */
- hba_tran->tran_tgt_init = cpqary3_tgt_init;
- hba_tran->tran_tgt_probe = cpqary3_tgt_probe;
-
- /* Resource Allocation */
- hba_tran->tran_init_pkt = cpqary3_tran_init_pkt;
- hba_tran->tran_destroy_pkt = cpqary3_tran_destroy_pkt;
- hba_tran->tran_sync_pkt = cpqary3_dma_sync;
- hba_tran->tran_dmafree = cpqary3_dmafree;
-
- /* Command Transport */
- hba_tran->tran_start = cpqary3_tran_start;
-
- /* Capability Management */
- hba_tran->tran_getcap = cpqary3_getcap;
- hba_tran->tran_setcap = cpqary3_setcap;
-
- /* Abort and Reset */
- hba_tran->tran_reset = cpqary3_tran_reset;
- hba_tran->tran_abort = cpqary3_tran_abort;
-}
-
-/* ARGSUSED */
-static int
-cpqary3_tgt_init(dev_info_t *hba_dip, dev_info_t *tgt_dip,
- scsi_hba_tran_t *hba_tran, struct scsi_device *sd)
-{
- uint32_t tid = SD2TGT(sd);
- uint32_t lun = SD2LUN(sd);
- cpqary3_t *ctlr;
- cpqary3_tgt_t *tgtp;
-
- ctlr = (cpqary3_t *)hba_tran->tran_hba_private;
-
- if ((CPQARY3_SUCCESS == cpqary3_probe4targets(ctlr)) &&
- (ctlr->cpq_ntargets > 0)) {
- (void) cpqary3_detect_target_geometry(ctlr);
- }
-
- /*
- * Validate the Target ID
- * Validate Lun --Ver1.10--
- * If not a valid target id, return FAILURE.
- * Derieve the per-controller
- */
-
- if ((tid >= CPQARY3_MAX_TGT) || (lun != 0)) {
- DTRACE_PROBE2(tgt_init_notsup,
- cpqary3_t *, ctlr, uint32_t, tid);
- return (DDI_FAILURE);
- }
-
- /*
- * Check to see if a target structure corrresponding to this
- * target Id exists.(support only for Logical Drives and Controller)
- * if target exists, update target flags, return SUCCESS
- * is target does not exist, return FAILURE
- */
-
- mutex_enter(&ctlr->cpq_mutex);
-
- if ((tgtp = cpqary3_target_from_id(ctlr, tid)) == NULL) {
- mutex_exit(&ctlr->cpq_mutex);
- return (DDI_FAILURE);
- }
-
- tgtp->tgt_dip = tgt_dip;
- tgtp->ctlr_flags = CPQARY3_CAP_DISCON_ENABLED |
- CPQARY3_CAP_SYNC_ENABLED | CPQARY3_CAP_WIDE_XFER_ENABLED |
- CPQARY3_CAP_ARQ_ENABLED;
-
- mutex_exit(&ctlr->cpq_mutex);
-
- DTRACE_PROBE1(tgt_init_done, uint32_t, tid);
-
- return (DDI_SUCCESS);
-}
-
-void
-cpqary3_tgt_free(dev_info_t *hba_dip, dev_info_t *tgt_dip,
- scsi_hba_tran_t *hba_tran, struct scsi_device *sd)
-{
- cpqary3_t *cpq = (cpqary3_t *)hba_tran->tran_hba_private;
-
- mutex_enter(&cpq->cpq_mutex);
- /*
- * XXX
- */
- mutex_exit(&cpq->cpq_mutex);
-}
-
-static int
-cpqary3_tgt_probe(struct scsi_device *sd, int (*waitfunc)())
-{
- /*
- * Probe for the presence of the target, using the scsi_hba_probe().
- * It inturn issues the SCSI inquiry command that is serviced by our
- * driver
- */
-
- extern int8_t cpqary3_detect_target_geometry(cpqary3_t *);
- struct scsi_hba_tran *hba_tran = sd->sd_address.a_hba_tran;
- cpqary3_t *ctlr = hba_tran->tran_hba_private;
-
- if ((CPQARY3_SUCCESS == cpqary3_probe4targets(ctlr)) &&
- (ctlr->cpq_ntargets > 0)) {
- (void) cpqary3_detect_target_geometry(ctlr);
- }
-
- return (scsi_hba_probe(sd, waitfunc));
-}
-
-/* ARGSUSED */
-static struct scsi_pkt *
-cpqary3_tran_init_pkt(struct scsi_address *sa, struct scsi_pkt *scsi_pktp,
- struct buf *bp, int cmdlen, int statuslen, int tgtlen,
- int flags, int (*callback)(), caddr_t arg)
-{
- cpqary3_t *cpq = SA2CTLR(sa);
- boolean_t allocated_packet = B_FALSE;
-
- cpqary3_pkt_t *privp;
- struct scsi_pkt *new_scsi_pktp;
-
- ASSERT(callback == NULL_FUNC || callback == SLEEP_FUNC);
-
- if (scsi_pktp == NULL) {
- /*
- * The framework requires we allocate a new packet
- * structure via scsi_hba_pkt_alloc(9F).
- */
- if ((scsi_pktp = scsi_hba_pkt_alloc(cpq->dip, sa, cmdlen,
- statuslen, tgtlen, sizeof (cpqary3_pkt_t), callback,
- NULL)) == NULL) {
- return (NULL);
- }
- allocated_packet = B_TRUE;
- }
-
- privp = (cpqary3_pkt_t *)scsi_pktp->pkt_ha_private;
-
- if (allocated_packet) {
- /*
- * Our private SCSI packet object was just allocated by
- * scsi_hba_pkt_alloc(9F). Initialise it:
- */
- bzero(privp, sizeof (*privp));
-
- /*
- * Link our private point back to the SCSI framework
- * packet object, and include the CDB/SCB lengths we
- * have been passed.
- */
- privp->scsi_cmd_pkt = scsi_pktp;
- privp->cdb_len = cmdlen;
- privp->scb_len = statuslen;
-
- if (flags & PKT_DMA_PARTIAL) {
- privp->cmd_flags |= DDI_DMA_PARTIAL;
- }
- }
-
- if (bp != NULL && allocated_packet) {
- /*
- * This is a new packet with an associated buffer. The
- * framework requires us to allocate appropriate DMA
- * resources.
- */
- privp->bf = bp;
- if (cpqary3_dma_alloc(cpq, scsi_pktp, bp, flags,
- callback) != DDI_SUCCESS) {
- scsi_hba_pkt_free(sa, scsi_pktp);
- return (NULL);
- }
- } else if (bp != NULL && !allocated_packet &&
- (flags & PKT_DMA_PARTIAL) != 0) {
- /*
- * This is not a new packet, but a buffer was passed in and we
- * had previously allocated DMA resources. This is a request
- * from the framework to move the DMA resources.
- */
- if (cpqary3_dma_move(scsi_pktp, bp, cpq) != DDI_SUCCESS) {
- return (NULL);
- }
- }
-
- return (scsi_pktp);
-}
-
-/*
- * Function : cpqary3_dma_alloc()
- * Description : This routine services requests for memory (dynamic)
- * as and when required by the OS.
- * Called By : cpqary3_init_pkt()
- * Parameters : per-controller, SCSI packet, buffer, flag modifier,
- * callback function
- * Calls : None
- * Return Values: SUCCESS / FAILURE
- */
-static int
-cpqary3_dma_alloc(cpqary3_t *cpqary3p, struct scsi_pkt *scsi_pktp,
- struct buf *bp, int flags, int (*callback)())
-{
- int32_t (*cb)(caddr_t);
- int32_t retvalue;
- uint32_t i = 0;
- uint32_t dma_flags;
- cpqary3_pkt_t *cpqary3_pktp;
- ddi_dma_attr_t tmp_dma_attr;
-
- cpqary3_pktp = (cpqary3_pkt_t *)scsi_pktp->pkt_ha_private;
-
- ASSERT(callback == NULL_FUNC || callback == SLEEP_FUNC);
- /*
- * Record the direction of the data transfer, so that it
- * can be used in appropriate synchronization during cpqary3_sync_pkt()
- */
- if (bp->b_flags & B_READ) {
- cpqary3_pktp->cmd_flags &= ~CFLAG_DMASEND;
- dma_flags = DDI_DMA_READ;
- } else {
- cpqary3_pktp->cmd_flags |= CFLAG_DMASEND;
- dma_flags = DDI_DMA_WRITE;
- }
-
- if (flags & PKT_CONSISTENT) {
- cpqary3_pktp->cmd_flags |= CFLAG_CMDIOPB;
- dma_flags |= DDI_DMA_CONSISTENT;
- }
-
- if (flags & PKT_DMA_PARTIAL) {
- dma_flags |= DDI_DMA_PARTIAL;
- }
-
- tmp_dma_attr = cpqary3_dma_attr;
- tmp_dma_attr.dma_attr_sgllen = cpqary3p->cpq_sg_cnt;
-
- cb = (callback == NULL_FUNC) ? DDI_DMA_DONTWAIT : DDI_DMA_SLEEP;
-
- /*
- * DMA resources are allocated thru a 2 step protocol :
- * - allocate a DMA handle
- * - bind the buffer to the handle
- * If both the steps succeed, we have succeeded in allocating resources
- */
-
- if (DDI_SUCCESS != (retvalue = ddi_dma_alloc_handle(cpqary3p->dip,
- &tmp_dma_attr, cb, CPQARY3_DMA_NO_CALLBACK,
- &cpqary3_pktp->cmd_dmahandle))) {
- switch (retvalue) {
- case DDI_DMA_NORESOURCES:
- /*
- * No Resources are available to be allocated
- */
- bioerror(bp, CPQARY3_BUFFER_ERROR_CLEAR);
- break;
-
- case DDI_DMA_BADATTR:
- /*
- * The attributes stated in our DMA attribute
- * structure is such that potential DMA resources can
- * not be allocated.
- */
- cmn_err(CE_CONT, "CPQary3: DmaAlloc: "
- "AllocHandle Failed BadAttr\n");
- bioerror(bp, EFAULT);
- break;
-
- default:
- /*
- * There is no other possible return value
- */
- cmn_err(CE_WARN,
- "CPQary3: dma_alloc: Unexpected Return Value %x "
- "From call to Allocate DMA Handle \n", retvalue);
- break;
- }
- return (CPQARY3_FAILURE);
- }
-
- retvalue = ddi_dma_buf_bind_handle(cpqary3_pktp->cmd_dmahandle, bp,
- dma_flags, cb, CPQARY3_DMA_NO_CALLBACK,
- &cpqary3_pktp->cmd_dmacookies[0], &cpqary3_pktp->cmd_ncookies);
-
- switch (retvalue) {
- case DDI_DMA_PARTIAL_MAP :
- case DDI_DMA_MAPPED :
- if (DDI_DMA_PARTIAL_MAP == retvalue) {
- if (ddi_dma_numwin(cpqary3_pktp->cmd_dmahandle,
- &cpqary3_pktp->cmd_nwin) == DDI_FAILURE) {
- cmn_err(CE_PANIC, "CPQary3: Retrieval of DMA "
- "windows number failed");
- }
-
- if (ddi_dma_getwin(cpqary3_pktp->cmd_dmahandle,
- cpqary3_pktp->cmd_curwin,
- &cpqary3_pktp->cmd_dma_offset,
- &cpqary3_pktp->cmd_dma_len,
- &cpqary3_pktp->cmd_dmacookies[0],
- &cpqary3_pktp->cmd_ncookies) == DDI_FAILURE) {
- cmn_err(CE_PANIC, "CPQary3: Activation of New "
- "DMA Window Failed");
- }
- } else {
- cpqary3_pktp->cmd_nwin = 1;
- cpqary3_pktp->cmd_dma_len = 0;
- cpqary3_pktp->cmd_dma_offset = 0;
- }
-
- cpqary3_pktp->cmd_dmacount = 0;
- i = 0;
- for (;;) {
- cpqary3_pktp->cmd_dmacount +=
- cpqary3_pktp->cmd_dmacookies[i++].dmac_size;
- /* SG */
- /* Check Out for Limits */
- if (i == cpqary3p->cpq_sg_cnt ||
- i == cpqary3_pktp->cmd_ncookies)
- break;
- /* SG */
-
- ddi_dma_nextcookie(cpqary3_pktp->cmd_dmahandle,
- &cpqary3_pktp->cmd_dmacookies[i]);
- }
-
- cpqary3_pktp->cmd_cookie = i;
- cpqary3_pktp->cmd_cookiecnt = i;
- cpqary3_pktp->cmd_flags |= CFLAG_DMAVALID;
-
- scsi_pktp->pkt_resid =
- bp->b_bcount - cpqary3_pktp->cmd_dmacount;
-
- return (CPQARY3_SUCCESS);
-
- case DDI_DMA_NORESOURCES:
- bioerror(bp, CPQARY3_BUFFER_ERROR_CLEAR);
- break;
-
- case DDI_DMA_NOMAPPING:
- bioerror(bp, EFAULT);
- break;
-
- case DDI_DMA_TOOBIG:
- bioerror(bp, EINVAL);
- break;
-
- case DDI_DMA_INUSE:
- cmn_err(CE_PANIC, "CPQary3: Another I/O transaction "
- "is using the DMA handle");
-
- default:
- cmn_err(CE_PANIC, "CPQary3: Unexpected ERROR "
- "returned from Call to Bind Buffer "
- "to Handle : 0x%X", i);
- }
-
- ddi_dma_free_handle(&cpqary3_pktp->cmd_dmahandle);
- cpqary3_pktp->cmd_dmahandle = NULL;
- cpqary3_pktp->cmd_flags &= ~CFLAG_DMAVALID;
-
- return (CPQARY3_FAILURE);
-
-}
-
-/*
- * Function : cpqary3_dma_move()
- * Description : This routine gets the next DMA window.
- * Called By : cpqary3_init_pkt()
- * Parameters : per-controller, SCSI packet, buffer
- * Calls : None
- * Return Values: SUCCESS / FAILURE
- */
-static int
-cpqary3_dma_move(struct scsi_pkt *scsi_pktp, struct buf *bp,
- cpqary3_t *cpqary3p)
-{
- uint32_t i = 0;
- cpqary3_pkt_t *cpqary3_pktp;
-
- cpqary3_pktp = PKT2PVTPKT(scsi_pktp);
-
- /*
- * If there are no more cookies remaining in this window,
- * must move to the next window first.
- */
- if (cpqary3_pktp->cmd_cookie == cpqary3_pktp->cmd_ncookies) {
- /* For small pkts, leave things where they are */
- if ((cpqary3_pktp->cmd_curwin == cpqary3_pktp->cmd_nwin) &&
- (cpqary3_pktp->cmd_nwin == 1))
- return (CPQARY3_SUCCESS);
-
- /* Shall not be able to move if last window */
- if (++cpqary3_pktp->cmd_curwin >= cpqary3_pktp->cmd_nwin)
- return (CPQARY3_FAILURE);
-
- if (ddi_dma_getwin(cpqary3_pktp->cmd_dmahandle,
- cpqary3_pktp->cmd_curwin, &cpqary3_pktp->cmd_dma_offset,
- &cpqary3_pktp->cmd_dma_len,
- &cpqary3_pktp->cmd_dmacookies[0],
- &cpqary3_pktp->cmd_ncookies) == DDI_FAILURE)
- return (CPQARY3_FAILURE);
-
- cpqary3_pktp->cmd_cookie = 0;
- } else {
- /* Still more cookies in this window - get the next one */
- ddi_dma_nextcookie(cpqary3_pktp->cmd_dmahandle,
- &cpqary3_pktp->cmd_dmacookies[0]);
- }
-
- /* Get remaining cookies in this window, up to our maximum */
- for (;;) {
- cpqary3_pktp->cmd_dmacount +=
- cpqary3_pktp->cmd_dmacookies[i++].dmac_size;
- cpqary3_pktp->cmd_cookie++;
- /* SG */
- /* no. of DATA SEGMENTS */
- if (i == cpqary3p->cpq_sg_cnt ||
- cpqary3_pktp->cmd_cookie == cpqary3_pktp->cmd_ncookies) {
- break;
- }
- /* SG */
-
- ddi_dma_nextcookie(cpqary3_pktp->cmd_dmahandle,
- &cpqary3_pktp->cmd_dmacookies[i]);
- }
-
- cpqary3_pktp->cmd_cookiecnt = i;
- scsi_pktp->pkt_resid = bp->b_bcount - cpqary3_pktp->cmd_dmacount;
-
- return (CPQARY3_SUCCESS);
-
-}
-
static void
cpqary3_set_arq_data(struct scsi_pkt *pkt, uchar_t key)
{
@@ -512,315 +47,6 @@ cpqary3_set_arq_data(struct scsi_pkt *pkt, uchar_t key)
arqstat->sts_sensedata.es_key = key;
}
-static int
-cpqary3_tran_start(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
-{
- cpqary3_t *cpq = SA2CTLR(sa);
- cpqary3_pkt_t *privp = PKT2PVTPKT(scsi_pktp);
- cpqary3_tgt_t *tgtp;
- cpqary3_command_t *cpcm;
- int r;
- boolean_t nointr = (scsi_pktp->pkt_flags & FLAG_NOINTR) != 0;
-
- /*
- * Determine the target to which this command is addressed.
- */
- if ((tgtp = cpqary3_target_from_addr(cpq, sa)) == NULL ||
- tgtp->type == CPQARY3_TARGET_NONE) {
- /*
- * This target does not exist.
- */
- return (TRAN_FATAL_ERROR);
- }
-
- /*
- * Initialise the SCSI packet as described in tran_start(9E). We will
- * progressively update these fields as the command moves through the
- * submission and completion states.
- */
- scsi_pktp->pkt_resid = 0;
- scsi_pktp->pkt_reason = CMD_CMPLT;
- scsi_pktp->pkt_statistics = 0;
- scsi_pktp->pkt_state = 0;
-
- /*
- * Check to see if we need any special handling for this SCSI
- * command.
- */
- switch (scsi_pktp->pkt_cdbp[0]) {
- case SCMD_FORMAT:
- case SCMD_LOG_SENSE_G1:
- case SCMD_MODE_SELECT:
- case SCMD_PERSISTENT_RESERVE_IN:
- /*
- * These SCSI commands are allegedly not supported by the
- * controller firmware.
- */
- cpqary3_set_arq_data(scsi_pktp, KEY_ILLEGAL_REQUEST);
- scsi_pktp->pkt_reason = CMD_BADMSG;
- scsi_pktp->pkt_state |= STATE_GOT_BUS | STATE_GOT_TARGET |
- STATE_SENT_CMD | STATE_XFERRED_DATA;
- if (!nointr && scsi_pktp->pkt_comp != NULL) {
- (*scsi_pktp->pkt_comp)(scsi_pktp);
- }
- return (TRAN_ACCEPT);
-
- case SCMD_SYNCHRONIZE_CACHE:
- /*
- * Emulate SYNCHRONIZE CACHE with the BMIC Flush Cache
- * command.
- */
- scsi_pktp->pkt_state |= STATE_GOT_BUS | STATE_GOT_TARGET |
- STATE_SENT_CMD;
- if ((r = cpqary3_flush_cache(cpq)) == ENOMEM) {
- return (TRAN_BUSY);
- } else if (r != 0) {
- scsi_pktp->pkt_reason = CMD_TIMEOUT;
- scsi_pktp->pkt_statistics |= STAT_TIMEOUT;
- } else {
- scsi_pktp->pkt_state |= STATE_XFERRED_DATA |
- STATE_GOT_STATUS;
- }
- if (!nointr && scsi_pktp->pkt_comp != NULL) {
- (*scsi_pktp->pkt_comp)(scsi_pktp);
- }
- return (TRAN_ACCEPT);
- }
-
- /*
- * Allocate a command object for this transaction:
- */
- if ((cpcm = cpqary3_command_alloc(cpq, CPQARY3_CMDTYPE_OS)) == NULL) {
- /*
- * Signal to the framework to back off.
- */
- return (TRAN_BUSY);
- }
- cpcm->cpcm_private = privp;
- privp->cmd_command = cpcm;
- if (nointr) {
- cpcm->cpcm_status |= CPQARY3_CMD_STATUS_POLLED;
- }
-
- if ((privp->cmd_flags & CFLAG_CMDIOPB) && privp->cmd_dmahandle) {
- (void) ddi_dma_sync(privp->cmd_dmahandle, 0, 0,
- DDI_DMA_SYNC_FORDEV);
- }
-
- /*
- * Build the command to send to the controller based on the SCSI
- * packet passed in by the framework.
- */
- VERIFY(privp->cmd_cookiecnt <= cpq->cpq_sg_cnt);
- cpqary3_build_cmdlist(cpcm, tgtp);
-
- mutex_enter(&cpq->cpq_mutex);
- if ((r = cpqary3_submit(cpq, cpcm)) != 0) {
- mutex_exit(&cpq->cpq_mutex);
-
- /*
- * The command could not be submitted, so free it now.
- */
- cpqary3_command_free(cpcm);
-
- /*
- * Inform the SCSI framework that we could not submit
- * the command.
- */
- return (r == EAGAIN ? TRAN_BUSY : TRAN_FATAL_ERROR);
- }
-
- /*
- * Update the SCSI packet to reflect submission of the command.
- */
- scsi_pktp->pkt_state |= STATE_GOT_BUS | STATE_GOT_TARGET |
- STATE_SENT_CMD;
-
- if (!nointr) {
- /*
- * This is a regular command submission, so we return
- * without polling for completion.
- */
- mutex_exit(&cpq->cpq_mutex);
- return (TRAN_ACCEPT);
- }
-
- /*
- * Poll the controller for completion of the command we submitted.
- * Once this routine has returned, the completion callback will have
- * been fired with either an active response (success or error) or a
- * timeout. The command is freed by the completion callback, so it
- * may not be referenced again after this call returns.
- */
- cpqary3_poll_for(cpq, cpcm);
- mutex_exit(&cpq->cpq_mutex);
- return (TRAN_ACCEPT);
-}
-
-/*
- * Function : cpqary3_dmafree
- * Description : This routine de-allocates previously allocated
- * DMA resources.
- * Called By : kernel
- * Parameters : SCSI address, SCSI packet
- * Calls : None
- * Return Values: None
- */
-/* ARGSUSED */
-static void
-cpqary3_dmafree(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
-{
- cpqary3_pkt_t *cpqary3_pktp;
-
- cpqary3_pktp = PKT2PVTPKT(scsi_pktp);
-
- /*
- * If any DMA was succesfully attempted earlier, free all allocated
- * resources
- */
-
- if (cpqary3_pktp->cmd_flags & CFLAG_DMAVALID) {
- if (!cpqary3_pktp->cmd_dmahandle) {
- DTRACE_PROBE(dmafree_null);
- return;
- }
- cpqary3_pktp->cmd_flags &= ~CFLAG_DMAVALID;
- (void) ddi_dma_unbind_handle(cpqary3_pktp->cmd_dmahandle);
- ddi_dma_free_handle(&cpqary3_pktp->cmd_dmahandle);
- cpqary3_pktp->cmd_dmahandle = NULL;
- }
-}
-
-/*
- * Function : cpqary3_dma_sync
- * Description : This routine synchronizes the CPU's / HBA's view of
- * the data associated with the pkt, typically by calling
- * ddi_dma_sync().
- * Called By : kernel
- * Parameters : SCSI address, SCSI packet
- * Calls : None
- * Return Values: None
- */
-/* ARGSUSED */
-static void
-cpqary3_dma_sync(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
-{
- cpqary3_pkt_t *cpqary3_pktp = PKT2PVTPKT(scsi_pktp);
-
- /*
- * Check whether DMA was attempted successfully earlier
- * If yes and
- * if the command flags is write, then synchronise the device else
- * synchronise the CPU
- */
-
- if (cpqary3_pktp->cmd_flags & CFLAG_DMAVALID) {
- (void) ddi_dma_sync(cpqary3_pktp->cmd_dmahandle,
- cpqary3_pktp->cmd_dma_offset, cpqary3_pktp->cmd_dma_len,
- (cpqary3_pktp->cmd_flags & CFLAG_DMASEND) ?
- DDI_DMA_SYNC_FORDEV : DDI_DMA_SYNC_FORCPU);
- }
-}
-
-/*
- * Function : cpqary3_destroy_pkt
- * Description : This routine de-allocates previously allocated
- * resources for the SCSI packet.
- * Called By : kernel
- * Parameters : SCSI address, SCSI packet
- * Calls : None
- * Return Values: None
- */
-static void
-cpqary3_tran_destroy_pkt(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
-{
- cpqary3_pkt_t *cpqary3_pktp;
-
- cpqary3_pktp = PKT2PVTPKT(scsi_pktp);
-
- /*
- * Deallocate DMA Resources, if allocated.
- * Free the SCSI Packet.
- */
-
- if (cpqary3_pktp->cmd_flags & CFLAG_DMAVALID) {
- if (!cpqary3_pktp->cmd_dmahandle) {
- DTRACE_PROBE(dmafree_null);
- } else {
- cpqary3_pktp->cmd_flags &= ~CFLAG_DMAVALID;
-
- (void) ddi_dma_unbind_handle(
- cpqary3_pktp->cmd_dmahandle);
- ddi_dma_free_handle(&cpqary3_pktp->cmd_dmahandle);
-
- cpqary3_pktp->cmd_dmahandle = NULL;
- }
- }
-
- scsi_hba_pkt_free(sa, scsi_pktp);
-}
-
-/*
- * The tran_reset(9E) entry point is called when the SCSI framework wishes us
- * to reset the SCSI bus (RESET_ALL), a particular target (RESET_TARGET), or a
- * particular logical unit (RESET_LUN).
- *
- * On success, return 1; on failure, return 0.
- */
-static int
-cpqary3_tran_reset(struct scsi_address *sa, int level)
-{
- /*
- * We currently have no support for resetting the controller.
- * Signal universal failure to the SCSI framework.
- */
- return (0);
-}
-
-/*
- * Function : cpqary3_abort()
- * Description : This routine aborts a particular command or all commands
- * directed towards a target.
- * Called By : kernel
- * Parameters : SCSI address, SCSI packet
- * Calls : None
- * Return Values: SUCCESS / FAILURE
- * [ abort of concernd command(s) was a success or
- * a failure. ]
- */
-static int
-cpqary3_tran_abort(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
-{
- cpqary3_t *cpq = SA2CTLR(sa);
- cpqary3_command_t *cpcm = NULL;
- cpqary3_tgt_t *tgtp;
- int r;
-
- mutex_enter(&cpq->cpq_mutex);
-
- if ((tgtp = cpqary3_target_from_addr(cpq, sa)) == NULL) {
- return (0);
- }
-
- /*
- * If SCSI packet exists, abort that particular command.
- * Else, abort all existing commands to the target
- * In either of the cases, we shall have to wait after the abort
- * functions are called to return the status.
- */
- if (scsi_pktp != NULL) {
- cpqary3_pkt_t *pktp = (cpqary3_pkt_t *)scsi_pktp->
- pkt_ha_private;
-
- cpcm = pktp->cmd_command;
- }
-
- r = cpqary3_send_abortcmd(cpq, tgtp, cpcm);
-
- mutex_exit(&cpq->cpq_mutex);
- return (r == 0 ? 1 : 0);
-}
-
/*
* Function : cpqary3_getcap
* Description : This routine is called to get the current value of a
@@ -830,12 +56,14 @@ cpqary3_tran_abort(struct scsi_address *sa, struct scsi_pkt *scsi_pktp)
* Calls : None
* Return Values: current value of capability / -1 (if unsupported)
*/
-static int
+int
cpqary3_getcap(struct scsi_address *sa, char *capstr, int tgtonly)
{
int index;
+#if 0
cpqary3_t *cpq = SA2CTLR(sa);
cpqary3_tgt_t *tgtp = cpqary3_target_from_addr(cpq, sa);
+#endif
/*
* If requested Capability is not supported, return -1.
@@ -859,6 +87,7 @@ cpqary3_getcap(struct scsi_address *sa, char *capstr, int tgtonly)
switch (index) {
case SCSI_CAP_DMA_MAX:
return ((int)cpqary3_dma_attr.dma_attr_maxxfer);
+#if 0
case SCSI_CAP_DISCONNECT:
return (tgtp->ctlr_flags & CPQARY3_CAP_DISCON_ENABLED);
case SCSI_CAP_SYNCHRONOUS:
@@ -869,6 +98,7 @@ cpqary3_getcap(struct scsi_address *sa, char *capstr, int tgtonly)
return ((tgtp->ctlr_flags & CPQARY3_CAP_ARQ_ENABLED) ? 1 : 0);
case SCSI_CAP_INITIATOR_ID:
return (CTLR_SCSI_ID);
+#endif
case SCSI_CAP_UNTAGGED_QING:
return (1);
case SCSI_CAP_TAGGED_QING:
@@ -877,8 +107,10 @@ cpqary3_getcap(struct scsi_address *sa, char *capstr, int tgtonly)
return (cpqary3_dma_attr.dma_attr_granular);
case SCSI_CAP_TOTAL_SECTORS:
return (CAP_NOT_DEFINED);
+#if 0
case SCSI_CAP_GEOMETRY:
return (cpqary3_target_geometry(sa));
+#endif
case SCSI_CAP_RESET_NOTIFICATION:
return (0);
default:
@@ -897,7 +129,7 @@ cpqary3_getcap(struct scsi_address *sa, char *capstr, int tgtonly)
* Return Values: SUCCESS / FAILURE / -1 (if capability is unsupported)
*/
/* ARGSUSED */
-static int
+int
cpqary3_setcap(struct scsi_address *sa, char *capstr, int value, int tgtonly)
{
int index;
@@ -958,8 +190,7 @@ cpqary3_oscmd_complete(cpqary3_command_t *cpcm)
cpqary3_t *cpqary3p = cpcm->cpcm_ctlr;
ErrorInfo_t *errorinfop = cpcm->cpcm_va_err;
CommandList_t *cmdlistp = cpcm->cpcm_va_cmd;
- struct scsi_pkt *scsi_pktp = cpcm->cpcm_private->scsi_cmd_pkt;
- boolean_t nointr = (scsi_pktp->pkt_flags & FLAG_NOINTR) != 0;
+ struct scsi_pkt *scsi_pktp = cpcm->cpcm_scsa->cpcms_pkt;
VERIFY(MUTEX_HELD(&cpqary3p->cpq_mutex));
VERIFY(cpcm->cpcm_type == CPQARY3_CMDTYPE_OS);
@@ -1068,17 +299,14 @@ cpqary3_oscmd_complete(cpqary3_command_t *cpcm)
bcopy((caddr_t)&errorinfop->SenseInfo[0],
(caddr_t)(&arq_statusp->sts_sensedata),
MIN(errorinfop->SenseLen,
- cpcm->cpcm_private->scb_len));
+ cpcm->cpcm_scsa->cpcms_pkt->pkt_scblen));
scsi_pktp->pkt_state |= STATE_ARQ_DONE;
}
}
finish:
mutex_exit(&cpqary3p->cpq_mutex);
- cpqary3_command_free(cpcm);
- if (!nointr && scsi_pktp->pkt_comp != NULL) {
- (*scsi_pktp->pkt_comp)(scsi_pktp);
- }
+ scsi_hba_pkt_comp(scsi_pktp);
mutex_enter(&cpqary3p->cpq_mutex);
}
diff --git a/usr/src/uts/common/io/cpqary3/cpqary3_util.c b/usr/src/uts/common/io/cpqary3/cpqary3_util.c
index 7b6f4f9fad..351735c2da 100644
--- a/usr/src/uts/common/io/cpqary3/cpqary3_util.c
+++ b/usr/src/uts/common/io/cpqary3/cpqary3_util.c
@@ -76,7 +76,8 @@ cpqary3_lookup_inflight(cpqary3_t *cpq, uint32_t tag)
return (avl_find(&cpq->cpq_inflight, &srch, NULL));
}
-cpqary3_tgt_t *
+#if 0
+cpqary3_target_t *
cpqary3_target_from_id(cpqary3_t *cpq, unsigned id)
{
VERIFY(MUTEX_HELD(&cpq->cpq_mutex));
@@ -95,7 +96,9 @@ cpqary3_target_from_addr(cpqary3_t *cpq, struct scsi_address *sa)
return (cpqary3_target_from_id(cpq, sa->a_target));
}
+#endif
+#if 0
/*
* Function : cpqary3_target_geometry
* Description : This function returns the geometry for the target.
@@ -117,6 +120,7 @@ cpqary3_target_geometry(struct scsi_address *sa)
return ((tgtp->properties.drive.heads << 16) |
tgtp->properties.drive.sectors);
}
+#endif
/*
* Function : cpqary3_synccmd_alloc
@@ -300,6 +304,7 @@ cpqary3_synccmd_send(cpqary3_t *cpqary3p, cpqary3_command_t *cpcm,
return (rc);
}
+#if 0
/*
* Function : cpqary3_detect_target_geometry
* Description : This function determines the geometry for all
@@ -433,3 +438,4 @@ cpqary3_detect_target_geometry(cpqary3_t *ctlr)
return (CPQARY3_SUCCESS);
}
+#endif