Lines Matching refs:state

79 static int hermon_drv_init(hermon_state_t *state, dev_info_t *dip,
81 static void hermon_drv_fini(hermon_state_t *state);
82 static void hermon_drv_fini2(hermon_state_t *state);
83 static int hermon_isr_init(hermon_state_t *state);
84 static void hermon_isr_fini(hermon_state_t *state);
86 static int hermon_hw_init(hermon_state_t *state);
88 static void hermon_hw_fini(hermon_state_t *state,
90 static int hermon_soft_state_init(hermon_state_t *state);
91 static void hermon_soft_state_fini(hermon_state_t *state);
92 static int hermon_icm_config_setup(hermon_state_t *state,
94 static void hermon_icm_tables_init(hermon_state_t *state);
95 static void hermon_icm_tables_fini(hermon_state_t *state);
96 static int hermon_icm_dma_init(hermon_state_t *state);
97 static void hermon_icm_dma_fini(hermon_state_t *state);
98 static void hermon_inithca_set(hermon_state_t *state,
100 static int hermon_hca_port_init(hermon_state_t *state);
101 static int hermon_hca_ports_shutdown(hermon_state_t *state, uint_t num_init);
102 static int hermon_internal_uarpg_init(hermon_state_t *state);
103 static void hermon_internal_uarpg_fini(hermon_state_t *state);
104 static int hermon_special_qp_contexts_reserve(hermon_state_t *state);
105 static void hermon_special_qp_contexts_unreserve(hermon_state_t *state);
106 static int hermon_sw_reset(hermon_state_t *state);
107 static int hermon_mcg_init(hermon_state_t *state);
108 static void hermon_mcg_fini(hermon_state_t *state);
109 static int hermon_fw_version_check(hermon_state_t *state);
110 static void hermon_device_info_report(hermon_state_t *state);
111 static int hermon_pci_capability_list(hermon_state_t *state,
113 static void hermon_pci_capability_vpd(hermon_state_t *state,
117 static int hermon_intr_or_msi_init(hermon_state_t *state);
118 static int hermon_add_intrs(hermon_state_t *state, int intr_type);
119 static int hermon_intr_or_msi_fini(hermon_state_t *state);
120 void hermon_pci_capability_msix(hermon_state_t *state, ddi_acc_handle_t hdl,
123 static uint64_t hermon_size_icm(hermon_state_t *state);
270 hermon_state_t *state; in hermon_getinfo() local
277 state = ddi_get_soft_state(hermon_statep, instance); in hermon_getinfo()
278 if (state == NULL) { in hermon_getinfo()
281 *result = (void *)state->hs_dip; in hermon_getinfo()
305 hermon_state_t *state; in hermon_open() local
315 state = ddi_get_soft_state(hermon_statep, instance); in hermon_open()
316 if (state == NULL) { in hermon_open()
372 if (!HERMON_IS_OPERATIONAL(state->hs_operational_mode)) { in hermon_open()
374 hr_indx = state->hs_open_ar_indx++; in hermon_open()
377 status = hermon_rsrc_alloc(state, HERMON_UARPG, 1, in hermon_open()
397 if (HERMON_IS_OPERATIONAL(state->hs_operational_mode)) { in hermon_open()
398 hermon_rsrc_free(state, &rsrcp); in hermon_open()
422 if (HERMON_IS_OPERATIONAL(state->hs_operational_mode)) { in hermon_open()
423 hermon_rsrc_free(state, &rsrcp); in hermon_open()
457 hermon_state_t *state; in hermon_close() local
466 state = ddi_get_soft_state(hermon_statep, instance); in hermon_close()
467 if (state == NULL) { in hermon_close()
528 if (HERMON_IS_OPERATIONAL(state->hs_operational_mode)) { in hermon_close()
530 hermon_rsrc_free(state, &rsrcp); in hermon_close()
546 hermon_state_t *state; in hermon_attach() local
566 state = ddi_get_soft_state(hermon_statep, instance); in hermon_attach()
567 if (state == NULL) { in hermon_attach()
575 HERMON_ATTACH_MSG_INIT(state->hs_attach_buf); in hermon_attach()
578 state->hs_dip = dip; in hermon_attach()
579 state->hs_instance = instance; in hermon_attach()
581 hermon_fm_init(state); in hermon_attach()
594 status = hermon_drv_init(state, dip, instance); in hermon_attach()
596 (HERMON_IS_OPERATIONAL(state->hs_operational_mode))) { in hermon_attach()
603 if ((hermon_get_state(state) & HCA_PIO_FM) && in hermon_attach()
604 HERMON_IS_OPERATIONAL(state->hs_operational_mode)) { in hermon_attach()
613 if (hermon_init_failure(state)) { in hermon_attach()
614 hermon_drv_fini(state); in hermon_attach()
615 HERMON_WARNING(state, "unable to " in hermon_attach()
617 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_attach()
627 if (hermon_fm_ereport_init(state) != DDI_SUCCESS) { in hermon_attach()
629 hermon_drv_fini(state); in hermon_attach()
630 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_attach()
640 hermon_drv_fini(state); in hermon_attach()
641 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_attach()
652 if (HERMON_IS_OPERATIONAL(state->hs_operational_mode)) { in hermon_attach()
657 &state->hs_ibtfinfo); in hermon_attach()
662 hermon_drv_fini(state); in hermon_attach()
663 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_attach()
673 HERMON_ENABLE_IBTF_CALLB(state, tmp_ibtfpriv); in hermon_attach()
675 ibc_post_attach(state->hs_ibtfpriv); in hermon_attach()
678 status = hermon_agent_handlers_init(state); in hermon_attach()
681 HERMON_QUIESCE_IBTF_CALLB(state); in hermon_attach()
682 if (state->hs_in_evcallb != 0) { in hermon_attach()
683 HERMON_WARNING(state, "unable to " in hermon_attach()
688 hermon_drv_fini(state); in hermon_attach()
689 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_attach()
696 if (!(HERMON_IS_OPERATIONAL(state->hs_operational_mode))) { in hermon_attach()
698 "(for maintenance mode only)", state->hs_instance); in hermon_attach()
699 hermon_fm_ereport(state, HCA_IBA_ERR, HCA_ERR_DEGRADED); in hermon_attach()
706 hermon_device_info_report(state); in hermon_attach()
723 state->hs_attach_buf); in hermon_attach()
724 if (hermon_get_state(state) & HCA_EREPORT_FM) { in hermon_attach()
725 hermon_fm_ereport(state, HCA_SYS_ERR, HCA_ERR_SRV_LOST); in hermon_attach()
727 hermon_drv_fini2(state); in hermon_attach()
728 hermon_fm_fini(state); in hermon_attach()
743 hermon_state_t *state; in hermon_detach() local
749 state = ddi_get_soft_state(hermon_statep, instance); in hermon_detach()
750 if (state == NULL) { in hermon_detach()
762 if (HERMON_IS_OPERATIONAL(state->hs_operational_mode)) { in hermon_detach()
764 status = hermon_agent_handlers_fini(state); in hermon_detach()
777 ibc_status = ibc_pre_detach(state->hs_ibtfpriv, cmd); in hermon_detach()
779 status = hermon_agent_handlers_init(state); in hermon_detach()
781 HERMON_WARNING(state, "failed to " in hermon_detach()
797 tmp_ibtfpriv = state->hs_ibtfpriv; in hermon_detach()
798 HERMON_QUIESCE_IBTF_CALLB(state); in hermon_detach()
799 if (state->hs_in_evcallb != 0) { in hermon_detach()
800 HERMON_WARNING(state, "unable to quiesce " in hermon_detach()
817 if (HERMON_IS_OPERATIONAL(state->hs_operational_mode)) { in hermon_detach()
819 hermon_drv_fini(state); in hermon_detach()
824 hermon_drv_fini2(state); in hermon_detach()
825 hermon_fm_fini(state); in hermon_detach()
849 hermon_dma_attr_init(hermon_state_t *state, ddi_dma_attr_t *dma_attr) in hermon_dma_attr_init() argument
872 hermon_dma_alloc(hermon_state_t *state, hermon_dma_info_t *dma_info, in hermon_dma_alloc() argument
884 hermon_dma_attr_init(state, &dma_attr); in hermon_dma_alloc()
886 if (state->hs_cfg_profile->cp_iommu_bypass == HERMON_BINDMEM_BYPASS) in hermon_dma_alloc()
891 status = ddi_dma_alloc_handle(state->hs_dip, &dma_attr, DDI_DMA_SLEEP, in hermon_dma_alloc()
901 &state->hs_reg_accattr, DDI_DMA_CONSISTENT, DDI_DMA_SLEEP, NULL, in hermon_dma_alloc()
929 status = hermon_map_cmd_post(state, dma_info, opcode, cookie, ccount); in hermon_dma_alloc()
969 hermon_icm_alloc(state, rsrc, index1, index2)
971 hermon_icm_free(state, rsrc, index1, index2)
984 hermon_icm_alloc(hermon_state_t *state, hermon_rsrc_type_t type, in hermon_icm_alloc() argument
998 icm = &state->hs_icm[type]; in hermon_icm_alloc()
1072 status = hermon_dma_alloc(state, dma_info, MAP_ICM); in hermon_icm_alloc()
1117 hermon_icm_free(hermon_state_t *state, hermon_rsrc_type_t type, in hermon_icm_free() argument
1124 icm = &state->hs_icm[type]; in hermon_icm_free()
1139 status = hermon_unmap_icm_cmd_post(state, dma_info); in hermon_icm_free()
1141 HERMON_WARNING(state, "UNMAP_ICM failure"); in hermon_icm_free()
1178 hermon_icm_num_to_hdl(hermon_state_t *state, hermon_rsrc_type_t type, in hermon_icm_num_to_hdl() argument
1186 icm = &state->hs_icm[type]; in hermon_icm_num_to_hdl()
1215 hermon_icm_set_num_to_hdl(hermon_state_t *state, hermon_rsrc_type_t type, in hermon_icm_set_num_to_hdl() argument
1222 icm = &state->hs_icm[type]; in hermon_icm_set_num_to_hdl()
1241 hermon_device_mode(hermon_state_t *state) in hermon_device_mode() argument
1243 if (state->hs_vendor_id != PCI_VENID_MLX) in hermon_device_mode()
1246 switch (state->hs_device_id) { in hermon_device_mode()
1266 hermon_drv_init(hermon_state_t *state, dev_info_t *dip, int instance) in hermon_drv_init() argument
1271 state->hs_vendor_id = HERMON_GET_VENDOR_ID(state->hs_dip); in hermon_drv_init()
1272 state->hs_device_id = HERMON_GET_DEVICE_ID(state->hs_dip); in hermon_drv_init()
1273 state->hs_revision_id = HERMON_GET_REVISION_ID(state->hs_dip); in hermon_drv_init()
1283 state->hs_operational_mode = hermon_device_mode(state); in hermon_drv_init()
1284 switch (state->hs_operational_mode) { in hermon_drv_init()
1286 state->hs_cfg_profile_setting = HERMON_CFG_MEMFREE; in hermon_drv_init()
1289 HERMON_FMANOTE(state, HERMON_FMA_MAINT); in hermon_drv_init()
1290 state->hs_fm_degraded_reason = HCA_FW_MISC; /* not fw reason */ in hermon_drv_init()
1293 HERMON_FMANOTE(state, HERMON_FMA_PCIID); in hermon_drv_init()
1294 HERMON_WARNING(state, "unexpected device type detected"); in hermon_drv_init()
1312 status = hermon_hw_init(state); in hermon_drv_init()
1315 state->hs_attach_buf); in hermon_drv_init()
1324 status = hermon_eq_arm_all(state); in hermon_drv_init()
1327 hermon_hw_fini(state, HERMON_DRV_CLEANUP_ALL); in hermon_drv_init()
1332 status = hermon_nop_post(state, 0x0, 0x0); in hermon_drv_init()
1335 hermon_hw_fini(state, HERMON_DRV_CLEANUP_ALL); in hermon_drv_init()
1340 status = hermon_soft_state_init(state); in hermon_drv_init()
1343 hermon_hw_fini(state, HERMON_DRV_CLEANUP_ALL); in hermon_drv_init()
1356 hermon_drv_fini(hermon_state_t *state) in hermon_drv_fini() argument
1359 hermon_soft_state_fini(state); in hermon_drv_fini()
1362 hermon_hw_fini(state, HERMON_DRV_CLEANUP_ALL); in hermon_drv_fini()
1371 hermon_drv_fini2(hermon_state_t *state) in hermon_drv_fini2() argument
1373 if (state->hs_fm_poll_thread) { in hermon_drv_fini2()
1374 ddi_periodic_delete(state->hs_fm_poll_thread); in hermon_drv_fini2()
1375 state->hs_fm_poll_thread = NULL; in hermon_drv_fini2()
1379 if (state->hs_fm_cmdhdl) { in hermon_drv_fini2()
1380 hermon_regs_map_free(state, &state->hs_fm_cmdhdl); in hermon_drv_fini2()
1381 state->hs_fm_cmdhdl = NULL; in hermon_drv_fini2()
1384 if (state->hs_reg_cmdhdl) { in hermon_drv_fini2()
1385 ddi_regs_map_free(&state->hs_reg_cmdhdl); in hermon_drv_fini2()
1386 state->hs_reg_cmdhdl = NULL; in hermon_drv_fini2()
1390 if (state->hs_msix_tbl_entries) { in hermon_drv_fini2()
1391 kmem_free(state->hs_msix_tbl_entries, in hermon_drv_fini2()
1392 state->hs_msix_tbl_size); in hermon_drv_fini2()
1393 state->hs_msix_tbl_entries = NULL; in hermon_drv_fini2()
1396 if (state->hs_msix_pba_entries) { in hermon_drv_fini2()
1397 kmem_free(state->hs_msix_pba_entries, in hermon_drv_fini2()
1398 state->hs_msix_pba_size); in hermon_drv_fini2()
1399 state->hs_msix_pba_entries = NULL; in hermon_drv_fini2()
1402 if (state->hs_fm_msix_tblhdl) { in hermon_drv_fini2()
1403 hermon_regs_map_free(state, &state->hs_fm_msix_tblhdl); in hermon_drv_fini2()
1404 state->hs_fm_msix_tblhdl = NULL; in hermon_drv_fini2()
1407 if (state->hs_reg_msix_tblhdl) { in hermon_drv_fini2()
1408 ddi_regs_map_free(&state->hs_reg_msix_tblhdl); in hermon_drv_fini2()
1409 state->hs_reg_msix_tblhdl = NULL; in hermon_drv_fini2()
1412 if (state->hs_fm_msix_pbahdl) { in hermon_drv_fini2()
1413 hermon_regs_map_free(state, &state->hs_fm_msix_pbahdl); in hermon_drv_fini2()
1414 state->hs_fm_msix_pbahdl = NULL; in hermon_drv_fini2()
1417 if (state->hs_reg_msix_pbahdl) { in hermon_drv_fini2()
1418 ddi_regs_map_free(&state->hs_reg_msix_pbahdl); in hermon_drv_fini2()
1419 state->hs_reg_msix_pbahdl = NULL; in hermon_drv_fini2()
1422 if (state->hs_fm_pcihdl) { in hermon_drv_fini2()
1423 hermon_pci_config_teardown(state, &state->hs_fm_pcihdl); in hermon_drv_fini2()
1424 state->hs_fm_pcihdl = NULL; in hermon_drv_fini2()
1427 if (state->hs_reg_pcihdl) { in hermon_drv_fini2()
1428 pci_config_teardown(&state->hs_reg_pcihdl); in hermon_drv_fini2()
1429 state->hs_reg_pcihdl = NULL; in hermon_drv_fini2()
1439 hermon_isr_init(hermon_state_t *state) in hermon_isr_init() argument
1444 for (intr = 0; intr < state->hs_intrmsi_allocd; intr++) { in hermon_isr_init()
1449 status = ddi_intr_add_handler(state->hs_intrmsi_hdl[intr], in hermon_isr_init()
1450 hermon_isr, (caddr_t)state, (void *)(uintptr_t)intr); in hermon_isr_init()
1460 if (state->hs_intrmsi_cap & DDI_INTR_FLAG_BLOCK) { in hermon_isr_init()
1462 &state->hs_intrmsi_hdl[intr], 1); in hermon_isr_init()
1467 status = ddi_intr_enable(state->hs_intrmsi_hdl[intr]); in hermon_isr_init()
1487 hermon_isr_fini(hermon_state_t *state) in hermon_isr_fini() argument
1491 for (intr = 0; intr < state->hs_intrmsi_allocd; intr++) { in hermon_isr_fini()
1493 if (state->hs_intrmsi_cap & DDI_INTR_FLAG_BLOCK) { in hermon_isr_fini()
1495 &state->hs_intrmsi_hdl[intr], 1); in hermon_isr_fini()
1497 (void) ddi_intr_disable(state->hs_intrmsi_hdl[intr]); in hermon_isr_fini()
1503 (void) ddi_intr_remove_handler(state->hs_intrmsi_hdl[intr]); in hermon_isr_fini()
1514 hermon_size_icm(hermon_state_t *state) in hermon_size_icm() argument
1527 devlim = &state->hs_devlim; in hermon_size_icm()
1528 cfg = state->hs_cfg_profile; in hermon_size_icm()
1559 num_mcgs * HERMON_MCGMEM_SZ(state); in hermon_size_icm()
1569 hermon_hw_init(hermon_state_t *state) in hermon_hw_init() argument
1582 state->hs_reg_accattr.devacc_attr_version = DDI_DEVICE_ATTR_V1; in hermon_hw_init()
1583 state->hs_reg_accattr.devacc_attr_endian_flags = DDI_STRUCTURE_BE_ACC; in hermon_hw_init()
1584 state->hs_reg_accattr.devacc_attr_dataorder = DDI_STRICTORDER_ACC; in hermon_hw_init()
1585 state->hs_reg_accattr.devacc_attr_access = DDI_DEFAULT_ACC; in hermon_hw_init()
1588 state->hs_fm_accattr.devacc_attr_version = in hermon_hw_init()
1589 hermon_devacc_attr_version(state); in hermon_hw_init()
1590 state->hs_fm_accattr.devacc_attr_endian_flags = DDI_STRUCTURE_BE_ACC; in hermon_hw_init()
1591 state->hs_fm_accattr.devacc_attr_dataorder = DDI_STRICTORDER_ACC; in hermon_hw_init()
1593 state->hs_fm_accattr.devacc_attr_access = in hermon_hw_init()
1594 hermon_devacc_attr_access(state); in hermon_hw_init()
1597 status = hermon_pci_config_setup(state, &state->hs_fm_pcihdl); in hermon_hw_init()
1599 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1600 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1607 hermon_set_msix_info(state); in hermon_hw_init()
1610 status = hermon_regs_map_setup(state, HERMON_CMD_BAR, in hermon_hw_init()
1611 &state->hs_reg_cmd_baseaddr, 0, 0, &state->hs_fm_accattr, in hermon_hw_init()
1612 &state->hs_fm_cmdhdl); in hermon_hw_init()
1614 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1615 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1636 status = ddi_regs_map_setup(state->hs_dip, HERMON_MSIX_BAR, in hermon_hw_init()
1637 &state->hs_reg_msi_baseaddr, 0, 0, &state->hs_reg_accattr, in hermon_hw_init()
1638 &state->hs_reg_msihdl); in hermon_hw_init()
1640 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1641 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1657 state->hs_cmd_regs.hcr = (hermon_hw_hcr_t *) in hermon_hw_init()
1658 ((uintptr_t)state->hs_reg_cmd_baseaddr + HERMON_CMD_HCR_OFFSET); in hermon_hw_init()
1659 state->hs_cmd_toggle = 0; /* initialize it for use */ in hermon_hw_init()
1662 state->hs_cmd_regs.sw_reset = (uint32_t *) in hermon_hw_init()
1663 ((uintptr_t)state->hs_reg_cmd_baseaddr + in hermon_hw_init()
1665 state->hs_cmd_regs.sw_semaphore = (uint32_t *) in hermon_hw_init()
1666 ((uintptr_t)state->hs_reg_cmd_baseaddr + in hermon_hw_init()
1670 bzero(&state->hs_hcaparams, sizeof (struct hermon_hw_initqueryhca_s)); in hermon_hw_init()
1673 status = hermon_cfg_profile_init_phase1(state); in hermon_hw_init()
1675 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1676 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1684 status = hermon_sw_reset(state); in hermon_hw_init()
1686 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1687 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1694 status = hermon_rsrc_init_phase1(state); in hermon_hw_init()
1696 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1697 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1705 status = hermon_cmn_query_cmd_post(state, QUERY_FW, 0, 0, &state->hs_fw, in hermon_hw_init()
1709 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1710 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1718 status = hermon_fw_version_check(state); in hermon_hw_init()
1720 HERMON_FMANOTE(state, HERMON_FMA_FWVER); in hermon_hw_init()
1721 if (state->hs_operational_mode == HERMON_HCA_MODE) { in hermon_hw_init()
1728 state->hs_fw.fw_rev_major, in hermon_hw_init()
1729 state->hs_fw.fw_rev_minor, in hermon_hw_init()
1730 state->hs_fw.fw_rev_subminor); in hermon_hw_init()
1734 state->hs_fw.fw_rev_major, in hermon_hw_init()
1735 state->hs_fw.fw_rev_minor, in hermon_hw_init()
1736 state->hs_fw.fw_rev_subminor); in hermon_hw_init()
1738 state->hs_operational_mode = HERMON_MAINTENANCE_MODE; in hermon_hw_init()
1739 state->hs_fm_degraded_reason = HCA_FW_MISMATCH; in hermon_hw_init()
1740 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1741 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1758 clr_intr_offset = state->hs_fw.clr_intr_offs & HERMON_CMD_OFFSET_MASK; in hermon_hw_init()
1761 state->hs_cmd_regs.clr_intr = (uint64_t *) in hermon_hw_init()
1762 (uintptr_t)(state->hs_reg_cmd_baseaddr + clr_intr_offset); in hermon_hw_init()
1769 state->hs_cmd_regs.fw_err_buf = (uint32_t *)(uintptr_t) in hermon_hw_init()
1770 (state->hs_reg_cmd_baseaddr + state->hs_fw.error_buf_addr); in hermon_hw_init()
1776 state->hs_fm_poll_thread = ddi_periodic_add( in hermon_hw_init()
1777 hermon_inter_err_chk, (void *)state, FM_POLL_INTERVAL, in hermon_hw_init()
1790 fw_size = 1 << highbit(state->hs_fw.fw_pages); in hermon_hw_init()
1791 state->hs_fw_dma.length = fw_size << HERMON_PAGESHIFT; in hermon_hw_init()
1792 status = hermon_dma_alloc(state, &state->hs_fw_dma, MAP_FA); in hermon_hw_init()
1795 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1796 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1805 status = hermon_run_fw_cmd_post(state); in hermon_hw_init()
1809 state->hs_operational_mode = HERMON_MAINTENANCE_MODE; in hermon_hw_init()
1810 state->hs_fm_degraded_reason = HCA_FW_CORRUPT; in hermon_hw_init()
1812 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1813 HERMON_ATTACH_MSG(state->hs_attach_buf, "hw_init_run_fw_fail"); in hermon_hw_init()
1831 status = hermon_cmn_query_cmd_post(state, QUERY_DEV_CAP, 0, 0, in hermon_hw_init()
1832 &state->hs_devlim, sizeof (hermon_hw_querydevlim_t), in hermon_hw_init()
1837 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1838 HERMON_ATTACH_MSG(state->hs_attach_buf, "hw_init_devcap_fail"); in hermon_hw_init()
1843 state->hs_rsvd_eqs = max(state->hs_devlim.num_rsvd_eq, in hermon_hw_init()
1844 (4 * state->hs_devlim.num_rsvd_uar)); in hermon_hw_init()
1853 if (state->hs_devlim.blu_flm) { /* Blue Flame Enabled */ in hermon_hw_init()
1854 offset = (uint64_t)1 << (state->hs_devlim.log_max_uar_sz + 20); in hermon_hw_init()
1858 status = hermon_regs_map_setup(state, HERMON_UAR_BAR, in hermon_hw_init()
1859 &state->hs_reg_uar_baseaddr, 0, offset, &state->hs_fm_accattr, in hermon_hw_init()
1860 &state->hs_fm_uarhdl); in hermon_hw_init()
1862 HERMON_ATTACH_MSG(state->hs_attach_buf, "UAR BAR mapping"); in hermon_hw_init()
1868 if (state->hs_devlim.blu_flm) { /* Blue Flame Enabled */ in hermon_hw_init()
1869 offset = (uint64_t)1 << (state->hs_devlim.log_max_uar_sz + 20); in hermon_hw_init()
1870 status = ddi_regs_map_setup(state->hs_dip, HERMON_UAR_BAR, in hermon_hw_init()
1871 &state->hs_reg_bf_baseaddr, offset, offset, in hermon_hw_init()
1872 &state->hs_reg_accattr, &state->hs_reg_bfhdl); in hermon_hw_init()
1874 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1880 state->hs_bf_offset = offset; in hermon_hw_init()
1886 status = hermon_cmn_query_cmd_post(state, QUERY_PORT, 0, 0x01, in hermon_hw_init()
1887 &state->hs_queryport, sizeof (hermon_hw_query_port_t), in hermon_hw_init()
1892 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1893 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1900 status = hermon_cfg_profile_init_phase2(state); in hermon_hw_init()
1903 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1904 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1911 state->hs_icm_sz = hermon_size_icm(state); in hermon_hw_init()
1912 status = hermon_set_icm_size_cmd_post(state); in hermon_hw_init()
1916 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1917 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1924 state->hs_icma_dma.length = 1 << highbit(state->hs_icma_sz); in hermon_hw_init()
1926 status = hermon_dma_alloc(state, &state->hs_icma_dma, MAP_ICM_AUX); in hermon_hw_init()
1929 (longlong_t)state->hs_icma_dma.length); in hermon_hw_init()
1930 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1931 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1941 state->hs_icm = kmem_zalloc(HERMON_NUM_ICM_RESOURCES * in hermon_hw_init()
1945 status = hermon_icm_config_setup(state, &state->hs_hcaparams); in hermon_hw_init()
1948 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1949 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1957 status = hermon_init_hca_cmd_post(state, &state->hs_hcaparams, in hermon_hw_init()
1961 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1962 HERMON_ATTACH_MSG(state->hs_attach_buf, "hw_init_hca_fail"); in hermon_hw_init()
1969 status = hermon_rsrc_init_phase2(state); in hermon_hw_init()
1971 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1972 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1980 status = hermon_cmn_query_cmd_post(state, QUERY_ADAPTER, 0, 0, in hermon_hw_init()
1981 &state->hs_adapter, sizeof (hermon_hw_queryadapter_t), in hermon_hw_init()
1986 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1987 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
1994 status = hermon_pd_alloc(state, &state->hs_pdhdl_internal, in hermon_hw_init()
1998 hermon_hw_fini(state, cleanup); in hermon_hw_init()
1999 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2007 status = hermon_internal_uarpg_init(state); in hermon_hw_init()
2010 hermon_hw_fini(state, cleanup); in hermon_hw_init()
2011 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2019 status = hermon_intr_or_msi_init(state); in hermon_hw_init()
2022 hermon_hw_fini(state, cleanup); in hermon_hw_init()
2023 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2030 status = hermon_isr_init(state); /* set up the isr */ in hermon_hw_init()
2033 hermon_hw_fini(state, cleanup); in hermon_hw_init()
2034 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2042 status = hermon_eq_init_all(state); in hermon_hw_init()
2045 hermon_hw_fini(state, cleanup); in hermon_hw_init()
2046 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2056 status = hermon_special_qp_contexts_reserve(state); in hermon_hw_init()
2059 hermon_hw_fini(state, cleanup); in hermon_hw_init()
2060 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2068 status = hermon_mcg_init(state); in hermon_hw_init()
2071 hermon_hw_fini(state, cleanup); in hermon_hw_init()
2072 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2080 status = hermon_hca_port_init(state); in hermon_hw_init()
2083 hermon_hw_fini(state, cleanup); in hermon_hw_init()
2084 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2093 status = hermon_getnodeinfo_cmd_post(state, HERMON_CMD_NOSLEEP_SPIN, in hermon_hw_init()
2097 hermon_hw_fini(state, cleanup); in hermon_hw_init()
2098 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2112 if (state->hs_cfg_profile->cp_nodeguid) { in hermon_hw_init()
2113 state->hs_nodeguid = state->hs_cfg_profile->cp_nodeguid; in hermon_hw_init()
2115 state->hs_nodeguid = nodeinfo.NodeGUID; in hermon_hw_init()
2118 if (state->hs_nodeguid != nodeinfo.NodeGUID) { in hermon_hw_init()
2131 if (state->hs_cfg_profile->cp_sysimgguid) { in hermon_hw_init()
2132 state->hs_sysimgguid = state->hs_cfg_profile->cp_sysimgguid; in hermon_hw_init()
2134 state->hs_sysimgguid = nodeinfo.SystemImageGUID; in hermon_hw_init()
2137 if (state->hs_sysimgguid != nodeinfo.SystemImageGUID) { in hermon_hw_init()
2143 status = hermon_getnodedesc_cmd_post(state, HERMON_CMD_NOSLEEP_SPIN, in hermon_hw_init()
2144 (sm_nodedesc_t *)&state->hs_nodedesc); in hermon_hw_init()
2147 hermon_hw_fini(state, cleanup); in hermon_hw_init()
2148 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_hw_init()
2163 hermon_hw_fini(hermon_state_t *state, hermon_drv_cleanup_level_t cleanup) in hermon_hw_fini() argument
2184 num_ports = state->hs_cfg_profile->cp_num_ports; in hermon_hw_fini()
2185 (void) hermon_hca_ports_shutdown(state, num_ports); in hermon_hw_fini()
2190 hermon_mcg_fini(state); in hermon_hw_fini()
2195 hermon_special_qp_contexts_unreserve(state); in hermon_hw_fini()
2204 status = hermon_eq_fini_all(state); in hermon_hw_fini()
2206 HERMON_WARNING(state, "failed to teardown EQs"); in hermon_hw_fini()
2212 hermon_isr_fini(state); in hermon_hw_fini()
2216 status = hermon_intr_or_msi_fini(state); in hermon_hw_fini()
2218 HERMON_WARNING(state, "failed to free intr/MSI"); in hermon_hw_fini()
2225 hermon_internal_uarpg_fini(state); in hermon_hw_fini()
2234 status = hermon_pd_free(state, &state->hs_pdhdl_internal); in hermon_hw_fini()
2236 HERMON_WARNING(state, "failed to free internal PD"); in hermon_hw_fini()
2243 hermon_rsrc_fini(state, HERMON_RSRC_CLEANUP_ALL); in hermon_hw_fini()
2255 status = hermon_unmap_icm_cmd_post(state, NULL); in hermon_hw_fini()
2262 hermon_icm_dma_fini(state); in hermon_hw_fini()
2265 hermon_icm_tables_fini(state); in hermon_hw_fini()
2268 kmem_free(state->hs_icm, HERMON_NUM_ICM_RESOURCES * in hermon_hw_fini()
2277 status = hermon_unmap_icm_aux_cmd_post(state); in hermon_hw_fini()
2288 hermon_dma_free(&state->hs_icma_dma); in hermon_hw_fini()
2292 if (state->hs_fm_uarhdl) { in hermon_hw_fini()
2293 hermon_regs_map_free(state, &state->hs_fm_uarhdl); in hermon_hw_fini()
2294 state->hs_fm_uarhdl = NULL; in hermon_hw_fini()
2297 if (state->hs_reg_uarhdl) { in hermon_hw_fini()
2298 ddi_regs_map_free(&state->hs_reg_uarhdl); in hermon_hw_fini()
2299 state->hs_reg_uarhdl = NULL; in hermon_hw_fini()
2302 if (state->hs_bf_offset != 0 && state->hs_reg_bfhdl) { in hermon_hw_fini()
2303 ddi_regs_map_free(&state->hs_reg_bfhdl); in hermon_hw_fini()
2304 state->hs_reg_bfhdl = NULL; in hermon_hw_fini()
2308 if (state->hs_pkey[i]) { in hermon_hw_fini()
2309 kmem_free(state->hs_pkey[i], (1 << in hermon_hw_fini()
2310 state->hs_cfg_profile->cp_log_max_pkeytbl) * in hermon_hw_fini()
2312 state->hs_pkey[i] = NULL; in hermon_hw_fini()
2314 if (state->hs_guid[i]) { in hermon_hw_fini()
2315 kmem_free(state->hs_guid[i], (1 << in hermon_hw_fini()
2316 state->hs_cfg_profile->cp_log_max_gidtbl) * in hermon_hw_fini()
2318 state->hs_guid[i] = NULL; in hermon_hw_fini()
2327 status = hermon_unmap_fa_cmd_post(state); in hermon_hw_fini()
2337 hermon_dma_free(&state->hs_fw_dma); in hermon_hw_fini()
2342 if (state->hs_fm_poll_thread) { in hermon_hw_fini()
2343 ddi_periodic_delete(state->hs_fm_poll_thread); in hermon_hw_fini()
2344 state->hs_fm_poll_thread = NULL; in hermon_hw_fini()
2350 hermon_rsrc_fini(state, HERMON_RSRC_CLEANUP_PHASE1_COMPLETE); in hermon_hw_fini()
2355 hermon_cfg_profile_fini(state); in hermon_hw_fini()
2363 if (state->hs_reg_msihdl) { in hermon_hw_fini()
2364 ddi_regs_map_free(&state->hs_reg_msihdl); in hermon_hw_fini()
2365 state->hs_reg_msihdl = NULL; in hermon_hw_fini()
2378 HERMON_WARNING(state, "unexpected driver cleanup level"); in hermon_hw_fini()
2389 hermon_soft_state_init(hermon_state_t *state) in hermon_soft_state_init() argument
2405 state->hs_ibtfinfo.hca_ci_vers = IBCI_V4; in hermon_soft_state_init()
2406 state->hs_ibtfinfo.hca_handle = (ibc_hca_hdl_t)state; in hermon_soft_state_init()
2407 state->hs_ibtfinfo.hca_ops = &hermon_ibc_ops; in hermon_soft_state_init()
2410 state->hs_ibtfinfo.hca_attr = hca_attr; in hermon_soft_state_init()
2412 hca_attr->hca_dip = state->hs_dip; in hermon_soft_state_init()
2413 hca_attr->hca_fw_major_version = state->hs_fw.fw_rev_major; in hermon_soft_state_init()
2414 hca_attr->hca_fw_minor_version = state->hs_fw.fw_rev_minor; in hermon_soft_state_init()
2415 hca_attr->hca_fw_micro_version = state->hs_fw.fw_rev_subminor; in hermon_soft_state_init()
2420 hca_attr->hca_max_cq_handlers = state->hs_intrmsi_allocd; in hermon_soft_state_init()
2435 if (state->hs_devlim.ud_multi) { in hermon_soft_state_init()
2438 if (state->hs_devlim.atomic) { in hermon_soft_state_init()
2441 if (state->hs_devlim.apm) { in hermon_soft_state_init()
2444 if (state->hs_devlim.pkey_v) { in hermon_soft_state_init()
2447 if (state->hs_devlim.qkey_v) { in hermon_soft_state_init()
2450 if (state->hs_devlim.ipoib_cksm) { in hermon_soft_state_init()
2454 if (state->hs_devlim.mod_wr_srq) { in hermon_soft_state_init()
2457 if (state->hs_devlim.lif) { in hermon_soft_state_init()
2460 if (state->hs_devlim.reserved_lkey) { in hermon_soft_state_init()
2462 hca_attr->hca_reserved_lkey = state->hs_devlim.rsv_lkey; in hermon_soft_state_init()
2464 if (state->hs_devlim.local_inv && state->hs_devlim.remote_inv && in hermon_soft_state_init()
2465 state->hs_devlim.fast_reg_wr) { /* fw needs to be >= 2.7.000 */ in hermon_soft_state_init()
2466 if ((state->hs_fw.fw_rev_major > 2) || in hermon_soft_state_init()
2467 ((state->hs_fw.fw_rev_major == 2) && in hermon_soft_state_init()
2468 (state->hs_fw.fw_rev_minor >= 7))) in hermon_soft_state_init()
2471 if (state->hs_devlim.log_max_rss_tbl_sz) { in hermon_soft_state_init()
2473 state->hs_devlim.log_max_rss_tbl_sz; in hermon_soft_state_init()
2474 if (state->hs_devlim.rss_xor) in hermon_soft_state_init()
2476 if (state->hs_devlim.rss_toep) in hermon_soft_state_init()
2479 if (state->hs_devlim.mps) { in hermon_soft_state_init()
2482 if (state->hs_devlim.zb) { in hermon_soft_state_init()
2490 if (state->hs_devlim.log_max_gso_sz) { in hermon_soft_state_init()
2492 (1 << state->hs_devlim.log_max_gso_sz); in hermon_soft_state_init()
2495 state->hs_devlim.max_desc_sz_sq - (64 + 4 + 16); in hermon_soft_state_init()
2499 max_send_wqe_bytes = state->hs_devlim.max_desc_sz_sq; in hermon_soft_state_init()
2500 max_recv_wqe_bytes = state->hs_devlim.max_desc_sz_rq; in hermon_soft_state_init()
2516 if (state->hs_devlim.fcoib && (caps2 & IBT_HCA2_MEM_MGT_EXT)) { in hermon_soft_state_init()
2530 hca_attr->hca_vendor_id = state->hs_vendor_id; in hermon_soft_state_init()
2531 hca_attr->hca_device_id = state->hs_device_id; in hermon_soft_state_init()
2532 hca_attr->hca_version_id = state->hs_revision_id; in hermon_soft_state_init()
2540 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_num_qp); in hermon_soft_state_init()
2542 state->hs_devlim.log_rsvd_qp); in hermon_soft_state_init()
2543 maxval = ((uint64_t)1 << state->hs_devlim.log_max_qp_sz); in hermon_soft_state_init()
2544 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_max_qp_sz); in hermon_soft_state_init()
2547 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2562 if (state->hs_devlim.max_sg_rq <= state->hs_devlim.max_sg_sq) { in hermon_soft_state_init()
2563 maxval = state->hs_devlim.max_sg_rq; in hermon_soft_state_init()
2565 maxval = state->hs_devlim.max_sg_sq; in hermon_soft_state_init()
2567 val = state->hs_cfg_profile->cp_wqe_max_sgl; in hermon_soft_state_init()
2570 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2575 if (state->hs_cfg_profile->cp_wqe_real_max_sgl > maxval) { in hermon_soft_state_init()
2576 state->hs_cfg_profile->cp_wqe_real_max_sgl = (uint32_t)maxval; in hermon_soft_state_init()
2579 val = state->hs_cfg_profile->cp_wqe_real_max_sgl; in hermon_soft_state_init()
2591 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_num_cq); in hermon_soft_state_init()
2593 state->hs_devlim.log_rsvd_cq); in hermon_soft_state_init()
2594 maxval = ((uint64_t)1 << state->hs_devlim.log_max_cq_sz); in hermon_soft_state_init()
2595 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_max_cq_sz) - 1; in hermon_soft_state_init()
2598 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2610 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_num_srq); in hermon_soft_state_init()
2612 state->hs_devlim.log_rsvd_srq); in hermon_soft_state_init()
2613 maxval = ((uint64_t)1 << state->hs_devlim.log_max_srq_sz); in hermon_soft_state_init()
2614 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_max_srq_sz); in hermon_soft_state_init()
2618 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2625 maxval = state->hs_devlim.max_sg_rq - 1; in hermon_soft_state_init()
2628 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2649 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_num_dmpt); in hermon_soft_state_init()
2651 state->hs_devlim.log_rsvd_dmpt); in hermon_soft_state_init()
2652 hca_attr->hca_max_mem_win = state->hs_devlim.mem_win ? (val - in hermon_soft_state_init()
2653 ((uint64_t)1 << state->hs_devlim.log_rsvd_dmpt)) : 0; in hermon_soft_state_init()
2654 maxval = state->hs_devlim.log_max_mrw_sz; in hermon_soft_state_init()
2655 val = state->hs_cfg_profile->cp_log_max_mrw_sz; in hermon_soft_state_init()
2658 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2665 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_num_rdb); in hermon_soft_state_init()
2667 val = state->hs_cfg_profile->cp_hca_max_rdma_in_qp; in hermon_soft_state_init()
2669 val = state->hs_cfg_profile->cp_hca_max_rdma_out_qp; in hermon_soft_state_init()
2682 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_num_qp); in hermon_soft_state_init()
2684 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_num_mcg); in hermon_soft_state_init()
2686 val = state->hs_cfg_profile->cp_num_qp_per_mcg; in hermon_soft_state_init()
2690 maxval = ((uint64_t)state->hs_cfg_profile->cp_num_ports << in hermon_soft_state_init()
2691 state->hs_queryport.log_max_pkey); in hermon_soft_state_init()
2692 val = ((uint64_t)state->hs_cfg_profile->cp_num_ports << in hermon_soft_state_init()
2693 state->hs_cfg_profile->cp_log_max_pkeytbl); in hermon_soft_state_init()
2697 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2704 maxval = state->hs_devlim.num_ports; in hermon_soft_state_init()
2705 val = state->hs_cfg_profile->cp_num_ports; in hermon_soft_state_init()
2708 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2715 hca_attr->hca_node_guid = state->hs_nodeguid; in hermon_soft_state_init()
2716 hca_attr->hca_si_guid = state->hs_sysimgguid; in hermon_soft_state_init()
2722 hca_attr->hca_local_ack_delay = state->hs_devlim.ca_ack_delay; in hermon_soft_state_init()
2725 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_max_gidtbl); in hermon_soft_state_init()
2727 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_max_pkeytbl); in hermon_soft_state_init()
2731 maxval = ((uint64_t)1 << state->hs_devlim.log_max_pd); in hermon_soft_state_init()
2732 val = ((uint64_t)1 << state->hs_cfg_profile->cp_log_num_pd); in hermon_soft_state_init()
2735 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2749 mutex_init(&state->hs_uar_lock, NULL, MUTEX_DRIVER, in hermon_soft_state_init()
2750 DDI_INTR_PRI(state->hs_intrmsi_pri)); in hermon_soft_state_init()
2753 state->hs_fw_flashstarted = 0; in hermon_soft_state_init()
2754 mutex_init(&state->hs_fw_flashlock, NULL, MUTEX_DRIVER, in hermon_soft_state_init()
2755 DDI_INTR_PRI(state->hs_intrmsi_pri)); in hermon_soft_state_init()
2758 mutex_init(&state->hs_info_lock, NULL, MUTEX_DRIVER, in hermon_soft_state_init()
2759 DDI_INTR_PRI(state->hs_intrmsi_pri)); in hermon_soft_state_init()
2762 hermon_qpn_avl_init(state); in hermon_soft_state_init()
2765 status = hermon_cq_sched_init(state); in hermon_soft_state_init()
2767 hermon_qpn_avl_fini(state); in hermon_soft_state_init()
2768 mutex_destroy(&state->hs_info_lock); in hermon_soft_state_init()
2769 mutex_destroy(&state->hs_fw_flashlock); in hermon_soft_state_init()
2770 mutex_destroy(&state->hs_uar_lock); in hermon_soft_state_init()
2772 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2778 status = hermon_fcoib_init(state); in hermon_soft_state_init()
2780 hermon_cq_sched_fini(state); in hermon_soft_state_init()
2781 hermon_qpn_avl_fini(state); in hermon_soft_state_init()
2782 mutex_destroy(&state->hs_info_lock); in hermon_soft_state_init()
2783 mutex_destroy(&state->hs_fw_flashlock); in hermon_soft_state_init()
2784 mutex_destroy(&state->hs_uar_lock); in hermon_soft_state_init()
2786 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2792 status = hermon_kstat_init(state); in hermon_soft_state_init()
2794 hermon_fcoib_fini(state); in hermon_soft_state_init()
2795 hermon_cq_sched_fini(state); in hermon_soft_state_init()
2796 hermon_qpn_avl_fini(state); in hermon_soft_state_init()
2797 mutex_destroy(&state->hs_info_lock); in hermon_soft_state_init()
2798 mutex_destroy(&state->hs_fw_flashlock); in hermon_soft_state_init()
2799 mutex_destroy(&state->hs_uar_lock); in hermon_soft_state_init()
2801 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_soft_state_init()
2815 hermon_soft_state_fini(hermon_state_t *state) in hermon_soft_state_fini() argument
2819 hermon_kstat_fini(state); in hermon_soft_state_fini()
2822 hermon_fcoib_fini(state); in hermon_soft_state_fini()
2825 hermon_cq_sched_fini(state); in hermon_soft_state_fini()
2828 hermon_qpn_avl_fini(state); in hermon_soft_state_fini()
2831 mutex_destroy(&state->hs_info_lock); in hermon_soft_state_fini()
2834 mutex_destroy(&state->hs_fw_flashlock); in hermon_soft_state_fini()
2837 mutex_destroy(&state->hs_uar_lock); in hermon_soft_state_fini()
2840 kmem_free(state->hs_ibtfinfo.hca_attr, sizeof (ibt_hca_attr_t)); in hermon_soft_state_fini()
2849 hermon_icm_config_setup(hermon_state_t *state, in hermon_icm_config_setup() argument
2863 devlim = &state->hs_devlim; in hermon_icm_config_setup()
2864 cfg = state->hs_cfg_profile; in hermon_icm_config_setup()
2865 icm = state->hs_icm; in hermon_icm_config_setup()
2887 icm[HERMON_MCG].object_size = HERMON_MCGMEM_SZ(state); in hermon_icm_config_setup()
2909 hermon_icm_tables_init(state); in hermon_icm_config_setup()
2978 hermon_icm_tables_fini(state); in hermon_icm_config_setup()
2982 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_icm_config_setup()
3003 hermon_inithca_set(state, inithca); in hermon_icm_config_setup()
3012 status = hermon_icm_dma_init(state); in hermon_icm_config_setup()
3015 hermon_icm_tables_fini(state); in hermon_icm_config_setup()
3016 HERMON_WARNING(state, "Failed to allocate initial ICM"); in hermon_icm_config_setup()
3017 HERMON_ATTACH_MSG(state->hs_attach_buf, in hermon_icm_config_setup()
3030 hermon_inithca_set(hermon_state_t *state, hermon_hw_initqueryhca_t *inithca) in hermon_inithca_set() argument
3038 icm = state->hs_icm; in hermon_inithca_set()
3039 cfg = state->hs_cfg_profile; in hermon_inithca_set()
3061 if (state->hs_devlim.ipoib_cksm) in hermon_inithca_set()
3126 highbit(HERMON_MCGMEM_SZ(state)) - 1; in hermon_inithca_set()
3211 hermon_icm_tables_init(hermon_state_t *state) in hermon_icm_tables_init() argument
3218 icm = state->hs_icm; in hermon_icm_tables_init()
3290 DDI_INTR_PRI(state->hs_intrmsi_pri)); in hermon_icm_tables_init()
3317 hermon_icm_tables_fini(hermon_state_t *state) in hermon_icm_tables_fini() argument
3324 icm = state->hs_icm; in hermon_icm_tables_fini()
3355 hermon_icm_dma_init(hermon_state_t *state) in hermon_icm_dma_init() argument
3392 icm = &state->hs_icm[type]; in hermon_icm_dma_init()
3395 status = hermon_icm_alloc(state, type, 0, 0); in hermon_icm_dma_init()
3399 icm = &state->hs_icm[type]; in hermon_icm_dma_init()
3401 hermon_icm_free(state, type, 0, 0); in hermon_icm_dma_init()
3423 hermon_icm_dma_fini(hermon_state_t *state) in hermon_icm_dma_fini() argument
3432 icm = &state->hs_icm[type]; in hermon_icm_dma_fini()
3452 hermon_hca_port_init(hermon_state_t *state) in hermon_hca_port_init() argument
3462 cfgprof = state->hs_cfg_profile; in hermon_hca_port_init()
3486 bzero(&state->hs_queryport, sizeof (hermon_hw_query_port_t)); in hermon_hca_port_init()
3487 status = hermon_cmn_query_cmd_post(state, QUERY_PORT, 0, in hermon_hca_port_init()
3488 (i + 1), &state->hs_queryport, in hermon_hca_port_init()
3496 state->hs_initport = &portinits[i]; in hermon_hca_port_init()
3531 maxval = state->hs_queryport.ib_mtu; in hermon_hca_port_init()
3542 maxval = state->hs_queryport.ib_port_wid; in hermon_hca_port_init()
3549 maxval = state->hs_queryport.max_vl; in hermon_hca_port_init()
3560 maxval = ((uint64_t)1 << state->hs_queryport.log_max_gid); in hermon_hca_port_init()
3569 maxval = ((uint64_t)1 << state->hs_queryport.log_max_pkey); in hermon_hca_port_init()
3580 status = hermon_set_port_cmd_post(state, initport, i + 1, in hermon_hca_port_init()
3591 status = hermon_set_port_cmd_post(state, initport, i + 1, in hermon_hca_port_init()
3606 status = hermon_init_port_cmd_post(state, i + 1, in hermon_hca_port_init()
3625 (void) hermon_hca_ports_shutdown(state, i); in hermon_hca_port_init()
3636 hermon_hca_ports_shutdown(hermon_state_t *state, uint_t num_init) in hermon_hca_ports_shutdown() argument
3648 status = hermon_close_port_cmd_post(state, i + 1, in hermon_hca_ports_shutdown()
3651 HERMON_WARNING(state, "failed to shutdown HCA port"); in hermon_hca_ports_shutdown()
3664 hermon_internal_uarpg_init(hermon_state_t *state) in hermon_internal_uarpg_init() argument
3679 status = hermon_rsrc_alloc(state, HERMON_UARPG, 1, HERMON_SLEEP, in hermon_internal_uarpg_init()
3680 &state->hs_uarkpg_rsrc); in hermon_internal_uarpg_init()
3686 state->hs_uar = (hermon_hw_uar_t *)state->hs_uarkpg_rsrc->hr_addr; in hermon_internal_uarpg_init()
3689 status = hermon_dbr_page_alloc(state, &info); in hermon_internal_uarpg_init()
3693 state->hs_kern_dbr = info; in hermon_internal_uarpg_init()
3703 hermon_internal_uarpg_fini(hermon_state_t *state) in hermon_internal_uarpg_fini() argument
3706 hermon_rsrc_free(state, &state->hs_uarkpg_rsrc); in hermon_internal_uarpg_fini()
3715 hermon_special_qp_contexts_reserve(hermon_state_t *state) in hermon_special_qp_contexts_reserve() argument
3721 mutex_init(&state->hs_spec_qplock, NULL, MUTEX_DRIVER, in hermon_special_qp_contexts_reserve()
3722 DDI_INTR_PRI(state->hs_intrmsi_pri)); in hermon_special_qp_contexts_reserve()
3730 status = hermon_rsrc_alloc(state, HERMON_QPC, 2, in hermon_special_qp_contexts_reserve()
3733 mutex_destroy(&state->hs_spec_qplock); in hermon_special_qp_contexts_reserve()
3736 state->hs_spec_qp0 = qp0_rsrc; in hermon_special_qp_contexts_reserve()
3744 status = hermon_rsrc_alloc(state, HERMON_QPC, 2, in hermon_special_qp_contexts_reserve()
3747 hermon_rsrc_free(state, &qp0_rsrc); in hermon_special_qp_contexts_reserve()
3748 mutex_destroy(&state->hs_spec_qplock); in hermon_special_qp_contexts_reserve()
3751 state->hs_spec_qp1 = qp1_rsrc; in hermon_special_qp_contexts_reserve()
3753 status = hermon_rsrc_alloc(state, HERMON_QPC, 4, in hermon_special_qp_contexts_reserve()
3756 hermon_rsrc_free(state, &qp1_rsrc); in hermon_special_qp_contexts_reserve()
3757 hermon_rsrc_free(state, &qp0_rsrc); in hermon_special_qp_contexts_reserve()
3758 mutex_destroy(&state->hs_spec_qplock); in hermon_special_qp_contexts_reserve()
3761 state->hs_spec_qp_unused = qp_resvd; in hermon_special_qp_contexts_reserve()
3772 hermon_special_qp_contexts_unreserve(hermon_state_t *state) in hermon_special_qp_contexts_unreserve() argument
3776 hermon_rsrc_free(state, &state->hs_spec_qp_unused); in hermon_special_qp_contexts_unreserve()
3779 hermon_rsrc_free(state, &state->hs_spec_qp1); in hermon_special_qp_contexts_unreserve()
3782 hermon_rsrc_free(state, &state->hs_spec_qp0); in hermon_special_qp_contexts_unreserve()
3785 mutex_destroy(&state->hs_spec_qplock); in hermon_special_qp_contexts_unreserve()
3795 hermon_sw_reset(hermon_state_t *state) in hermon_sw_reset() argument
3797 ddi_acc_handle_t hdl = hermon_get_pcihdl(state); in hermon_sw_reset()
3798 ddi_acc_handle_t cmdhdl = hermon_get_cmdhdl(state); in hermon_sw_reset()
3814 reset_delay = state->hs_cfg_profile->cp_sw_reset_delay; in hermon_sw_reset()
3820 hermon_pio_start(state, cmdhdl, pio_error, fm_loop_cnt, fm_status, in hermon_sw_reset()
3822 hermon_pio_start(state, hdl, pio_error2, fm_loop_cnt2, fm_status2, in hermon_sw_reset()
3827 status = hermon_pci_capability_list(state, hdl); in hermon_sw_reset()
3848 sem = ddi_get32(cmdhdl, state->hs_cmd_regs.sw_semaphore); in hermon_sw_reset()
3862 hermon_pci_config_teardown(state, &hdl); in hermon_sw_reset()
3866 (void *)state->hs_cmd_regs.sw_semaphore); in hermon_sw_reset()
3868 hermon_fm_ereport(state, HCA_IBA_ERR, HCA_ERR_NON_FATAL); in hermon_sw_reset()
3875 state->hs_cfg_data[i] = pci_config_get32(hdl, i << 2); in hermon_sw_reset()
3882 ddi_put32(cmdhdl, state->hs_cmd_regs.sw_reset, HERMON_SW_RESET_START); in hermon_sw_reset()
3911 pci_config_put32(hdl, i << 2, state->hs_cfg_data[i]); in hermon_sw_reset()
3919 offset = state->hs_pci_cap_offset; in hermon_sw_reset()
3920 data32 = state->hs_pci_cap_devctl; in hermon_sw_reset()
3922 data32 = state->hs_pci_cap_lnkctl; in hermon_sw_reset()
3925 pci_config_put32(hdl, 0x04, (state->hs_cfg_data[1] | 0x0006)); in hermon_sw_reset()
3928 hermon_pio_end(state, hdl, pio_error2, fm_loop_cnt2, fm_status2, in hermon_sw_reset()
3930 hermon_pio_end(state, cmdhdl, pio_error, fm_loop_cnt, fm_status, in hermon_sw_reset()
3938 hermon_fm_ereport(state, HCA_SYS_ERR, HCA_ERR_NON_FATAL); in hermon_sw_reset()
3948 hermon_mcg_init(hermon_state_t *state) in hermon_mcg_init() argument
3957 mcg_tmp_sz = HERMON_MCGMEM_SZ(state); in hermon_mcg_init()
3958 state->hs_mcgtmp = kmem_zalloc(mcg_tmp_sz, KM_SLEEP); in hermon_mcg_init()
3965 mutex_init(&state->hs_mcglock, NULL, MUTEX_DRIVER, in hermon_mcg_init()
3966 DDI_INTR_PRI(state->hs_intrmsi_pri)); in hermon_mcg_init()
3977 hermon_mcg_fini(hermon_state_t *state) in hermon_mcg_fini() argument
3983 mcg_tmp_sz = HERMON_MCGMEM_SZ(state); in hermon_mcg_fini()
3984 kmem_free(state->hs_mcgtmp, mcg_tmp_sz); in hermon_mcg_fini()
3987 mutex_destroy(&state->hs_mcglock); in hermon_mcg_fini()
3997 hermon_fw_version_check(hermon_state_t *state) in hermon_fw_version_check() argument
4015 switch (state->hs_operational_mode) { in hermon_fw_version_check()
4031 if (state->hs_fw.fw_rev_major < hermon_fw_ver_major) { in hermon_fw_version_check()
4033 } else if (state->hs_fw.fw_rev_major > hermon_fw_ver_major) { in hermon_fw_version_check()
4041 if (state->hs_fw.fw_rev_minor < hermon_fw_ver_minor) { in hermon_fw_version_check()
4043 } else if (state->hs_fw.fw_rev_minor > hermon_fw_ver_minor) { in hermon_fw_version_check()
4052 if (state->hs_fw.fw_rev_subminor < hermon_fw_ver_subminor) { in hermon_fw_version_check()
4054 } else if (state->hs_fw.fw_rev_subminor > hermon_fw_ver_subminor) { in hermon_fw_version_check()
4067 hermon_device_info_report(hermon_state_t *state) in hermon_device_info_report() argument
4071 "HW rev: %02d\n", state->hs_instance, state->hs_fw.fw_rev_major, in hermon_device_info_report()
4072 state->hs_fw.fw_rev_minor, state->hs_fw.fw_rev_subminor, in hermon_device_info_report()
4073 state->hs_revision_id); in hermon_device_info_report()
4075 state->hs_instance, state->hs_nodedesc, state->hs_nodeguid); in hermon_device_info_report()
4085 hermon_pci_capability_list(hermon_state_t *state, ddi_acc_handle_t hdl) in hermon_pci_capability_list() argument
4090 state->hs_pci_cap_offset = 0; /* make sure it's cleared */ in hermon_pci_capability_list()
4135 hermon_pci_capability_vpd(state, hdl, offset); in hermon_pci_capability_list()
4138 hermon_pci_capability_vpd(state, hdl, offset); in hermon_pci_capability_list()
4146 state->hs_pci_cap_offset = offset; in hermon_pci_capability_list()
4149 state->hs_pci_cap_devctl = data32; in hermon_pci_capability_list()
4152 state->hs_pci_cap_lnkctl = data32; in hermon_pci_capability_list()
4220 hermon_pci_capability_vpd(hermon_state_t *state, ddi_acc_handle_t hdl, in hermon_pci_capability_vpd() argument
4268 if (name_length > sizeof (state->hs_hca_name)) { in hermon_pci_capability_vpd()
4273 (void) memcpy(state->hs_hca_name, &vpd.vpd_char[vpd_str_id + 3], in hermon_pci_capability_vpd()
4275 state->hs_hca_name[name_length] = 0; in hermon_pci_capability_vpd()
4290 if (pn_length > sizeof (state->hs_hca_pn)) { in hermon_pci_capability_vpd()
4295 (void) memcpy(state->hs_hca_pn, in hermon_pci_capability_vpd()
4298 state->hs_hca_pn[pn_length] = 0; in hermon_pci_capability_vpd()
4299 state->hs_hca_pn_len = pn_length; in hermon_pci_capability_vpd()
4300 cmn_err(CE_CONT, "!vpd %s\n", state->hs_hca_pn); in hermon_pci_capability_vpd()
4309 state->hs_hca_pn_len = 0; in hermon_pci_capability_vpd()
4319 hermon_intr_or_msi_init(hermon_state_t *state) in hermon_intr_or_msi_init() argument
4324 status = ddi_intr_get_supported_types(state->hs_dip, in hermon_intr_or_msi_init()
4325 &state->hs_intr_types_avail); in hermon_intr_or_msi_init()
4337 if ((state->hs_cfg_profile->cp_use_msi_if_avail != 0) && in hermon_intr_or_msi_init()
4338 (state->hs_intr_types_avail & DDI_INTR_TYPE_MSIX)) { in hermon_intr_or_msi_init()
4339 status = hermon_add_intrs(state, DDI_INTR_TYPE_MSIX); in hermon_intr_or_msi_init()
4341 state->hs_intr_type_chosen = DDI_INTR_TYPE_MSIX; in hermon_intr_or_msi_init()
4354 if ((state->hs_cfg_profile->cp_use_msi_if_avail != 0) && in hermon_intr_or_msi_init()
4355 (state->hs_intr_types_avail & DDI_INTR_TYPE_MSI)) { in hermon_intr_or_msi_init()
4356 status = hermon_add_intrs(state, DDI_INTR_TYPE_MSI); in hermon_intr_or_msi_init()
4358 state->hs_intr_type_chosen = DDI_INTR_TYPE_MSI; in hermon_intr_or_msi_init()
4367 if (state->hs_intr_types_avail & DDI_INTR_TYPE_FIXED) { in hermon_intr_or_msi_init()
4368 status = hermon_add_intrs(state, DDI_INTR_TYPE_FIXED); in hermon_intr_or_msi_init()
4370 state->hs_intr_type_chosen = DDI_INTR_TYPE_FIXED; in hermon_intr_or_msi_init()
4387 hermon_state_t *state = (hermon_state_t *)arg1; in hermon_intr_cb_handler() local
4390 "action %d, cbarg %d\n", state->hs_instance, action, in hermon_intr_cb_handler()
4400 hermon_add_intrs(hermon_state_t *state, int intr_type) in hermon_add_intrs() argument
4404 if (state->hs_intr_cb_hdl == NULL) { in hermon_add_intrs()
4405 status = ddi_cb_register(state->hs_dip, DDI_CB_FLAG_INTR, in hermon_add_intrs()
4406 hermon_intr_cb_handler, state, NULL, in hermon_add_intrs()
4407 &state->hs_intr_cb_hdl); in hermon_add_intrs()
4411 state->hs_intr_cb_hdl = NULL; in hermon_add_intrs()
4417 status = ddi_intr_get_nintrs(state->hs_dip, intr_type, in hermon_add_intrs()
4418 &state->hs_intrmsi_count); in hermon_add_intrs()
4420 (void) ddi_cb_unregister(state->hs_intr_cb_hdl); in hermon_add_intrs()
4421 state->hs_intr_cb_hdl = NULL; in hermon_add_intrs()
4426 status = ddi_intr_get_navail(state->hs_dip, intr_type, in hermon_add_intrs()
4427 &state->hs_intrmsi_avail); in hermon_add_intrs()
4429 (void) ddi_cb_unregister(state->hs_intr_cb_hdl); in hermon_add_intrs()
4430 state->hs_intr_cb_hdl = NULL; in hermon_add_intrs()
4435 if ((state->hs_intrmsi_avail < 1) || (state->hs_intrmsi_count < 1)) { in hermon_add_intrs()
4436 (void) ddi_cb_unregister(state->hs_intr_cb_hdl); in hermon_add_intrs()
4437 state->hs_intr_cb_hdl = NULL; in hermon_add_intrs()
4449 status = ddi_intr_alloc(state->hs_dip, &state->hs_intrmsi_hdl[0], in hermon_add_intrs()
4450 intr_type, 0, min(min(HERMON_MSIX_MAX, state->hs_intrmsi_avail), in hermon_add_intrs()
4451 hermon_msix_max), &state->hs_intrmsi_allocd, DDI_INTR_ALLOC_NORMAL); in hermon_add_intrs()
4453 (void) ddi_cb_unregister(state->hs_intr_cb_hdl); in hermon_add_intrs()
4454 state->hs_intr_cb_hdl = NULL; in hermon_add_intrs()
4459 if (state->hs_intrmsi_allocd < 1) { in hermon_add_intrs()
4460 (void) ddi_cb_unregister(state->hs_intr_cb_hdl); in hermon_add_intrs()
4461 state->hs_intr_cb_hdl = NULL; in hermon_add_intrs()
4469 status = ddi_intr_get_pri(state->hs_intrmsi_hdl[0], in hermon_add_intrs()
4470 &state->hs_intrmsi_pri); in hermon_add_intrs()
4473 (void) ddi_intr_free(state->hs_intrmsi_hdl[0]); in hermon_add_intrs()
4475 (void) ddi_cb_unregister(state->hs_intr_cb_hdl); in hermon_add_intrs()
4476 state->hs_intr_cb_hdl = NULL; in hermon_add_intrs()
4481 if (state->hs_intrmsi_pri >= ddi_intr_get_hilevel_pri()) { in hermon_add_intrs()
4483 (void) ddi_intr_free(state->hs_intrmsi_hdl[0]); in hermon_add_intrs()
4489 status = ddi_intr_get_cap(state->hs_intrmsi_hdl[0], in hermon_add_intrs()
4490 &state->hs_intrmsi_cap); in hermon_add_intrs()
4493 (void) ddi_intr_free(state->hs_intrmsi_hdl[0]); in hermon_add_intrs()
4507 hermon_intr_or_msi_fini(hermon_state_t *state) in hermon_intr_or_msi_fini() argument
4512 for (intr = 0; intr < state->hs_intrmsi_allocd; intr++) { in hermon_intr_or_msi_fini()
4515 status = ddi_intr_free(state->hs_intrmsi_hdl[intr]); in hermon_intr_or_msi_fini()
4520 if (state->hs_intr_cb_hdl) { in hermon_intr_or_msi_fini()
4521 (void) ddi_cb_unregister(state->hs_intr_cb_hdl); in hermon_intr_or_msi_fini()
4522 state->hs_intr_cb_hdl = NULL; in hermon_intr_or_msi_fini()
4530 hermon_pci_capability_msix(hermon_state_t *state, ddi_acc_handle_t hdl, in hermon_pci_capability_msix() argument
4568 msix_data = ddi_get32(state->hs_reg_msihdl, in hermon_pci_capability_msix()
4569 (uint32_t *)((uintptr_t)state->hs_reg_msi_baseaddr in hermon_pci_capability_msix()
4590 hermon_state_t *state = ddi_get_soft_state(hermon_statep, in get_msix_ctrl() local
4592 ddi_acc_handle_t pci_cfg_hdl = hermon_get_pcihdl(state); in get_msix_ctrl()
4629 hermon_set_msix_info(hermon_state_t *state) in hermon_set_msix_info() argument
4651 ddi_acc_handle_t pci_cfg_hdl = hermon_get_pcihdl(state); in hermon_set_msix_info()
4662 state->hs_msix_tbl_offset = PCI_CAP_GET32(pci_cfg_hdl, 0, caps_ctrl, in hermon_set_msix_info()
4666 breg = pci_msix_bir_index[state->hs_msix_tbl_offset & in hermon_set_msix_info()
4671 state->hs_msix_tbl_offset = state->hs_msix_tbl_offset & in hermon_set_msix_info()
4675 state->hs_msix_tbl_size = ((msix_ctrl & PCI_MSIX_TBL_SIZE_MASK) + 1) * in hermon_set_msix_info()
4678 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, state->hs_dip, in hermon_set_msix_info()
4698 state->hs_msix_tbl_rnumber = rnumber; in hermon_set_msix_info()
4701 dev_attr.devacc_attr_version = hermon_devacc_attr_version(state); in hermon_set_msix_info()
4702 dev_attr.devacc_attr_access = hermon_devacc_attr_access(state); in hermon_set_msix_info()
4705 if (hermon_regs_map_setup(state, state->hs_msix_tbl_rnumber, in hermon_set_msix_info()
4706 (caddr_t *)&state->hs_msix_tbl_addr, state->hs_msix_tbl_offset, in hermon_set_msix_info()
4707 state->hs_msix_tbl_size, &dev_attr, in hermon_set_msix_info()
4708 &state->hs_fm_msix_tblhdl) != DDI_SUCCESS) { in hermon_set_msix_info()
4712 state->hs_msix_pba_offset = PCI_CAP_GET32(pci_cfg_hdl, 0, caps_ctrl, in hermon_set_msix_info()
4716 breg = pci_msix_bir_index[state->hs_msix_pba_offset & in hermon_set_msix_info()
4721 state->hs_msix_pba_offset = state->hs_msix_pba_offset & in hermon_set_msix_info()
4725 state->hs_msix_pba_size = in hermon_set_msix_info()
4741 state->hs_msix_pba_rnumber = rnumber; in hermon_set_msix_info()
4745 if (hermon_regs_map_setup(state, state->hs_msix_pba_rnumber, in hermon_set_msix_info()
4746 (caddr_t *)&state->hs_msix_pba_addr, state->hs_msix_pba_offset, in hermon_set_msix_info()
4747 state->hs_msix_pba_size, &dev_attr, in hermon_set_msix_info()
4748 &state->hs_fm_msix_pbahdl) != DDI_SUCCESS) { in hermon_set_msix_info()
4749 hermon_regs_map_free(state, &state->hs_fm_msix_tblhdl); in hermon_set_msix_info()
4750 state->hs_fm_msix_tblhdl = NULL; in hermon_set_msix_info()
4755 state->hs_msix_tbl_entries = kmem_alloc(state->hs_msix_tbl_size, in hermon_set_msix_info()
4759 state->hs_msix_pba_entries = kmem_alloc(state->hs_msix_pba_size, in hermon_set_msix_info()
4765 hermon_intr_disable(hermon_state_t *state) in hermon_intr_disable() argument
4768 ddi_acc_handle_t pci_cfg_hdl = hermon_get_pcihdl(state); in hermon_intr_disable()
4769 ddi_acc_handle_t msix_tblhdl = hermon_get_msix_tblhdl(state); in hermon_intr_disable()
4772 ASSERT(state->hs_intr_types_avail & in hermon_intr_disable()
4780 if ((state->hs_cfg_profile->cp_use_msi_if_avail != 0) && in hermon_intr_disable()
4781 (state->hs_intr_types_avail & DDI_INTR_TYPE_MSIX)) { in hermon_intr_disable()
4795 for (i = 0; i < get_msix_tbl_size(state->hs_dip); in hermon_intr_disable()
4798 char *addr = state->hs_msix_tbl_addr + i + j; in hermon_intr_disable()
4811 ASSERT(state->hs_intr_types_avail & DDI_INTR_TYPE_FIXED); in hermon_intr_disable()
4825 hermon_state_t *state = ddi_get_soft_state(hermon_statep, in hermon_quiesce() local
4827 ddi_acc_handle_t pcihdl = hermon_get_pcihdl(state); in hermon_quiesce()
4828 ddi_acc_handle_t cmdhdl = hermon_get_cmdhdl(state); in hermon_quiesce()
4829 ddi_acc_handle_t msix_tbl_hdl = hermon_get_msix_tblhdl(state); in hermon_quiesce()
4830 ddi_acc_handle_t msix_pba_hdl = hermon_get_msix_pbahdl(state); in hermon_quiesce()
4831 uint32_t sem, reset_delay = state->hs_cfg_profile->cp_sw_reset_delay; in hermon_quiesce()
4837 ASSERT(state != NULL); in hermon_quiesce()
4840 state->hs_quiescing = B_TRUE; in hermon_quiesce()
4843 if (!HERMON_IS_OPERATIONAL(state->hs_operational_mode)) { in hermon_quiesce()
4848 if (hermon_get_state(state) & HCA_EREPORT_FM) { in hermon_quiesce()
4849 hermon_clr_state_nolock(state, HCA_EREPORT_FM); in hermon_quiesce()
4853 if (hermon_hca_ports_shutdown(state, in hermon_quiesce()
4854 state->hs_cfg_profile->cp_num_ports) != HERMON_CMD_SUCCESS) { in hermon_quiesce()
4855 state->hs_quiescing = B_FALSE; in hermon_quiesce()
4860 if (hermon_close_hca_cmd_post(state, HERMON_CMD_NOSLEEP_SPIN) != in hermon_quiesce()
4862 state->hs_quiescing = B_FALSE; in hermon_quiesce()
4867 if (hermon_intr_disable(state) != DDI_SUCCESS) { in hermon_quiesce()
4868 state->hs_quiescing = B_FALSE; in hermon_quiesce()
4876 if (hermon_pci_capability_list(state, pcihdl) != DDI_SUCCESS) { in hermon_quiesce()
4877 state->hs_quiescing = B_FALSE; in hermon_quiesce()
4895 sem = ddi_get32(cmdhdl, state->hs_cmd_regs.sw_semaphore); in hermon_quiesce()
4905 state->hs_quiescing = B_FALSE; in hermon_quiesce()
4912 for (i = 0; i < get_msix_tbl_size(state->hs_dip); in hermon_quiesce()
4915 char *addr = state->hs_msix_tbl_addr + i + j; in hermon_quiesce()
4918 *(uint32_t *)(uintptr_t)(state-> in hermon_quiesce()
4923 for (i = 0; i < get_msix_pba_size(state->hs_dip); i += 8) { in hermon_quiesce()
4924 char *addr = state->hs_msix_pba_addr + i; in hermon_quiesce()
4927 *(uint64_t *)(uintptr_t)(state-> in hermon_quiesce()
4936 state->hs_cfg_data[i] = in hermon_quiesce()
4942 ddi_put32(cmdhdl, state->hs_cmd_regs.sw_reset, HERMON_SW_RESET_START); in hermon_quiesce()
4959 state->hs_quiescing = B_FALSE; in hermon_quiesce()
4968 pci_config_put32(pcihdl, i << 2, state->hs_cfg_data[i]); in hermon_quiesce()
4975 for (i = 0; i < get_msix_pba_size(state->hs_dip); i += 8) { in hermon_quiesce()
4976 char *addr = state->hs_msix_pba_addr + i; in hermon_quiesce()
4978 (state->hs_msix_pba_entries + i); in hermon_quiesce()
4983 for (i = 0; i < get_msix_tbl_size(state->hs_dip); in hermon_quiesce()
4986 char *addr = state->hs_msix_tbl_addr + i + j; in hermon_quiesce()
4988 (state->hs_msix_tbl_entries + i + j); in hermon_quiesce()
4999 offset = state->hs_pci_cap_offset; in hermon_quiesce()
5000 data32 = state->hs_pci_cap_devctl; in hermon_quiesce()
5002 data32 = state->hs_pci_cap_lnkctl; in hermon_quiesce()
5006 pci_config_put32(pcihdl, 0x04, (state->hs_cfg_data[1] | 0x0006)); in hermon_quiesce()