Lines Matching defs:socalp
161 static void socal_disable(socal_state_t *socalp);
162 static void socal_init_transport_interface(socal_state_t *socalp);
163 static int socal_cqalloc_init(socal_state_t *socalp, uint32_t index);
164 static void socal_cqinit(socal_state_t *socalp, uint32_t index);
165 static int socal_start(socal_state_t *socalp);
166 static void socal_doreset(socal_state_t *socalp);
168 static int socal_diag_request(socal_state_t *socalp, uint32_t port,
170 static void socal_download_ucode(socal_state_t *socalp);
171 static void socal_init_cq_desc(socal_state_t *socalp);
172 static void socal_init_wwn(socal_state_t *socalp);
173 static void socal_enable(socal_state_t *socalp);
174 static int socal_establish_pool(socal_state_t *socalp, uint32_t poolid);
175 static int socal_add_pool_buffer(socal_state_t *socalp, uint32_t poolid);
176 static int socal_issue_adisc(socal_state_t *socalp, uint32_t port, uint32_t
178 static int socal_issue_lbf(socal_state_t *socalp, uint32_t port,
180 static int socal_issue_rls(socal_state_t *socalp, uint32_t port, uint32_t
189 static int socal_getmap(socal_state_t *socalp, uint32_t port, caddr_t arg,
193 static void socal_fix_harda(socal_state_t *socalp, int port);
473 socal_state_t *socalp;
493 if ((socalp = ddi_get_driver_private(dip)) == NULL)
496 if (!socalp->socal_shutdown) {
500 if (socal_start(socalp) != FCAL_SUCCESS) {
552 socalp = ddi_get_soft_state(socal_soft_state_p, instance);
553 if (socalp == (socal_state_t *)NULL) {
559 instance, socalp));
561 socalp->dip = dip;
563 porta = &socalp->port_state[0];
564 portb = &socalp->port_state[1];
568 (void) strcpy(socalp->socal_name, cptr);
574 porta->sp_board = socalp;
575 portb->sp_board = socalp;
608 socalp->socal_n_wwn.w.wwn_hi = s;
610 (caddr_t)&socalp->socal_n_wwn.w.wwn_lo,
612 socalp->socal_n_wwn.w.naa_id = NAA_ID_IEEE;
613 socalp->socal_n_wwn.w.nport_id = 0;
615 bcopy((caddr_t)wwn, (caddr_t)&socalp->socal_n_wwn, FC_WWN_SIZE);
622 (void) sprintf(&socalp->socal_stats.node_wwn[i << 1],
623 "%02x", socalp->socal_n_wwn.raw_wwn[i]);
626 instance, socalp->socal_stats.node_wwn));
628 bcopy((caddr_t)&socalp->socal_n_wwn, (caddr_t)&porta->sp_p_wwn,
630 bcopy((caddr_t)&socalp->socal_n_wwn, (caddr_t)&portb->sp_p_wwn,
638 (void) sprintf(&socalp->socal_stats.port_wwn[0][i << 1],
640 (void) sprintf(&socalp->socal_stats.port_wwn[1][i << 1],
644 instance, socalp->socal_stats.port_wwn[0]));
646 instance, socalp->socal_stats.port_wwn[1]));
650 socal_disp_err(socalp, CE_WARN, "attach.4011",
657 socal_disp_err(socalp, CE_WARN, "attach.4012",
671 if (ddi_map_regs(dip, 0, &socalp->socal_xrp, 0, 0)
673 socalp->socal_xrp = NULL;
674 socal_disp_err(socalp, CE_WARN, "attach.4020",
679 socalp->socal_rp = (socal_reg_t *)(socalp->socal_xrp +
683 if (ddi_map_regs(dip, 0, &socalp->socal_eeprom, 0, 0) !=
685 socalp->socal_eeprom = NULL;
686 socal_disp_err(socalp, CE_WARN, "attach.4010",
691 instance, socalp->socal_eeprom));
693 if (ddi_map_regs(dip, 1, &socalp->socal_xrp, 0, 0) !=
695 socalp->socal_xrp = NULL;
696 socal_disp_err(socalp, CE_WARN, "attach.4020",
701 instance, socalp->socal_xrp));
703 if (ddi_map_regs(dip, 2, (caddr_t *)&socalp->socal_rp, 0, 0) !=
705 socalp->socal_rp = NULL;
706 socal_disp_err(socalp, CE_WARN, "attach.4030",
711 instance, socalp->socal_rp));
716 if (ddi_peek32(dip, (int32_t *)&socalp->socal_rp->socal_csr.w,
718 socal_disp_err(socalp, CE_WARN, "attach.4040",
723 socal_disable(socalp);
726 if (ddi_poke32(dip, (int32_t *)(socalp->socal_xrp + SOCAL_XRAM_UCODE),
728 socal_disp_err(socalp, CE_WARN, "attach.4050",
734 if (ddi_peek32(dip, (int32_t *)(socalp->socal_xrp + SOCAL_XRAM_UCODE),
737 socal_disp_err(socalp, CE_WARN, "attach.4051",
744 socalp->socal_rp->socal_cr.w &=
746 socalp->socal_rp->socal_cr.w |= i<<24;
748 bcopy((caddr_t)socalp->socal_xrp, (caddr_t)cptr, 0x10000);
750 socalp->socal_rp->socal_cr.w &= ~SOCAL_CR_EXTERNAL_RAM_BANK_MASK;
756 socal_disp_err(socalp, CE_WARN, "attach.4052",
762 socalp->xram_reqp = (soc_cq_t *)(socalp->socal_xrp +
764 socalp->xram_rspp = (soc_cq_t *)(socalp->socal_xrp +
767 if ((socalp->socal_ksp = kstat_create("socal", instance, "statistics",
770 socal_disp_err(socalp, CE_WARN, "attach.4053",
773 socalp->socal_stats.version = 2;
774 (void) sprintf(socalp->socal_stats.drvr_name,
776 socalp->socal_stats.pstats[0].port = 0;
777 socalp->socal_stats.pstats[1].port = 1;
778 socalp->socal_ksp->ks_data = (void *)&socalp->socal_stats;
779 kstat_install(socalp->socal_ksp);
787 &socalp->iblkc,
788 &socalp->idevc,
790 (caddr_t)socalp) != DDI_SUCCESS) {
791 socal_disp_err(socalp, CE_WARN, "attach.4060",
796 ddi_set_driver_private(dip, socalp);
799 mutex_init(&socalp->k_imr_mtx, NULL, MUTEX_DRIVER,
800 (void *)socalp->iblkc);
802 mutex_init(&socalp->board_mtx, NULL, MUTEX_DRIVER,
803 (void *)socalp->iblkc);
804 mutex_init(&socalp->ioctl_mtx, NULL, MUTEX_DRIVER,
805 (void *)socalp->iblkc);
808 mutex_init(&socalp->abort_mtx, NULL, MUTEX_DRIVER,
809 (void *)socalp->iblkc);
811 cv_init(&socalp->board_cv, NULL, CV_DRIVER, NULL);
817 mutex_init(&porta->sp_mtx, NULL, MUTEX_DRIVER, socalp->iblkc);
819 mutex_init(&portb->sp_mtx, NULL, MUTEX_DRIVER, socalp->iblkc);
825 socal_wcopy((uint_t *)socalp->socal_xrp + SOCAL_XRAM_SERV_PARAMS,
826 (uint_t *)socalp->socal_service_params, SOCAL_SVC_LENGTH);
831 socal_init_transport_interface(socalp);
839 if (socal_cqalloc_init(socalp, i) != FCAL_SUCCESS) {
848 burstsize = ddi_dma_burstsizes(socalp->request[0].skc_dhandle);
855 socalp->socal_cfg = (socalp->socal_cfg & ~SOCAL_CR_SBUS_BURST_SIZE_MASK)
859 if (ddi_dma_set_sbus64(socalp->request[0].skc_dhandle,
864 socalp->socal_cfg |= SOCAL_CR_SBUS_ENHANCED;
865 burstsize = ddi_dma_burstsizes(socalp->request[0].
875 socalp->socal_cfg = (socalp->socal_cfg &
881 ddi_remove_intr(dip, 0, socalp->iblkc);
882 socalp->iblkc = (void *)NULL;
888 &socalp->iblkc,
889 &socalp->idevc,
891 (caddr_t)socalp) != DDI_SUCCESS) {
892 socal_disp_err(socalp, CE_WARN, "attach.4060",
898 instance, socalp->socal_cfg));
907 if (socal_start(socalp) != FCAL_SUCCESS)
921 socal_disable(socalp);
933 socal_state_t *socalp;
942 if ((socalp = ddi_get_driver_private(dip)) == NULL)
949 if (socalp->port_state[i].sp_status & PORT_TARGET_MODE)
954 socal_force_reset((void *)socalp, 0, DONT_RESET_PORT);
976 socal_state_t *socalp;
981 if ((socalp = ddi_get_soft_state(socal_soft_state_p, instance)) == 0) {
989 mutex_enter(&socalp->board_mtx);
990 if (socalp->socal_busy > 0) {
991 mutex_exit(&socalp->board_mtx);
995 socalp->socal_busy = -1;
996 mutex_exit(&socalp->board_mtx);
999 mutex_enter(&socalp->k_imr_mtx);
1000 socal_disable(socalp);
1001 mutex_exit(&socalp->k_imr_mtx);
1004 if (socalp->iblkc != (void *)NULL) {
1005 ddi_remove_intr(dip, (uint_t)0, socalp->iblkc);
1012 portp = &socalp->port_state[i];
1032 mutex_destroy(&socalp->request[i].skc_mtx);
1033 mutex_destroy(&socalp->response[i].skc_mtx);
1034 cv_destroy(&socalp->request[i].skc_cv);
1035 cv_destroy(&socalp->response[i].skc_cv);
1037 if (socalp->request[i].skc_dhandle) {
1038 (void) ddi_dma_unbind_handle(socalp->
1040 ddi_dma_free_handle(&socalp->request[i].skc_dhandle);
1042 if (socalp->request[i].skc_cq_raw) {
1043 ddi_dma_mem_free(&socalp->request[i].skc_acchandle);
1044 socalp->request[i].skc_cq_raw = NULL;
1045 socalp->request[i].skc_cq = NULL;
1047 if (socalp->response[i].skc_dhandle) {
1048 (void) ddi_dma_unbind_handle(socalp->
1050 ddi_dma_free_handle(&socalp->response[i].skc_dhandle);
1052 if (socalp->response[i].skc_cq_raw) {
1053 ddi_dma_mem_free(&socalp->response[i].skc_acchandle);
1054 socalp->response[i].skc_cq_raw = NULL;
1055 socalp->response[i].skc_cq = NULL;
1057 if (socalp->request[i].deferred_intr_timeoutid) {
1058 (void) untimeout(socalp->
1061 if (socalp->response[i].deferred_intr_timeoutid) {
1062 (void) untimeout(socalp->
1067 mutex_destroy(&socalp->abort_mtx);
1068 mutex_destroy(&socalp->board_mtx);
1069 mutex_destroy(&socalp->ioctl_mtx);
1070 cv_destroy(&socalp->board_cv);
1075 if (socalp->pool_dhandle) {
1076 (void) ddi_dma_unbind_handle(socalp->pool_dhandle);
1077 ddi_dma_free_handle(&socalp->pool_dhandle);
1079 if (socalp->pool) {
1080 ddi_dma_mem_free(&socalp->pool_acchandle);
1085 if (socalp->socal_eeprom != NULL) {
1086 ddi_unmap_regs(dip, 0, &socalp->socal_eeprom, 0, 0);
1090 if (socalp->socal_xrp != NULL) {
1091 ddi_unmap_regs(dip, 1, &socalp->socal_xrp, 0, 0);
1095 if (socalp->socal_rp != NULL) {
1096 ddi_unmap_regs(dip, 2, (caddr_t *)&socalp->socal_rp, 0, 0);
1099 if (socalp->socal_ksp != NULL)
1100 kstat_delete(socalp->socal_ksp);
1102 mutex_destroy(&socalp->k_imr_mtx);
1137 socal_state_t *socalp;
1139 if ((socalp = ddi_get_driver_private(dip)) == NULL)
1152 mutex_enter(&socalp->board_mtx);
1153 mutex_enter(&socalp->port_state[port].sp_mtx);
1154 if (socalp->port_state[port].sp_status &
1156 mutex_exit(&socalp->port_state[port].sp_mtx);
1157 mutex_exit(&socalp->board_mtx);
1160 socalp->socal_busy++;
1161 socalp->port_state[port].sp_status |= PORT_CHILD_INIT;
1162 mutex_exit(&socalp->port_state[port].sp_mtx);
1163 mutex_exit(&socalp->board_mtx);
1165 socalp->port_state[port].sp_transport);
1173 socal_state_t *socalp;
1175 socalp = ddi_get_driver_private(dip);
1189 mutex_enter(&socalp->board_mtx);
1190 mutex_enter(&socalp->port_state[port].sp_mtx);
1191 socalp->socal_busy--;
1192 socalp->port_state[port].sp_status &= ~PORT_CHILD_INIT;
1193 mutex_exit(&socalp->port_state[port].sp_mtx);
1194 mutex_exit(&socalp->board_mtx);
1263 socal_state_t *socalp;
1269 socalp = ddi_get_soft_state(socal_soft_state_p, instance);
1270 if (socalp)
1271 *result = socalp->dip;
1292 socal_state_t *socalp =
1297 if (socalp == NULL)
1301 port_statep = &socalp->port_state[port];
1316 socal_state_t *socalp =
1322 port_statep = &socalp->port_state[port];
1338 socal_state_t *socalp =
1367 if (socalp == NULL)
1407 dip = socalp->dip;
1422 if (socalp->socal_eeprom) {
1425 &socalp->request[i].skc_mtx);
1427 &socalp->response[i].skc_mtx);
1429 i = socalp->socal_rp->socal_cr.w;
1430 socalp->socal_rp->socal_cr.w &=
1432 socalp->socal_rp->socal_cr.w |= 3 << 16;
1435 bcopy((caddr_t)socalp->socal_eeprom + (unsigned)
1437 socalp->socal_rp->socal_cr.w = i;
1439 mutex_exit(&socalp->request[i].skc_mtx);
1441 &socalp->response[i].skc_mtx);
1473 mutex_enter(&socalp->k_imr_mtx);
1474 socal_disable(socalp);
1475 mutex_exit(&socalp->k_imr_mtx);
1480 (void) socal_force_reset((void *)socalp, 0,
1485 mutex_enter(&socalp->request[i].skc_mtx);
1486 mutex_enter(&socalp->response[i].skc_mtx);
1490 socalp->socal_rp->socal_cr.w &=
1492 socalp->socal_rp->socal_cr.w |= i<<24;
1493 (void) copyout((caddr_t)socalp->socal_xrp,
1496 socalp->socal_rp->socal_cr.w &=
1499 mutex_exit(&socalp->request[i].skc_mtx);
1500 mutex_exit(&socalp->response[i].skc_mtx);
1510 mutex_enter(&socalp->ioctl_mtx);
1511 if (socal_getmap(socalp, port, (caddr_t)arg, 0, 0) ==
1514 mutex_exit(&socalp->ioctl_mtx);
1517 mutex_enter(&socalp->ioctl_mtx);
1518 retval = socal_bypass_dev((void *)socalp, port, arg);
1519 mutex_exit(&socalp->ioctl_mtx);
1522 mutex_enter(&socalp->ioctl_mtx);
1523 retval = socal_force_lip((void *)socalp, port, 0,
1525 mutex_exit(&socalp->ioctl_mtx);
1528 mutex_enter(&socalp->ioctl_mtx);
1529 retval = socal_force_offline((void *)socalp, port, 0);
1530 mutex_exit(&socalp->ioctl_mtx);
1546 mutex_enter(&socalp->ioctl_mtx);
1547 retval = socal_issue_adisc(socalp, port,
1550 mutex_exit(&socalp->ioctl_mtx);
1581 mutex_enter(&socalp->ioctl_mtx);
1582 retval = socal_issue_rls(socalp, port, dest,
1584 mutex_exit(&socalp->ioctl_mtx);
1603 mutex_enter(&socalp->ioctl_mtx);
1605 port_statep = &socalp->port_state[port];
1610 mutex_exit(&socalp->ioctl_mtx);
1616 retval = socal_diag_request((void *)socalp, port, &r,
1618 mutex_exit(&socalp->ioctl_mtx);
1625 mutex_enter(&socalp->ioctl_mtx);
1626 port_statep = &socalp->port_state[port];
1630 mutex_exit(&socalp->ioctl_mtx);
1634 retval = socal_diag_request((void *)socalp, port, &r,
1636 mutex_exit(&socalp->ioctl_mtx);
1642 mutex_enter(&socalp->ioctl_mtx);
1643 port_statep = &socalp->port_state[port];
1649 mutex_exit(&socalp->ioctl_mtx);
1660 retval = socal_diag_request((void *)socalp, port, &r,
1662 mutex_exit(&socalp->ioctl_mtx);
1669 mutex_enter(&socalp->ioctl_mtx);
1670 retval = socal_diag_request((void *)socalp, port, &r,
1672 mutex_exit(&socalp->ioctl_mtx);
1678 mutex_enter(&socalp->ioctl_mtx);
1679 retval = socal_diag_request((void *)socalp, port, &r,
1681 mutex_exit(&socalp->ioctl_mtx);
1687 mutex_enter(&socalp->ioctl_mtx);
1688 retval = socal_diag_request((void *)socalp, port, &r,
1690 mutex_exit(&socalp->ioctl_mtx);
1696 mutex_enter(&socalp->ioctl_mtx);
1697 retval = socal_diag_request((void *)socalp, port, &r,
1699 mutex_exit(&socalp->ioctl_mtx);
1705 mutex_enter(&socalp->ioctl_mtx);
1706 retval = socal_diag_request((void *)socalp, port, &r,
1708 mutex_exit(&socalp->ioctl_mtx);
1714 mutex_enter(&socalp->ioctl_mtx);
1715 retval = socal_diag_request((void *)socalp, port, &r,
1717 mutex_exit(&socalp->ioctl_mtx);
1723 mutex_enter(&socalp->ioctl_mtx);
1724 retval = socal_diag_request((void *)socalp, port, &r,
1726 mutex_exit(&socalp->ioctl_mtx);
1735 mutex_enter(&socalp->ioctl_mtx);
1736 retval = socal_diag_request((void *)socalp, port, &r,
1738 mutex_exit(&socalp->ioctl_mtx);
1765 mutex_enter(&socalp->ioctl_mtx);
1766 retval = socal_issue_lbf(socalp, port, flb_pl,
1768 mutex_exit(&socalp->ioctl_mtx);
1817 socal_disable(socal_state_t *socalp)
1823 if (!socalp->socal_rp)
1826 socalp->socal_rp->socal_imr = socalp->socal_k_imr = 0;
1827 socalp->socal_rp->socal_csr.w = SOCAL_CSR_SOFT_RESET;
1829 i = socalp->socal_rp->socal_csr.w;
1845 socal_init_transport_interface(socal_state_t *socalp)
1851 xport = socalp->port_state[i].sp_transport;
1853 (void *)(socalp->iblkc));
1857 xport->fcal_handle = (void *)socalp;
1859 xport->fcal_iblock = socalp->iblkc;
1862 xport->fcal_loginparms = socalp->socal_service_params;
1863 bcopy((caddr_t)&socalp->socal_n_wwn,
1865 bcopy((caddr_t)&socalp->port_state[i].sp_p_wwn,
1883 socal_cqalloc_init(socal_state_t *socalp, uint32_t index)
1895 mutex_init(&socalp->request[index].skc_mtx, NULL, MUTEX_DRIVER,
1896 (void *)socalp->iblkc);
1897 mutex_init(&socalp->response[index].skc_mtx, NULL, MUTEX_DRIVER,
1898 (void *)socalp->iblkc);
1899 cv_init(&socalp->request[index].skc_cv, NULL, CV_DRIVER, NULL);
1900 cv_init(&socalp->response[index].skc_cv, NULL, CV_DRIVER, NULL);
1905 cqp = &socalp->request[index];
1907 if (ddi_dma_alloc_handle(socalp->dip, &socal_dma_attr,
1910 socal_disp_err(socalp, CE_WARN, "driver.4020",
1920 socal_disp_err(socalp, CE_WARN, "driver.4030",
1926 socal_disp_err(socalp, CE_WARN, "driver.4035",
1938 socal_disp_err(socalp, CE_WARN, "driver.4040",
1945 socal_disp_err(socalp, CE_WARN, "driver.4045",
1951 socalp->request[index].skc_cq_raw = NULL;
1952 socalp->request[index].skc_cq = (cqe_t *)NULL;
1953 socalp->request[index].skc_dhandle = 0;
1959 cqp = &socalp->response[index];
1961 if (ddi_dma_alloc_handle(socalp->dip, &socal_dma_attr,
1964 socal_disp_err(socalp, CE_WARN, "driver.4050",
1974 socal_disp_err(socalp, CE_WARN, "driver.4060",
1980 socal_disp_err(socalp, CE_WARN, "driver.4065",
1993 socal_disp_err(socalp, CE_WARN, "driver.4070",
2000 socal_disp_err(socalp, CE_WARN, "driver.4075",
2006 socalp->response[index].skc_cq_raw = NULL;
2007 socalp->response[index].skc_cq = (cqe_t *)NULL;
2008 socalp->response[index].skc_dhandle = 0;
2014 socal_cqinit(socalp, index);
2018 if (socalp->request[index].skc_dhandle) {
2020 (void) ddi_dma_unbind_handle(socalp->
2022 ddi_dma_free_handle(&socalp->request[index].skc_dhandle);
2024 if (socalp->request[index].skc_cq_raw)
2025 ddi_dma_mem_free(&socalp->request[index].skc_acchandle);
2027 if (socalp->response[index].skc_dhandle) {
2029 (void) ddi_dma_unbind_handle(socalp->
2031 ddi_dma_free_handle(&socalp->response[index].skc_dhandle);
2033 if (socalp->response[index].skc_cq_raw)
2034 ddi_dma_mem_free(&socalp->response[index].skc_acchandle);
2036 socalp->request[index].skc_dhandle = NULL;
2037 socalp->response[index].skc_dhandle = NULL;
2038 socalp->request[index].skc_cq_raw = NULL;
2039 socalp->request[index].skc_cq = NULL;
2040 socalp->response[index].skc_cq_raw = NULL;
2041 socalp->response[index].skc_cq = NULL;
2042 mutex_destroy(&socalp->request[index].skc_mtx);
2043 mutex_destroy(&socalp->response[index].skc_mtx);
2044 cv_destroy(&socalp->request[index].skc_cv);
2045 cv_destroy(&socalp->response[index].skc_cv);
2055 socal_cqinit(socal_state_t *socalp, uint32_t index)
2057 socal_kcq_t *kcq_req = &socalp->request[index];
2058 socal_kcq_t *kcq_rsp = &socalp->response[index];
2073 kcq_req->skc_socalp = socalp;
2074 kcq_rsp->skc_socalp = socalp;
2077 (socalp->xram_reqp + (index * sizeof (struct cq))/8);
2079 (socalp->xram_rspp + (index * sizeof (struct cq))/8);
2092 socal_start(socal_state_t *socalp)
2096 if (!socalp)
2099 socal_download_ucode(socalp);
2100 socal_init_cq_desc(socalp);
2101 socal_init_wwn(socalp);
2103 mutex_enter(&socalp->port_state[0].sp_mtx);
2104 socalp->port_state[0].sp_status
2106 socalp->port_state[0].sp_status |= PORT_OFFLINE;
2107 mutex_exit(&socalp->port_state[0].sp_mtx);
2109 mutex_enter(&socalp->port_state[1].sp_mtx);
2110 socalp->port_state[1].sp_status
2112 socalp->port_state[1].sp_status |= PORT_OFFLINE;
2113 mutex_exit(&socalp->port_state[1].sp_mtx);
2115 socal_enable(socalp);
2117 if (socalp->port_state[0].sp_status & PORT_DISABLED)
2118 (void) socal_diag_request((void *)socalp, 0, &r,
2120 if (socalp->port_state[1].sp_status & PORT_DISABLED)
2121 (void) socal_diag_request((void *)socalp, 1, &r,
2124 mutex_enter(&socalp->k_imr_mtx);
2125 socalp->socal_shutdown = 0;
2126 mutex_exit(&socalp->k_imr_mtx);
2128 mutex_enter(&socalp->board_mtx);
2129 if (socal_establish_pool(socalp, 1) != FCAL_SUCCESS) {
2130 mutex_exit(&socalp->board_mtx);
2133 if (socal_add_pool_buffer(socalp, 1) != FCAL_SUCCESS) {
2134 mutex_exit(&socalp->board_mtx);
2138 mutex_exit(&socalp->board_mtx);
2143 socal_doreset(socal_state_t *socalp)
2150 mutex_enter(&socalp->request[i].skc_mtx);
2151 mutex_enter(&socalp->response[i].skc_mtx);
2154 mutex_enter(&socalp->k_imr_mtx);
2155 socal_disable(socalp);
2157 if (socalp->pool_dhandle) {
2158 (void) ddi_dma_unbind_handle(socalp->pool_dhandle);
2159 ddi_dma_free_handle(&socalp->pool_dhandle);
2162 if (socalp->pool)
2163 ddi_dma_mem_free(&socalp->pool_acchandle);
2165 socalp->pool_dhandle = NULL;
2166 socalp->pool = NULL;
2169 socal_cqinit(socalp, i);
2172 port_statep = &socalp->port_state[i];
2182 mutex_exit(&socalp->k_imr_mtx);
2185 mutex_exit(&socalp->request[i].skc_mtx);
2186 mutex_exit(&socalp->response[i].skc_mtx);
2190 for (scbp = socalp->port_state[i].sp_unsol_cb; scbp;
2196 mutex_enter(&socalp->request[i].skc_mtx);
2197 mutex_enter(&socalp->response[i].skc_mtx);
2202 socalp->request[i].skc_overflowh = NULL;
2203 if (socalp->request[i].skc_full & SOCAL_SKC_SLEEP)
2204 cv_broadcast(&socalp->request[i].skc_cv);
2208 mutex_exit(&socalp->request[i].skc_mtx);
2209 mutex_exit(&socalp->response[i].skc_mtx);
2226 socal_download_ucode(socal_state_t *socalp)
2236 (uint_t *)socalp->socal_xrp, fw_len);
2238 socal_fix_harda(socalp, 0);
2239 socal_fix_harda(socalp, 1);
2242 socal_wcopy((uint_t *)(socalp->socal_xrp+SOCAL_XRAM_FW_DATE_STR),
2250 socal_disp_err(socalp, CE_CONT, "driver.1010", buf);
2251 (void) strcpy(socalp->socal_stats.fw_revision,
2257 socal_disp_err(socalp, CE_CONT, "driver.3010", buf);
2258 (void) strcpy(socalp->socal_stats.fw_revision,
2273 socal_state_t *socalp,
2281 instance = ddi_get_instance(socalp->dip);
2312 socal_init_cq_desc(socal_state_t *socalp)
2330 (uint32_t)socalp->request[i].
2344 (uint_t *)socalp->xram_reqp, /* pointer to xram location */
2354 (uint32_t)socalp->response[i].
2365 (uint_t *)socalp->xram_rspp, /* pointer to xram location */
2370 socal_init_wwn(socal_state_t *socalp)
2373 socal_wcopy((uint_t *)&socalp->socal_n_wwn,
2374 (uint_t *)(socalp->socal_xrp +
2378 socal_wcopy((uint_t *)&socalp->port_state[0].sp_p_wwn,
2379 (uint_t *)(socalp->socal_xrp + SOCAL_XRAM_PORTA_WWN),
2383 socal_wcopy((uint_t *)&socalp->port_state[1].sp_p_wwn,
2384 (uint_t *)(socalp->socal_xrp + SOCAL_XRAM_PORTB_WWN),
2391 mutex_enter(&socalp->port_state[0].sp_transport->fcal_mtx);
2392 mutex_enter(&socalp->port_state[1].sp_transport->fcal_mtx);
2394 socal_wcopy((uint_t *)(socalp->socal_xrp + SOCAL_XRAM_SERV_PARAMS),
2395 (uint_t *)&socalp->socal_service_params, SOCAL_SVC_LENGTH);
2396 mutex_exit(&socalp->port_state[1].sp_transport->fcal_mtx);
2397 mutex_exit(&socalp->port_state[0].sp_transport->fcal_mtx);
2401 socal_enable(socal_state_t *socalp)
2404 ddi_get_instance(socalp->dip)));
2406 socalp->socal_rp->socal_cr.w = socalp->socal_cfg;
2407 socalp->socal_rp->socal_csr.w = SOCAL_CSR_SOCAL_TO_HOST;
2409 socalp->socal_k_imr = (uint32_t)SOCAL_CSR_SOCAL_TO_HOST |
2411 socalp->socal_rp->socal_imr = (uint32_t)socalp->socal_k_imr;
2425 socal_establish_pool(socal_state_t *socalp, uint32_t poolid)
2467 result = socal_cq_enque(socalp, NULL, (cqe_t *)prq, CQ_REQUEST_1,
2486 socal_add_pool_buffer(socal_state_t *socalp, uint32_t poolid)
2500 if (ddi_dma_alloc_handle(socalp->dip, &socal_dma_attr,
2501 DDI_DMA_DONTWAIT, NULL, &socalp->pool_dhandle) != DDI_SUCCESS)
2504 if (ddi_dma_mem_alloc(socalp->pool_dhandle, SOCAL_POOL_SIZE,
2506 (caddr_t *)&socalp->pool, &real_len, &socalp->pool_acchandle)
2513 if (ddi_dma_addr_bind_handle(socalp->pool_dhandle, (struct as *)NULL,
2514 (caddr_t)socalp->pool, SOCAL_POOL_SIZE,
2516 NULL, &socalp->pool_dcookie, &ccount) != DDI_DMA_MAPPED)
2533 (uint32_t)socalp->pool_dcookie.dmac_address;
2552 result = socal_cq_enque(socalp, NULL, (cqe_t *)drq, CQ_REQUEST_1,
2558 socal_disp_err(socalp, CE_WARN, "driver.4110",
2560 if (socalp->pool_dhandle) {
2562 (void) ddi_dma_unbind_handle(socalp->pool_dhandle);
2563 ddi_dma_free_handle(&socalp->pool_dhandle);
2565 if (socalp->pool)
2566 ddi_dma_mem_free(&socalp->pool_acchandle);
2567 socalp->pool_dhandle = NULL;
2574 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
2577 int instance = ddi_get_instance(socalp->dip);
2586 port_statep = &socalp->port_state[port];
2594 return (socal_cq_enque(socalp, port_statep, (cqe_t *)sp,
2614 socal_cq_enque(socal_state_t *socalp, socal_port_t *port_statep, cqe_t *cqe,
2619 int instance = ddi_get_instance(socalp->dip);
2628 kcq = &socalp->request[rqix];
2637 if (socalp->socal_shutdown) {
2678 socalp->socal_stats.qfulls++;
2683 mutex_enter(&socalp->k_imr_mtx);
2684 socalp->socal_rp->socal_imr =
2685 (socalp->socal_k_imr |= bitmask);
2686 mutex_exit(&socalp->k_imr_mtx);
2704 SOCAL_REQUESTQ_INDEX(rqix, socalp->socal_rp->socal_reqp.w);
2745 socalp->socal_rp->socal_csr.w = wmask | (kcq->skc_in << 24);
2756 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
2757 register volatile socal_reg_t *socalreg = socalp->socal_rp;
2771 port_statep = &socalp->port_state[port];
2778 if ((retval = socal_cq_enque(socalp, port_statep, (cqe_t *)sp,
2788 if ((SOCAL_INTR_CAUSE(socalp, csr)) &
2790 socal_intr_solicited(socalp, 0);
2803 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
2876 socal_take_core(socalp);
2878 socal_disp_err(socalp, CE_WARN, "link.6040",
2908 socal_state_t *socalp = (socal_state_t *)ssp;
2909 socal_port_t *port_statep = &socalp->port_state[port];
2912 socal_packet_alloc(socalp, polled ? FCAL_NOSLEEP : FCAL_SLEEP))
2925 fcalpkt->fcal_pkt_cookie = (void *)socalp;
2936 socal_state_t *socalp = (socal_state_t *)ssp;
2937 socal_port_t *port_statep = &socalp->port_state[port];
2953 socalp->socal_stats.pstats[port].lips++;
2955 socal_packet_alloc(socalp, polled ? FCAL_NOSLEEP : FCAL_SLEEP))
2965 fcalpkt->fcal_pkt_cookie = (void *)socalp;
2975 socal_state_t *socalp = (socal_state_t *)ssp;
2976 socal_port_t *port_statep = &socalp->port_state[port];
2979 socalp->socal_stats.pstats[port].abts++;
2980 kcq = &socalp->request[CQ_REQUEST_1];
2994 socalp->socal_stats.pstats[port].abts_ok++;
3005 socal_packet_alloc(socalp, polled ? FCAL_NOSLEEP : FCAL_SLEEP))
3009 mutex_enter(&socalp->abort_mtx);
3013 mutex_exit(&socalp->abort_mtx);
3027 fcalpkt2->fcal_pkt_cookie = (void *)socalp;
3028 mutex_exit(&socalp->abort_mtx);
3048 socal_state_t *socalp = (socal_state_t *)ssp;
3049 socal_port_t *port_statep = &socalp->port_state[port];
3052 socal_packet_alloc(socalp, FCAL_SLEEP))
3071 socal_state_t *socalp = (socal_state_t *)ssp;
3073 mutex_enter(&socalp->k_imr_mtx);
3074 if (socalp->socal_shutdown) {
3075 mutex_exit(&socalp->k_imr_mtx);
3078 socalp->socal_shutdown = 1;
3079 mutex_exit(&socalp->k_imr_mtx);
3081 socalp->socal_stats.resets++;
3082 socal_doreset(socalp);
3084 if (socal_start(socalp) != FCAL_SUCCESS) {
3096 socal_state_t *socalp = (socal_state_t *)ssp;
3097 socal_port_t *port_statep = &socalp->port_state[port];
3137 socal_state_t *socalp = (socal_state_t *)ssp;
3144 port_statep = &socalp->port_state[port];
3182 socal_state_t *socalp = (socal_state_t *)arg;
3183 register volatile socal_reg_t *socalreg = socalp->socal_rp;
3187 int instance = ddi_get_instance(socalp->dip);
3194 cause = (int)SOCAL_INTR_CAUSE(socalp, csr);
3201 socalp->socal_on_intr = 0;
3205 socalp->socal_on_intr = 1;
3216 socal_intr_unsolicited(socalp, 1);
3221 socal_intr_solicited(socalp, 0);
3228 * socal_intr_solicited(socalp, 0);
3240 socalp->socal_stats.reqq_intrs++;
3244 socal_kcq_t *kcq = &socalp->request[j];
3254 if (socal_cq_enque(socalp, (socal_port_t *)
3270 mutex_enter(&socalp->k_imr_mtx);
3271 socalp->socal_rp->socal_imr =
3272 (socalp->socal_k_imr &= ~i);
3273 mutex_exit(&socalp->k_imr_mtx);
3281 cause = (int)SOCAL_INTR_CAUSE(socalp, csr);
3286 socalp->socal_on_intr = 0;
3291 socal_intr_solicited(socal_state_t *socalp, uint32_t srq)
3300 register volatile socal_reg_t *socalreg = socalp->socal_rp;
3308 int instance = ddi_get_instance(socalp->dip);
3312 kcq = &socalp->response[srq];
3378 if ((socal_core & SOCAL_TAKE_CORE) && ddi_peek8(socalp->dip,
3382 socal_take_core(socalp);
3390 socal_disp_err(socalp, CE_WARN, "link.4060", buf);
3420 mutex_enter(&socalp->abort_mtx);
3422 mutex_exit(&socalp->abort_mtx);
3444 socalp->socal_stats.pstats[i].
3447 socalp->socal_stats.pstats[i].
3480 port_statep = &socalp->port_state[port];
3491 (void *)socalp, port,
3503 mutex_enter(&socalp->abort_mtx);
3517 mutex_exit(&socalp->abort_mtx);
3528 mutex_exit(&socalp->abort_mtx);
3531 mutex_exit(&socalp->abort_mtx);
3606 socal_intr_unsolicited(socal_state_t *socalp, uint32_t urq)
3614 register volatile socal_reg_t *socalreg = socalp->socal_rp;
3623 int instance = ddi_get_instance(socalp->dip);
3628 kcq = &socalp->response[urq];
3703 socal_disp_err(socalp, CE_WARN, "driver.4030",
3750 port_statep = &socalp->port_state[port];
3765 socalp->socal_stats.pstats[port].els_rcvd++;
3766 socal_us_els(socalp, (cqe_t *)cqe, (caddr_t)cqe_cont);
3788 socal_disp_err(socalp, CE_WARN, "link.4020", buf);
3817 socal_disp_err(socalp, CE_WARN,
3825 socal_disp_err(socalp, CE_WARN, "link.4040", buf);
3843 socal_disp_err(socalp, CE_CONT, "link.6010",
3849 socalp->socal_stats.pstats[port].onlines++;
3859 socal_disp_err(socalp, CE_CONT, "link.6010",
3865 socalp->socal_stats.pstats[port].online_loops++;
3880 socal_disp_err(socalp, CE_CONT, "link.5010",
3888 socalp->socal_stats.pstats[port].offlines++;
3897 socal_disp_err(socalp, CE_WARN, "link.3020",
3913 socal_flush_overflowq(socalp, port,
3915 socal_flush_overflowq(socalp, port,
3924 socal_disp_err(socalp, CE_WARN, "link.4050", buf);
3927 socalp->socal_rp->socal_cr.w,
3928 socalp->socal_rp->socal_sae.w,
3929 socalp->socal_rp->socal_csr.w,
3930 socalp->socal_rp->socal_imr));
3981 socalp->socal_stats.pstats[port].unsol_resps++;
3996 socal_us_els(socal_state_t *socalp, cqe_t *cqe, caddr_t payload)
4009 socal_disp_err(socalp, CE_WARN, "link.4010",
4030 socal_disp_err(socalp, CE_CONT, "link.1010", buf);
4043 socal_packet_alloc(socal_state_t *socalp, fcal_sleep_t sleep)
4071 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
4077 mutex_enter(&socalp->port_state[port].sp_mtx);
4078 socalp->port_state[port].sp_status &= ~PORT_LILP_PENDING;
4079 cv_broadcast(&socalp->port_state[port].sp_cv);
4080 mutex_exit(&socalp->port_state[port].sp_mtx);
4087 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
4093 mutex_enter(&socalp->port_state[port].sp_mtx);
4094 socalp->port_state[port].sp_status &= ~PORT_LIP_PENDING;
4095 cv_broadcast(&socalp->port_state[port].sp_cv);
4096 mutex_exit(&socalp->port_state[port].sp_mtx);
4103 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
4109 mutex_enter(&socalp->port_state[port].sp_mtx);
4110 socalp->port_state[port].sp_status &= ~PORT_ADISC_PENDING;
4111 cv_broadcast(&socalp->port_state[port].sp_cv);
4112 mutex_exit(&socalp->port_state[port].sp_mtx);
4119 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
4125 mutex_enter(&socalp->port_state[port].sp_mtx);
4126 socalp->port_state[port].sp_status &= ~PORT_LBF_PENDING;
4127 cv_broadcast(&socalp->port_state[port].sp_cv);
4128 mutex_exit(&socalp->port_state[port].sp_mtx);
4135 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
4141 mutex_enter(&socalp->port_state[port].sp_mtx);
4142 socalp->port_state[port].sp_status &= ~PORT_RLS_PENDING;
4143 cv_broadcast(&socalp->port_state[port].sp_cv);
4144 mutex_exit(&socalp->port_state[port].sp_mtx);
4151 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
4157 mutex_enter(&socalp->port_state[port].sp_mtx);
4158 socalp->port_state[port].sp_status &= ~PORT_OFFLINE_PENDING;
4159 cv_broadcast(&socalp->port_state[port].sp_cv);
4160 mutex_exit(&socalp->port_state[port].sp_mtx);
4167 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
4173 mutex_enter(&socalp->abort_mtx);
4178 mutex_exit(&socalp->abort_mtx);
4183 mutex_enter(&socalp->port_state[port].sp_mtx);
4184 socalp->port_state[port].sp_status &= ~PORT_ABORT_PENDING;
4185 cv_broadcast(&socalp->port_state[port].sp_cv);
4186 mutex_exit(&socalp->port_state[port].sp_mtx);
4193 socal_state_t *socalp = (socal_state_t *)fcalpkt->fcal_pkt_cookie;
4198 mutex_enter(&socalp->port_state[port].sp_mtx);
4199 socalp->port_state[port].sp_status &= ~PORT_BYPASS_PENDING;
4200 cv_broadcast(&socalp->port_state[port].sp_cv);
4201 mutex_exit(&socalp->port_state[port].sp_mtx);
4212 socal_diag_request(socal_state_t *socalp, uint32_t port, uint_t *diagcode,
4217 socal_port_t *port_statep = &socalp->port_state[port];
4222 if (socal_getmap(socalp, port, (caddr_t)&map, 0, FKIOCTL)
4229 if ((fcalpkt = socal_packet_alloc(socalp, FCAL_SLEEP))
4238 fcalpkt->fcal_pkt_cookie = (void *)socalp;
4248 socal_state_t *socalp = (socal_state_t *)ssp;
4249 socal_port_t *port_statep = &socalp->port_state[port];
4252 socal_packet_alloc(socalp, polled ? FCAL_NOSLEEP : FCAL_SLEEP))
4261 fcalpkt->fcal_pkt_cookie = (void *)socalp;
4267 socal_issue_adisc(socal_state_t *socalp, uint32_t port, uint32_t dest,
4276 port_statep = &socalp->port_state[port];
4279 socal_els_alloc(socalp, port, dest, sizeof (la_els_adisc_t),
4293 bcopy((caddr_t)&socalp->socal_n_wwn,
4311 socal_issue_lbf(socal_state_t *socalp, uint32_t port,
4319 port_statep = &socalp->port_state[port];
4321 if ((fcalpkt = socal_lbf_alloc(socalp, port, length, length,
4343 socal_issue_rls(socal_state_t *socalp, uint32_t port, uint32_t dest,
4353 port_statep = &socalp->port_state[port];
4355 if (dest == socal_getmap(socalp, port, NULL, 0, 0)) {
4371 socal_els_alloc(socalp, port, dest, sizeof (la_els_rls_t),
4408 socal_els_alloc(socal_state_t *socalp, uint32_t port, uint32_t dest,
4428 socal_packet_alloc(socalp, polled ? FCAL_NOSLEEP : FCAL_SLEEP))
4443 if ((ouralpa = socal_getmap(socalp, port, NULL, 0, 0)) == -1)
4446 if (ddi_dma_alloc_handle(socalp->dip, &socal_dma_attr,
4472 if (ddi_dma_alloc_handle(socalp->dip, &socal_dma_attr,
4517 fcalpkt->fcal_pkt_cookie = (void *)socalp;
4557 socal_lbf_alloc(socal_state_t *socalp, uint32_t port,
4577 socal_packet_alloc(socalp, polled ? FCAL_NOSLEEP : FCAL_SLEEP))
4592 if (ddi_dma_alloc_handle(socalp->dip, &socal_dma_attr,
4618 if (ddi_dma_alloc_handle(socalp->dip, &socal_dma_attr,
4664 fcalpkt->fcal_pkt_cookie = (void *)socalp;
4669 fhp->d_id = socalp->port_state[port].sp_src_id;
4670 fhp->s_id = socalp->port_state[port].sp_src_id;
4757 socal_getmap(socal_state_t *socalp, uint32_t port, caddr_t arg,
4769 port_statep = &socalp->port_state[port];
4784 if (ddi_dma_alloc_handle(socalp->dip, &socal_dma_attr,
4807 retval = socal_lilp_map((void *)socalp, port,
4857 socal_flush_overflowq(socal_state_t *socalp, int port, int q_no)
4862 kcq = &socalp->request[q_no];
4904 socal_state_t *socalp = kcq->skc_socalp;
4906 ASSERT((socalp != NULL));
4917 if (socalp->socal_on_intr) {
4926 socal_intr_solicited(socalp, 0);
4932 socal_state_t *socalp = (socal_state_t *)arg;
4935 socal_disable(socalp);
4937 mutex_enter(&socalp->request[i].skc_mtx);
4938 mutex_enter(&socalp->response[i].skc_mtx);
4941 socalp->socal_rp->socal_cr.w &=
4943 socalp->socal_rp->socal_cr.w |= i<<24;
4944 (void) bcopy((caddr_t)socalp->socal_xrp,
4948 mutex_exit(&socalp->request[i].skc_mtx);
4949 mutex_exit(&socalp->response[i].skc_mtx);
4951 instance = ddi_get_instance(socalp->dip);
4960 socal_fix_harda(socal_state_t *socalp, int port)
4962 socal_port_t *portp = &socalp->port_state[port];
4963 uint_t *xrp = (uint_t *)socalp->socal_xrp;
4988 socal_state_t *socalp;
5000 socalp = ddi_get_soft_state(socal_soft_state_p, instance);
5001 if (socalp == NULL)
5007 if (socalp->port_state[port].sp_status & PORT_CHILD_INIT)
5014 mutex_enter(&socalp->board_mtx);
5015 mutex_enter(&socalp->port_state[port].sp_mtx);
5016 if (socalp->socal_busy < 0) {
5017 mutex_exit(&socalp->port_state[port].sp_mtx);
5018 mutex_exit(&socalp->board_mtx);
5021 socalp->socal_busy++;
5022 socalp->port_state[port].sp_status |= PORT_CHILD_INIT;
5023 mutex_exit(&socalp->port_state[port].sp_mtx);
5024 mutex_exit(&socalp->board_mtx);
5031 if (hard_alpa != socalp->port_state[port].sp_hard_alpa) {
5032 socalp->port_state[port].sp_hard_alpa = hard_alpa;
5038 return (socalp->port_state[port].sp_transport);
5046 socal_sftm_detach(socal_state_t *socalp, int port)
5048 mutex_enter(&socalp->board_mtx);
5049 socalp->socal_busy--;
5050 socalp->port_state[port].sp_status &= ~PORT_CHILD_INIT;
5051 mutex_exit(&socalp->board_mtx);