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