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 Wesolowskiint cpqary3_target_geometry(struct scsi_address *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint8_t cpqary3_detect_target_geometry(cpqary3_t *);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_read_conf_file
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine reads the driver configuration file.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_attach()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : device-information pointer, per_controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_read_conf_file(dev_info_t *dip, cpqary3_t *cpqary3p)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski char *ptr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3p->noe_support = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Plugin the code necessary to read from driver's conf file.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * As of now, we are not interested in reading the onf file
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * for any purpose.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * eg. :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * retvalue = ddi_getprop(DDI_DEV_T_NONE, dip, DDI_PROP_DONTPASS,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * "cpqary3_online_debug", -1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * We are calling ddi_prop_lookup_string
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * which gets the property value, which is passed at
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * the grub menu. If the user wants to use the older
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * target mapping algorithm,(prior to 1.80)at the grub menu
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * "cpqary3_tgtmap=off" should be entered. if this
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * string is entered, then we will set the
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * value of the variable legacy_mapping to one, which
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * will be used in
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_detect_target_geometry()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * and cpqary3_probe4LVs(), to decide on the
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * mapping algorithm
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, 0,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "cpqary3_tgtmap", &ptr) == DDI_PROP_SUCCESS) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (strcmp("off", ptr) == 0) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3p->legacy_mapping = 1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_prop_free(ptr);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, 0,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "cpqary3_noesupport", &ptr) == DDI_PROP_SUCCESS) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (strcmp("on", ptr) == 0) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3p->noe_support = 1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (strcmp("off", ptr) == 0) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3p->noe_support = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ddi_prop_free(ptr);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_tick_hdlr
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine is called once in 60 seconds to detect any
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * command that is pending with the controller and has
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * timed out.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Once invoked, it re-initializes itself such that it is
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * invoked after an interval of 60 seconds.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : kernel
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_tick_hdlr(void *arg)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski clock_t cpqary3_lbolt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski clock_t cpqary3_ticks;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_t *ctlr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_pkt_t *pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski struct scsi_pkt *scsi_pktp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvt_t *local;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski volatile CfgTable_t *ctp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t i;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t no_cmds = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * The per-controller shall be passed as argument.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Read the HeartBeat of the controller.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * if the current heartbeat is the same as the one recorded earlier,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * the f/w has locked up!!!
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (NULL == (ctlr = (cpqary3_t *)arg))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctp = (CfgTable_t *)ctlr->ct;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* CONTROLLER_LOCKUP */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ctlr->heartbeat == DDI_GET32(ctlr, &ctp->HeartBeat)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ctlr->lockup_logged == CPQARY3_FALSE) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_WARN, "CPQary3 : "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "%s HBA firmware Locked !!!", ctlr->hba_name);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_WARN, "CPQary3 : "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "Please reboot the system");
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,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_LOCKUP_INTR_DISABLE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->controller_lockup = CPQARY3_TRUE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->lockup_logged = CPQARY3_TRUE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* CONTROLLER_LOCKUP */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski no_cmds = (uint32_t)((ctlr->ctlr_maxcmds / 3) *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski NO_OF_CMDLIST_IN_A_BLK);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski for (i = 0; i < no_cmds; i++) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski local = &ctlr->cmdmemlistp->pool[i];
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ASSERT(local != NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski pktp = MEM2PVTPKT(local);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!pktp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski continue;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((local->cmdpvt_flag == CPQARY3_TIMEOUT) ||
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (local->cmdpvt_flag == CPQARY3_RESET)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski continue;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (local->occupied == CPQARY3_OCCUPIED) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp = pktp->scsi_cmd_pkt;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_lbolt = ddi_get_lbolt();
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((scsi_pktp) && (scsi_pktp->pkt_time)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_ticks = cpqary3_lbolt -
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski pktp->cmd_start_time;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((drv_hztousec(cpqary3_ticks)/1000000) >
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_time) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_reason = CMD_TIMEOUT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_statistics =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STAT_TIMEOUT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski scsi_pktp->pkt_state = STATE_GOT_BUS |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski STATE_GOT_TARGET | STATE_SENT_CMD;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski local->cmdpvt_flag = CPQARY3_TIMEOUT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* This should always be the case */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (scsi_pktp->pkt_comp) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (*scsi_pktp->pkt_comp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (scsi_pktp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski continue;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->heartbeat = DDI_GET32(ctlr, &ctp->HeartBeat);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&ctlr->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->tick_tmout_id = timeout(cpqary3_tick_hdlr,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (caddr_t)ctlr, drv_usectohz(CPQARY3_TICKTMOUT_VALUE));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_init_ctlr_resource
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine initializes the command list, initializes
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * the controller, enables the interrupt.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_attach()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per_controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_init_ctlr(), cpqary3_meminit(),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_intr_onoff(),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: SUCCESS / FAILURE
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * [ Shall return failure if any of the mandatory
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * initializations / setup of resources fail ]
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiuint16_t
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_init_ctlr_resource(cpqary3_t *ctlr)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#ifdef CPQARY3_DEBUG_MEM
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int8_t i = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#endif
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Initialize the Controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Alocate Memory Pool for driver supported number of Commands
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * return if not successful
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Allocate target structure for controller and initialize the same
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Detect all existing targets and allocate target structure for each
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Determine geometry for all existing targets
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Initialize the condition variables
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski RETURN_FAILURE_IF_NULL(ctlr);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (CPQARY3_FAILURE == cpqary3_init_ctlr(ctlr))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return ((CPQARY3_FAILURE));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (CPQARY3_FAILURE == cpqary3_meminit(ctlr))
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return ((CPQARY3_FAILURE));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#ifdef CPQARY3_DEBUG_MEM
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * This code is in place to test the memory management of this driver.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * This block of code allocates and de-allocates memory as many number
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * of times as given in the for loop.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * After the for loop is executed, it returns a failure, which in turn
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * would result in attach being failed.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_CONT, "CPQary3 : _init_ctlr_resource : Testing memory \n");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski for (i = 0; i < 15; i++) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (CPQARY3_SUCCESS != cpqary3_meminit(ctlr)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_CONT, "CPQary3 : meminit failed : "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "attempt %d \n", i);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_CONT,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "CPQary3 : INIT successful : attempt %d \n", i);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_memfini(ctlr, CPQARY3_MEMLIST_DONE |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_PHYCTGS_DONE | CPQARY3_CMDMEM_DONE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_CONT,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "CPQary3 : FINI successful : attempt %d \n", i);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski#endif
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[CTLR_SCSI_ID] = MEM_ZALLOC(sizeof (cpqary3_tgt_t));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (!(ctlr->cpqary3_tgtp[CTLR_SCSI_ID])) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_WARN, "CPQary3: Target Initialization Failed");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_memfini(ctlr, CPQARY3_MEMLIST_DONE |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_PHYCTGS_DONE | CPQARY3_CMDMEM_DONE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[CTLR_SCSI_ID]->type = CPQARY3_TARGET_CTLR;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_intr_onoff(ctlr, CPQARY3_INTR_DISABLE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Initialize all condition variables :
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * for the immediate call back
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * for the disable noe
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * for fulsh cache
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * for probe device
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cv_init(&ctlr->cv_immediate_wait, NULL, CV_DRIVER, NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cv_init(&ctlr->cv_noe_wait, NULL, CV_DRIVER, NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cv_init(&ctlr->cv_flushcache_wait, NULL, CV_DRIVER, NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cv_init(&ctlr->cv_abort_wait, NULL, CV_DRIVER, NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cv_init(&ctlr->cv_ioctl_wait, NULL, CV_DRIVER, NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_SUCCESS);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_target_geometry
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This function returns the geometry for the target.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_getcap()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : Target SCSI address
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : None
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: Device Geometry
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_target_geometry(struct scsi_address *sa)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
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 * The target CHS are stored in the per-target structure
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * during attach time. Use these values
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return ((tgtp->properties.drive.heads << 16) |
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski tgtp->properties.drive.sectors);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_synccmd_alloc
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This function allocates the DMA buffer for the commands
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : 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(), cpqary3_probe4Tapes(),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_detect_target_geometry()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per_controller, buffer size
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_alloc_phyctgs_mem(), cpqary3_cmdlist_occupy()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: memp
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_cmdpvt_t *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_synccmd_alloc(cpqary3_t *cpqary3p, size_t bufsz)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_private_t *cmddmah = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski uint32_t dmabufpa = 0; /* XXX 32-bit pa? */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvt_t *memp = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* first, allocate any necessary dma buffers */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (bufsz > 0) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_phyctg_t *dmah = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski caddr_t dmabufva = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* first, allocate the command's dma handle */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmddmah = (cpqary3_private_t *)MEM_ZALLOC(sizeof (*cmddmah));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cmddmah == NULL) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_WARN, "cpqary3_synccmd_alloc: "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "no memory for cmddmah");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* next, allocate dma handle */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dmah = (cpqary3_phyctg_t *)MEM_ZALLOC(sizeof (*dmah));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (dmah == NULL) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski MEM_SFREE(cmddmah, sizeof (*cmddmah));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_WARN, "cpqary3_synccmd_alloc: "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "no memory for dmah");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* now, allocate dma buffer */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski dmabufva = cpqary3_alloc_phyctgs_mem(cpqary3p, bufsz,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski &dmabufpa, dmah);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (dmabufva == NULL) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski MEM_SFREE(cmddmah, sizeof (*cmddmah));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_WARN, "cpqary3_synccmd_alloc: "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "no memory for dma buf");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bzero(dmabufva, bufsz);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* attach dma buffer to command dma handle */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmddmah->sg = dmabufva;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmddmah->phyctgp = dmah;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* next, allocate a command packet */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp = cpqary3_cmdlist_occupy(cpqary3p);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (memp == NULL) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cmddmah != NULL) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_free_phyctgs_mem(cmddmah->phyctgp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_FREE_PHYCTG_MEM);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski MEM_SFREE(cmddmah, sizeof (*cmddmah));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmn_err(CE_WARN, "cpqary3_synccmd_alloc: "
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski "cannot get free command");
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (NULL);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->cmdpvt_flag = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->cmdlist_memaddr->Header.Tag.drvinfo_n_err =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_SYNCCMD_SUCCESS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* attach dma resources to command */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->driverdata = cmddmah;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->cmdlist_memaddr->SG[0].Addr = dmabufpa;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->cmdlist_memaddr->SG[0].Len = (uint32_t)bufsz;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* done */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (memp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_synccmd_cleanup
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine cleans up the command
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_process_pkt(), cpqary3_synccmd_free()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per_command_memory
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_free_phyctgs_mem(), cpqary3_cmdlist_release()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: none
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_synccmd_cleanup(cpqary3_cmdpvt_t *memp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * ordinary users should not call this routine
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * (use cpqary3_synccmd_free() instead). this is
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * for use ONLY by cpqary3_synccmd_free() and
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_process_pkt().
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (memp->driverdata != NULL) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* free dma resources */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_free_phyctgs_mem(memp->driverdata->phyctgp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_FREE_PHYCTG_MEM);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski MEM_SFREE(memp->driverdata, sizeof (cpqary3_private_t));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->driverdata = NULL;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* release command */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->cmdpvt_flag = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdlist_release(memp, CPQARY3_HOLD_SW_MUTEX);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_synccmd_free
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine frees the command and the
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * associated resources.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : 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(), cpqary3_probe4Tapes(),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_detect_target_geometry()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per_controller, per_command_memory
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_synccmd_cleanup()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: NONE
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskivoid
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_synccmd_free(cpqary3_t *cpqary3p, cpqary3_cmdpvt_t *memp)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * so, the user is done with this command packet.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * we have three possible scenarios here:
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 1) the command was never submitted to the controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * or
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 2) the command has completed at the controller and has
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * been fully processed by the interrupt processing
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * mechanism and is no longer on the submitted or
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * retrieve queues.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * or
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 3) the command is not yet complete at the controller,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * and/or hasn't made it through cpqary3_process_pkt()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * yet.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski *
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * For cases (1) and (2), we can go ahead and free the
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * command and the associated resources. For case (3), we
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * must mark the command as no longer needed, and let
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_process_pkt() clean it up instead.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&(cpqary3p->sw_mutex));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (memp->cmdpvt_flag == CPQARY3_SYNC_SUBMITTED) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * command is still pending (case #3 above).
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * mark the command as abandoned and let
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_process_pkt() clean it up.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->cmdpvt_flag = CPQARY3_SYNC_TIMEOUT;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&(cpqary3p->sw_mutex));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->cmdpvt_flag = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&(cpqary3p->sw_mutex));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * command was either never submitted or has completed
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * (cases #1 and #2 above). so, clean it up.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_synccmd_cleanup(memp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* done */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski} /* cpqary3_synccmd_free() */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_synccmd_send
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This routine sends the command to the controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : 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(), cpqary3_probe4Tapes(),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_detect_target_geometry()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per_controller, per_command_memory, timeout value,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * flag(wait for reply)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_submit(), cpqary3_add2submitted_cmdq()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: SUCCESS / FAILURE
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_synccmd_send(cpqary3_t *cpqary3p, cpqary3_cmdpvt_t *memp,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski clock_t timeoutms, int flags)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski clock_t absto = 0; /* absolute timeout */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int waitsig = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int rc = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski kcondvar_t *cv = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* compute absolute timeout, if necessary */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (timeoutms > 0)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski absto = ddi_get_lbolt() + drv_usectohz(timeoutms * 1000);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* heed signals during wait? */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (flags & CPQARY3_SYNCCMD_SEND_WAITSIG)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski waitsig = 1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* acquire the sw mutex for our wait */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&(cpqary3p->sw_mutex));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* submit command to controller */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_enter(&(cpqary3p->hw_mutex));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->cmdpvt_flag = CPQARY3_SYNC_SUBMITTED;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski memp->cmdlist_memaddr->Header.Tag.drvinfo_n_err =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_SYNCCMD_SUCCESS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (EIO == cpqary3_submit(cpqary3p, memp->cmdlist_phyaddr)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&(cpqary3p->hw_mutex));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&(cpqary3p->sw_mutex));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski rc = -1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (rc);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&(cpqary3p->hw_mutex));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* wait for command completion, timeout, or signal */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski while (memp->cmdpvt_flag == CPQARY3_SYNC_SUBMITTED) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski kmutex_t *mt = &(cpqary3p->sw_mutex);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cv = &(cpqary3p->cv_ioctl_wait);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* wait with the request behavior */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (absto) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski clock_t crc;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (waitsig) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski crc = cv_timedwait_sig(cv, mt, absto);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski crc = cv_timedwait(cv, mt, absto);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (crc > 0)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski rc = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski else
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski rc = (-1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (waitsig) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski rc = cv_wait_sig(cv, mt);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (rc > 0)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski rc = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski else
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski rc = (-1);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cv_wait(cv, mt);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski rc = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * if our wait was interrupted (timeout),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * then break here
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (rc) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski break;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* our wait is done, so release the sw mutex */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski mutex_exit(&(cpqary3p->sw_mutex));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* return the results */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (rc);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski/*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Function : cpqary3_detect_target_geometry
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Description : This function determines the geometry for all
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * the existing targets for the controller.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Called By : cpqary3_tgt_init()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Parameters : per controller
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Calls : cpqary3_synccmd_alloc(), cpqary3_synccmd_send()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * cpqary3_synccmd_free()
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return Values: SUCCESS / FAILURE
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * [ Shall return failure only if Memory constraints exist
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * or controller does not respond ]
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskiint8_t
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowskicpqary3_detect_target_geometry(cpqary3_t *ctlr)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski{
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int i;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int8_t ld_count = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int8_t loop_cnt = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski IdLogDrive *idlogdrive;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CommandList_t *cmdlistp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvt_t *cpqary3_cmdpvtp;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski RETURN_FAILURE_IF_NULL(ctlr);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Occupy a Command List
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Allocate Memory for return data
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If error, RETURN 0.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * get the Request Block from the CommandList
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Fill in the Request Packet with the corresponding values
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Submit the Command and Poll for its completion
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If success, continue else RETURN 0
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Sync Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvtp = cpqary3_synccmd_alloc(ctlr, sizeof (IdLogDrive));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_cmdpvtp == NULL)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp = cpqary3_cmdpvtp->cmdlist_memaddr;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski idlogdrive = (IdLogDrive *)cpqary3_cmdpvtp->driverdata->sg;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Sync Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Update Cmd Header */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Header.SGList = 1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Header.SGTotal = 1;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Header.Tag.drvinfo_n_err = CPQARY3_SYNCCMD_SUCCESS;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Cmd Reques */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.CDBLen = CPQARY3_CDBLEN_16;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.CDB[0] = 0x26;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.CDB[6] = BMIC_IDENTIFY_LOGICAL_DRIVE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.CDB[7] = (sizeof (IdLogDrive) >> 8) & 0xff;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.CDB[8] = sizeof (IdLogDrive) & 0xff;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.Type.Type = CISS_TYPE_CMD;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.Type.Attribute = CISS_ATTR_HEADOFQUEUE;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.Type.Direction = CISS_XFER_READ;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * For all the Targets that exist, issue an IDENTIFY LOGICAL DRIVE.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * That returns values which includes the dsired Geometry also.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Update the Geometry in the per-target structure.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * NOTE : When the loop is executed for i=controller's SCSI ID, just
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * increament by one so that we are talking to the next logical
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * drive in our per-target structure.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Depending upon the value of the variable legacy_mapping
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * set in cpqary3_attach(),
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * the target mapping algorithm to be used by the driver is decided.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (ctlr->legacy_mapping == 1) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski loop_cnt = ((ctlr->num_of_targets > CTLR_SCSI_ID) ?
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (ctlr->num_of_targets + 1) : (ctlr->num_of_targets));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski for (i = 0; i < loop_cnt; i++) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (i == CTLR_SCSI_ID) /* Go to Next logical target */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski i++;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bzero(idlogdrive, sizeof (IdLogDrive));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.CDB[1] =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[i]->logical_id;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Always zero */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Header.LUN.PhysDev.TargetId = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Logical volume Id numbering scheme is as follows
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x00000, 0x00001, ... - for Direct Attached
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x10000, 0x10001, ... - If 1st Port of HBA is
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * connected to MSA20 / MSA500
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x20000, 0x20001, ... - If 2nd Port of HBA is
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * connected to MSA20 / MSA500
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Header.LUN.PhysDev.Bus =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (ctlr->cpqary3_tgtp[i]->logical_id) >> 16;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Header.LUN.PhysDev.Mode =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (cmdlistp->Header.LUN.PhysDev.Bus > 0) ?
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski MASK_PERIPHERIAL_DEV_ADDR : PERIPHERIAL_DEV_ADDR;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Submit the command
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Poll for its completion
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If polling is not successful, something is wrong
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * with the controler
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return FAILURE (No point in continuing if h/w is
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * faulty !!!)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* PERF */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvtp->complete = cpqary3_synccmd_complete;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* PERF */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Sync Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_synccmd_send(ctlr, cpqary3_cmdpvtp, 90000,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_SYNCCMD_SEND_WAITSIG) != 0) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Timed out */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_synccmd_free(ctlr, cpqary3_cmdpvtp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((cpqary3_cmdpvtp->
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlist_memaddr->Header.Tag.drvinfo_n_err ==
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_SYNCCMD_FAILURE) &&
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (cpqary3_cmdpvtp->errorinfop->CommandStatus != 2)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE1(id_logdrv_fail,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ErrorInfo_t *, cpqary3_cmdpvtp->errorinfop);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_synccmd_free(ctlr, cpqary3_cmdpvtp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Sync Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[i]->properties.drive.heads =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski idlogdrive->heads;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[i]->properties.drive.sectors =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski idlogdrive->sectors;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE2(tgt_geometry_detect,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int, i, IdLogDrive *, idlogdrive);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski } else {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Fix for QXCR1000446657: Logical drives are re numbered
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * after deleting a Logical drive.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * introduced, new variable ld_count, which gets
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * incremented when the Target ID is found.
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * And for i=controller's SCSI ID and LDs with holes are found,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * we continue talking to
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * the next logical drive in the per-target structure
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski for (i = 0; ld_count < ctlr->num_of_targets; i++) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (i == CTLR_SCSI_ID ||
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[i] == NULL)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Go to the Next logical target */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski continue;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski bzero(idlogdrive, sizeof (IdLogDrive));
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Request.CDB[1] =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[i]->logical_id;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Always zero */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Header.LUN.PhysDev.TargetId = 0;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Logical volume Id numbering scheme is as follows
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x00000, 0x00001, ... - for Direct Attached
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x10000, 0x10001, ... - If 1st Port of HBA is
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * connected to MSA20 / MSA500
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * 0x20000, 0x20001, ... - If 2nd Port of HBA is
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * connected to MSA20 / MSA500
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Header.LUN.PhysDev.Bus =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (ctlr->cpqary3_tgtp[i]->logical_id) >> 16;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlistp->Header.LUN.PhysDev.Mode =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (cmdlistp->Header.LUN.PhysDev.Bus > 0) ?
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski MASK_PERIPHERIAL_DEV_ADDR : PERIPHERIAL_DEV_ADDR;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* PERF */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_cmdpvtp->complete = cpqary3_synccmd_complete;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* PERF */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /*
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Submit the command
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Poll for its completion
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * If polling is not successful, something is wrong
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * with the controler
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * Return FAILURE (No point in continuing if h/w is
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski * faulty !!!)
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Sync Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if (cpqary3_synccmd_send(ctlr, cpqary3_cmdpvtp, 90000,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_SYNCCMD_SEND_WAITSIG) != 0) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Timed out */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_synccmd_free(ctlr, cpqary3_cmdpvtp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski if ((cpqary3_cmdpvtp->
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cmdlist_memaddr->Header.Tag.drvinfo_n_err ==
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski CPQARY3_SYNCCMD_FAILURE) &&
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski (cpqary3_cmdpvtp->errorinfop->CommandStatus != 2)) {
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE1(id_logdrv_fail,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ErrorInfo_t *, cpqary3_cmdpvtp->errorinfop);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_synccmd_free(ctlr, cpqary3_cmdpvtp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_FAILURE);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Sync Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[i]->properties.drive.heads =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski idlogdrive->heads;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ctlr->cpqary3_tgtp[i]->properties.drive.sectors =
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski idlogdrive->sectors;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski DTRACE_PROBE2(tgt_geometry_detect,
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski int, i, IdLogDrive *, idlogdrive);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski ld_count++;
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski }
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Sync Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski cpqary3_synccmd_free(ctlr, cpqary3_cmdpvtp);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski /* Sync Changes */
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski return (CPQARY3_SUCCESS);
80c94ecd7a524eb933a4bb221a9618b9dc490e76Keith M Wesolowski}