585 DDI_DMA_SYNC_FORDEV);
586 if (++mpt->m_free_index == mpt->m_free_queue_depth) {
587 mpt->m_free_index = 0;
588 }
589 ddi_put32(mpt->m_datap, &mpt->m_reg->ReplyFreeHostIndex,
590 mpt->m_free_index);
591 }
592
593 if (free_dma)
594 mptsas_dma_addr_destroy(&cmd->cmd_dmahandle, &accessp);
595
596 if (cmd && (cmd->cmd_flags & CFLAG_PREPARED)) {
597 mptsas_remove_cmd(mpt, cmd);
598 config_flags &= (~MPTSAS_REQUEST_POOL_CMD);
599 }
600 if (config_flags & MPTSAS_REQUEST_POOL_CMD)
601 mptsas_return_to_pool(mpt, cmd);
602
603 if (config_flags & MPTSAS_CMD_TIMEOUT) {
604 mpt->m_softstate &= ~MPTSAS_SS_MSG_UNIT_RESET;
605 if ((mptsas_restart_ioc(mpt)) == DDI_FAILURE) {
606 mptsas_log(mpt, CE_WARN, "mptsas_restart_ioc failed");
607 }
608 }
609
610 return (rval);
611 }
612
613 int
614 mptsas_send_config_request_msg(mptsas_t *mpt, uint8_t action, uint8_t pagetype,
615 uint32_t pageaddress, uint8_t pagenumber, uint8_t pageversion,
616 uint8_t pagelength, uint32_t SGEflagslength, uint64_t SGEaddress)
617 {
618 pMpi2ConfigRequest_t config;
619 int send_numbytes;
620
621 bzero(mpt->m_hshk_memp, sizeof (MPI2_CONFIG_REQUEST));
622 config = (pMpi2ConfigRequest_t)mpt->m_hshk_memp;
623 ddi_put8(mpt->m_hshk_acc_hdl, &config->Function, MPI2_FUNCTION_CONFIG);
624 ddi_put8(mpt->m_hshk_acc_hdl, &config->Action, action);
625 ddi_put8(mpt->m_hshk_acc_hdl, &config->Header.PageNumber, pagenumber);
626 ddi_put8(mpt->m_hshk_acc_hdl, &config->Header.PageType, pagetype);
1186 "reply data for TM request");
1187 break;
1188 }
1189 }
1190 mutex_enter(&mpt->m_mutex);
1191 }
1192
1193 /*
1194 * clear the TM slot before returning
1195 */
1196 slots->m_slot[MPTSAS_TM_SLOT(mpt)] = NULL;
1197
1198 /*
1199 * If we lost our task management command
1200 * we need to reset the ioc
1201 */
1202 if (rval == FALSE) {
1203 mptsas_log(mpt, CE_WARN, "mptsas_ioc_task_management failed "
1204 "try to reset ioc to recovery!");
1205 mpt->m_softstate &= ~MPTSAS_SS_MSG_UNIT_RESET;
1206 if (mptsas_restart_ioc(mpt)) {
1207 mptsas_log(mpt, CE_WARN, "mptsas_restart_ioc failed");
1208 rval = FAILED;
1209 }
1210 }
1211
1212 return (rval);
1213 }
1214
1215 /*
1216 * Complete firmware download frame for v2.0 cards.
1217 */
1218 static void
1219 mptsas_uflash2(pMpi2FWDownloadRequest fwdownload,
1220 ddi_acc_handle_t acc_hdl, uint32_t size, uint8_t type,
1221 ddi_dma_cookie_t flsh_cookie)
1222 {
1223 pMpi2FWDownloadTCSGE_t tcsge;
1224 pMpi2SGESimple64_t sge;
1225 uint32_t flagslength;
1226
1227 ddi_put8(acc_hdl, &fwdownload->Function,
1389 mpt->m_acc_req_frame_hdl, size, type, flsh_cookie);
1390 else
1391 mptsas_uflash2((pMpi2FWDownloadRequest)memp,
1392 mpt->m_acc_req_frame_hdl, size, type, flsh_cookie);
1393
1394 /*
1395 * Start command
1396 */
1397 (void) ddi_dma_sync(mpt->m_dma_req_frame_hdl, 0, 0,
1398 DDI_DMA_SYNC_FORDEV);
1399 request_desc = (cmd->cmd_slot << 16) +
1400 MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
1401 cmd->cmd_rfm = NULL;
1402 MPTSAS_START_CMD(mpt, request_desc);
1403
1404 rvalue = 0;
1405 (void) cv_reltimedwait(&mpt->m_fw_cv, &mpt->m_mutex,
1406 drv_usectohz(60 * MICROSEC), TR_CLOCK_TICK);
1407 if (!(cmd->cmd_flags & CFLAG_FINISHED)) {
1408 mpt->m_softstate &= ~MPTSAS_SS_MSG_UNIT_RESET;
1409 if ((mptsas_restart_ioc(mpt)) == DDI_FAILURE) {
1410 mptsas_log(mpt, CE_WARN, "mptsas_restart_ioc failed");
1411 }
1412 rvalue = -1;
1413 }
1414 mptsas_remove_cmd(mpt, cmd);
1415 mptsas_dma_addr_destroy(&flsh_dma_handle, &flsh_accessp);
1416
1417 return (rvalue);
1418 }
1419
1420 static int
1421 mptsas_sasdevpage_0_cb(mptsas_t *mpt, caddr_t page_memp,
1422 ddi_acc_handle_t accessp, uint16_t iocstatus, uint32_t iocloginfo,
1423 va_list ap)
1424 {
1425 #ifndef __lock_lint
1426 _NOTE(ARGUNUSED(ap))
1427 #endif
1428 pMpi2SasDevicePage0_t sasdevpage;
1429 int rval = DDI_SUCCESS, i;
1430 uint8_t *sas_addr = NULL;
|
585 DDI_DMA_SYNC_FORDEV);
586 if (++mpt->m_free_index == mpt->m_free_queue_depth) {
587 mpt->m_free_index = 0;
588 }
589 ddi_put32(mpt->m_datap, &mpt->m_reg->ReplyFreeHostIndex,
590 mpt->m_free_index);
591 }
592
593 if (free_dma)
594 mptsas_dma_addr_destroy(&cmd->cmd_dmahandle, &accessp);
595
596 if (cmd && (cmd->cmd_flags & CFLAG_PREPARED)) {
597 mptsas_remove_cmd(mpt, cmd);
598 config_flags &= (~MPTSAS_REQUEST_POOL_CMD);
599 }
600 if (config_flags & MPTSAS_REQUEST_POOL_CMD)
601 mptsas_return_to_pool(mpt, cmd);
602
603 if (config_flags & MPTSAS_CMD_TIMEOUT) {
604 mpt->m_softstate &= ~MPTSAS_SS_MSG_UNIT_RESET;
605 if ((mptsas_reset_handler(mpt)) == DDI_FAILURE) {
606 mptsas_log(mpt, CE_WARN, "mptsas_reset_handler failed");
607 }
608 }
609
610 return (rval);
611 }
612
613 int
614 mptsas_send_config_request_msg(mptsas_t *mpt, uint8_t action, uint8_t pagetype,
615 uint32_t pageaddress, uint8_t pagenumber, uint8_t pageversion,
616 uint8_t pagelength, uint32_t SGEflagslength, uint64_t SGEaddress)
617 {
618 pMpi2ConfigRequest_t config;
619 int send_numbytes;
620
621 bzero(mpt->m_hshk_memp, sizeof (MPI2_CONFIG_REQUEST));
622 config = (pMpi2ConfigRequest_t)mpt->m_hshk_memp;
623 ddi_put8(mpt->m_hshk_acc_hdl, &config->Function, MPI2_FUNCTION_CONFIG);
624 ddi_put8(mpt->m_hshk_acc_hdl, &config->Action, action);
625 ddi_put8(mpt->m_hshk_acc_hdl, &config->Header.PageNumber, pagenumber);
626 ddi_put8(mpt->m_hshk_acc_hdl, &config->Header.PageType, pagetype);
1186 "reply data for TM request");
1187 break;
1188 }
1189 }
1190 mutex_enter(&mpt->m_mutex);
1191 }
1192
1193 /*
1194 * clear the TM slot before returning
1195 */
1196 slots->m_slot[MPTSAS_TM_SLOT(mpt)] = NULL;
1197
1198 /*
1199 * If we lost our task management command
1200 * we need to reset the ioc
1201 */
1202 if (rval == FALSE) {
1203 mptsas_log(mpt, CE_WARN, "mptsas_ioc_task_management failed "
1204 "try to reset ioc to recovery!");
1205 mpt->m_softstate &= ~MPTSAS_SS_MSG_UNIT_RESET;
1206 if (mptsas_reset_handler(mpt)) {
1207 mptsas_log(mpt, CE_WARN, "mptsas_reset_handler failed");
1208 rval = FAILED;
1209 }
1210 }
1211
1212 return (rval);
1213 }
1214
1215 /*
1216 * Complete firmware download frame for v2.0 cards.
1217 */
1218 static void
1219 mptsas_uflash2(pMpi2FWDownloadRequest fwdownload,
1220 ddi_acc_handle_t acc_hdl, uint32_t size, uint8_t type,
1221 ddi_dma_cookie_t flsh_cookie)
1222 {
1223 pMpi2FWDownloadTCSGE_t tcsge;
1224 pMpi2SGESimple64_t sge;
1225 uint32_t flagslength;
1226
1227 ddi_put8(acc_hdl, &fwdownload->Function,
1389 mpt->m_acc_req_frame_hdl, size, type, flsh_cookie);
1390 else
1391 mptsas_uflash2((pMpi2FWDownloadRequest)memp,
1392 mpt->m_acc_req_frame_hdl, size, type, flsh_cookie);
1393
1394 /*
1395 * Start command
1396 */
1397 (void) ddi_dma_sync(mpt->m_dma_req_frame_hdl, 0, 0,
1398 DDI_DMA_SYNC_FORDEV);
1399 request_desc = (cmd->cmd_slot << 16) +
1400 MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
1401 cmd->cmd_rfm = NULL;
1402 MPTSAS_START_CMD(mpt, request_desc);
1403
1404 rvalue = 0;
1405 (void) cv_reltimedwait(&mpt->m_fw_cv, &mpt->m_mutex,
1406 drv_usectohz(60 * MICROSEC), TR_CLOCK_TICK);
1407 if (!(cmd->cmd_flags & CFLAG_FINISHED)) {
1408 mpt->m_softstate &= ~MPTSAS_SS_MSG_UNIT_RESET;
1409 if ((mptsas_reset_handler(mpt)) == DDI_FAILURE) {
1410 mptsas_log(mpt, CE_WARN, "mptsas_reset_handler failed");
1411 }
1412 rvalue = -1;
1413 }
1414 mptsas_remove_cmd(mpt, cmd);
1415 mptsas_dma_addr_destroy(&flsh_dma_handle, &flsh_accessp);
1416
1417 return (rvalue);
1418 }
1419
1420 static int
1421 mptsas_sasdevpage_0_cb(mptsas_t *mpt, caddr_t page_memp,
1422 ddi_acc_handle_t accessp, uint16_t iocstatus, uint32_t iocloginfo,
1423 va_list ap)
1424 {
1425 #ifndef __lock_lint
1426 _NOTE(ARGUNUSED(ap))
1427 #endif
1428 pMpi2SasDevicePage0_t sasdevpage;
1429 int rval = DDI_SUCCESS, i;
1430 uint8_t *sas_addr = NULL;
|