Lines Matching refs:softs

78 #define	AAC_DEV(softs, t)	(((t) < AAC_MAX_LD) ? \  argument
79 &(softs)->containers[(t)].dev : \
80 ((t) < AAC_MAX_DEV(softs)) ? \
81 &(softs)->nondasds[AAC_PD(t)].dev : NULL)
82 #define AAC_DEVCFG_BEGIN(softs, tgt) \ argument
83 aac_devcfg((softs), (tgt), 1)
84 #define AAC_DEVCFG_END(softs, tgt) \ argument
85 aac_devcfg((softs), (tgt), 0)
137 #define AAC_MIR_SIZE(softs, acc, mir) \ argument
138 (((softs)->flags & AAC_FLAGS_LBA_64BIT) ? \
151 #define PCI_MEM_GET32(softs, off) \ argument
152 ddi_get32((softs)->pci_mem_handle, \
153 (void *)((softs)->pci_mem_base_vaddr + (off)))
154 #define PCI_MEM_PUT32(softs, off, val) \ argument
155 ddi_put32((softs)->pci_mem_handle, \
156 (void *)((softs)->pci_mem_base_vaddr + (off)), \
158 #define PCI_MEM_GET16(softs, off) \ argument
159 ddi_get16((softs)->pci_mem_handle, \
160 (void *)((softs)->pci_mem_base_vaddr + (off)))
161 #define PCI_MEM_PUT16(softs, off, val) \ argument
162 ddi_put16((softs)->pci_mem_handle, \
163 (void *)((softs)->pci_mem_base_vaddr + (off)), (uint16_t)(val))
165 #define PCI_MEM_REP_PUT8(softs, off, valp, count) \ argument
166 ddi_rep_put8((softs)->pci_mem_handle, (uint8_t *)(valp), \
167 (uint8_t *)((softs)->pci_mem_base_vaddr + (off)), \
170 #define PCI_MEM_REP_GET8(softs, off, valp, count) \ argument
171 ddi_rep_get8((softs)->pci_mem_handle, (uint8_t *)(valp), \
172 (uint8_t *)((softs)->pci_mem_base_vaddr + (off)), \
187 #define AAC_ENABLE_INTR(softs) { \ argument
188 if (softs->flags & AAC_FLAGS_NEW_COMM) \
189 PCI_MEM_PUT32(softs, AAC_OIMR, ~AAC_DB_INTR_NEW); \
191 PCI_MEM_PUT32(softs, AAC_OIMR, ~AAC_DB_INTR_BITS); \
192 softs->state |= AAC_STATE_INTR; \
195 #define AAC_DISABLE_INTR(softs) { \ argument
196 PCI_MEM_PUT32(softs, AAC_OIMR, ~0); \
197 softs->state &= ~AAC_STATE_INTR; \
199 #define AAC_STATUS_CLR(softs, mask) PCI_MEM_PUT32(softs, AAC_ODBR, mask) argument
200 #define AAC_STATUS_GET(softs) PCI_MEM_GET32(softs, AAC_ODBR) argument
201 #define AAC_NOTIFY(softs, val) PCI_MEM_PUT32(softs, AAC_IDBR, val) argument
202 #define AAC_OUTB_GET(softs) PCI_MEM_GET32(softs, AAC_OQUE) argument
203 #define AAC_OUTB_SET(softs, val) PCI_MEM_PUT32(softs, AAC_OQUE, val) argument
204 #define AAC_FWSTATUS_GET(softs) \ argument
205 ((softs)->aac_if.aif_get_fwstatus(softs))
206 #define AAC_MAILBOX_GET(softs, mb) \ argument
207 ((softs)->aac_if.aif_get_mailbox((softs), (mb)))
208 #define AAC_MAILBOX_SET(softs, cmd, arg0, arg1, arg2, arg3) \ argument
209 ((softs)->aac_if.aif_set_mailbox((softs), (cmd), \
332 static int aac_do_quiesce(struct aac_softstate *softs);
333 static int aac_do_unquiesce(struct aac_softstate *softs);
763 struct aac_softstate *softs = NULL; in aac_attach() local
782 AACDB_PRINT(softs, CE_WARN, "Cannot alloc soft state"); in aac_attach()
785 softs = ddi_get_soft_state(aac_softstatep, instance); in aac_attach()
788 softs->instance = instance; in aac_attach()
789 softs->devinfo_p = dip; in aac_attach()
790 softs->buf_dma_attr = softs->addr_dma_attr = aac_dma_attr; in aac_attach()
791 softs->addr_dma_attr.dma_attr_granular = 1; in aac_attach()
792 softs->acc_attr = aac_acc_attr; in aac_attach()
793 softs->reg_attr = aac_acc_attr; in aac_attach()
794 softs->card = AAC_UNKNOWN_CARD; in aac_attach()
796 softs->debug_flags = aac_debug_flags; in aac_attach()
797 softs->debug_fib_flags = aac_debug_fib_flags; in aac_attach()
801 aac_fm_init(softs); in aac_attach()
804 if (aac_check_card_type(softs) == AACERR) { in aac_attach()
805 AACDB_PRINT(softs, CE_WARN, "Card not supported"); in aac_attach()
813 (caddr_t *)&softs->pci_mem_base_vaddr, 0, in aac_attach()
814 softs->map_size_min, &softs->reg_attr, in aac_attach()
815 &softs->pci_mem_handle) != DDI_SUCCESS) in aac_attach()
818 softs->map_size = softs->map_size_min; in aac_attach()
821 AAC_DISABLE_INTR(softs); in aac_attach()
824 mutex_init(&softs->io_lock, NULL, MUTEX_DRIVER, in aac_attach()
825 DDI_INTR_PRI(softs->intr_pri)); in aac_attach()
826 mutex_init(&softs->q_comp_mutex, NULL, MUTEX_DRIVER, in aac_attach()
827 DDI_INTR_PRI(softs->intr_pri)); in aac_attach()
828 mutex_init(&softs->time_mutex, NULL, MUTEX_DRIVER, in aac_attach()
829 DDI_INTR_PRI(softs->intr_pri)); in aac_attach()
830 mutex_init(&softs->ev_lock, NULL, MUTEX_DRIVER, in aac_attach()
831 DDI_INTR_PRI(softs->intr_pri)); in aac_attach()
832 mutex_init(&softs->aifq_mutex, NULL, in aac_attach()
833 MUTEX_DRIVER, DDI_INTR_PRI(softs->intr_pri)); in aac_attach()
834 cv_init(&softs->event, NULL, CV_DRIVER, NULL); in aac_attach()
835 cv_init(&softs->sync_fib_cv, NULL, CV_DRIVER, NULL); in aac_attach()
836 cv_init(&softs->drain_cv, NULL, CV_DRIVER, NULL); in aac_attach()
837 cv_init(&softs->event_wait_cv, NULL, CV_DRIVER, NULL); in aac_attach()
838 cv_init(&softs->event_disp_cv, NULL, CV_DRIVER, NULL); in aac_attach()
839 cv_init(&softs->aifq_cv, NULL, CV_DRIVER, NULL); in aac_attach()
844 aac_cmd_initq(&softs->q_wait[i]); in aac_attach()
845 aac_cmd_initq(&softs->q_busy); in aac_attach()
846 aac_cmd_initq(&softs->q_comp); in aac_attach()
849 softs->legacy = 1; /* default to use legacy name */ in aac_attach()
853 AACDB_PRINT(softs, CE_NOTE, "legacy-name disabled"); in aac_attach()
854 softs->legacy = 0; in aac_attach()
863 mutex_enter(&softs->io_lock); in aac_attach()
864 if (aac_common_attach(softs) == AACERR) { in aac_attach()
865 mutex_exit(&softs->io_lock); in aac_attach()
868 mutex_exit(&softs->io_lock); in aac_attach()
875 AACDB_PRINT(softs, CE_NOTE, "buf breakup enabled"); in aac_attach()
876 softs->flags |= AAC_FLAGS_BRKUP; in aac_attach()
880 softs->dma_max = softs->buf_dma_attr.dma_attr_maxxfer; in aac_attach()
881 if (softs->flags & AAC_FLAGS_BRKUP) { in aac_attach()
882 softs->dma_max = ddi_prop_get_int(DDI_DEV_T_ANY, dip, in aac_attach()
883 DDI_PROP_DONTPASS, "dma-max", softs->dma_max); in aac_attach()
886 if (aac_hba_setup(softs) != AACOK) in aac_attach()
893 AACDB_PRINT(softs, CE_WARN, "failed to create devctl node"); in aac_attach()
900 AACDB_PRINT(softs, CE_WARN, "failed to create scsi node"); in aac_attach()
908 AACDB_PRINT(softs, CE_WARN, "failed to create aac node"); in aac_attach()
913 softs->state |= AAC_STATE_RUN; in aac_attach()
916 softs->fibctx_p = &softs->aifctx; in aac_attach()
917 if ((softs->event_thread = thread_create(NULL, 0, aac_event_thread, in aac_attach()
918 softs, 0, &p0, TS_RUN, minclsyspri)) == NULL) { in aac_attach()
919 AACDB_PRINT(softs, CE_WARN, "aif thread create failed"); in aac_attach()
920 softs->state &= ~AAC_STATE_RUN; in aac_attach()
924 aac_unhold_bus(softs, AAC_IOCMD_SYNC | AAC_IOCMD_ASYNC); in aac_attach()
927 softs->timeout_id = timeout(aac_timer, (void *)softs, in aac_attach()
932 AACDB_PRINT(softs, CE_NOTE, "aac attached ok"); in aac_attach()
941 aac_common_detach(softs); in aac_attach()
947 mutex_destroy(&softs->io_lock); in aac_attach()
948 mutex_destroy(&softs->q_comp_mutex); in aac_attach()
949 mutex_destroy(&softs->time_mutex); in aac_attach()
950 mutex_destroy(&softs->ev_lock); in aac_attach()
951 mutex_destroy(&softs->aifq_mutex); in aac_attach()
952 cv_destroy(&softs->event); in aac_attach()
953 cv_destroy(&softs->sync_fib_cv); in aac_attach()
954 cv_destroy(&softs->drain_cv); in aac_attach()
955 cv_destroy(&softs->event_wait_cv); in aac_attach()
956 cv_destroy(&softs->event_disp_cv); in aac_attach()
957 cv_destroy(&softs->aifq_cv); in aac_attach()
960 ddi_regs_map_free(&softs->pci_mem_handle); in aac_attach()
961 aac_fm_fini(softs); in aac_attach()
963 softs->card = AACERR; in aac_attach()
973 struct aac_softstate *softs = AAC_TRAN2SOFTS(tran); in aac_detach() local
975 DBCALLED(softs, 1); in aac_detach()
986 mutex_enter(&softs->io_lock); in aac_detach()
987 AAC_DISABLE_INTR(softs); in aac_detach()
988 softs->state = AAC_STATE_STOPPED; in aac_detach()
993 mutex_exit(&softs->io_lock); in aac_detach()
995 aac_common_detach(softs); in aac_detach()
997 mutex_enter(&softs->io_lock); in aac_detach()
1000 mutex_exit(&softs->io_lock); in aac_detach()
1003 mutex_enter(&softs->time_mutex); in aac_detach()
1004 if (softs->timeout_id) { in aac_detach()
1005 timeout_id_t tid = softs->timeout_id; in aac_detach()
1006 softs->timeout_id = 0; in aac_detach()
1008 mutex_exit(&softs->time_mutex); in aac_detach()
1010 mutex_enter(&softs->time_mutex); in aac_detach()
1012 mutex_exit(&softs->time_mutex); in aac_detach()
1015 mutex_enter(&softs->ev_lock); in aac_detach()
1016 cv_signal(&softs->event_disp_cv); in aac_detach()
1017 cv_wait(&softs->event_wait_cv, &softs->ev_lock); in aac_detach()
1018 mutex_exit(&softs->ev_lock); in aac_detach()
1020 cv_destroy(&softs->aifq_cv); in aac_detach()
1021 cv_destroy(&softs->event_disp_cv); in aac_detach()
1022 cv_destroy(&softs->event_wait_cv); in aac_detach()
1023 cv_destroy(&softs->drain_cv); in aac_detach()
1024 cv_destroy(&softs->sync_fib_cv); in aac_detach()
1025 cv_destroy(&softs->event); in aac_detach()
1026 mutex_destroy(&softs->aifq_mutex); in aac_detach()
1027 mutex_destroy(&softs->ev_lock); in aac_detach()
1028 mutex_destroy(&softs->time_mutex); in aac_detach()
1029 mutex_destroy(&softs->q_comp_mutex); in aac_detach()
1030 mutex_destroy(&softs->io_lock); in aac_detach()
1032 ddi_regs_map_free(&softs->pci_mem_handle); in aac_detach()
1033 aac_fm_fini(softs); in aac_detach()
1034 softs->hwif = AAC_HWIF_UNKNOWN; in aac_detach()
1035 softs->card = AAC_UNKNOWN_CARD; in aac_detach()
1045 struct aac_softstate *softs = AAC_DIP2SOFTS(dip); in aac_reset() local
1047 DBCALLED(softs, 1); in aac_reset()
1049 mutex_enter(&softs->io_lock); in aac_reset()
1050 AAC_DISABLE_INTR(softs); in aac_reset()
1051 (void) aac_shutdown(softs); in aac_reset()
1052 mutex_exit(&softs->io_lock); in aac_reset()
1070 struct aac_softstate *softs = AAC_DIP2SOFTS(dip); in aac_quiesce() local
1072 if (softs == NULL) in aac_quiesce()
1075 _NOTE(ASSUMING_PROTECTED(softs->state)) in aac_quiesce()
1076 AAC_DISABLE_INTR(softs); in aac_quiesce()
1105 aac_shutdown(struct aac_softstate *softs) in aac_shutdown() argument
1111 (void) aac_sync_fib_slot_bind(softs, &softs->sync_ac); in aac_shutdown()
1112 acc = softs->sync_ac.slotp->fib_acc_handle; in aac_shutdown()
1114 cc = (struct aac_close_command *)&softs->sync_ac.slotp->fibp->data[0]; in aac_shutdown()
1120 rval = aac_sync_fib(softs, ContainerCommand, in aac_shutdown()
1122 aac_sync_fib_slot_release(softs, &softs->sync_ac); in aac_shutdown()
1124 AACDB_PRINT(softs, CE_NOTE, in aac_shutdown()
1132 struct aac_softstate *softs = (void *)arg; in aac_softintr() local
1134 if (!AAC_IS_Q_EMPTY(&softs->q_comp)) { in aac_softintr()
1135 aac_drain_comp_q(softs); in aac_softintr()
1219 aac_send_command(struct aac_softstate *softs, struct aac_slot *slotp) in aac_send_command() argument
1223 index = PCI_MEM_GET32(softs, AAC_IQUE); in aac_send_command()
1225 index = PCI_MEM_GET32(softs, AAC_IQUE); in aac_send_command()
1231 PCI_MEM_PUT32(softs, device, in aac_send_command()
1234 PCI_MEM_PUT32(softs, device, (uint32_t)(slotp->fib_phyaddr >> 32)); in aac_send_command()
1236 PCI_MEM_PUT32(softs, device, slotp->acp->fib_size); in aac_send_command()
1237 PCI_MEM_PUT32(softs, AAC_IQUE, index); in aac_send_command()
1242 aac_end_io(struct aac_softstate *softs, struct aac_cmd *acp) in aac_end_io() argument
1249 aac_release_slot(softs, acp->slotp); in aac_end_io()
1256 aac_set_throttle(softs, dvp, q, in aac_end_io()
1257 softs->total_slots); in aac_end_io()
1271 AACDB_PRINT(softs, CE_NOTE, in aac_end_io()
1279 softs->bus_ncmds[q]--; in aac_end_io()
1280 aac_cmd_delete(&softs->q_busy, acp); in aac_end_io()
1282 aac_cmd_delete(&softs->q_wait[q], acp); in aac_end_io()
1286 mutex_enter(&softs->q_comp_mutex); in aac_end_io()
1287 aac_cmd_enqueue(&softs->q_comp, acp); in aac_end_io()
1288 mutex_exit(&softs->q_comp_mutex); in aac_end_io()
1290 cv_broadcast(&softs->event); in aac_end_io()
1295 aac_handle_io(struct aac_softstate *softs, int index) in aac_handle_io() argument
1305 ASSERT(index >= 0 && index < softs->total_slots); in aac_handle_io()
1306 slotp = &softs->io_slot[index]; in aac_handle_io()
1342 acp->ac_comp(softs, acp); in aac_handle_io()
1344 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_UNAFFECTED); in aac_handle_io()
1351 aac_end_io(softs, acp); in aac_handle_io()
1361 aac_process_intr_new(struct aac_softstate *softs) in aac_process_intr_new() argument
1365 index = AAC_OUTB_GET(softs); in aac_process_intr_new()
1367 index = AAC_OUTB_GET(softs); in aac_process_intr_new()
1368 if (aac_check_acc_handle(softs->pci_mem_handle) != DDI_SUCCESS) { in aac_process_intr_new()
1369 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_UNAFFECTED); in aac_process_intr_new()
1375 aac_handle_io(softs, index); in aac_process_intr_new()
1387 fibp = (struct aac_fib *)(softs-> \ in aac_process_intr_new()
1389 fib_size = PCI_MEM_GET16(softs, index + \ in aac_process_intr_new()
1392 aac_save_aif(softs, softs->pci_mem_handle, in aac_process_intr_new()
1399 AAC_OUTB_SET(softs, index); in aac_process_intr_new()
1400 AAC_STATUS_CLR(softs, AAC_DB_RESPONSE_READY); in aac_process_intr_new()
1403 index = AAC_OUTB_GET(softs); in aac_process_intr_new()
1410 aac_start_waiting_io(softs); in aac_process_intr_new()
1420 struct aac_softstate *softs = (void *)arg; in aac_intr_new() local
1423 mutex_enter(&softs->io_lock); in aac_intr_new()
1424 if (aac_process_intr_new(softs)) in aac_intr_new()
1428 mutex_exit(&softs->io_lock); in aac_intr_new()
1430 aac_drain_comp_q(softs); in aac_intr_new()
1441 aac_process_intr_old(struct aac_softstate *softs) in aac_process_intr_old() argument
1445 status = AAC_STATUS_GET(softs); in aac_process_intr_old()
1446 if (aac_check_acc_handle(softs->pci_mem_handle) != DDI_SUCCESS) { in aac_process_intr_old()
1447 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_UNAFFECTED); in aac_process_intr_old()
1454 AAC_STATUS_CLR(softs, AAC_DB_RESPONSE_READY); in aac_process_intr_old()
1455 (void) AAC_STATUS_GET(softs); in aac_process_intr_old()
1456 while (aac_fib_dequeue(softs, AAC_HOST_NORM_RESP_Q, in aac_process_intr_old()
1458 aac_handle_io(softs, slot_idx); in aac_process_intr_old()
1464 aac_start_waiting_io(softs); in aac_process_intr_old()
1469 AAC_STATUS_CLR(softs, AAC_DB_COMMAND_READY); in aac_process_intr_old()
1470 (void) AAC_STATUS_GET(softs); in aac_process_intr_old()
1471 if (aac_fib_dequeue(softs, AAC_HOST_NORM_CMD_Q, &aif_idx) == in aac_process_intr_old()
1473 ddi_acc_handle_t acc = softs->comm_space_acc_handle; in aac_process_intr_old()
1481 #define AAC_SYNC_AIF(softs, aif_idx, type) \ in aac_process_intr_old() argument
1482 { (void) ddi_dma_sync((softs)->comm_space_dma_handle, \ in aac_process_intr_old()
1488 AAC_SYNC_AIF(softs, aif_idx, DDI_DMA_SYNC_FORCPU); in aac_process_intr_old()
1489 fibp = &softs->comm_space->adapter_fibs[aif_idx]; in aac_process_intr_old()
1492 aac_save_aif(softs, acc, fibp, fib_size); in aac_process_intr_old()
1503 AAC_SYNC_AIF(softs, aif_idx, in aac_process_intr_old()
1509 &softs->comm_space->adapter_fibs[aif_idx]. \ in aac_process_intr_old()
1512 &softs->comm_space->adapter_fibs[aif_idx]. \ in aac_process_intr_old()
1515 &softs->comm_space->adapter_fibs[aif_idx]. \ in aac_process_intr_old()
1517 if (aac_fib_enqueue(softs, AAC_ADAP_NORM_RESP_Q, in aac_process_intr_old()
1524 AAC_STATUS_CLR(softs, AAC_DB_PRINTF_READY); in aac_process_intr_old()
1525 (void) AAC_STATUS_GET(softs); in aac_process_intr_old()
1526 (void) ddi_dma_sync(softs->comm_space_dma_handle, in aac_process_intr_old()
1529 if (aac_check_dma_handle(softs->comm_space_dma_handle) == in aac_process_intr_old()
1532 softs->comm_space->adapter_print_buf); in aac_process_intr_old()
1534 ddi_fm_service_impact(softs->devinfo_p, in aac_process_intr_old()
1536 AAC_NOTIFY(softs, AAC_DB_PRINTF_READY); in aac_process_intr_old()
1545 AAC_STATUS_CLR(softs, AAC_DB_COMMAND_NOT_FULL); in aac_process_intr_old()
1548 AAC_STATUS_CLR(softs, AAC_DB_COMMAND_NOT_FULL); in aac_process_intr_old()
1549 AAC_STATUS_CLR(softs, AAC_DB_RESPONSE_NOT_FULL); in aac_process_intr_old()
1559 struct aac_softstate *softs = (void *)arg; in aac_intr_old() local
1562 mutex_enter(&softs->io_lock); in aac_intr_old()
1563 if (aac_process_intr_old(softs)) in aac_intr_old()
1567 mutex_exit(&softs->io_lock); in aac_intr_old()
1569 aac_drain_comp_q(softs); in aac_intr_old()
1577 aac_query_intrs(struct aac_softstate *softs, int intr_type) in aac_query_intrs() argument
1579 dev_info_t *dip = softs->devinfo_p; in aac_query_intrs()
1583 AACDB_PRINT(softs, CE_NOTE, in aac_query_intrs()
1589 AACDB_PRINT(softs, CE_WARN, in aac_query_intrs()
1598 AACDB_PRINT(softs, CE_WARN, in aac_query_intrs()
1604 AACDB_PRINT(softs, CE_NOTE, in aac_query_intrs()
1609 softs->intr_size = count * sizeof (ddi_intr_handle_t); in aac_query_intrs()
1610 softs->htable = kmem_alloc(softs->intr_size, KM_SLEEP); in aac_query_intrs()
1620 ret = ddi_intr_alloc(dip, softs->htable, intr_type, 0, in aac_query_intrs()
1624 AACDB_PRINT(softs, CE_WARN, in aac_query_intrs()
1631 AACDB_PRINT(softs, CE_NOTE, in aac_query_intrs()
1636 softs->intr_cnt = actual; in aac_query_intrs()
1639 if ((ret = ddi_intr_get_pri(softs->htable[0], in aac_query_intrs()
1640 &softs->intr_pri)) != DDI_SUCCESS) { in aac_query_intrs()
1641 AACDB_PRINT(softs, CE_WARN, in aac_query_intrs()
1647 if (softs->intr_pri >= ddi_intr_get_hilevel_pri()) { in aac_query_intrs()
1648 AACDB_PRINT(softs, CE_WARN, in aac_query_intrs()
1658 (void) ddi_intr_free(softs->htable[i]); in aac_query_intrs()
1660 kmem_free(softs->htable, softs->intr_size); in aac_query_intrs()
1669 aac_add_intrs(struct aac_softstate *softs) in aac_add_intrs() argument
1675 actual = softs->intr_cnt; in aac_add_intrs()
1676 aac_intr = (ddi_intr_handler_t *)((softs->flags & AAC_FLAGS_NEW_COMM) ? in aac_add_intrs()
1681 if ((ret = ddi_intr_add_handler(softs->htable[i], in aac_add_intrs()
1682 aac_intr, (caddr_t)softs, NULL)) != DDI_SUCCESS) { in aac_add_intrs()
1688 (void) ddi_intr_free(softs->htable[i]); in aac_add_intrs()
1690 kmem_free(softs->htable, softs->intr_size); in aac_add_intrs()
1695 if ((ret = ddi_intr_get_cap(softs->htable[0], &softs->intr_cap)) in aac_add_intrs()
1701 (void) ddi_intr_free(softs->htable[i]); in aac_add_intrs()
1703 kmem_free(softs->htable, softs->intr_size); in aac_add_intrs()
1714 aac_remove_intrs(struct aac_softstate *softs) in aac_remove_intrs() argument
1719 (void) aac_disable_intrs(softs); in aac_remove_intrs()
1721 for (i = 0; i < softs->intr_cnt; i++) { in aac_remove_intrs()
1722 (void) ddi_intr_remove_handler(softs->htable[i]); in aac_remove_intrs()
1723 (void) ddi_intr_free(softs->htable[i]); in aac_remove_intrs()
1726 kmem_free(softs->htable, softs->intr_size); in aac_remove_intrs()
1730 aac_enable_intrs(struct aac_softstate *softs) in aac_enable_intrs() argument
1734 if (softs->intr_cap & DDI_INTR_FLAG_BLOCK) { in aac_enable_intrs()
1736 if (ddi_intr_block_enable(softs->htable, softs->intr_cnt) != in aac_enable_intrs()
1743 for (i = 0; i < softs->intr_cnt; i++) { in aac_enable_intrs()
1744 if (ddi_intr_enable(softs->htable[i]) != DDI_SUCCESS) in aac_enable_intrs()
1752 aac_disable_intrs(struct aac_softstate *softs) in aac_disable_intrs() argument
1756 if (softs->intr_cap & DDI_INTR_FLAG_BLOCK) { in aac_disable_intrs()
1758 if (ddi_intr_block_disable(softs->htable, softs->intr_cnt) != in aac_disable_intrs()
1764 for (i = 0; i < softs->intr_cnt; i++) { in aac_disable_intrs()
1765 if (ddi_intr_disable(softs->htable[i]) != DDI_SUCCESS) in aac_disable_intrs()
1776 aac_set_pkt_reason(struct aac_softstate *softs, struct aac_cmd *acp, in aac_set_pkt_reason() argument
1780 _NOTE(ARGUNUSED(softs)) in aac_set_pkt_reason()
1791 aac_soft_callback(struct aac_softstate *softs, struct aac_cmd *acp) in aac_soft_callback() argument
1804 mutex_enter(&softs->q_comp_mutex); in aac_soft_callback()
1805 aac_cmd_enqueue(&softs->q_comp, acp); in aac_soft_callback()
1806 mutex_exit(&softs->q_comp_mutex); in aac_soft_callback()
1807 ddi_trigger_softintr(softs->softint_id); in aac_soft_callback()
1820 aac_ld_complete(struct aac_softstate *softs, struct aac_cmd *acp) in aac_ld_complete() argument
1849 aac_pd_complete(struct aac_softstate *softs, struct aac_cmd *acp) in aac_pd_complete() argument
1882 AACDB_PRINT(softs, CE_NOTE, "DATA_OVERRUN: " \ in aac_pd_complete()
1896 aac_set_pkt_reason(softs, acp, in aac_pd_complete()
1917 AACDB_PRINT(softs, CE_NOTE, in aac_pd_complete()
1920 aac_set_pkt_reason(softs, acp, CMD_ABORTED, in aac_pd_complete()
1924 AACDB_PRINT(softs, CE_NOTE, in aac_pd_complete()
1928 aac_set_pkt_reason(softs, acp, CMD_ABORT_FAIL, in aac_pd_complete()
1932 AACDB_PRINT(softs, CE_NOTE, in aac_pd_complete()
1936 aac_set_pkt_reason(softs, acp, CMD_PER_FAIL, 0); in aac_pd_complete()
1945 AACDB_PRINT(softs, CE_NOTE, in aac_pd_complete()
1952 aac_set_pkt_reason(softs, acp, CMD_DEV_GONE, 0); in aac_pd_complete()
1956 AACDB_PRINT(softs, CE_NOTE, in aac_pd_complete()
1960 aac_set_pkt_reason(softs, acp, CMD_TIMEOUT, in aac_pd_complete()
1964 AACDB_PRINT(softs, CE_NOTE, in aac_pd_complete()
1968 aac_set_pkt_reason(softs, acp, CMD_RESET, in aac_pd_complete()
1972 AACDB_PRINT(softs, CE_NOTE, "srb_status=%d, " \ in aac_pd_complete()
1975 aac_set_pkt_reason(softs, acp, CMD_TRAN_ERR, 0); in aac_pd_complete()
1999 AACDB_PRINT(softs, CE_NOTE, in aac_pd_complete()
2009 AACDB_PRINT(softs, CE_WARN, "invaild scsi status: " \ in aac_pd_complete()
2012 aac_set_pkt_reason(softs, acp, CMD_TRAN_ERR, 0); in aac_pd_complete()
2015 AACDB_PRINT(softs, CE_NOTE, "SRB failed: fib status %d", in aac_pd_complete()
2017 aac_set_pkt_reason(softs, acp, CMD_TRAN_ERR, 0); in aac_pd_complete()
2026 aac_ioctl_complete(struct aac_softstate *softs, struct aac_cmd *acp) in aac_ioctl_complete() argument
2042 ASSERT(acp->fib_size <= softs->aac_max_fib_size); in aac_ioctl_complete()
2052 aac_sync_complete(struct aac_softstate *softs, struct aac_cmd *acp) in aac_sync_complete() argument
2061 aac_synccache_complete(struct aac_softstate *softs, struct aac_cmd *acp) in aac_synccache_complete() argument
2080 aac_startstop_complete(struct aac_softstate *softs, struct aac_cmd *acp) in aac_startstop_complete() argument
2094 AACDB_PRINT(softs, CE_WARN, "Cannot start/stop a unit"); in aac_startstop_complete()
2103 aac_check_card_type(struct aac_softstate *softs) in aac_check_card_type() argument
2110 if ((pci_config_setup(softs->devinfo_p, &pci_config_handle)) != in aac_check_card_type()
2112 AACDB_PRINT(softs, CE_WARN, "Cannot setup pci config space"); in aac_check_card_type()
2116 softs->vendid = pci_config_get16(pci_config_handle, PCI_CONF_VENID); in aac_check_card_type()
2117 softs->devid = pci_config_get16(pci_config_handle, PCI_CONF_DEVID); in aac_check_card_type()
2118 softs->subvendid = pci_config_get16(pci_config_handle, in aac_check_card_type()
2120 softs->subsysid = pci_config_get16(pci_config_handle, in aac_check_card_type()
2125 if ((aac_cards[card_index].vendor == softs->vendid) && in aac_check_card_type()
2126 (aac_cards[card_index].device == softs->devid) && in aac_check_card_type()
2127 (aac_cards[card_index].subvendor == softs->subvendid) && in aac_check_card_type()
2128 (aac_cards[card_index].subsys == softs->subsysid)) { in aac_check_card_type()
2134 softs->card = card_index; in aac_check_card_type()
2135 softs->hwif = aac_cards[card_index].hwif; in aac_check_card_type()
2143 if (softs->vendid != 0x9005) { in aac_check_card_type()
2144 AACDB_PRINT(softs, CE_WARN, in aac_check_card_type()
2145 "Unknown vendor 0x%x", softs->vendid); in aac_check_card_type()
2148 switch (softs->devid) { in aac_check_card_type()
2150 softs->hwif = AAC_HWIF_I960RX; in aac_check_card_type()
2153 softs->hwif = AAC_HWIF_RKT; in aac_check_card_type()
2156 AACDB_PRINT(softs, CE_WARN, in aac_check_card_type()
2157 "Unknown device \"pci9005,%x\"", softs->devid); in aac_check_card_type()
2163 switch (softs->hwif) { in aac_check_card_type()
2165 softs->aac_if = aac_rx_interface; in aac_check_card_type()
2166 softs->map_size_min = AAC_MAP_SIZE_MIN_RX; in aac_check_card_type()
2169 softs->aac_if = aac_rkt_interface; in aac_check_card_type()
2170 softs->map_size_min = AAC_MAP_SIZE_MIN_RKT; in aac_check_card_type()
2173 AACDB_PRINT(softs, CE_WARN, in aac_check_card_type()
2174 "Unknown hardware interface %d", softs->hwif); in aac_check_card_type()
2179 (void *)strncpy(softs->vendor_name, aac_cards[card_index].vid, in aac_check_card_type()
2181 (void *)strncpy(softs->product_name, aac_cards[card_index].desc, in aac_check_card_type()
2185 softs->flags = aac_cards[card_index].quirks; in aac_check_card_type()
2200 softs->pci_mem_base_paddr = 0xfffffff0UL & \ in aac_check_card_type()
2215 aac_register_intrs(struct aac_softstate *softs) in aac_register_intrs() argument
2220 ASSERT(softs->devinfo_p); in aac_register_intrs()
2221 dip = softs->devinfo_p; in aac_register_intrs()
2225 AACDB_PRINT(softs, CE_WARN, in aac_register_intrs()
2229 AACDB_PRINT(softs, CE_NOTE, in aac_register_intrs()
2234 if (aac_query_intrs(softs, DDI_INTR_TYPE_MSI) in aac_register_intrs()
2236 AACDB_PRINT(softs, CE_WARN, in aac_register_intrs()
2240 softs->intr_type = DDI_INTR_TYPE_MSI; in aac_register_intrs()
2242 if (aac_query_intrs(softs, DDI_INTR_TYPE_FIXED) in aac_register_intrs()
2244 AACDB_PRINT(softs, CE_WARN, in aac_register_intrs()
2248 softs->intr_type = DDI_INTR_TYPE_FIXED; in aac_register_intrs()
2250 AACDB_PRINT(softs, CE_WARN, in aac_register_intrs()
2256 if (aac_add_intrs(softs) != DDI_SUCCESS) { in aac_register_intrs()
2257 AACDB_PRINT(softs, CE_WARN, in aac_register_intrs()
2259 softs->intr_type == DDI_INTR_TYPE_MSI ? "MSI" : "FIXED"); in aac_register_intrs()
2262 (void) aac_enable_intrs(softs); in aac_register_intrs()
2264 if (ddi_add_softintr(dip, DDI_SOFTINT_LOW, &softs->softint_id, in aac_register_intrs()
2265 NULL, NULL, aac_softintr, (caddr_t)softs) != DDI_SUCCESS) { in aac_register_intrs()
2266 AACDB_PRINT(softs, CE_WARN, in aac_register_intrs()
2268 aac_remove_intrs(softs); in aac_register_intrs()
2276 aac_unregister_intrs(struct aac_softstate *softs) in aac_unregister_intrs() argument
2278 aac_remove_intrs(softs); in aac_unregister_intrs()
2279 ddi_remove_softintr(softs->softint_id); in aac_unregister_intrs()
2287 aac_check_firmware(struct aac_softstate *softs) in aac_check_firmware() argument
2300 if ((aac_sync_mbcommand(softs, AAC_MONKER_GETINFO, 0, 0, 0, 0, in aac_check_firmware()
2310 options = AAC_MAILBOX_GET(softs, 1); in aac_check_firmware()
2311 atu_size = AAC_MAILBOX_GET(softs, 2); in aac_check_firmware()
2314 if (softs->state & AAC_STATE_RESET) { in aac_check_firmware()
2315 if ((softs->support_opt == options) && in aac_check_firmware()
2316 (softs->atu_size == atu_size)) in aac_check_firmware()
2328 softs->support_opt = options; in aac_check_firmware()
2329 softs->atu_size = atu_size; in aac_check_firmware()
2333 (softs->flags & AAC_FLAGS_NO4GB) == 0) { in aac_check_firmware()
2334 AACDB_PRINT(softs, CE_NOTE, "!Enable FIB map 4GB window"); in aac_check_firmware()
2335 softs->flags |= AAC_FLAGS_4GB_WINDOW; in aac_check_firmware()
2343 softs->addr_dma_attr.dma_attr_addr_lo = 0x2000ull; in aac_check_firmware()
2344 softs->addr_dma_attr.dma_attr_addr_hi = 0x7fffffffull; in aac_check_firmware()
2348 AACDB_PRINT(softs, CE_NOTE, "!Enable SG map 64-bit address"); in aac_check_firmware()
2349 softs->buf_dma_attr.dma_attr_addr_hi = 0xffffffffffffffffull; in aac_check_firmware()
2350 softs->buf_dma_attr.dma_attr_seg = 0xffffffffffffffffull; in aac_check_firmware()
2351 softs->flags |= AAC_FLAGS_SG_64BIT; in aac_check_firmware()
2355 softs->flags |= AAC_FLAGS_ARRAY_64BIT; in aac_check_firmware()
2356 AACDB_PRINT(softs, CE_NOTE, "!Enable 64-bit array size"); in aac_check_firmware()
2360 if ((ddi_prop_lookup_string(DDI_DEV_T_ANY, softs->devinfo_p, 0, in aac_check_firmware()
2363 AACDB_PRINT(softs, CE_NOTE, in aac_check_firmware()
2365 softs->flags |= AAC_FLAGS_NONDASD; in aac_check_firmware()
2373 if ((aac_sync_mbcommand(softs, AAC_MONKER_GETCOMMPREF, in aac_check_firmware()
2375 options = AAC_MAILBOX_GET(softs, 1); in aac_check_firmware()
2378 options = AAC_MAILBOX_GET(softs, 2); in aac_check_firmware()
2380 options = AAC_MAILBOX_GET(softs, 3); in aac_check_firmware()
2385 if ((softs->support_opt & AAC_SUPPORTED_NEW_COMM) && in aac_check_firmware()
2388 if ((atu_size > softs->map_size) && in aac_check_firmware()
2389 (ddi_regs_map_setup(softs->devinfo_p, 1, in aac_check_firmware()
2390 (caddr_t *)&data, 0, atu_size, &softs->reg_attr, in aac_check_firmware()
2392 ddi_regs_map_free(&softs->pci_mem_handle); in aac_check_firmware()
2393 softs->pci_mem_handle = pci_handle; in aac_check_firmware()
2394 softs->pci_mem_base_vaddr = data; in aac_check_firmware()
2395 softs->map_size = atu_size; in aac_check_firmware()
2397 if (atu_size == softs->map_size) { in aac_check_firmware()
2398 softs->flags |= AAC_FLAGS_NEW_COMM; in aac_check_firmware()
2399 AACDB_PRINT(softs, CE_NOTE, in aac_check_firmware()
2405 if (softs->flags & AAC_FLAGS_NEW_COMM) { in aac_check_firmware()
2406 softs->aac_max_fibs = max_fibs; in aac_check_firmware()
2407 softs->aac_max_fib_size = max_fib_size; in aac_check_firmware()
2408 softs->aac_max_sectors = max_sectors; in aac_check_firmware()
2409 softs->aac_sg_tablesize = sg_tablesize; in aac_check_firmware()
2411 softs->flags |= AAC_FLAGS_RAW_IO; in aac_check_firmware()
2412 AACDB_PRINT(softs, CE_NOTE, "!Enable RawIO"); in aac_check_firmware()
2414 softs->aac_max_fibs = in aac_check_firmware()
2415 (softs->flags & AAC_FLAGS_256FIBS) ? 256 : 512; in aac_check_firmware()
2416 softs->aac_max_fib_size = AAC_FIB_SIZE; in aac_check_firmware()
2417 softs->aac_max_sectors = 128; /* 64K */ in aac_check_firmware()
2418 if (softs->flags & AAC_FLAGS_17SG) in aac_check_firmware()
2419 softs->aac_sg_tablesize = 17; in aac_check_firmware()
2420 else if (softs->flags & AAC_FLAGS_34SG) in aac_check_firmware()
2421 softs->aac_sg_tablesize = 34; in aac_check_firmware()
2422 else if (softs->flags & AAC_FLAGS_SG_64BIT) in aac_check_firmware()
2423 softs->aac_sg_tablesize = (AAC_FIB_DATASIZE - in aac_check_firmware()
2428 softs->aac_sg_tablesize = (AAC_FIB_DATASIZE - in aac_check_firmware()
2434 if ((softs->flags & AAC_FLAGS_RAW_IO) && in aac_check_firmware()
2435 (softs->flags & AAC_FLAGS_ARRAY_64BIT)) { in aac_check_firmware()
2436 softs->flags |= AAC_FLAGS_LBA_64BIT; in aac_check_firmware()
2437 AACDB_PRINT(softs, CE_NOTE, "!Enable 64-bit array"); in aac_check_firmware()
2439 softs->buf_dma_attr.dma_attr_sgllen = softs->aac_sg_tablesize; in aac_check_firmware()
2440 softs->buf_dma_attr.dma_attr_maxxfer = softs->aac_max_sectors << 9; in aac_check_firmware()
2451 softs->buf_dma_attr.dma_attr_count_max = in aac_check_firmware()
2452 softs->buf_dma_attr.dma_attr_maxxfer - 1; in aac_check_firmware()
2455 if (softs->flags & AAC_FLAGS_RAW_IO) in aac_check_firmware()
2456 softs->aac_cmd_fib = aac_cmd_fib_rawio; in aac_check_firmware()
2457 else if (softs->flags & AAC_FLAGS_SG_64BIT) in aac_check_firmware()
2458 softs->aac_cmd_fib = aac_cmd_fib_brw64; in aac_check_firmware()
2460 softs->aac_cmd_fib = aac_cmd_fib_brw; in aac_check_firmware()
2461 softs->aac_cmd_fib_scsi = (softs->flags & AAC_FLAGS_SG_64BIT) ? \ in aac_check_firmware()
2465 softs->slen = sizeof (struct scsi_arq_status); in aac_check_firmware()
2466 if ((softs->flags & AAC_FLAGS_LBA_64BIT) && in aac_check_firmware()
2467 softs->slen < AAC_ARQ64_LENGTH) in aac_check_firmware()
2468 softs->slen = AAC_ARQ64_LENGTH; in aac_check_firmware()
2470 AACDB_PRINT(softs, CE_NOTE, in aac_check_firmware()
2472 softs->aac_max_fibs, softs->aac_max_fib_size, in aac_check_firmware()
2473 softs->aac_max_sectors, softs->aac_sg_tablesize); in aac_check_firmware()
2479 aac_fsa_rev(struct aac_softstate *softs, struct FsaRev *fsarev0, in aac_fsa_rev() argument
2482 ddi_acc_handle_t acc = softs->sync_ac.slotp->fib_acc_handle; in aac_fsa_rev()
2497 aac_get_adapter_info(struct aac_softstate *softs, in aac_get_adapter_info() argument
2500 struct aac_cmd *acp = &softs->sync_ac; in aac_get_adapter_info()
2507 (void) aac_sync_fib_slot_bind(softs, acp); in aac_get_adapter_info()
2512 if (aac_sync_fib(softs, RequestAdapterInfo, in aac_get_adapter_info()
2514 AACDB_PRINT(softs, CE_WARN, "RequestAdapterInfo failed"); in aac_get_adapter_info()
2528 aac_fsa_rev(softs, &ainfp->KernelRevision, in aac_get_adapter_info()
2530 aac_fsa_rev(softs, &ainfp->MonitorRevision, in aac_get_adapter_info()
2532 aac_fsa_rev(softs, &ainfp->HardwareRevision, in aac_get_adapter_info()
2534 aac_fsa_rev(softs, &ainfp->BIOSRevision, in aac_get_adapter_info()
2544 if (!(softs->support_opt & in aac_get_adapter_info()
2546 AACDB_PRINT(softs, CE_WARN, in aac_get_adapter_info()
2552 if (aac_sync_fib(softs, RequestSupplementAdapterInfo, in aac_get_adapter_info()
2555 AACDB_PRINT(softs, CE_WARN, in aac_get_adapter_info()
2574 aac_fsa_rev(softs, &sinfp->FlashFirmwareRevision, in aac_get_adapter_info()
2577 aac_fsa_rev(softs, &sinfp->FlashFirmwareBootRevision, in aac_get_adapter_info()
2595 aac_sync_fib_slot_release(softs, acp); in aac_get_adapter_info()
2600 aac_get_bus_info(struct aac_softstate *softs, uint32_t *bus_max, in aac_get_bus_info() argument
2603 struct aac_cmd *acp = &softs->sync_ac; in aac_get_bus_info()
2613 (void) aac_sync_fib_slot_bind(softs, acp); in aac_get_bus_info()
2622 rval = aac_sync_fib(softs, ContainerCommand, in aac_get_bus_info()
2626 AACDB_PRINT(softs, CE_WARN, in aac_get_bus_info()
2646 rval = aac_sync_fib(softs, ContainerCommand, in aac_get_bus_info()
2652 AACDB_PRINT(softs, CE_WARN, "GetBusInfo command fail"); in aac_get_bus_info()
2660 aac_sync_fib_slot_release(softs, acp); in aac_get_bus_info()
2703 aac_handle_adapter_config_issues(struct aac_softstate *softs) in aac_handle_adapter_config_issues() argument
2705 struct aac_cmd *acp = &softs->sync_ac; in aac_handle_adapter_config_issues()
2716 (void) aac_sync_fib_slot_bind(softs, acp); in aac_handle_adapter_config_issues()
2728 rval = aac_sync_fib(softs, ContainerCommand, in aac_handle_adapter_config_issues()
2744 rval = aac_sync_fib(softs, ContainerCommand, in aac_handle_adapter_config_issues()
2768 aac_sync_fib_slot_release(softs, acp); in aac_handle_adapter_config_issues()
2776 aac_common_attach(struct aac_softstate *softs) in aac_common_attach() argument
2782 DBCALLED(softs, 1); in aac_common_attach()
2791 while (AAC_OUTB_GET(softs) != 0xfffffffful) in aac_common_attach()
2798 status = AAC_FWSTATUS_GET(softs); in aac_common_attach()
2802 AAC_BUSYWAIT(AAC_FWSTATUS_GET(softs) & AAC_KERNEL_UP_AND_RUNNING, i); in aac_common_attach()
2805 aac_fm_ereport(softs, DDI_FM_DEVICE_NO_RESPONSE); in aac_common_attach()
2806 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_LOST); in aac_common_attach()
2811 if (aac_check_firmware(softs) == AACERR) { in aac_common_attach()
2812 aac_fm_ereport(softs, DDI_FM_DEVICE_NO_RESPONSE); in aac_common_attach()
2813 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_LOST); in aac_common_attach()
2818 if (aac_register_intrs(softs) == AACERR) { in aac_common_attach()
2825 if (softs->comm_space_dma_handle == NULL) { in aac_common_attach()
2826 if (aac_alloc_comm_space(softs) != AACOK) in aac_common_attach()
2829 if (aac_setup_comm_space(softs) != AACOK) { in aac_common_attach()
2831 aac_fm_ereport(softs, DDI_FM_DEVICE_NO_RESPONSE); in aac_common_attach()
2832 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_LOST); in aac_common_attach()
2837 if (aac_get_fw_debug_buffer(softs) != AACOK) in aac_common_attach()
2842 if ((softs->total_slots == 0) && (aac_create_slots(softs) != AACOK)) { in aac_common_attach()
2846 AACDB_PRINT(softs, CE_NOTE, "%d slots allocated", softs->total_slots); in aac_common_attach()
2849 if (softs->total_fibs < softs->total_slots) { in aac_common_attach()
2850 aac_alloc_fibs(softs); in aac_common_attach()
2851 if (softs->total_fibs == 0) in aac_common_attach()
2853 AACDB_PRINT(softs, CE_NOTE, "%d fibs allocated", in aac_common_attach()
2854 softs->total_fibs); in aac_common_attach()
2857 AAC_STATUS_CLR(softs, ~0); /* Clear out all interrupts */ in aac_common_attach()
2858 AAC_ENABLE_INTR(softs); /* Enable the interrupts we can handle */ in aac_common_attach()
2860 if (aac_get_adapter_info(softs, NULL, &sinf) == AACOK) { in aac_common_attach()
2861 softs->feature_bits = sinf.FeatureBits; in aac_common_attach()
2862 softs->support_opt2 = sinf.SupportedOptions2; in aac_common_attach()
2865 if (CARD_IS_UNKNOWN(softs->card)) { in aac_common_attach()
2873 AACDB_PRINT(softs, CE_NOTE, "sinf.AdapterTypeText = " in aac_common_attach()
2892 (void *)strncpy(softs->vendor_name, p0, in aac_common_attach()
2894 (void *)strncpy(softs->product_name, p1, in aac_common_attach()
2900 (void *)strncpy(softs->product_name, in aac_common_attach()
2916 softs->vendor_name, softs->product_name, in aac_common_attach()
2917 softs->vendid, softs->devid, softs->subvendid, softs->subsysid, in aac_common_attach()
2918 softs->pci_mem_base_paddr); in aac_common_attach()
2921 if (aac_handle_adapter_config_issues(softs) != AACMPE_OK) { in aac_common_attach()
2923 aac_fm_ereport(softs, DDI_FM_DEVICE_NO_RESPONSE); in aac_common_attach()
2924 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_LOST); in aac_common_attach()
2929 if (aac_probe_containers(softs) != AACOK) { in aac_common_attach()
2936 if (softs->feature_bits & AAC_FEATURE_SUPPORTED_JBOD) { in aac_common_attach()
2937 if ((ddi_prop_lookup_string(DDI_DEV_T_ANY, softs->devinfo_p, in aac_common_attach()
2940 AACDB_PRINT(softs, CE_NOTE, in aac_common_attach()
2942 softs->flags |= AAC_FLAGS_JBOD; in aac_common_attach()
2949 if (softs->flags & (AAC_FLAGS_NONDASD | AAC_FLAGS_JBOD)) { in aac_common_attach()
2954 if (aac_get_bus_info(softs, &bus_max, &tgt_max) != AACOK) { in aac_common_attach()
2958 AACDB_PRINT(softs, CE_NOTE, "bus_max=%d, tgt_max=%d", in aac_common_attach()
2960 if (bus_max != softs->bus_max || tgt_max != softs->tgt_max) { in aac_common_attach()
2961 if (softs->state & AAC_STATE_RESET) { in aac_common_attach()
2966 softs->bus_max = bus_max; in aac_common_attach()
2967 softs->tgt_max = tgt_max; in aac_common_attach()
2968 if (softs->nondasds) { in aac_common_attach()
2969 kmem_free(softs->nondasds, AAC_MAX_PD(softs) * \ in aac_common_attach()
2972 softs->nondasds = kmem_zalloc(AAC_MAX_PD(softs) * \ in aac_common_attach()
2976 for (bus = 0; bus < softs->bus_max; bus++) { in aac_common_attach()
2977 for (tgt = 0; tgt < softs->tgt_max; tgt++) { in aac_common_attach()
2979 &softs->nondasds[index++]; in aac_common_attach()
2989 if (aac_check_dma_handle(softs->comm_space_dma_handle) != DDI_SUCCESS) { in aac_common_attach()
2990 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_LOST); in aac_common_attach()
2994 if (aac_check_acc_handle(softs->pci_mem_handle) != DDI_SUCCESS) { in aac_common_attach()
2995 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_LOST); in aac_common_attach()
2999 for (i = 0; i < softs->total_slots; i++) { in aac_common_attach()
3000 if (aac_check_dma_handle(softs->io_slot[i].fib_dma_handle) != in aac_common_attach()
3002 ddi_fm_service_impact(softs->devinfo_p, in aac_common_attach()
3010 if (softs->state & AAC_STATE_RESET) in aac_common_attach()
3012 if (softs->nondasds) { in aac_common_attach()
3013 kmem_free(softs->nondasds, AAC_MAX_PD(softs) * \ in aac_common_attach()
3015 softs->nondasds = NULL; in aac_common_attach()
3017 if (softs->total_fibs > 0) in aac_common_attach()
3018 aac_destroy_fibs(softs); in aac_common_attach()
3019 if (softs->total_slots > 0) in aac_common_attach()
3020 aac_destroy_slots(softs); in aac_common_attach()
3021 if (softs->comm_space_dma_handle) in aac_common_attach()
3022 aac_free_comm_space(softs); in aac_common_attach()
3030 aac_common_detach(struct aac_softstate *softs) in aac_common_detach() argument
3032 DBCALLED(softs, 1); in aac_common_detach()
3034 aac_unregister_intrs(softs); in aac_common_detach()
3036 mutex_enter(&softs->io_lock); in aac_common_detach()
3037 (void) aac_shutdown(softs); in aac_common_detach()
3039 if (softs->nondasds) { in aac_common_detach()
3040 kmem_free(softs->nondasds, AAC_MAX_PD(softs) * \ in aac_common_detach()
3042 softs->nondasds = NULL; in aac_common_detach()
3044 aac_destroy_fibs(softs); in aac_common_detach()
3045 aac_destroy_slots(softs); in aac_common_detach()
3046 aac_free_comm_space(softs); in aac_common_detach()
3047 mutex_exit(&softs->io_lock); in aac_common_detach()
3055 aac_sync_mbcommand(struct aac_softstate *softs, uint32_t cmd, in aac_sync_mbcommand() argument
3066 AAC_MAILBOX_SET(softs, cmd, arg0, arg1, arg2, arg3); in aac_sync_mbcommand()
3069 AAC_STATUS_CLR(softs, AAC_DB_SYNC_COMMAND); in aac_sync_mbcommand()
3072 AAC_NOTIFY(softs, AAC_DB_SYNC_COMMAND); in aac_sync_mbcommand()
3076 AAC_BUSYWAIT(AAC_STATUS_GET(softs) & AAC_DB_SYNC_COMMAND, timeout); in aac_sync_mbcommand()
3078 AACDB_PRINT(softs, CE_WARN, in aac_sync_mbcommand()
3080 AAC_IMMEDIATE_TIMEOUT, AAC_FWSTATUS_GET(softs)); in aac_sync_mbcommand()
3085 AAC_STATUS_CLR(softs, AAC_DB_SYNC_COMMAND); in aac_sync_mbcommand()
3088 status = AAC_MAILBOX_GET(softs, 0); in aac_sync_mbcommand()
3092 AACDB_PRINT(softs, CE_WARN, in aac_sync_mbcommand()
3104 aac_sync_fib(struct aac_softstate *softs, uint16_t cmd, uint16_t fibsize) in aac_sync_fib() argument
3106 struct aac_cmd *acp = &softs->sync_ac; in aac_sync_fib()
3109 if (softs->state & AAC_STATE_INTR) in aac_sync_fib()
3122 aac_cmd_fib_header(softs, acp, cmd); in aac_sync_fib()
3127 aac_start_io(softs, acp); in aac_sync_fib()
3129 if (softs->state & AAC_STATE_INTR) in aac_sync_fib()
3130 return (aac_do_sync_io(softs, acp)); in aac_sync_fib()
3132 return (aac_do_poll_io(softs, acp)); in aac_sync_fib()
3202 aac_fib_enqueue(struct aac_softstate *softs, int queue, uint32_t fib_addr, in aac_fib_enqueue() argument
3205 ddi_dma_handle_t dma = softs->comm_space_dma_handle; in aac_fib_enqueue()
3206 ddi_acc_handle_t acc = softs->comm_space_acc_handle; in aac_fib_enqueue()
3209 DBCALLED(softs, 2); in aac_fib_enqueue()
3214 (void) ddi_dma_sync(dma, (uintptr_t)softs->qtablep->qt_qindex[queue] - \ in aac_fib_enqueue()
3215 (uintptr_t)softs->comm_space, sizeof (uint32_t) * 2, in aac_fib_enqueue()
3218 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_UNAFFECTED); in aac_fib_enqueue()
3223 &softs->qtablep->qt_qindex[queue][AAC_PRODUCER_INDEX]); in aac_fib_enqueue()
3225 &softs->qtablep->qt_qindex[queue][AAC_CONSUMER_INDEX]); in aac_fib_enqueue()
3239 ddi_put32(acc, &((softs->qentries[queue] + pi)->aq_fib_size), fib_size); in aac_fib_enqueue()
3240 ddi_put32(acc, &((softs->qentries[queue] + pi)->aq_fib_addr), fib_addr); in aac_fib_enqueue()
3241 (void) ddi_dma_sync(dma, (uintptr_t)(softs->qentries[queue] + pi) - \ in aac_fib_enqueue()
3242 (uintptr_t)softs->comm_space, sizeof (struct aac_queue_entry), in aac_fib_enqueue()
3246 ddi_put32(acc, &softs->qtablep->qt_qindex[queue][AAC_PRODUCER_INDEX], in aac_fib_enqueue()
3249 (uintptr_t)&softs->qtablep->qt_qindex[queue][AAC_PRODUCER_INDEX] - \ in aac_fib_enqueue()
3250 (uintptr_t)softs->comm_space, sizeof (uint32_t), in aac_fib_enqueue()
3254 AAC_NOTIFY(softs, aac_qinfo[queue].notify); in aac_fib_enqueue()
3263 aac_fib_dequeue(struct aac_softstate *softs, int queue, int *idxp) in aac_fib_dequeue() argument
3265 ddi_acc_handle_t acc = softs->comm_space_acc_handle; in aac_fib_dequeue()
3266 ddi_dma_handle_t dma = softs->comm_space_dma_handle; in aac_fib_dequeue()
3270 DBCALLED(softs, 2); in aac_fib_dequeue()
3275 (void) ddi_dma_sync(dma, (uintptr_t)softs->qtablep->qt_qindex[queue] - \ in aac_fib_dequeue()
3276 (uintptr_t)softs->comm_space, sizeof (uint32_t) * 2, in aac_fib_dequeue()
3279 &softs->qtablep->qt_qindex[queue][AAC_PRODUCER_INDEX]); in aac_fib_dequeue()
3281 &softs->qtablep->qt_qindex[queue][AAC_CONSUMER_INDEX]); in aac_fib_dequeue()
3302 (void) ddi_dma_sync(dma, (uintptr_t)(softs->qentries[queue] + pi) - \ in aac_fib_dequeue()
3303 (uintptr_t)softs->comm_space, sizeof (struct aac_queue_entry), in aac_fib_dequeue()
3306 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_UNAFFECTED); in aac_fib_dequeue()
3314 &(softs->qentries[queue] + ci)->aq_fib_addr); in aac_fib_dequeue()
3320 &(softs->qentries[queue] + ci)->aq_fib_addr) / AAC_FIB_SIZE; in aac_fib_dequeue()
3329 ddi_put32(acc, &softs->qtablep->qt_qindex[queue][AAC_CONSUMER_INDEX], in aac_fib_dequeue()
3332 (uintptr_t)&softs->qtablep->qt_qindex[queue][AAC_CONSUMER_INDEX] - \ in aac_fib_dequeue()
3333 (uintptr_t)softs->comm_space, sizeof (uint32_t), in aac_fib_dequeue()
3337 AAC_NOTIFY(softs, aac_qinfo[queue].notify); in aac_fib_dequeue()
3342 aac_get_mntinfo(struct aac_softstate *softs, int cid) in aac_get_mntinfo() argument
3344 ddi_acc_handle_t acc = softs->sync_ac.slotp->fib_acc_handle; in aac_get_mntinfo()
3345 struct aac_fib *fibp = softs->sync_ac.slotp->fibp; in aac_get_mntinfo()
3350 (softs->flags & AAC_FLAGS_LBA_64BIT) ? in aac_get_mntinfo()
3355 if (aac_sync_fib(softs, ContainerCommand, in aac_get_mntinfo()
3357 AACDB_PRINT(softs, CE_WARN, "Error probe container %d", cid); in aac_get_mntinfo()
3368 aac_get_container_count(struct aac_softstate *softs, int *count) in aac_get_container_count() argument
3374 (void) aac_sync_fib_slot_bind(softs, &softs->sync_ac); in aac_get_container_count()
3375 acc = softs->sync_ac.slotp->fib_acc_handle; in aac_get_container_count()
3377 if ((mir = aac_get_mntinfo(softs, 0)) == NULL) { in aac_get_container_count()
3383 AACDB_PRINT(softs, CE_CONT, in aac_get_container_count()
3391 aac_sync_fib_slot_release(softs, &softs->sync_ac); in aac_get_container_count()
3396 aac_get_container_uid(struct aac_softstate *softs, uint32_t cid, uint32_t *uid) in aac_get_container_uid() argument
3398 ddi_acc_handle_t acc = softs->sync_ac.slotp->fib_acc_handle; in aac_get_container_uid()
3400 &softs->sync_ac.slotp->fibp->data[0]; in aac_get_container_uid()
3407 if (aac_sync_fib(softs, ContainerCommand, in aac_get_container_uid()
3421 aac_get_container_info(struct aac_softstate *softs, int cid) in aac_get_container_info() argument
3423 ddi_acc_handle_t acc = softs->sync_ac.slotp->fib_acc_handle; in aac_get_container_info()
3429 rval_uid = aac_get_container_uid(softs, cid, &uid); in aac_get_container_info()
3432 if ((mir = aac_get_mntinfo(softs, cid)) == NULL) { in aac_get_container_info()
3433 AACDB_PRINT(softs, CE_CONT, in aac_get_container_info()
3440 AACDB_PRINT(softs, CE_CONT, in aac_get_container_info()
3450 aac_probe_container(struct aac_softstate *softs, uint32_t cid) in aac_probe_container() argument
3453 struct aac_container *dvp = &softs->containers[cid]; in aac_probe_container()
3457 (void) aac_sync_fib_slot_bind(softs, &softs->sync_ac); in aac_probe_container()
3458 acc = softs->sync_ac.slotp->fib_acc_handle; in aac_probe_container()
3461 if ((mir = aac_get_container_info(softs, cid)) == NULL) { in aac_probe_container()
3468 AACDB_PRINT(softs, CE_NOTE, in aac_probe_container()
3480 size = AAC_MIR_SIZE(softs, acc, mir); in aac_probe_container()
3484 AACDB_PRINT(softs, CE_WARN, in aac_probe_container()
3491 AACDB_PRINT(softs, CE_NOTE, in aac_probe_container()
3498 AACDB_PRINT(softs, CE_NOTE, in aac_probe_container()
3520 aac_sync_fib_slot_release(softs, &softs->sync_ac); in aac_probe_container()
3529 aac_probe_containers(struct aac_softstate *softs) in aac_probe_containers() argument
3534 count = softs->container_count; in aac_probe_containers()
3535 if (aac_get_container_count(softs, &count) == AACERR) in aac_probe_containers()
3539 enum aac_cfg_event event = aac_probe_container(softs, i); in aac_probe_containers()
3542 (void) aac_handle_dr(softs, i, -1, event); in aac_probe_containers()
3547 if (count < softs->container_count) { in aac_probe_containers()
3550 for (dvp = &softs->containers[count]; in aac_probe_containers()
3551 dvp < &softs->containers[softs->container_count]; dvp++) { in aac_probe_containers()
3554 AACDB_PRINT(softs, CE_NOTE, ">>> Container %d deleted", in aac_probe_containers()
3557 (void) aac_handle_dr(softs, dvp->cid, -1, in aac_probe_containers()
3562 softs->container_count = count; in aac_probe_containers()
3563 AACDB_PRINT(softs, CE_CONT, "?Total %d container(s) found", total); in aac_probe_containers()
3568 aac_probe_jbod(struct aac_softstate *softs, int tgt, int event) in aac_probe_jbod() argument
3571 ASSERT(tgt < AAC_MAX_DEV(softs)); in aac_probe_jbod()
3573 dvp = AAC_DEV(softs, tgt); in aac_probe_jbod()
3577 AACDB_PRINT(softs, CE_NOTE, in aac_probe_jbod()
3583 AACDB_PRINT(softs, CE_NOTE, in aac_probe_jbod()
3590 (void) aac_handle_dr(softs, tgt, 0, event); in aac_probe_jbod()
3595 aac_alloc_comm_space(struct aac_softstate *softs) in aac_alloc_comm_space() argument
3603 softs->devinfo_p, in aac_alloc_comm_space()
3604 &softs->addr_dma_attr, in aac_alloc_comm_space()
3607 &softs->comm_space_dma_handle) != DDI_SUCCESS) { in aac_alloc_comm_space()
3608 AACDB_PRINT(softs, CE_WARN, in aac_alloc_comm_space()
3613 softs->comm_space_dma_handle, in aac_alloc_comm_space()
3615 &softs->acc_attr, in aac_alloc_comm_space()
3619 (caddr_t *)&softs->comm_space, in aac_alloc_comm_space()
3621 &softs->comm_space_acc_handle) != DDI_SUCCESS) { in aac_alloc_comm_space()
3622 AACDB_PRINT(softs, CE_WARN, in aac_alloc_comm_space()
3627 softs->comm_space_dma_handle, in aac_alloc_comm_space()
3629 (caddr_t)softs->comm_space, in aac_alloc_comm_space()
3636 AACDB_PRINT(softs, CE_WARN, in aac_alloc_comm_space()
3640 softs->comm_space_phyaddr = cookie.dmac_address; in aac_alloc_comm_space()
3644 if (softs->comm_space_acc_handle) { in aac_alloc_comm_space()
3645 ddi_dma_mem_free(&softs->comm_space_acc_handle); in aac_alloc_comm_space()
3646 softs->comm_space_acc_handle = NULL; in aac_alloc_comm_space()
3648 if (softs->comm_space_dma_handle) { in aac_alloc_comm_space()
3649 ddi_dma_free_handle(&softs->comm_space_dma_handle); in aac_alloc_comm_space()
3650 softs->comm_space_dma_handle = NULL; in aac_alloc_comm_space()
3656 aac_free_comm_space(struct aac_softstate *softs) in aac_free_comm_space() argument
3659 (void) ddi_dma_unbind_handle(softs->comm_space_dma_handle); in aac_free_comm_space()
3660 ddi_dma_mem_free(&softs->comm_space_acc_handle); in aac_free_comm_space()
3661 softs->comm_space_acc_handle = NULL; in aac_free_comm_space()
3662 ddi_dma_free_handle(&softs->comm_space_dma_handle); in aac_free_comm_space()
3663 softs->comm_space_dma_handle = NULL; in aac_free_comm_space()
3664 softs->comm_space_phyaddr = NULL; in aac_free_comm_space()
3672 aac_setup_comm_space(struct aac_softstate *softs) in aac_setup_comm_space() argument
3674 ddi_dma_handle_t dma = softs->comm_space_dma_handle; in aac_setup_comm_space()
3675 ddi_acc_handle_t acc = softs->comm_space_acc_handle; in aac_setup_comm_space()
3680 comm_space_phyaddr = softs->comm_space_phyaddr; in aac_setup_comm_space()
3683 initp = &softs->comm_space->init_data; in aac_setup_comm_space()
3690 if (softs->flags & AAC_FLAGS_RAW_IO) { in aac_setup_comm_space()
3693 if (softs->flags & AAC_FLAGS_NEW_COMM) in aac_setup_comm_space()
3703 ddi_put32(acc, &initp->MaxIoCommands, softs->aac_max_fibs); in aac_setup_comm_space()
3705 (softs->aac_max_sectors << 9)); in aac_setup_comm_space()
3706 ddi_put32(acc, &initp->MaxFibSize, softs->aac_max_fib_size); in aac_setup_comm_space()
3733 softs->qtablep = (struct aac_queue_table *) \ in aac_setup_comm_space()
3734 ((char *)&softs->comm_space->qtable + qoffset); in aac_setup_comm_space()
3739 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3742 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3745 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3748 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3751 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3754 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3757 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3760 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3763 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3766 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3769 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3772 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3775 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3778 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3781 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3784 ddi_put32(acc, &softs->qtablep-> \ in aac_setup_comm_space()
3789 softs->qentries[AAC_HOST_NORM_CMD_Q] = in aac_setup_comm_space()
3790 &softs->qtablep->qt_HostNormCmdQueue[0]; in aac_setup_comm_space()
3791 softs->qentries[AAC_HOST_HIGH_CMD_Q] = in aac_setup_comm_space()
3792 &softs->qtablep->qt_HostHighCmdQueue[0]; in aac_setup_comm_space()
3793 softs->qentries[AAC_ADAP_NORM_CMD_Q] = in aac_setup_comm_space()
3794 &softs->qtablep->qt_AdapNormCmdQueue[0]; in aac_setup_comm_space()
3795 softs->qentries[AAC_ADAP_HIGH_CMD_Q] = in aac_setup_comm_space()
3796 &softs->qtablep->qt_AdapHighCmdQueue[0]; in aac_setup_comm_space()
3797 softs->qentries[AAC_HOST_NORM_RESP_Q] = in aac_setup_comm_space()
3798 &softs->qtablep->qt_HostNormRespQueue[0]; in aac_setup_comm_space()
3799 softs->qentries[AAC_HOST_HIGH_RESP_Q] = in aac_setup_comm_space()
3800 &softs->qtablep->qt_HostHighRespQueue[0]; in aac_setup_comm_space()
3801 softs->qentries[AAC_ADAP_NORM_RESP_Q] = in aac_setup_comm_space()
3802 &softs->qtablep->qt_AdapNormRespQueue[0]; in aac_setup_comm_space()
3803 softs->qentries[AAC_ADAP_HIGH_RESP_Q] = in aac_setup_comm_space()
3804 &softs->qtablep->qt_AdapHighRespQueue[0]; in aac_setup_comm_space()
3809 if (aac_sync_mbcommand(softs, AAC_MONKER_INITSTRUCT, in aac_setup_comm_space()
3813 AACDB_PRINT(softs, CE_WARN, in aac_setup_comm_space()
3822 aac_vendor_id(struct aac_softstate *softs, uchar_t *buf) in aac_vendor_id() argument
3825 bcopy(softs->vendor_name, buf, strlen(softs->vendor_name)); in aac_vendor_id()
3830 aac_product_id(struct aac_softstate *softs, uchar_t *buf) in aac_product_id() argument
3833 bcopy(softs->product_name, buf, strlen(softs->product_name)); in aac_product_id()
3841 aac_lun_serialno(struct aac_softstate *softs, int tgt, uchar_t *buf) in aac_lun_serialno() argument
3848 uid = softs->containers[tgt].uid; in aac_lun_serialno()
3861 aac_inquiry(struct aac_softstate *softs, struct scsi_pkt *pkt, in aac_inquiry() argument
3912 (void) aac_lun_serialno(softs, tgt, sp); in aac_inquiry()
3939 sp = aac_vendor_id(softs, sp); in aac_inquiry()
3940 sp = aac_product_id(softs, sp); in aac_inquiry()
3941 sp = aac_lun_serialno(softs, tgt, sp); in aac_inquiry()
3971 (void) aac_vendor_id(softs, (uchar_t *)inqp->inq_vid); in aac_inquiry()
3972 (void) aac_product_id(softs, (uchar_t *)inqp->inq_pid); in aac_inquiry()
3989 aac_mode_sense(struct aac_softstate *softs, struct scsi_pkt *pkt, in aac_mode_sense() argument
4030 if (softs->flags & AAC_FLAGS_LBA_64BIT) { in aac_mode_sense()
4038 if (softs->flags & AAC_FLAGS_LBA_64BIT) { in aac_mode_sense()
4107 softs->flags & AAC_FLAGS_LBA_64BIT) { in aac_mode_sense()
4148 struct aac_softstate *softs = AAC_TRAN2SOFTS(tran); in aac_tran_tgt_init() local
4150 int ctl = ddi_get_instance(softs->devinfo_p); in aac_tran_tgt_init()
4156 DBCALLED(softs, 2); in aac_tran_tgt_init()
4163 if (aac_find_child(softs, tgt, lun) != NULL) { in aac_tran_tgt_init()
4176 mutex_enter(&softs->io_lock); in aac_tran_tgt_init()
4177 if (tgt >= AAC_MAX_DEV(softs)) { in aac_tran_tgt_init()
4178 AACDB_PRINT_TRAN(softs, in aac_tran_tgt_init()
4180 mutex_exit(&softs->io_lock); in aac_tran_tgt_init()
4185 dvp = (struct aac_device *)&softs->containers[tgt]; in aac_tran_tgt_init()
4187 AACDB_PRINT_TRAN(softs, "aac_tran_tgt_init: c%dt%dL%d", in aac_tran_tgt_init()
4189 mutex_exit(&softs->io_lock); in aac_tran_tgt_init()
4197 if (softs->containers[tgt].dev.dip == NULL && in aac_tran_tgt_init()
4199 softs->containers[tgt].dev.dip = tgt_dip; in aac_tran_tgt_init()
4201 dvp = (struct aac_device *)&softs->nondasds[AAC_PD(tgt)]; in aac_tran_tgt_init()
4208 if (softs->nondasds[AAC_PD(tgt)].dev.dip == NULL && in aac_tran_tgt_init()
4210 softs->nondasds[AAC_PD(tgt)].dev.dip = tgt_dip; in aac_tran_tgt_init()
4213 if (softs->flags & AAC_FLAGS_BRKUP) { in aac_tran_tgt_init()
4221 AACDB_PRINT(softs, CE_NOTE, in aac_tran_tgt_init()
4224 mutex_exit(&softs->io_lock); in aac_tran_tgt_init()
4236 struct aac_softstate *softs = SD2AAC(sd); in aac_tran_tgt_free() local
4239 mutex_enter(&softs->io_lock); in aac_tran_tgt_free()
4241 if (softs->containers[tgt].dev.dip == tgt_dip) in aac_tran_tgt_free()
4242 softs->containers[tgt].dev.dip = NULL; in aac_tran_tgt_free()
4244 if (softs->nondasds[AAC_PD(tgt)].dev.dip == tgt_dip) in aac_tran_tgt_free()
4245 softs->nondasds[AAC_PD(tgt)].dev.dip = NULL; in aac_tran_tgt_free()
4246 softs->nondasds[AAC_PD(tgt)].dev.flags &= ~AAC_DFLAG_VALID; in aac_tran_tgt_free()
4248 mutex_exit(&softs->io_lock); in aac_tran_tgt_free()
4259 aac_check_adapter_health(struct aac_softstate *softs) in aac_check_adapter_health() argument
4263 rval = PCI_MEM_GET32(softs, AAC_OMR0); in aac_check_adapter_health()
4278 aac_abort_iocmd(struct aac_softstate *softs, struct aac_cmd *acp, in aac_abort_iocmd() argument
4290 AACDB_PRINT(softs, CE_NOTE, "CMD_TIMEOUT: acp=0x%p", in aac_abort_iocmd()
4292 aac_set_pkt_reason(softs, acp, CMD_TIMEOUT, in aac_abort_iocmd()
4297 AACDB_PRINT(softs, CE_NOTE, "CMD_RESET: acp=0x%p", acp); in aac_abort_iocmd()
4298 aac_set_pkt_reason(softs, acp, CMD_RESET, in aac_abort_iocmd()
4302 AACDB_PRINT(softs, CE_NOTE, "CMD_ABORTED: acp=0x%p", in aac_abort_iocmd()
4304 aac_set_pkt_reason(softs, acp, CMD_ABORTED, in aac_abort_iocmd()
4309 aac_end_io(softs, acp); in aac_abort_iocmd()
4317 aac_abort_iocmds(struct aac_softstate *softs, int iocmd, struct scsi_pkt *pkt, in aac_abort_iocmds() argument
4340 if (AAC_DEV_IS_VALID(&softs->containers[i].dev)) in aac_abort_iocmds()
4341 softs->containers[i].reset = 1; in aac_abort_iocmds()
4343 while ((acp = softs->q_busy.q_head) != NULL) in aac_abort_iocmds()
4344 aac_abort_iocmd(softs, acp, reason); in aac_abort_iocmds()
4351 aac_abort_iocmd(softs, ac_arg, reason); in aac_abort_iocmds()
4353 while ((acp = softs->q_wait[i].q_head) != NULL) in aac_abort_iocmds()
4354 aac_abort_iocmd(softs, acp, reason); in aac_abort_iocmds()
4367 struct aac_softstate *softs = arg; in aac_check_drain() local
4369 mutex_enter(&softs->io_lock); in aac_check_drain()
4370 if (softs->ndrains) { in aac_check_drain()
4371 softs->drain_timeid = 0; in aac_check_drain()
4376 if ((softs->bus_throttle[AAC_CMDQ_ASYNC] > 0 || in aac_check_drain()
4377 softs->bus_ncmds[AAC_CMDQ_ASYNC] == 0) && in aac_check_drain()
4378 (softs->bus_throttle[AAC_CMDQ_SYNC] > 0 || in aac_check_drain()
4379 softs->bus_ncmds[AAC_CMDQ_SYNC] == 0)) in aac_check_drain()
4380 cv_broadcast(&softs->drain_cv); in aac_check_drain()
4382 softs->drain_timeid = timeout(aac_check_drain, softs, in aac_check_drain()
4385 mutex_exit(&softs->io_lock); in aac_check_drain()
4393 aac_start_drain(struct aac_softstate *softs) in aac_start_drain() argument
4395 if (softs->ndrains == 0) { in aac_start_drain()
4396 ASSERT(softs->drain_timeid == 0); in aac_start_drain()
4397 softs->drain_timeid = timeout(aac_check_drain, softs, in aac_start_drain()
4400 softs->ndrains++; in aac_start_drain()
4408 aac_stop_drain(struct aac_softstate *softs) in aac_stop_drain() argument
4410 softs->ndrains--; in aac_stop_drain()
4411 if (softs->ndrains == 0) { in aac_stop_drain()
4412 if (softs->drain_timeid != 0) { in aac_stop_drain()
4413 timeout_id_t tid = softs->drain_timeid; in aac_stop_drain()
4415 softs->drain_timeid = 0; in aac_stop_drain()
4416 mutex_exit(&softs->io_lock); in aac_stop_drain()
4418 mutex_enter(&softs->io_lock); in aac_stop_drain()
4433 aac_reset_adapter(struct aac_softstate *softs) in aac_reset_adapter() argument
4439 DBCALLED(softs, 1); in aac_reset_adapter()
4441 ASSERT(softs->state & AAC_STATE_RESET); in aac_reset_adapter()
4443 ddi_fm_acc_err_clear(softs->pci_mem_handle, DDI_FME_VER0); in aac_reset_adapter()
4445 AAC_DISABLE_INTR(softs); in aac_reset_adapter()
4447 health = aac_check_adapter_health(softs); in aac_reset_adapter()
4449 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_LOST); in aac_reset_adapter()
4453 (void) aac_shutdown(softs); in aac_reset_adapter()
4456 if ((aac_sync_mbcommand(softs, AAC_IOP_RESET, 0, 0, 0, 0, in aac_reset_adapter()
4473 PCI_MEM_PUT32(softs, AAC_IRCSR, AAC_IRCSR_CORES_RST); in aac_reset_adapter()
4491 (void) aac_sync_fib_slot_bind(softs, &softs->sync_ac); in aac_reset_adapter()
4492 acc = softs->sync_ac.slotp->fib_acc_handle; in aac_reset_adapter()
4494 fibp = softs->sync_ac.slotp->fibp; in aac_reset_adapter()
4504 (void) aac_sync_fib(softs, ContainerCommand, in aac_reset_adapter()
4506 aac_sync_fib_slot_release(softs, &softs->sync_ac); in aac_reset_adapter()
4508 if (aac_check_adapter_health(softs) != 0) in aac_reset_adapter()
4509 ddi_fm_service_impact(softs->devinfo_p, in aac_reset_adapter()
4525 if (aac_common_attach(softs) != AACOK) in aac_reset_adapter()
4531 AAC_ENABLE_INTR(softs); in aac_reset_adapter()
4536 aac_set_throttle(struct aac_softstate *softs, struct aac_device *dvp, int q, in aac_set_throttle() argument
4543 if ((softs->state & AAC_STATE_QUIESCED) || softs->ndrains) in aac_set_throttle()
4549 aac_hold_bus(struct aac_softstate *softs, int iocmds) in aac_hold_bus() argument
4556 softs->bus_throttle[q] = 0; in aac_hold_bus()
4558 aac_set_throttle(softs, in aac_hold_bus()
4559 &softs->containers[i].dev, q, 0); in aac_hold_bus()
4560 for (i = 0; i < AAC_MAX_PD(softs); i++) in aac_hold_bus()
4561 aac_set_throttle(softs, in aac_hold_bus()
4562 &softs->nondasds[i].dev, q, 0); in aac_hold_bus()
4568 aac_unhold_bus(struct aac_softstate *softs, int iocmds) in aac_unhold_bus() argument
4579 if (q == AAC_CMDQ_ASYNC && ((softs->state & in aac_unhold_bus()
4580 AAC_STATE_QUIESCED) || softs->ndrains)) in aac_unhold_bus()
4583 max_throttle = softs->total_slots - in aac_unhold_bus()
4586 max_throttle = softs->total_slots - 1; in aac_unhold_bus()
4587 softs->bus_throttle[q] = max_throttle; in aac_unhold_bus()
4589 aac_set_throttle(softs, in aac_unhold_bus()
4590 &softs->containers[i].dev, in aac_unhold_bus()
4592 for (i = 0; i < AAC_MAX_PD(softs); i++) in aac_unhold_bus()
4593 aac_set_throttle(softs, &softs->nondasds[i].dev, in aac_unhold_bus()
4600 aac_do_reset(struct aac_softstate *softs) in aac_do_reset() argument
4605 softs->state |= AAC_STATE_RESET; in aac_do_reset()
4606 health = aac_check_adapter_health(softs); in aac_do_reset()
4613 int sync_cmds = softs->bus_ncmds[AAC_CMDQ_SYNC]; in aac_do_reset()
4614 int async_cmds = softs->bus_ncmds[AAC_CMDQ_ASYNC]; in aac_do_reset()
4627 aac_hold_bus(softs, AAC_IOCMD_SYNC | AAC_IOCMD_ASYNC); in aac_do_reset()
4632 intr_handler = (softs->flags & AAC_FLAGS_NEW_COMM) ? in aac_do_reset()
4634 while ((softs->bus_ncmds[AAC_CMDQ_SYNC] || in aac_do_reset()
4635 softs->bus_ncmds[AAC_CMDQ_ASYNC]) && timeout) { in aac_do_reset()
4637 (void) intr_handler(softs); in aac_do_reset()
4640 aac_unhold_bus(softs, AAC_IOCMD_SYNC | AAC_IOCMD_ASYNC); in aac_do_reset()
4642 if (softs->bus_ncmds[AAC_CMDQ_SYNC] == 0 && in aac_do_reset()
4643 softs->bus_ncmds[AAC_CMDQ_ASYNC] == 0) { in aac_do_reset()
4647 } else if (softs->bus_ncmds[AAC_CMDQ_SYNC] < sync_cmds || in aac_do_reset()
4648 softs->bus_ncmds[AAC_CMDQ_ASYNC] < async_cmds) { in aac_do_reset()
4659 if ((rval = aac_reset_adapter(softs)) == AAC_IOP_RESET_FAILED) in aac_do_reset()
4660 softs->state |= AAC_STATE_DEAD; in aac_do_reset()
4663 softs->state &= ~AAC_STATE_RESET; in aac_do_reset()
4670 struct aac_softstate *softs = AAC_TRAN2SOFTS(ap->a_hba_tran); in aac_tran_reset() local
4673 DBCALLED(softs, 1); in aac_tran_reset()
4680 mutex_enter(&softs->io_lock); in aac_tran_reset()
4681 switch (rval = aac_do_reset(softs)) { in aac_tran_reset()
4683 aac_abort_iocmds(softs, AAC_IOCMD_OUTSTANDING | AAC_IOCMD_ASYNC, in aac_tran_reset()
4685 aac_start_waiting_io(softs); in aac_tran_reset()
4689 aac_abort_iocmds(softs, AAC_IOCMD_ALL, NULL, CMD_RESET); in aac_tran_reset()
4692 aac_start_waiting_io(softs); in aac_tran_reset()
4694 mutex_exit(&softs->io_lock); in aac_tran_reset()
4696 aac_drain_comp_q(softs); in aac_tran_reset()
4703 struct aac_softstate *softs = AAC_TRAN2SOFTS(ap->a_hba_tran); in aac_tran_abort() local
4705 DBCALLED(softs, 1); in aac_tran_abort()
4707 mutex_enter(&softs->io_lock); in aac_tran_abort()
4708 aac_abort_iocmds(softs, 0, pkt, CMD_ABORTED); in aac_tran_abort()
4709 mutex_exit(&softs->io_lock); in aac_tran_abort()
4711 aac_drain_comp_q(softs); in aac_tran_abort()
4742 aac_unknown_scmd(struct aac_softstate *softs, struct aac_cmd *acp) in aac_unknown_scmd() argument
4744 AACDB_PRINT(softs, CE_CONT, "SCMD 0x%x not supported", in aac_unknown_scmd()
4748 aac_soft_callback(softs, acp); in aac_unknown_scmd()
4755 aac_tran_start_ld(struct aac_softstate *softs, struct aac_cmd *acp) in aac_tran_start_ld() argument
4771 aac_inquiry(softs, pkt, cdbp, bp); in aac_tran_start_ld()
4772 aac_soft_callback(softs, acp); in aac_tran_start_ld()
4796 aac_soft_callback(softs, acp); in aac_tran_start_ld()
4818 aac_soft_callback(softs, acp); in aac_tran_start_ld()
4820 aac_unknown_scmd(softs, acp); in aac_tran_start_ld()
4827 if (softs->flags & AAC_FLAGS_RAW_IO) { in aac_tran_start_ld()
4834 AACDB_PRINT(softs, CE_WARN, "64-bit LBA not supported"); in aac_tran_start_ld()
4835 aac_unknown_scmd(softs, acp); in aac_tran_start_ld()
4865 rval = aac_do_io(softs, acp); in aac_tran_start_ld()
4875 aac_soft_callback(softs, acp); in aac_tran_start_ld()
4880 aac_soft_callback(softs, acp); in aac_tran_start_ld()
4896 aac_mode_sense(softs, pkt, cdbp, bp, capacity); in aac_tran_start_ld()
4897 aac_soft_callback(softs, acp); in aac_tran_start_ld()
4903 if (softs->support_opt2 & AAC_SUPPORTED_POWER_MANAGEMENT) { in aac_tran_start_ld()
4906 rval = aac_do_io(softs, acp); in aac_tran_start_ld()
4922 aac_soft_callback(softs, acp); in aac_tran_start_ld()
4930 rval = aac_do_io(softs, acp); in aac_tran_start_ld()
4936 aac_soft_callback(softs, acp); in aac_tran_start_ld()
4941 aac_unknown_scmd(softs, acp); in aac_tran_start_ld()
4952 struct aac_softstate *softs = AAC_TRAN2SOFTS(ap->a_hba_tran); in aac_tran_start() local
4957 DBCALLED(softs, 2); in aac_tran_start()
4982 ddi_fm_service_impact(softs->devinfo_p, in aac_tran_start()
4990 mutex_enter(&softs->io_lock); in aac_tran_start()
4991 AACDB_PRINT_SCMD(softs, acp); in aac_tran_start()
4993 !(softs->state & AAC_STATE_DEAD)) { in aac_tran_start()
4996 rval = aac_tran_start_ld(softs, acp); in aac_tran_start()
5000 rval = aac_do_io(softs, acp); in aac_tran_start()
5005 if (!(softs->state & AAC_STATE_DEAD)) { in aac_tran_start()
5006 AACDB_PRINT_TRAN(softs, in aac_tran_start()
5011 AACDB_PRINT(softs, CE_WARN, in aac_tran_start()
5019 mutex_exit(&softs->io_lock); in aac_tran_start()
5026 struct aac_softstate *softs = AAC_TRAN2SOFTS(ap->a_hba_tran); in aac_tran_getcap() local
5030 DBCALLED(softs, 2); in aac_tran_getcap()
5034 AACDB_PRINT(softs, CE_WARN, in aac_tran_getcap()
5039 mutex_enter(&softs->io_lock); in aac_tran_getcap()
5040 dvp = AAC_DEV(softs, ap->a_target); in aac_tran_getcap()
5042 mutex_exit(&softs->io_lock); in aac_tran_getcap()
5043 AACDB_PRINT_TRAN(softs, "Bad target t%dL%d to getcap", in aac_tran_getcap()
5057 rval = softs->dma_max; in aac_tran_getcap()
5063 mutex_exit(&softs->io_lock); in aac_tran_getcap()
5065 AACDB_PRINT_TRAN(softs, "GetCap> %s t%dL%d: rval=%d", in aac_tran_getcap()
5074 struct aac_softstate *softs = AAC_TRAN2SOFTS(ap->a_hba_tran); in aac_tran_setcap() local
5078 DBCALLED(softs, 2); in aac_tran_setcap()
5082 AACDB_PRINT(softs, CE_WARN, in aac_tran_setcap()
5087 mutex_enter(&softs->io_lock); in aac_tran_setcap()
5088 dvp = AAC_DEV(softs, ap->a_target); in aac_tran_setcap()
5090 mutex_exit(&softs->io_lock); in aac_tran_setcap()
5091 AACDB_PRINT_TRAN(softs, "Bad target t%dL%d to setcap", in aac_tran_setcap()
5109 mutex_exit(&softs->io_lock); in aac_tran_setcap()
5111 AACDB_PRINT_TRAN(softs, "SetCap> %s t%dL%d val=%d: rval=%d", in aac_tran_setcap()
5133 aac_cmd_dma_alloc(struct aac_softstate *softs, struct aac_cmd *acp, in aac_cmd_dma_alloc() argument
5153 AACDB_PRINT(softs, CE_WARN, in aac_cmd_dma_alloc()
5157 AACDB_PRINT(softs, CE_WARN, "Nothing to transfer"); in aac_cmd_dma_alloc()
5187 rval = ddi_dma_alloc_handle(softs->devinfo_p, in aac_cmd_dma_alloc()
5188 &softs->buf_dma_attr, cb, arg, in aac_cmd_dma_alloc()
5191 AACDB_PRINT(softs, CE_WARN, in aac_cmd_dma_alloc()
5206 AACDB_PRINT_TRAN(softs, in aac_cmd_dma_alloc()
5214 &softs->acc_attr, DDI_DMA_STREAMING, in aac_cmd_dma_alloc()
5218 AACDB_PRINT(softs, CE_NOTE, in aac_cmd_dma_alloc()
5239 AACDB_PRINT(softs, CE_WARN, in aac_cmd_dma_alloc()
5244 AACDB_PRINT_TRAN(softs, "buf bind, %d seg(s)", in aac_cmd_dma_alloc()
5250 AACDB_PRINT_TRAN(softs, "buf bind, %d seg(s)", in aac_cmd_dma_alloc()
5258 AACDB_PRINT(softs, CE_WARN, in aac_cmd_dma_alloc()
5264 AACDB_PRINT(softs, CE_WARN, in aac_cmd_dma_alloc()
5269 AACDB_PRINT(softs, CE_WARN, in aac_cmd_dma_alloc()
5275 AACDB_PRINT(softs, CE_WARN, in aac_cmd_dma_alloc()
5283 if (acp->left_cookien > softs->aac_sg_tablesize) { in aac_cmd_dma_alloc()
5284 AACDB_PRINT(softs, CE_NOTE, "large cookiec received %d", in aac_cmd_dma_alloc()
5298 AACDB_PRINT(softs, CE_WARN, in aac_cmd_dma_alloc()
5323 if (acp->bcount > softs->buf_dma_attr.dma_attr_maxxfer) { in aac_cmd_dma_alloc()
5324 AACDB_PRINT(softs, CE_NOTE, in aac_cmd_dma_alloc()
5346 AACDB_PRINT_TRAN(softs, in aac_cmd_dma_alloc()
5364 struct aac_softstate *softs = AAC_TRAN2SOFTS(ap->a_hba_tran); in aac_tran_init_pkt() local
5367 DBCALLED(softs, 2); in aac_tran_init_pkt()
5374 slen = (statuslen > softs->slen) ? statuslen : softs->slen; in aac_tran_init_pkt()
5375 pkt = scsi_hba_pkt_alloc(softs->devinfo_p, ap, cmdlen, in aac_tran_init_pkt()
5378 AACDB_PRINT(softs, CE_WARN, "Alloc scsi pkt failed"); in aac_tran_init_pkt()
5386 acp->dvp = &softs->containers[ap->a_target].dev; in aac_tran_init_pkt()
5387 acp->aac_cmd_fib = softs->aac_cmd_fib; in aac_tran_init_pkt()
5390 _NOTE(ASSUMING_PROTECTED(softs->nondasds)) in aac_tran_init_pkt()
5392 acp->dvp = &softs->nondasds[AAC_PD(ap->a_target)].dev; in aac_tran_init_pkt()
5393 acp->aac_cmd_fib = softs->aac_cmd_fib_scsi; in aac_tran_init_pkt()
5401 if (aac_cmd_dma_alloc(softs, acp, bp, flags, callback, arg) == AACOK) in aac_tran_init_pkt()
5441 aac_do_quiesce(struct aac_softstate *softs) in aac_do_quiesce() argument
5443 aac_hold_bus(softs, AAC_IOCMD_ASYNC); in aac_do_quiesce()
5444 if (softs->bus_ncmds[AAC_CMDQ_ASYNC]) { in aac_do_quiesce()
5445 aac_start_drain(softs); in aac_do_quiesce()
5447 if (cv_wait_sig(&softs->drain_cv, in aac_do_quiesce()
5448 &softs->io_lock) == 0) { in aac_do_quiesce()
5450 aac_stop_drain(softs); in aac_do_quiesce()
5451 aac_unhold_bus(softs, AAC_IOCMD_ASYNC); in aac_do_quiesce()
5452 aac_start_waiting_io(softs); in aac_do_quiesce()
5455 } while (softs->bus_ncmds[AAC_CMDQ_ASYNC]); in aac_do_quiesce()
5456 aac_stop_drain(softs); in aac_do_quiesce()
5459 softs->state |= AAC_STATE_QUIESCED; in aac_do_quiesce()
5466 struct aac_softstate *softs = AAC_DIP2SOFTS(dip); in aac_tran_quiesce() local
5469 DBCALLED(softs, 1); in aac_tran_quiesce()
5471 mutex_enter(&softs->io_lock); in aac_tran_quiesce()
5472 if (aac_do_quiesce(softs) == AACOK) in aac_tran_quiesce()
5476 mutex_exit(&softs->io_lock); in aac_tran_quiesce()
5481 aac_do_unquiesce(struct aac_softstate *softs) in aac_do_unquiesce() argument
5483 softs->state &= ~AAC_STATE_QUIESCED; in aac_do_unquiesce()
5484 aac_unhold_bus(softs, AAC_IOCMD_ASYNC); in aac_do_unquiesce()
5486 aac_start_waiting_io(softs); in aac_do_unquiesce()
5493 struct aac_softstate *softs = AAC_DIP2SOFTS(dip); in aac_tran_unquiesce() local
5496 DBCALLED(softs, 1); in aac_tran_unquiesce()
5498 mutex_enter(&softs->io_lock); in aac_tran_unquiesce()
5499 if (aac_do_unquiesce(softs) == AACOK) in aac_tran_unquiesce()
5503 mutex_exit(&softs->io_lock); in aac_tran_unquiesce()
5508 aac_hba_setup(struct aac_softstate *softs) in aac_hba_setup() argument
5513 hba_tran = scsi_hba_tran_alloc(softs->devinfo_p, SCSI_HBA_CANSLEEP); in aac_hba_setup()
5516 hba_tran->tran_hba_private = softs; in aac_hba_setup()
5532 rval = scsi_hba_attach_setup(softs->devinfo_p, &softs->buf_dma_attr, in aac_hba_setup()
5536 AACDB_PRINT(softs, CE_WARN, "aac_hba_setup failed"); in aac_hba_setup()
5540 softs->hba_tran = hba_tran; in aac_hba_setup()
5552 aac_cmd_fib_header(struct aac_softstate *softs, struct aac_cmd *acp, in aac_cmd_fib_header() argument
5577 ddi_put16(acc, &fibp->Header.SenderSize, softs->aac_max_fib_size); in aac_cmd_fib_header()
5587 aac_cmd_fib_rawio(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_fib_rawio() argument
5599 aac_cmd_fib_header(softs, acp, RawIo); in aac_cmd_fib_rawio()
5627 aac_cmd_fib_brw64(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_fib_brw64() argument
5639 aac_cmd_fib_header(softs, acp, ContainerCommand64); in aac_cmd_fib_brw64()
5667 aac_cmd_fib_brw(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_fib_brw() argument
5695 aac_cmd_fib_header(softs, acp, ContainerCommand); in aac_cmd_fib_brw()
5716 aac_cmd_fib_copy(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_fib_copy() argument
5730 aac_cmd_fib_sync(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_fib_sync() argument
5738 aac_cmd_fib_header(softs, acp, ContainerCommand); in aac_cmd_fib_sync()
5750 aac_cmd_fib_startstop(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_fib_startstop() argument
5759 aac_cmd_fib_header(softs, acp, ContainerCommand); in aac_cmd_fib_startstop()
5807 aac_cmd_fib_scsi32(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_fib_scsi32() argument
5819 aac_cmd_fib_header(softs, acp, ScsiPortCommand); in aac_cmd_fib_scsi32()
5834 aac_cmd_fib_scsi64(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_fib_scsi64() argument
5846 aac_cmd_fib_header(softs, acp, ScsiPortCommandU64); in aac_cmd_fib_scsi64()
5863 aac_cmd_slot_bind(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_slot_bind() argument
5867 if (slotp = aac_get_slot(softs)) { in aac_cmd_slot_bind()
5870 acp->aac_cmd_fib(softs, acp); in aac_cmd_slot_bind()
5879 aac_bind_io(struct aac_softstate *softs, struct aac_cmd *acp) in aac_bind_io() argument
5884 if (softs->bus_ncmds[q] < softs->bus_throttle[q]) { in aac_bind_io()
5889 return (aac_cmd_slot_bind(softs, acp)); in aac_bind_io()
5892 aac_set_throttle(softs, dvp, AAC_CMDQ_ASYNC, in aac_bind_io()
5896 return (aac_cmd_slot_bind(softs, acp)); in aac_bind_io()
5903 aac_sync_fib_slot_bind(struct aac_softstate *softs, struct aac_cmd *acp) in aac_sync_fib_slot_bind() argument
5907 while (softs->sync_ac.slotp) in aac_sync_fib_slot_bind()
5908 cv_wait(&softs->sync_fib_cv, &softs->io_lock); in aac_sync_fib_slot_bind()
5910 if (slotp = aac_get_slot(softs)) { in aac_sync_fib_slot_bind()
5921 aac_sync_fib_slot_release(struct aac_softstate *softs, struct aac_cmd *acp) in aac_sync_fib_slot_release() argument
5925 aac_release_slot(softs, acp->slotp); in aac_sync_fib_slot_release()
5929 cv_signal(&softs->sync_fib_cv); in aac_sync_fib_slot_release()
5933 aac_start_io(struct aac_softstate *softs, struct aac_cmd *acp) in aac_start_io() argument
5949 softs->bus_ncmds[q]++; in aac_start_io()
5950 aac_cmd_enqueue(&softs->q_busy, acp); in aac_start_io()
5952 AACDB_PRINT_FIB(softs, slotp); in aac_start_io()
5954 if (softs->flags & AAC_FLAGS_NEW_COMM) { in aac_start_io()
5955 rval = aac_send_command(softs, slotp); in aac_start_io()
5961 rval = aac_fib_enqueue(softs, AAC_ADAP_NORM_CMD_Q, in aac_start_io()
5966 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_UNAFFECTED); in aac_start_io()
5973 AACDB_PRINT(softs, CE_NOTE, "SCMD send failed"); in aac_start_io()
5976 aac_set_pkt_reason(softs, acp, CMD_INCOMPLETE, 0); in aac_start_io()
5978 aac_end_io(softs, acp); in aac_start_io()
5980 ddi_trigger_softintr(softs->softint_id); in aac_start_io()
5985 aac_start_waitq(struct aac_softstate *softs, struct aac_cmd_queue *q) in aac_start_waitq() argument
5992 if (aac_bind_io(softs, acp) == AACOK) { in aac_start_waitq()
5994 aac_start_io(softs, acp); in aac_start_waitq()
5996 if (softs->free_io_slot_head == NULL) in aac_start_waitq()
6002 aac_start_waiting_io(struct aac_softstate *softs) in aac_start_waiting_io() argument
6008 if (softs->q_wait[AAC_CMDQ_SYNC].q_head) in aac_start_waiting_io()
6009 aac_start_waitq(softs, &softs->q_wait[AAC_CMDQ_SYNC]); in aac_start_waiting_io()
6010 if (softs->q_wait[AAC_CMDQ_ASYNC].q_head) in aac_start_waiting_io()
6011 aac_start_waitq(softs, &softs->q_wait[AAC_CMDQ_ASYNC]); in aac_start_waiting_io()
6015 aac_drain_comp_q(struct aac_softstate *softs) in aac_drain_comp_q() argument
6022 mutex_enter(&softs->q_comp_mutex); in aac_drain_comp_q()
6023 acp = aac_cmd_dequeue(&softs->q_comp); in aac_drain_comp_q()
6024 mutex_exit(&softs->q_comp_mutex); in aac_drain_comp_q()
6037 softs->devinfo_p, in aac_drain_comp_q()
6043 if ((aac_check_acc_handle(softs-> \ in aac_drain_comp_q()
6045 (aac_check_acc_handle(softs-> \ in aac_drain_comp_q()
6047 ddi_fm_service_impact(softs->devinfo_p, in aac_drain_comp_q()
6049 ddi_fm_acc_err_clear(softs-> \ in aac_drain_comp_q()
6054 if (aac_check_dma_handle(softs-> \ in aac_drain_comp_q()
6056 ddi_fm_service_impact(softs->devinfo_p, in aac_drain_comp_q()
6070 aac_alloc_fib(struct aac_softstate *softs, struct aac_slot *slotp) in aac_alloc_fib() argument
6078 softs->devinfo_p, in aac_alloc_fib()
6079 &softs->addr_dma_attr, in aac_alloc_fib()
6083 AACDB_PRINT(softs, CE_WARN, in aac_alloc_fib()
6089 softs->aac_max_fib_size, in aac_alloc_fib()
6090 &softs->acc_attr, in aac_alloc_fib()
6097 AACDB_PRINT(softs, CE_WARN, in aac_alloc_fib()
6105 softs->aac_max_fib_size, in aac_alloc_fib()
6111 AACDB_PRINT(softs, CE_WARN, in aac_alloc_fib()
6118 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_LOST); in aac_alloc_fib()
6124 ddi_fm_service_impact(softs->devinfo_p, DDI_SERVICE_LOST); in aac_alloc_fib()
6155 aac_alloc_fibs(struct aac_softstate *softs) in aac_alloc_fibs() argument
6160 for (i = 0; i < softs->total_slots && in aac_alloc_fibs()
6161 softs->total_fibs < softs->total_slots; i++) { in aac_alloc_fibs()
6162 slotp = &(softs->io_slot[i]); in aac_alloc_fibs()
6165 if (aac_alloc_fib(softs, slotp) != AACOK) in aac_alloc_fibs()
6169 aac_release_slot(softs, slotp); in aac_alloc_fibs()
6170 softs->total_fibs++; in aac_alloc_fibs()
6175 aac_destroy_fibs(struct aac_softstate *softs) in aac_destroy_fibs() argument
6179 while ((slotp = softs->free_io_slot_head) != NULL) { in aac_destroy_fibs()
6181 softs->free_io_slot_head = slotp->next; in aac_destroy_fibs()
6183 ASSERT(slotp->index == (slotp - softs->io_slot)); in aac_destroy_fibs()
6184 softs->total_fibs--; in aac_destroy_fibs()
6186 ASSERT(softs->total_fibs == 0); in aac_destroy_fibs()
6190 aac_create_slots(struct aac_softstate *softs) in aac_create_slots() argument
6194 softs->total_slots = softs->aac_max_fibs; in aac_create_slots()
6195 softs->io_slot = kmem_zalloc(sizeof (struct aac_slot) * \ in aac_create_slots()
6196 softs->total_slots, KM_SLEEP); in aac_create_slots()
6197 if (softs->io_slot == NULL) { in aac_create_slots()
6198 AACDB_PRINT(softs, CE_WARN, "Cannot allocate slot"); in aac_create_slots()
6201 for (i = 0; i < softs->total_slots; i++) in aac_create_slots()
6202 softs->io_slot[i].index = i; in aac_create_slots()
6203 softs->free_io_slot_head = NULL; in aac_create_slots()
6204 softs->total_fibs = 0; in aac_create_slots()
6209 aac_destroy_slots(struct aac_softstate *softs) in aac_destroy_slots() argument
6211 ASSERT(softs->free_io_slot_head == NULL); in aac_destroy_slots()
6213 kmem_free(softs->io_slot, sizeof (struct aac_slot) * \ in aac_destroy_slots()
6214 softs->total_slots); in aac_destroy_slots()
6215 softs->io_slot = NULL; in aac_destroy_slots()
6216 softs->total_slots = 0; in aac_destroy_slots()
6220 aac_get_slot(struct aac_softstate *softs) in aac_get_slot() argument
6224 if ((slotp = softs->free_io_slot_head) != NULL) { in aac_get_slot()
6225 softs->free_io_slot_head = slotp->next; in aac_get_slot()
6232 aac_release_slot(struct aac_softstate *softs, struct aac_slot *slotp) in aac_release_slot() argument
6234 ASSERT((slotp->index >= 0) && (slotp->index < softs->total_slots)); in aac_release_slot()
6235 ASSERT(slotp == &softs->io_slot[slotp->index]); in aac_release_slot()
6238 slotp->next = softs->free_io_slot_head; in aac_release_slot()
6239 softs->free_io_slot_head = slotp; in aac_release_slot()
6243 aac_do_io(struct aac_softstate *softs, struct aac_cmd *acp) in aac_do_io() argument
6245 if (aac_bind_io(softs, acp) == AACOK) in aac_do_io()
6246 aac_start_io(softs, acp); in aac_do_io()
6248 aac_cmd_enqueue(&softs->q_wait[AAC_CMDQ(acp)], acp); in aac_do_io()
6257 if (aac_do_poll_io(softs, acp) == AACOK) in aac_do_io()
6260 if (aac_do_sync_io(softs, acp) == AACOK) in aac_do_io()
6267 aac_do_poll_io(struct aac_softstate *softs, struct aac_cmd *acp) in aac_do_poll_io() argument
6274 intr_handler = (softs->flags & AAC_FLAGS_NEW_COMM) ? in aac_do_poll_io()
6279 AAC_BUSYWAIT((intr_handler(softs) != AAC_DB_RESPONSE_READY), i); in aac_do_poll_io()
6281 aac_cmd_timeout(softs, acp); in aac_do_poll_io()
6284 ddi_trigger_softintr(softs->softint_id); in aac_do_poll_io()
6292 aac_do_sync_io(struct aac_softstate *softs, struct aac_cmd *acp) in aac_do_sync_io() argument
6294 ASSERT(softs && acp); in aac_do_sync_io()
6297 cv_wait(&softs->event, &softs->io_lock); in aac_do_sync_io()
6336 aac_save_aif(struct aac_softstate *softs, ddi_acc_handle_t acc, in aac_save_aif() argument
6351 mutex_enter(&softs->aifq_mutex); in aac_save_aif()
6354 fibp = &softs->aifq[softs->aifq_idx].d; in aac_save_aif()
6359 if (aac_check_acc_handle(softs->pci_mem_handle) != DDI_SUCCESS) { in aac_save_aif()
6360 ddi_fm_service_impact(softs->devinfo_p, in aac_save_aif()
6362 mutex_exit(&softs->aifq_mutex); in aac_save_aif()
6366 AACDB_PRINT_AIF(softs, (struct aac_aif_command *)&fibp->data[0]); in aac_save_aif()
6369 current = softs->aifq_idx; in aac_save_aif()
6374 softs->aifq_wrap = 1; in aac_save_aif()
6375 for (ctx_p = softs->fibctx_p; ctx_p; ctx_p = ctx_p->next) { in aac_save_aif()
6385 softs->aifq_idx = next; in aac_save_aif()
6388 cv_broadcast(&softs->aifq_cv); in aac_save_aif()
6389 mutex_exit(&softs->aifq_mutex); in aac_save_aif()
6392 aac_event_disp(softs, AAC_EVENT_AIF); in aac_save_aif()
6396 aac_return_aif_common(struct aac_softstate *softs, struct aac_fib_context *ctx, in aac_return_aif_common() argument
6402 if (current == softs->aifq_idx && in aac_return_aif_common()
6406 *fibpp = &softs->aifq[current].d; in aac_return_aif_common()
6414 aac_return_aif(struct aac_softstate *softs, struct aac_fib_context *ctx, in aac_return_aif() argument
6419 mutex_enter(&softs->aifq_mutex); in aac_return_aif()
6420 rval = aac_return_aif_common(softs, ctx, fibpp); in aac_return_aif()
6421 mutex_exit(&softs->aifq_mutex); in aac_return_aif()
6426 aac_return_aif_wait(struct aac_softstate *softs, struct aac_fib_context *ctx, in aac_return_aif_wait() argument
6431 mutex_enter(&softs->aifq_mutex); in aac_return_aif_wait()
6432 rval = aac_return_aif_common(softs, ctx, fibpp); in aac_return_aif_wait()
6434 AACDB_PRINT(softs, CE_NOTE, "Waiting for AIF"); in aac_return_aif_wait()
6435 rval = cv_wait_sig(&softs->aifq_cv, &softs->aifq_mutex); in aac_return_aif_wait()
6437 mutex_exit(&softs->aifq_mutex); in aac_return_aif_wait()
6452 aac_handle_aif(struct aac_softstate *softs, struct aac_aif_command *aif) in aac_handle_aif() argument
6454 ddi_acc_handle_t acc = softs->comm_space_acc_handle; in aac_handle_aif()
6471 if (AAC_DEV_IS_VALID(&softs->containers[cid].dev)) in aac_handle_aif()
6472 softs->devcfg_wait_on = AifEnConfigChange; in aac_handle_aif()
6475 if (softs->devcfg_wait_on == en_type) in aac_handle_aif()
6485 softs->devcfg_wait_on = AifEnConfigChange; in aac_handle_aif()
6488 if (!softs->devcfg_wait_on) in aac_handle_aif()
6489 softs->devcfg_wait_on = AifEnConfigChange; in aac_handle_aif()
6497 if (!(softs->flags & AAC_FLAGS_JBOD)) in aac_handle_aif()
6504 if (!(softs->flags & AAC_FLAGS_JBOD)) in aac_handle_aif()
6511 if (softs->devcfg_wait_on == en_type) in aac_handle_aif()
6526 softs->devcfg_wait_on = AifEnContainerChange; in aac_handle_aif()
6529 softs->devcfg_wait_on = AifEnContainerChange; in aac_handle_aif()
6535 softs->devcfg_wait_on = 0; in aac_handle_aif()
6536 (void) aac_probe_containers(softs); in aac_handle_aif()
6541 (void) aac_probe_jbod(softs, in aac_handle_aif()
6542 AAC_P2VTGT(softs, bus_id, tgt_id), event); in aac_handle_aif()
6552 aac_aif_event(struct aac_softstate *softs) in aac_aif_event() argument
6558 if (aac_return_aif(softs, &softs->aifctx, &fibp) != 0) in aac_aif_event()
6562 if (softs->aifctx.ctx_overrun) { in aac_aif_event()
6563 softs->aifctx.ctx_overrun = 0; in aac_aif_event()
6574 (void) aac_handle_aif(softs, aifp); in aac_aif_event()
6583 aac_cmd_timeout(struct aac_softstate *softs, struct aac_cmd *acp) in aac_cmd_timeout() argument
6587 AACDB_PRINT(softs, CE_WARN, "acp %p timed out", acp); in aac_cmd_timeout()
6588 AACDB_PRINT_FIB(softs, acp->slotp); in aac_cmd_timeout()
6600 switch (aac_do_reset(softs)) { in aac_cmd_timeout()
6602 aac_abort_iocmds(softs, AAC_IOCMD_OUTSTANDING, NULL, CMD_RESET); in aac_cmd_timeout()
6603 aac_start_waiting_io(softs); in aac_cmd_timeout()
6607 aac_abort_iocmds(softs, AAC_IOCMD_ALL, NULL, CMD_TIMEOUT); in aac_cmd_timeout()
6610 aac_start_waiting_io(softs); in aac_cmd_timeout()
6621 aac_sync_tick(struct aac_softstate *softs) in aac_sync_tick() argument
6626 mutex_enter(&softs->time_mutex); in aac_sync_tick()
6627 ASSERT(softs->time_sync <= softs->timebase); in aac_sync_tick()
6628 softs->time_sync = 0; in aac_sync_tick()
6629 mutex_exit(&softs->time_mutex); in aac_sync_tick()
6632 (void) aac_sync_fib_slot_bind(softs, &softs->sync_ac); in aac_sync_tick()
6633 acc = softs->sync_ac.slotp->fib_acc_handle; in aac_sync_tick()
6635 ddi_put32(acc, (void *)&softs->sync_ac.slotp->fibp->data[0], in aac_sync_tick()
6637 rval = aac_sync_fib(softs, SendHostTime, AAC_FIB_SIZEOF(uint32_t)); in aac_sync_tick()
6638 aac_sync_fib_slot_release(softs, &softs->sync_ac); in aac_sync_tick()
6640 mutex_enter(&softs->time_mutex); in aac_sync_tick()
6641 softs->time_sync = softs->timebase; in aac_sync_tick()
6644 softs->time_sync += aac_tick << 1; in aac_sync_tick()
6646 softs->time_sync += AAC_SYNC_TICK; in aac_sync_tick()
6647 mutex_exit(&softs->time_mutex); in aac_sync_tick()
6654 aac_daemon(struct aac_softstate *softs) in aac_daemon() argument
6660 mutex_enter(&softs->time_mutex); in aac_daemon()
6661 ASSERT(softs->time_out <= softs->timebase); in aac_daemon()
6662 softs->time_out = 0; in aac_daemon()
6663 softs_timebase = softs->timebase; in aac_daemon()
6664 mutex_exit(&softs->time_mutex); in aac_daemon()
6672 for (acp = softs->q_busy.q_head; acp; acp = acp->next) { in aac_daemon()
6686 aac_cmd_timeout(softs, acp); in aac_daemon()
6696 mutex_enter(&softs->time_mutex); in aac_daemon()
6697 softs->time_out = softs->timebase + aac_tick; in aac_daemon()
6698 mutex_exit(&softs->time_mutex); in aac_daemon()
6706 aac_event_thread(struct aac_softstate *softs) in aac_event_thread() argument
6710 DBCALLED(softs, 1); in aac_event_thread()
6712 mutex_enter(&softs->ev_lock); in aac_event_thread()
6716 if ((events = softs->events) == 0) { in aac_event_thread()
6717 cv_wait(&softs->event_disp_cv, &softs->ev_lock); in aac_event_thread()
6718 events = softs->events; in aac_event_thread()
6720 softs->events = 0; in aac_event_thread()
6721 mutex_exit(&softs->ev_lock); in aac_event_thread()
6723 mutex_enter(&softs->io_lock); in aac_event_thread()
6724 if ((softs->state & AAC_STATE_RUN) && in aac_event_thread()
6725 (softs->state & AAC_STATE_DEAD) == 0) { in aac_event_thread()
6727 aac_daemon(softs); in aac_event_thread()
6729 aac_sync_tick(softs); in aac_event_thread()
6731 aac_aif_event(softs); in aac_event_thread()
6735 mutex_exit(&softs->io_lock); in aac_event_thread()
6737 mutex_enter(&softs->ev_lock); in aac_event_thread()
6740 cv_signal(&softs->event_wait_cv); in aac_event_thread()
6741 mutex_exit(&softs->ev_lock); in aac_event_thread()
6752 struct aac_softstate *softs = arg; in aac_timer() local
6755 mutex_enter(&softs->time_mutex); in aac_timer()
6758 if (softs->timeout_id) { in aac_timer()
6759 softs->timeout_id = timeout(aac_timer, (void *)softs, in aac_timer()
6762 mutex_exit(&softs->time_mutex); in aac_timer()
6767 softs->timebase += aac_tick; in aac_timer()
6770 if (softs->time_out && softs->time_out <= softs->timebase) in aac_timer()
6772 if (softs->time_sync && softs->time_sync <= softs->timebase) in aac_timer()
6775 mutex_exit(&softs->time_mutex); in aac_timer()
6778 aac_event_disp(softs, events); in aac_timer()
6785 aac_event_disp(struct aac_softstate *softs, int events) in aac_event_disp() argument
6787 mutex_enter(&softs->ev_lock); in aac_event_disp()
6788 softs->events |= events; in aac_event_disp()
6789 cv_broadcast(&softs->event_disp_cv); in aac_event_disp()
6790 mutex_exit(&softs->ev_lock); in aac_event_disp()
6797 aac_rx_get_fwstatus(struct aac_softstate *softs) in aac_rx_get_fwstatus() argument
6799 return (PCI_MEM_GET32(softs, AAC_OMR0)); in aac_rx_get_fwstatus()
6803 aac_rx_get_mailbox(struct aac_softstate *softs, int mb) in aac_rx_get_mailbox() argument
6805 return (PCI_MEM_GET32(softs, AAC_RX_MAILBOX + mb * 4)); in aac_rx_get_mailbox()
6809 aac_rx_set_mailbox(struct aac_softstate *softs, uint32_t cmd, in aac_rx_set_mailbox() argument
6812 PCI_MEM_PUT32(softs, AAC_RX_MAILBOX, cmd); in aac_rx_set_mailbox()
6813 PCI_MEM_PUT32(softs, AAC_RX_MAILBOX + 4, arg0); in aac_rx_set_mailbox()
6814 PCI_MEM_PUT32(softs, AAC_RX_MAILBOX + 8, arg1); in aac_rx_set_mailbox()
6815 PCI_MEM_PUT32(softs, AAC_RX_MAILBOX + 12, arg2); in aac_rx_set_mailbox()
6816 PCI_MEM_PUT32(softs, AAC_RX_MAILBOX + 16, arg3); in aac_rx_set_mailbox()
6820 aac_rkt_get_fwstatus(struct aac_softstate *softs) in aac_rkt_get_fwstatus() argument
6822 return (PCI_MEM_GET32(softs, AAC_OMR0)); in aac_rkt_get_fwstatus()
6826 aac_rkt_get_mailbox(struct aac_softstate *softs, int mb) in aac_rkt_get_mailbox() argument
6828 return (PCI_MEM_GET32(softs, AAC_RKT_MAILBOX + mb *4)); in aac_rkt_get_mailbox()
6832 aac_rkt_set_mailbox(struct aac_softstate *softs, uint32_t cmd, in aac_rkt_set_mailbox() argument
6835 PCI_MEM_PUT32(softs, AAC_RKT_MAILBOX, cmd); in aac_rkt_set_mailbox()
6836 PCI_MEM_PUT32(softs, AAC_RKT_MAILBOX + 4, arg0); in aac_rkt_set_mailbox()
6837 PCI_MEM_PUT32(softs, AAC_RKT_MAILBOX + 8, arg1); in aac_rkt_set_mailbox()
6838 PCI_MEM_PUT32(softs, AAC_RKT_MAILBOX + 12, arg2); in aac_rkt_set_mailbox()
6839 PCI_MEM_PUT32(softs, AAC_RKT_MAILBOX + 16, arg3); in aac_rkt_set_mailbox()
6848 struct aac_softstate *softs; in aac_open() local
6867 softs = ddi_get_soft_state(aac_softstatep, instance); in aac_open()
6868 if (softs == NULL) in aac_open()
6903 struct aac_softstate *softs; in aac_ioctl() local
6920 softs = ddi_get_soft_state(aac_softstatep, instance); in aac_ioctl()
6921 return (aac_do_ioctl(softs, dev, cmd, arg, flag)); in aac_ioctl()
6946 aac_fm_init(struct aac_softstate *softs) in aac_fm_init() argument
6953 softs->fm_capabilities = ddi_getprop(DDI_DEV_T_ANY, softs->devinfo_p, in aac_fm_init()
6959 if (softs->fm_capabilities) { in aac_fm_init()
6961 softs->reg_attr.devacc_attr_access = DDI_FLAGERR_ACC; in aac_fm_init()
6962 softs->addr_dma_attr.dma_attr_flags |= DDI_DMA_FLAGERR; in aac_fm_init()
6963 softs->buf_dma_attr.dma_attr_flags |= DDI_DMA_FLAGERR; in aac_fm_init()
6970 ddi_fm_init(softs->devinfo_p, &softs->fm_capabilities, &fm_ibc); in aac_fm_init()
6976 if (DDI_FM_EREPORT_CAP(softs->fm_capabilities) || in aac_fm_init()
6977 DDI_FM_ERRCB_CAP(softs->fm_capabilities)) { in aac_fm_init()
6978 pci_ereport_setup(softs->devinfo_p); in aac_fm_init()
6984 if (DDI_FM_ERRCB_CAP(softs->fm_capabilities)) { in aac_fm_init()
6985 ddi_fm_handler_register(softs->devinfo_p, in aac_fm_init()
6986 aac_fm_error_cb, (void *) softs); in aac_fm_init()
6996 aac_fm_fini(struct aac_softstate *softs) in aac_fm_fini() argument
6999 if (softs->fm_capabilities) { in aac_fm_fini()
7003 if (DDI_FM_ERRCB_CAP(softs->fm_capabilities)) { in aac_fm_fini()
7004 ddi_fm_handler_unregister(softs->devinfo_p); in aac_fm_fini()
7010 if (DDI_FM_EREPORT_CAP(softs->fm_capabilities) || in aac_fm_fini()
7011 DDI_FM_ERRCB_CAP(softs->fm_capabilities)) { in aac_fm_fini()
7012 pci_ereport_teardown(softs->devinfo_p); in aac_fm_fini()
7016 ddi_fm_fini(softs->devinfo_p); in aac_fm_fini()
7019 softs->reg_attr.devacc_attr_access = DDI_DEFAULT_ACC; in aac_fm_fini()
7020 softs->addr_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR; in aac_fm_fini()
7021 softs->buf_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR; in aac_fm_fini()
7044 aac_fm_ereport(struct aac_softstate *softs, char *detail) in aac_fm_ereport() argument
7051 if (DDI_FM_EREPORT_CAP(softs->fm_capabilities)) { in aac_fm_ereport()
7052 ddi_fm_ereport_post(softs->devinfo_p, buf, ena, DDI_NOSLEEP, in aac_fm_ereport()
7103 aac_find_child(struct aac_softstate *softs, uint16_t tgt, uint8_t lun) in aac_find_child() argument
7111 struct aac_device *dvp = &softs->containers[tgt].dev; in aac_find_child()
7117 for (child = ddi_get_child(softs->devinfo_p); in aac_find_child()
7134 aac_config_child(struct aac_softstate *softs, struct scsi_device *sd, in aac_config_child() argument
7147 DBCALLED(softs, 2); in aac_config_child()
7152 AACDB_PRINT(softs, CE_WARN, in aac_config_child()
7157 childname = (softs->legacy && dtype == DTYPE_DIRECT) ? "sd" : nodename; in aac_config_child()
7160 rval = ndi_devi_alloc(softs->devinfo_p, childname, DEVI_SID_NODEID, in aac_config_child()
7165 AACDB_PRINT(softs, CE_WARN, "unable to create " in aac_config_child()
7172 AACDB_PRINT(softs, CE_WARN, "unable to create " in aac_config_child()
7180 AACDB_PRINT(softs, CE_WARN, "unable to create " in aac_config_child()
7188 AACDB_PRINT(softs, CE_WARN, "unable to online t%dL%d", in aac_config_child()
7204 aac_probe_lun(struct aac_softstate *softs, struct scsi_device *sd) in aac_probe_lun() argument
7209 DBCALLED(softs, 2); in aac_probe_lun()
7215 mutex_enter(&softs->io_lock); in aac_probe_lun()
7216 event = aac_probe_container(softs, tgt); in aac_probe_lun()
7217 mutex_exit(&softs->io_lock); in aac_probe_lun()
7236 AACDB_PRINT(softs, CE_NOTE, in aac_probe_lun()
7244 if (!(softs->flags & AAC_FLAGS_NONDASD)) in aac_probe_lun()
7246 AACDB_PRINT(softs, CE_NOTE, "non-DASD %d found", tgt); in aac_probe_lun()
7249 if (!(softs->flags & AAC_FLAGS_JBOD) || qual != 0) in aac_probe_lun()
7251 AACDB_PRINT(softs, CE_NOTE, "JBOD DASD %d found", tgt); in aac_probe_lun()
7254 mutex_enter(&softs->io_lock); in aac_probe_lun()
7255 softs->nondasds[AAC_PD(tgt)].dev.flags |= AAC_DFLAG_VALID; in aac_probe_lun()
7256 mutex_exit(&softs->io_lock); in aac_probe_lun()
7262 aac_config_lun(struct aac_softstate *softs, uint16_t tgt, uint8_t lun, in aac_config_lun() argument
7269 DBCALLED(softs, 2); in aac_config_lun()
7271 if ((child = aac_find_child(softs, tgt, lun)) != NULL) { in aac_config_lun()
7278 sd.sd_address.a_hba_tran = softs->hba_tran; in aac_config_lun()
7281 if ((rval = aac_probe_lun(softs, &sd)) == NDI_SUCCESS) in aac_config_lun()
7282 rval = aac_config_child(softs, &sd, ldip); in aac_config_lun()
7292 aac_config_tgt(struct aac_softstate *softs, int tgt) in aac_config_tgt() argument
7302 ap.a_hba_tran = softs->hba_tran; in aac_config_tgt()
7374 AACDB_PRINT(softs, CE_WARN, in aac_config_tgt()
7378 if (aac_config_lun(softs, tgt, lun, &ldip) == in aac_config_tgt()
7388 if (aac_config_lun(softs, tgt, 0, &ldip) == NDI_SUCCESS) in aac_config_tgt()
7396 aac_devcfg(struct aac_softstate *softs, int tgt, int en) in aac_devcfg() argument
7400 mutex_enter(&softs->io_lock); in aac_devcfg()
7401 dvp = AAC_DEV(softs, tgt); in aac_devcfg()
7406 mutex_exit(&softs->io_lock); in aac_devcfg()
7413 struct aac_softstate *softs; in aac_tran_bus_config() local
7417 if ((softs = ddi_get_soft_state(aac_softstatep, in aac_tran_bus_config()
7422 mutex_enter(&softs->io_lock); in aac_tran_bus_config()
7423 if (softs->state & AAC_STATE_QUIESCED) { in aac_tran_bus_config()
7424 AACDB_PRINT(softs, CE_NOTE, in aac_tran_bus_config()
7426 mutex_exit(&softs->io_lock); in aac_tran_bus_config()
7429 mutex_exit(&softs->io_lock); in aac_tran_bus_config()
7431 DBCALLED(softs, 1); in aac_tran_bus_config()
7444 if (tgt >= AAC_MAX_DEV(softs)) { in aac_tran_bus_config()
7450 AAC_DEVCFG_BEGIN(softs, tgt); in aac_tran_bus_config()
7451 rval = aac_config_lun(softs, tgt, lun, childp); in aac_tran_bus_config()
7452 AAC_DEVCFG_END(softs, tgt); in aac_tran_bus_config()
7462 AAC_DEVCFG_BEGIN(softs, tgt); in aac_tran_bus_config()
7463 (void) aac_config_lun(softs, tgt, 0, NULL); in aac_tran_bus_config()
7464 AAC_DEVCFG_END(softs, tgt); in aac_tran_bus_config()
7470 for (bus = 0; bus < softs->bus_max; bus++) { in aac_tran_bus_config()
7471 AACDB_PRINT(softs, CE_NOTE, "bus %d:", bus); in aac_tran_bus_config()
7472 for (tgt = 0; tgt < softs->tgt_max; tgt++, index++) { in aac_tran_bus_config()
7473 AAC_DEVCFG_BEGIN(softs, index); in aac_tran_bus_config()
7474 if (aac_config_tgt(softs, index)) in aac_tran_bus_config()
7476 AAC_DEVCFG_END(softs, index); in aac_tran_bus_config()
7479 AACDB_PRINT(softs, CE_CONT, in aac_tran_bus_config()
7494 aac_handle_dr(struct aac_softstate *softs, int tgt, int lun, int event) in aac_handle_dr() argument
7501 DBCALLED(softs, 1); in aac_handle_dr()
7504 dvp = AAC_DEV(softs, tgt); in aac_handle_dr()
7507 if (!(softs->state & AAC_STATE_RUN)) in aac_handle_dr()
7509 mutex_exit(&softs->io_lock); in aac_handle_dr()
7516 ndi_devi_enter(softs->devinfo_p, &circ1); in aac_handle_dr()
7517 (void) aac_config_lun(softs, tgt, 0, NULL); in aac_handle_dr()
7518 AACDB_PRINT(softs, CE_NOTE, "c%dt%dL%d onlined", in aac_handle_dr()
7519 softs->instance, tgt, lun); in aac_handle_dr()
7520 ndi_devi_exit(softs->devinfo_p, circ1); in aac_handle_dr()
7524 mutex_enter(&softs->io_lock); in aac_handle_dr()
7525 (void) aac_do_reset(softs); in aac_handle_dr()
7526 mutex_exit(&softs->io_lock); in aac_handle_dr()
7529 AACDB_PRINT(softs, CE_NOTE, "c%dt%dL%d offlined", in aac_handle_dr()
7530 softs->instance, tgt, lun); in aac_handle_dr()
7535 mutex_enter(&softs->io_lock); in aac_handle_dr()
7991 aac_get_fw_debug_buffer(struct aac_softstate *softs) in aac_get_fw_debug_buffer() argument
7993 if (aac_sync_mbcommand(softs, AAC_MONKER_GETDRVPROP, in aac_get_fw_debug_buffer()
7995 uint32_t mondrv_buf_paddrl = AAC_MAILBOX_GET(softs, 1); in aac_get_fw_debug_buffer()
7996 uint32_t mondrv_buf_paddrh = AAC_MAILBOX_GET(softs, 2); in aac_get_fw_debug_buffer()
7997 uint32_t mondrv_buf_size = AAC_MAILBOX_GET(softs, 3); in aac_get_fw_debug_buffer()
7998 uint32_t mondrv_hdr_size = AAC_MAILBOX_GET(softs, 4); in aac_get_fw_debug_buffer()
8002 softs->pci_mem_base_paddr; in aac_get_fw_debug_buffer()
8009 (offset + mondrv_buf_size < softs->map_size)) { in aac_get_fw_debug_buffer()
8011 softs->debug_buf_offset = offset; in aac_get_fw_debug_buffer()
8012 softs->debug_header_size = mondrv_hdr_size; in aac_get_fw_debug_buffer()
8013 softs->debug_buf_size = mondrv_buf_size; in aac_get_fw_debug_buffer()
8014 softs->debug_fw_flags = 0; in aac_get_fw_debug_buffer()
8015 softs->debug_flags &= ~AACDB_FLAGS_FW_PRINT; in aac_get_fw_debug_buffer()
8026 aac_dbflag_on(struct aac_softstate *softs, int flag) in aac_dbflag_on() argument
8028 int debug_flags = softs ? softs->debug_flags : aac_debug_flags; in aac_dbflag_on()
8035 aac_cmn_err(struct aac_softstate *softs, uint_t lev, char sl, int noheader) in aac_cmn_err() argument
8048 softs->vendor_name, softs->instance, in aac_cmn_err()
8052 softs->vendor_name, softs->instance, in aac_cmn_err()
8065 aac_printf(struct aac_softstate *softs, uint_t lev, const char *fmt, ...) in aac_printf() argument
8083 if (softs) { in aac_printf()
8084 if ((softs->debug_flags & AACDB_FLAGS_FW_PRINT) && in aac_printf()
8086 (softs->debug_buf_size)) { in aac_printf()
8091 if (count > softs->debug_buf_size) in aac_printf()
8092 count = (uint16_t)softs->debug_buf_size; in aac_printf()
8099 if (!PCI_MEM_GET32(softs, in aac_printf()
8100 softs->debug_buf_offset + \ in aac_printf()
8113 if (!PCI_MEM_GET32(softs, softs->debug_buf_offset + \ in aac_printf()
8115 PCI_MEM_REP_PUT8(softs, in aac_printf()
8116 softs->debug_buf_offset + \ in aac_printf()
8117 softs->debug_header_size, in aac_printf()
8119 PCI_MEM_PUT32(softs, in aac_printf()
8120 softs->debug_buf_offset + \ in aac_printf()
8122 softs->debug_fw_flags); in aac_printf()
8123 PCI_MEM_PUT32(softs, in aac_printf()
8124 softs->debug_buf_offset + \ in aac_printf()
8128 softs->debug_flags &= ~AACDB_FLAGS_FW_PRINT; in aac_printf()
8136 if (softs->debug_flags & AACDB_FLAGS_KERNEL_PRINT) in aac_printf()
8137 aac_cmn_err(softs, lev, sl, in aac_printf()
8138 (softs->debug_flags & AACDB_FLAGS_NO_HEADERS)); in aac_printf()
8142 aac_cmn_err(softs, lev, sl, 1); in aac_printf()
8163 aac_print_scmd(struct aac_softstate *softs, struct aac_cmd *acp) in aac_print_scmd() argument
8168 int ctl = ddi_get_instance(softs->devinfo_p); in aac_print_scmd()
8184 aac_printf(softs, CE_NOTE, in aac_print_scmd()
8193 aac_printf(softs, CE_NOTE, in aac_print_scmd()
8201 aac_printf(softs, CE_NOTE, in aac_print_scmd()
8209 aac_printf(softs, CE_NOTE, in aac_print_scmd()
8218 aac_printf(softs, CE_NOTE, in aac_print_scmd()
8225 aac_printf(softs, CE_NOTE, "SCMD> %s --> c%dt%dL%d %s", in aac_print_scmd()
8231 aac_print_fib(struct aac_softstate *softs, struct aac_slot *slotp) in aac_print_fib() argument
8243 if (!(softs->debug_fib_flags & acp->fib_flags)) in aac_print_fib()
8254 if (!(softs->debug_fib_flags & AACDB_FLAGS_FIB_SYNC)) in aac_print_fib()
8265 if (softs->debug_fib_flags & AACDB_FLAGS_FIB_HEADER) { in aac_print_fib()
8266 aac_printf(softs, CE_NOTE, "FIB> from %s", caller); in aac_print_fib()
8267 aac_printf(softs, CE_NOTE, " XferState %d", in aac_print_fib()
8269 aac_printf(softs, CE_NOTE, " Command %d", in aac_print_fib()
8271 aac_printf(softs, CE_NOTE, " StructType %d", in aac_print_fib()
8273 aac_printf(softs, CE_NOTE, " Flags 0x%x", in aac_print_fib()
8275 aac_printf(softs, CE_NOTE, " Size %d", in aac_print_fib()
8277 aac_printf(softs, CE_NOTE, " SenderSize %d", in aac_print_fib()
8279 aac_printf(softs, CE_NOTE, " SenderAddr 0x%x", in aac_print_fib()
8281 aac_printf(softs, CE_NOTE, " RcvrAddr 0x%x", in aac_print_fib()
8283 aac_printf(softs, CE_NOTE, " SenderData 0x%x", in aac_print_fib()
8311 aac_printf(softs, CE_NOTE, "FIB> %s (0x%x, 0x%x, 0x%x)", in aac_print_fib()
8337 aac_printf(softs, CE_NOTE, in aac_print_fib()
8343 aac_printf(softs, CE_NOTE, in aac_print_fib()
8369 aac_printf(softs, CE_NOTE, in aac_print_fib()
8377 aac_printf(softs, CE_NOTE, in aac_print_fib()
8392 aac_printf(softs, CE_NOTE, in aac_print_fib()
8400 aac_printf(softs, CE_NOTE, " %d: 0x%08x.%08x/%d", i, in aac_print_fib()
8425 aac_printf(softs, CE_NOTE, "FIB> %s, sz=%d", in aac_print_fib()
8428 aac_printf(softs, CE_NOTE, "FIB> %s, sz=%d", in aac_print_fib()
8431 aac_printf(softs, CE_NOTE, "FIB> %s: Unknown(0x%x), sz=%d", in aac_print_fib()
8434 aac_printf(softs, CE_NOTE, "FIB> Unknown(0x%x), sz=%d", in aac_print_fib()
8439 aac_print_aif(struct aac_softstate *softs, struct aac_aif_command *aif) in aac_print_aif() argument
8454 aac_printf(softs, CE_NOTE, "AIF! %s", str); in aac_print_aif()
8456 aac_printf(softs, CE_NOTE, "AIF! Unknown(0x%x)", in aac_print_aif()
8477 aac_printf(softs, CE_NOTE, in aac_print_aif()
8485 aac_printf(softs, CE_NOTE, "AIF! APIReport (%d)", in aac_print_aif()
8490 aac_printf(softs, CE_NOTE, "AIF! DriverNotify (%d)", in aac_print_aif()
8495 aac_printf(softs, CE_NOTE, "AIF! AIF %d (%d)", in aac_print_aif()