Lines Matching refs:mlxp
474 mlxcx_load_prop_defaults(mlxcx_t *mlxp) in mlxcx_load_prop_defaults() argument
476 mlxcx_drv_props_t *p = &mlxp->mlx_props; in mlxcx_load_prop_defaults()
477 mlxcx_port_t *port = &mlxp->mlx_ports[0]; in mlxcx_load_prop_defaults()
479 VERIFY((mlxp->mlx_attach & MLXCX_ATTACH_PORTS) != 0); in mlxcx_load_prop_defaults()
480 VERIFY((mlxp->mlx_attach & (MLXCX_ATTACH_CQS | MLXCX_ATTACH_WQS)) == 0); in mlxcx_load_prop_defaults()
503 mlxcx_warn(mlxp, "Encountered a port with a speed we don't " in mlxcx_load_prop_defaults()
516 mlxcx_load_model_props(mlxcx_t *mlxp) in mlxcx_load_model_props() argument
518 mlxcx_drv_props_t *p = &mlxp->mlx_props; in mlxcx_load_model_props()
520 mlxcx_load_prop_defaults(mlxp); in mlxcx_load_model_props()
522 p->mldp_cq_size_shift = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_model_props()
525 p->mldp_sq_size_shift = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_model_props()
528 p->mldp_rq_size_shift = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_model_props()
534 mlxcx_load_props(mlxcx_t *mlxp) in mlxcx_load_props() argument
536 mlxcx_drv_props_t *p = &mlxp->mlx_props; in mlxcx_load_props()
538 p->mldp_eq_size_shift = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
541 p->mldp_cqemod_period_usec = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
544 p->mldp_cqemod_count = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
547 p->mldp_intrmod_period_usec = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
551 p->mldp_tx_ngroups = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
554 p->mldp_tx_nrings_per_group = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
558 p->mldp_rx_ngroups_large = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
561 p->mldp_rx_ngroups_small = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
565 mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS, in mlxcx_load_props()
568 mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS, in mlxcx_load_props()
571 p->mldp_ftbl_root_size_shift = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
575 p->mldp_tx_bind_threshold = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
579 p->mldp_ftbl_vlan_size_shift = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
584 mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS, in mlxcx_load_props()
587 mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS, in mlxcx_load_props()
590 mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS, in mlxcx_load_props()
593 p->mldp_rx_per_cq = ddi_getprop(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_load_props()
599 mlxcx_warn(mlxp, "!rx_limit_per_completion = %u is " in mlxcx_load_props()
607 mlxp->mlx_dip, DDI_PROP_CANSLEEP | DDI_PROP_DONTPASS, in mlxcx_load_props()
612 mlxcx_note(mlxcx_t *mlxp, const char *fmt, ...) in mlxcx_note() argument
617 if (mlxp != NULL && mlxp->mlx_dip != NULL) { in mlxcx_note()
618 vdev_err(mlxp->mlx_dip, CE_NOTE, fmt, ap); in mlxcx_note()
626 mlxcx_warn(mlxcx_t *mlxp, const char *fmt, ...) in mlxcx_warn() argument
631 if (mlxp != NULL && mlxp->mlx_dip != NULL) { in mlxcx_warn()
632 vdev_err(mlxp->mlx_dip, CE_WARN, fmt, ap); in mlxcx_warn()
640 mlxcx_panic(mlxcx_t *mlxp, const char *fmt, ...) in mlxcx_panic() argument
645 if (mlxp != NULL && mlxp->mlx_dip != NULL) { in mlxcx_panic()
646 vdev_err(mlxp->mlx_dip, CE_PANIC, fmt, ap); in mlxcx_panic()
654 mlxcx_get16(mlxcx_t *mlxp, uintptr_t off) in mlxcx_get16() argument
656 uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base; in mlxcx_get16()
657 return (ddi_get16(mlxp->mlx_regs_handle, (void *)addr)); in mlxcx_get16()
661 mlxcx_get32(mlxcx_t *mlxp, uintptr_t off) in mlxcx_get32() argument
663 uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base; in mlxcx_get32()
664 return (ddi_get32(mlxp->mlx_regs_handle, (void *)addr)); in mlxcx_get32()
668 mlxcx_get64(mlxcx_t *mlxp, uintptr_t off) in mlxcx_get64() argument
670 uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base; in mlxcx_get64()
671 return (ddi_get64(mlxp->mlx_regs_handle, (void *)addr)); in mlxcx_get64()
675 mlxcx_put32(mlxcx_t *mlxp, uintptr_t off, uint32_t val) in mlxcx_put32() argument
677 uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base; in mlxcx_put32()
678 ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val); in mlxcx_put32()
682 mlxcx_put64(mlxcx_t *mlxp, uintptr_t off, uint64_t val) in mlxcx_put64() argument
684 uintptr_t addr = off + (uintptr_t)mlxp->mlx_regs_base; in mlxcx_put64()
685 ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val); in mlxcx_put64()
689 mlxcx_uar_put32(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint32_t val) in mlxcx_uar_put32() argument
696 (uintptr_t)mlxp->mlx_regs_base; in mlxcx_uar_put32()
697 ddi_put32(mlxp->mlx_regs_handle, (void *)addr, val); in mlxcx_uar_put32()
701 mlxcx_uar_put64(mlxcx_t *mlxp, mlxcx_uar_t *mlu, uintptr_t off, uint64_t val) in mlxcx_uar_put64() argument
704 (uintptr_t)mlxp->mlx_regs_base; in mlxcx_uar_put64()
705 ddi_put64(mlxp->mlx_regs_handle, (void *)addr, val); in mlxcx_uar_put64()
709 mlxcx_fm_fini(mlxcx_t *mlxp) in mlxcx_fm_fini() argument
711 if (mlxp->mlx_fm_caps == 0) in mlxcx_fm_fini()
714 if (DDI_FM_ERRCB_CAP(mlxp->mlx_fm_caps)) in mlxcx_fm_fini()
715 ddi_fm_handler_unregister(mlxp->mlx_dip); in mlxcx_fm_fini()
717 if (DDI_FM_EREPORT_CAP(mlxp->mlx_fm_caps) || in mlxcx_fm_fini()
718 DDI_FM_ERRCB_CAP(mlxp->mlx_fm_caps)) in mlxcx_fm_fini()
719 pci_ereport_teardown(mlxp->mlx_dip); in mlxcx_fm_fini()
721 ddi_fm_fini(mlxp->mlx_dip); in mlxcx_fm_fini()
723 mlxp->mlx_fm_caps = 0; in mlxcx_fm_fini()
727 mlxcx_fm_ereport(mlxcx_t *mlxp, const char *detail) in mlxcx_fm_ereport() argument
732 if (!DDI_FM_EREPORT_CAP(mlxp->mlx_fm_caps)) in mlxcx_fm_ereport()
737 ddi_fm_ereport_post(mlxp->mlx_dip, buf, ena, DDI_NOSLEEP, in mlxcx_fm_ereport()
754 mlxcx_fm_init(mlxcx_t *mlxp) in mlxcx_fm_init() argument
760 mlxp->mlx_fm_caps = ddi_prop_get_int(DDI_DEV_T_ANY, mlxp->mlx_dip, in mlxcx_fm_init()
763 if (mlxp->mlx_fm_caps < 0) { in mlxcx_fm_init()
764 mlxp->mlx_fm_caps = 0; in mlxcx_fm_init()
766 mlxp->mlx_fm_caps &= def; in mlxcx_fm_init()
768 if (mlxp->mlx_fm_caps == 0) in mlxcx_fm_init()
771 ddi_fm_init(mlxp->mlx_dip, &mlxp->mlx_fm_caps, &iblk); in mlxcx_fm_init()
772 if (DDI_FM_EREPORT_CAP(mlxp->mlx_fm_caps) || in mlxcx_fm_init()
773 DDI_FM_ERRCB_CAP(mlxp->mlx_fm_caps)) { in mlxcx_fm_init()
774 pci_ereport_setup(mlxp->mlx_dip); in mlxcx_fm_init()
776 if (DDI_FM_ERRCB_CAP(mlxp->mlx_fm_caps)) { in mlxcx_fm_init()
777 ddi_fm_handler_register(mlxp->mlx_dip, mlxcx_fm_errcb, in mlxcx_fm_init()
778 (void *)mlxp); in mlxcx_fm_init()
783 mlxcx_mlbs_teardown(mlxcx_t *mlxp, mlxcx_buf_shard_t *s) in mlxcx_mlbs_teardown() argument
796 mlxcx_buf_destroy(mlxp, buf); in mlxcx_mlbs_teardown()
808 mlxcx_teardown_bufs(mlxcx_t *mlxp) in mlxcx_teardown_bufs() argument
812 while ((s = list_remove_head(&mlxp->mlx_buf_shards)) != NULL) { in mlxcx_teardown_bufs()
813 mlxcx_mlbs_teardown(mlxp, s); in mlxcx_teardown_bufs()
816 list_destroy(&mlxp->mlx_buf_shards); in mlxcx_teardown_bufs()
818 kmem_cache_destroy(mlxp->mlx_bufs_cache); in mlxcx_teardown_bufs()
822 mlxcx_teardown_pages(mlxcx_t *mlxp) in mlxcx_teardown_pages() argument
830 mutex_enter(&mlxp->mlx_pagemtx); in mlxcx_teardown_pages()
832 while (mlxp->mlx_npages > 0) { in mlxcx_teardown_pages()
835 ASSERT0(avl_is_empty(&mlxp->mlx_pages)); in mlxcx_teardown_pages()
836 req = MIN(mlxp->mlx_npages, MLXCX_MANAGE_PAGES_MAX_PAGES); in mlxcx_teardown_pages()
838 if (!mlxcx_cmd_return_pages(mlxp, req, pas, &ret)) { in mlxcx_teardown_pages()
839 mlxcx_warn(mlxp, "hardware refused to return pages, " in mlxcx_teardown_pages()
840 "leaking %u remaining pages", mlxp->mlx_npages); in mlxcx_teardown_pages()
849 mdp = avl_find(&mlxp->mlx_pages, &probe, NULL); in mlxcx_teardown_pages()
852 avl_remove(&mlxp->mlx_pages, mdp); in mlxcx_teardown_pages()
853 mlxp->mlx_npages--; in mlxcx_teardown_pages()
857 mlxcx_panic(mlxp, "hardware returned a page " in mlxcx_teardown_pages()
869 mlxcx_warn(mlxp, "hardware refused to return " in mlxcx_teardown_pages()
871 mlxp->mlx_npages); in mlxcx_teardown_pages()
878 avl_destroy(&mlxp->mlx_pages); in mlxcx_teardown_pages()
881 mutex_exit(&mlxp->mlx_pagemtx); in mlxcx_teardown_pages()
882 mutex_destroy(&mlxp->mlx_pagemtx); in mlxcx_teardown_pages()
888 mlxcx_eq_alloc_dma(mlxcx_t *mlxp, mlxcx_event_queue_t *mleq) in mlxcx_eq_alloc_dma() argument
897 mleq->mleq_entshift = mlxp->mlx_props.mldp_eq_size_shift; in mlxcx_eq_alloc_dma()
902 mlxcx_dma_acc_attr(mlxp, &acc); in mlxcx_eq_alloc_dma()
903 mlxcx_dma_queue_attr(mlxp, &attr); in mlxcx_eq_alloc_dma()
905 ret = mlxcx_dma_alloc(mlxp, &mleq->mleq_dma, &attr, &acc, in mlxcx_eq_alloc_dma()
908 mlxcx_warn(mlxp, "failed to allocate EQ memory"); in mlxcx_eq_alloc_dma()
923 mlxcx_eq_rele_dma(mlxcx_t *mlxp, mlxcx_event_queue_t *mleq) in mlxcx_eq_rele_dma() argument
936 mlxcx_teardown_flow_table(mlxcx_t *mlxp, mlxcx_flow_table_t *ft) in mlxcx_teardown_flow_table() argument
947 if (!mlxcx_cmd_delete_flow_table_entry(mlxp, fe)) { in mlxcx_teardown_flow_table()
948 mlxcx_panic(mlxp, "failed to delete flow " in mlxcx_teardown_flow_table()
958 if (!mlxcx_cmd_destroy_flow_group(mlxp, fg)) { in mlxcx_teardown_flow_table()
959 mlxcx_panic(mlxp, "failed to destroy flow " in mlxcx_teardown_flow_table()
968 if (!mlxcx_cmd_destroy_flow_table(mlxp, ft)) { in mlxcx_teardown_flow_table()
969 mlxcx_panic(mlxp, "failed to destroy flow table %u", in mlxcx_teardown_flow_table()
981 mlxcx_teardown_ports(mlxcx_t *mlxp) in mlxcx_teardown_ports() argument
987 for (i = 0; i < mlxp->mlx_nports; ++i) { in mlxcx_teardown_ports()
988 p = &mlxp->mlx_ports[i]; in mlxcx_teardown_ports()
998 mlxcx_teardown_flow_table(mlxp, ft); in mlxcx_teardown_ports()
1008 kmem_free(mlxp->mlx_ports, mlxp->mlx_ports_size); in mlxcx_teardown_ports()
1009 mlxp->mlx_ports = NULL; in mlxcx_teardown_ports()
1013 mlxcx_teardown_wqs(mlxcx_t *mlxp) in mlxcx_teardown_wqs() argument
1017 while ((mlwq = list_head(&mlxp->mlx_wqs)) != NULL) { in mlxcx_teardown_wqs()
1018 mlxcx_wq_teardown(mlxp, mlwq); in mlxcx_teardown_wqs()
1020 list_destroy(&mlxp->mlx_wqs); in mlxcx_teardown_wqs()
1024 mlxcx_teardown_cqs(mlxcx_t *mlxp) in mlxcx_teardown_cqs() argument
1028 while ((mlcq = list_head(&mlxp->mlx_cqs)) != NULL) { in mlxcx_teardown_cqs()
1029 mlxcx_cq_teardown(mlxp, mlcq); in mlxcx_teardown_cqs()
1031 list_destroy(&mlxp->mlx_cqs); in mlxcx_teardown_cqs()
1035 mlxcx_teardown_eqs(mlxcx_t *mlxp) in mlxcx_teardown_eqs() argument
1040 for (i = 0; i < mlxp->mlx_intr_count; ++i) { in mlxcx_teardown_eqs()
1041 mleq = &mlxp->mlx_eqs[i]; in mlxcx_teardown_eqs()
1045 if (!mlxcx_cmd_destroy_eq(mlxp, mleq)) { in mlxcx_teardown_eqs()
1046 mlxcx_warn(mlxp, "failed to destroy " in mlxcx_teardown_eqs()
1052 mlxcx_eq_rele_dma(mlxp, mleq); in mlxcx_teardown_eqs()
1059 mlxcx_teardown_checktimers(mlxcx_t *mlxp) in mlxcx_teardown_checktimers() argument
1061 if (mlxp->mlx_props.mldp_eq_check_interval_sec > 0) in mlxcx_teardown_checktimers()
1062 ddi_periodic_delete(mlxp->mlx_eq_checktimer); in mlxcx_teardown_checktimers()
1063 if (mlxp->mlx_props.mldp_cq_check_interval_sec > 0) in mlxcx_teardown_checktimers()
1064 ddi_periodic_delete(mlxp->mlx_cq_checktimer); in mlxcx_teardown_checktimers()
1065 if (mlxp->mlx_props.mldp_wq_check_interval_sec > 0) in mlxcx_teardown_checktimers()
1066 ddi_periodic_delete(mlxp->mlx_wq_checktimer); in mlxcx_teardown_checktimers()
1070 mlxcx_teardown(mlxcx_t *mlxp) in mlxcx_teardown() argument
1073 dev_info_t *dip = mlxp->mlx_dip; in mlxcx_teardown()
1075 if (mlxp->mlx_attach & MLXCX_ATTACH_INTRS) { in mlxcx_teardown()
1079 mlxcx_intr_disable(mlxp); in mlxcx_teardown()
1082 if (mlxp->mlx_attach & MLXCX_ATTACH_SENSORS) { in mlxcx_teardown()
1083 mlxcx_teardown_sensors(mlxp); in mlxcx_teardown()
1084 mlxp->mlx_attach &= ~MLXCX_ATTACH_SENSORS; in mlxcx_teardown()
1087 if (mlxp->mlx_attach & MLXCX_ATTACH_CHKTIMERS) { in mlxcx_teardown()
1088 mlxcx_teardown_checktimers(mlxp); in mlxcx_teardown()
1089 mlxp->mlx_attach &= ~MLXCX_ATTACH_CHKTIMERS; in mlxcx_teardown()
1092 if (mlxp->mlx_attach & MLXCX_ATTACH_GROUPS) { in mlxcx_teardown()
1093 mlxcx_teardown_groups(mlxp); in mlxcx_teardown()
1094 mlxp->mlx_attach &= ~MLXCX_ATTACH_GROUPS; in mlxcx_teardown()
1097 if (mlxp->mlx_attach & MLXCX_ATTACH_WQS) { in mlxcx_teardown()
1098 mlxcx_teardown_wqs(mlxp); in mlxcx_teardown()
1099 mlxp->mlx_attach &= ~MLXCX_ATTACH_WQS; in mlxcx_teardown()
1102 if (mlxp->mlx_attach & MLXCX_ATTACH_CQS) { in mlxcx_teardown()
1103 mlxcx_teardown_cqs(mlxp); in mlxcx_teardown()
1104 mlxp->mlx_attach &= ~MLXCX_ATTACH_CQS; in mlxcx_teardown()
1107 if (mlxp->mlx_attach & MLXCX_ATTACH_BUFS) { in mlxcx_teardown()
1108 mlxcx_teardown_bufs(mlxp); in mlxcx_teardown()
1109 mlxp->mlx_attach &= ~MLXCX_ATTACH_BUFS; in mlxcx_teardown()
1112 if (mlxp->mlx_attach & MLXCX_ATTACH_PORTS) { in mlxcx_teardown()
1113 mlxcx_teardown_ports(mlxp); in mlxcx_teardown()
1114 mlxp->mlx_attach &= ~MLXCX_ATTACH_PORTS; in mlxcx_teardown()
1117 if (mlxp->mlx_attach & MLXCX_ATTACH_INTRS) { in mlxcx_teardown()
1118 mlxcx_teardown_eqs(mlxp); in mlxcx_teardown()
1119 mlxcx_intr_teardown(mlxp); in mlxcx_teardown()
1120 mlxp->mlx_attach &= ~MLXCX_ATTACH_INTRS; in mlxcx_teardown()
1123 if (mlxp->mlx_attach & MLXCX_ATTACH_UAR_PD_TD) { in mlxcx_teardown()
1124 if (mlxp->mlx_uar.mlu_allocated) { in mlxcx_teardown()
1125 if (!mlxcx_cmd_dealloc_uar(mlxp, &mlxp->mlx_uar)) { in mlxcx_teardown()
1126 mlxcx_warn(mlxp, "failed to release UAR"); in mlxcx_teardown()
1129 mutex_destroy(&mlxp->mlx_uar.mlu_bf[i].mbf_mtx); in mlxcx_teardown()
1131 if (mlxp->mlx_pd.mlpd_allocated && in mlxcx_teardown()
1132 !mlxcx_cmd_dealloc_pd(mlxp, &mlxp->mlx_pd)) { in mlxcx_teardown()
1133 mlxcx_warn(mlxp, "failed to release PD"); in mlxcx_teardown()
1135 if (mlxp->mlx_tdom.mltd_allocated && in mlxcx_teardown()
1136 !mlxcx_cmd_dealloc_tdom(mlxp, &mlxp->mlx_tdom)) { in mlxcx_teardown()
1137 mlxcx_warn(mlxp, "failed to release TDOM"); in mlxcx_teardown()
1139 mlxp->mlx_attach &= ~MLXCX_ATTACH_UAR_PD_TD; in mlxcx_teardown()
1142 if (mlxp->mlx_attach & MLXCX_ATTACH_INIT_HCA) { in mlxcx_teardown()
1143 if (!mlxcx_cmd_teardown_hca(mlxp)) { in mlxcx_teardown()
1144 mlxcx_warn(mlxp, "failed to send teardown HCA " in mlxcx_teardown()
1147 mlxp->mlx_attach &= ~MLXCX_ATTACH_INIT_HCA; in mlxcx_teardown()
1150 if (mlxp->mlx_attach & MLXCX_ATTACH_PAGE_LIST) { in mlxcx_teardown()
1151 mlxcx_teardown_pages(mlxp); in mlxcx_teardown()
1152 mlxp->mlx_attach &= ~MLXCX_ATTACH_PAGE_LIST; in mlxcx_teardown()
1155 if (mlxp->mlx_attach & MLXCX_ATTACH_ASYNC_TQ) { in mlxcx_teardown()
1157 mlxp->mlx_npages_req[i].mla_mlx = NULL; in mlxcx_teardown()
1158 mutex_destroy(&mlxp->mlx_npages_req[i].mla_mtx); in mlxcx_teardown()
1160 taskq_destroy(mlxp->mlx_async_tq); in mlxcx_teardown()
1161 mlxp->mlx_async_tq = NULL; in mlxcx_teardown()
1162 mlxp->mlx_attach &= ~MLXCX_ATTACH_ASYNC_TQ; in mlxcx_teardown()
1165 if (mlxp->mlx_attach & MLXCX_ATTACH_ENABLE_HCA) { in mlxcx_teardown()
1166 if (!mlxcx_cmd_disable_hca(mlxp)) { in mlxcx_teardown()
1167 mlxcx_warn(mlxp, "failed to send DISABLE HCA command " in mlxcx_teardown()
1170 mlxp->mlx_attach &= ~MLXCX_ATTACH_ENABLE_HCA; in mlxcx_teardown()
1173 if (mlxp->mlx_attach & MLXCX_ATTACH_CMD) { in mlxcx_teardown()
1174 mlxcx_cmd_queue_fini(mlxp); in mlxcx_teardown()
1175 mlxp->mlx_attach &= ~MLXCX_ATTACH_CMD; in mlxcx_teardown()
1178 if (mlxp->mlx_attach & MLXCX_ATTACH_CAPS) { in mlxcx_teardown()
1179 kmem_free(mlxp->mlx_caps, sizeof (mlxcx_caps_t)); in mlxcx_teardown()
1180 mlxp->mlx_caps = NULL; in mlxcx_teardown()
1181 mlxp->mlx_attach &= ~MLXCX_ATTACH_CAPS; in mlxcx_teardown()
1184 if (mlxp->mlx_attach & MLXCX_ATTACH_REGS) { in mlxcx_teardown()
1185 ddi_regs_map_free(&mlxp->mlx_regs_handle); in mlxcx_teardown()
1186 mlxp->mlx_regs_handle = NULL; in mlxcx_teardown()
1187 mlxp->mlx_attach &= ~MLXCX_ATTACH_REGS; in mlxcx_teardown()
1190 if (mlxp->mlx_attach & MLXCX_ATTACH_PCI_CONFIG) { in mlxcx_teardown()
1191 pci_config_teardown(&mlxp->mlx_cfg_handle); in mlxcx_teardown()
1192 mlxp->mlx_cfg_handle = NULL; in mlxcx_teardown()
1193 mlxp->mlx_attach &= ~MLXCX_ATTACH_PCI_CONFIG; in mlxcx_teardown()
1196 if (mlxp->mlx_attach & MLXCX_ATTACH_FM) { in mlxcx_teardown()
1197 mlxcx_fm_fini(mlxp); in mlxcx_teardown()
1198 mlxp->mlx_attach &= ~MLXCX_ATTACH_FM; in mlxcx_teardown()
1201 VERIFY3S(mlxp->mlx_attach, ==, 0); in mlxcx_teardown()
1202 ddi_soft_state_free(mlxcx_softstate, mlxp->mlx_inst); in mlxcx_teardown()
1207 mlxcx_get_model(mlxcx_t *mlxp) in mlxcx_get_model() argument
1212 venid = pci_config_get16(mlxp->mlx_cfg_handle, PCI_CONF_VENID); in mlxcx_get_model()
1215 mlxp->mlx_type = MLXCX_DEV_UNKNOWN; in mlxcx_get_model()
1219 devid = pci_config_get16(mlxp->mlx_cfg_handle, PCI_CONF_DEVID); in mlxcx_get_model()
1224 mlxp->mlx_type = MLXCX_DEV_CX4; in mlxcx_get_model()
1231 mlxp->mlx_type = MLXCX_DEV_CX5; in mlxcx_get_model()
1237 mlxp->mlx_type = MLXCX_DEV_CX6; in mlxcx_get_model()
1240 mlxp->mlx_type = MLXCX_DEV_UNKNOWN; in mlxcx_get_model()
1245 mlxcx_regs_map(mlxcx_t *mlxp) in mlxcx_regs_map() argument
1251 if (ddi_dev_regsize(mlxp->mlx_dip, MLXCX_REG_NUMBER, &memsize) != in mlxcx_regs_map()
1253 mlxcx_warn(mlxp, "failed to get register set size"); in mlxcx_regs_map()
1265 if (DDI_FM_ACC_ERR_CAP(mlxp->mlx_fm_caps)) { in mlxcx_regs_map()
1271 ret = ddi_regs_map_setup(mlxp->mlx_dip, MLXCX_REG_NUMBER, in mlxcx_regs_map()
1272 &mlxp->mlx_regs_base, 0, memsize, &da, &mlxp->mlx_regs_handle); in mlxcx_regs_map()
1275 mlxcx_warn(mlxp, "failed to map device registers: %d", ret); in mlxcx_regs_map()
1283 mlxcx_check_issi(mlxcx_t *mlxp) in mlxcx_check_issi() argument
1287 if (!mlxcx_cmd_query_issi(mlxp, &issi)) { in mlxcx_check_issi()
1288 mlxcx_warn(mlxp, "failed to get ISSI"); in mlxcx_check_issi()
1293 mlxcx_warn(mlxp, "hardware does not support software ISSI, " in mlxcx_check_issi()
1298 if (!mlxcx_cmd_set_issi(mlxp, MLXCX_CURRENT_ISSI)) { in mlxcx_check_issi()
1299 mlxcx_warn(mlxp, "failed to set ISSI to %u", in mlxcx_check_issi()
1308 mlxcx_give_pages(mlxcx_t *mlxp, int32_t npages, int32_t *ngiven) in mlxcx_give_pages() argument
1335 mlxcx_dma_acc_attr(mlxp, &acc); in mlxcx_give_pages()
1336 mlxcx_dma_page_attr(mlxp, &attr); in mlxcx_give_pages()
1337 if (!mlxcx_dma_alloc(mlxp, &mdp->mxdp_dma, &attr, &acc, in mlxcx_give_pages()
1339 mlxcx_warn(mlxp, "failed to allocate 4k page %u/%u", i, in mlxcx_give_pages()
1358 if (!mlxcx_cmd_give_pages(mlxp, in mlxcx_give_pages()
1360 mlxcx_warn(mlxp, "!hardware refused our gift of %u " in mlxcx_give_pages()
1368 mutex_enter(&mlxp->mlx_pagemtx); in mlxcx_give_pages()
1370 avl_add(&mlxp->mlx_pages, pages[i]); in mlxcx_give_pages()
1372 mlxp->mlx_npages += npages; in mlxcx_give_pages()
1373 mutex_exit(&mlxp->mlx_pagemtx); in mlxcx_give_pages()
1393 mlxcx_init_pages(mlxcx_t *mlxp, uint_t type) in mlxcx_init_pages() argument
1397 if (!mlxcx_cmd_query_pages(mlxp, type, &npages)) { in mlxcx_init_pages()
1398 mlxcx_warn(mlxp, "failed to determine boot pages"); in mlxcx_init_pages()
1403 if (!mlxcx_give_pages(mlxp, npages, &given)) in mlxcx_init_pages()
1415 mlxcx_t *mlxp = cookie; in mlxcx_bufs_cache_constr() local
1419 b->mlb_mlx = mlxp; in mlxcx_bufs_cache_constr()
1430 mlxcx_t *mlxp = cookie; in mlxcx_bufs_cache_destr() local
1432 VERIFY3P(b->mlb_mlx, ==, mlxp); in mlxcx_bufs_cache_destr()
1438 mlxcx_mlbs_create(mlxcx_t *mlxp) in mlxcx_mlbs_create() argument
1445 DDI_INTR_PRI(mlxp->mlx_intr_pri)); in mlxcx_mlbs_create()
1454 list_insert_tail(&mlxp->mlx_buf_shards, s); in mlxcx_mlbs_create()
1460 mlxcx_setup_bufs(mlxcx_t *mlxp) in mlxcx_setup_bufs() argument
1465 ddi_get_instance(mlxp->mlx_dip)); in mlxcx_setup_bufs()
1466 mlxp->mlx_bufs_cache = kmem_cache_create(namebuf, in mlxcx_setup_bufs()
1469 NULL, mlxp, NULL, 0); in mlxcx_setup_bufs()
1471 list_create(&mlxp->mlx_buf_shards, sizeof (mlxcx_buf_shard_t), in mlxcx_setup_bufs()
1478 mlxcx_fm_qstate_ereport(mlxcx_t *mlxp, const char *qtype, uint32_t qnum, in mlxcx_fm_qstate_ereport() argument
1484 if (!DDI_FM_EREPORT_CAP(mlxp->mlx_fm_caps)) in mlxcx_fm_qstate_ereport()
1491 ddi_fm_ereport_post(mlxp->mlx_dip, buf, ena, DDI_NOSLEEP, in mlxcx_fm_qstate_ereport()
1498 ddi_fm_service_impact(mlxp->mlx_dip, DDI_SERVICE_DEGRADED); in mlxcx_fm_qstate_ereport()
1519 mlxcx_t *mlxp = (mlxcx_t *)arg; in mlxcx_eq_check() local
1526 for (i = 0; i < mlxp->mlx_intr_count; ++i) { in mlxcx_eq_check()
1527 eq = &mlxp->mlx_eqs[i]; in mlxcx_eq_check()
1539 if (!mlxcx_cmd_query_eq(mlxp, eq, &ctx)) in mlxcx_eq_check()
1552 mlxcx_fm_qstate_ereport(mlxp, "event", in mlxcx_eq_check()
1554 mlxcx_warn(mlxp, "EQ %u is in bad status: %x (%s)", in mlxcx_eq_check()
1562 mlxcx_fm_ereport(mlxp, DDI_FM_DEVICE_STALL); in mlxcx_eq_check()
1563 mlxcx_warn(mlxp, "EQ %u isn't armed", in mlxcx_eq_check()
1577 mlxcx_t *mlxp = (mlxcx_t *)arg; in mlxcx_cq_check() local
1583 for (cq = list_head(&mlxp->mlx_cqs); cq != NULL; in mlxcx_cq_check()
1584 cq = list_next(&mlxp->mlx_cqs, cq)) { in mlxcx_cq_check()
1600 if (!mlxcx_cmd_query_cq(mlxp, cq, &ctx)) in mlxcx_cq_check()
1632 mlxcx_fm_qstate_ereport(mlxp, "completion", in mlxcx_cq_check()
1634 mlxcx_warn(mlxp, "%sCQ 0x%x is in bad status: %x (%s)", in mlxcx_cq_check()
1645 mlxcx_fm_ereport(mlxp, DDI_FM_DEVICE_STALL); in mlxcx_cq_check()
1646 mlxcx_warn(mlxp, "%sCQ 0x%x (%p) isn't armed", in mlxcx_cq_check()
1658 mlxcx_check_sq(mlxcx_t *mlxp, mlxcx_work_queue_t *sq) in mlxcx_check_sq() argument
1663 if (!mlxcx_cmd_query_sq(mlxp, sq, &ctx)) in mlxcx_check_sq()
1671 mlxcx_fm_qstate_ereport(mlxp, "send", in mlxcx_check_sq()
1678 mlxcx_fm_qstate_ereport(mlxp, "send", in mlxcx_check_sq()
1684 mlxcx_fm_qstate_ereport(mlxp, "send", in mlxcx_check_sq()
1689 mlxcx_fm_qstate_ereport(mlxp, "send", in mlxcx_check_sq()
1697 mlxcx_check_rq(mlxcx_t *mlxp, mlxcx_work_queue_t *rq) in mlxcx_check_rq() argument
1703 if (!mlxcx_cmd_query_rq(mlxp, rq, &ctx)) in mlxcx_check_rq()
1711 mlxcx_fm_qstate_ereport(mlxp, "receive", in mlxcx_check_rq()
1718 mlxcx_fm_qstate_ereport(mlxp, "receive", in mlxcx_check_rq()
1724 mlxcx_fm_qstate_ereport(mlxp, "receive", in mlxcx_check_rq()
1729 mlxcx_fm_qstate_ereport(mlxp, "receive", in mlxcx_check_rq()
1739 mlxcx_t *mlxp = (mlxcx_t *)arg; in mlxcx_wq_check() local
1742 for (wq = list_head(&mlxp->mlx_wqs); wq != NULL; in mlxcx_wq_check()
1743 wq = list_next(&mlxp->mlx_wqs, wq)) { in mlxcx_wq_check()
1761 mlxcx_check_sq(mlxp, wq); in mlxcx_wq_check()
1764 mlxcx_check_rq(mlxp, wq); in mlxcx_wq_check()
1771 mlxcx_setup_checktimers(mlxcx_t *mlxp) in mlxcx_setup_checktimers() argument
1773 if (mlxp->mlx_props.mldp_eq_check_interval_sec > 0) { in mlxcx_setup_checktimers()
1774 mlxp->mlx_eq_checktimer = ddi_periodic_add(mlxcx_eq_check, mlxp, in mlxcx_setup_checktimers()
1775 mlxp->mlx_props.mldp_eq_check_interval_sec * NANOSEC, in mlxcx_setup_checktimers()
1778 if (mlxp->mlx_props.mldp_cq_check_interval_sec > 0) { in mlxcx_setup_checktimers()
1779 mlxp->mlx_cq_checktimer = ddi_periodic_add(mlxcx_cq_check, mlxp, in mlxcx_setup_checktimers()
1780 mlxp->mlx_props.mldp_cq_check_interval_sec * NANOSEC, in mlxcx_setup_checktimers()
1783 if (mlxp->mlx_props.mldp_wq_check_interval_sec > 0) { in mlxcx_setup_checktimers()
1784 mlxp->mlx_wq_checktimer = ddi_periodic_add(mlxcx_wq_check, mlxp, in mlxcx_setup_checktimers()
1785 mlxp->mlx_props.mldp_wq_check_interval_sec * NANOSEC, in mlxcx_setup_checktimers()
1841 mlxcx_setup_ports(mlxcx_t *mlxp) in mlxcx_setup_ports() argument
1849 VERIFY3U(mlxp->mlx_nports, >, 0); in mlxcx_setup_ports()
1850 mlxp->mlx_ports_size = mlxp->mlx_nports * sizeof (mlxcx_port_t); in mlxcx_setup_ports()
1851 mlxp->mlx_ports = kmem_zalloc(mlxp->mlx_ports_size, KM_SLEEP); in mlxcx_setup_ports()
1853 for (i = 0; i < mlxp->mlx_nports; ++i) { in mlxcx_setup_ports()
1854 p = &mlxp->mlx_ports[i]; in mlxcx_setup_ports()
1856 p->mlx_port_event.mla_mlx = mlxp; in mlxcx_setup_ports()
1859 MUTEX_DRIVER, DDI_INTR_PRI(mlxp->mlx_async_intr_pri)); in mlxcx_setup_ports()
1862 DDI_INTR_PRI(mlxp->mlx_intr_pri)); in mlxcx_setup_ports()
1864 if (!mlxcx_cmd_query_nic_vport_ctx(mlxp, p)) { in mlxcx_setup_ports()
1868 if (!mlxcx_cmd_query_port_mtu(mlxp, p)) { in mlxcx_setup_ports()
1872 if (!mlxcx_cmd_query_port_status(mlxp, p)) { in mlxcx_setup_ports()
1876 if (!mlxcx_cmd_query_port_speed(mlxp, p)) { in mlxcx_setup_ports()
1880 if (!mlxcx_cmd_modify_nic_vport_ctx(mlxp, p, in mlxcx_setup_ports()
1885 if (!mlxcx_cmd_query_port_fec(mlxp, p)) { in mlxcx_setup_ports()
1894 for (i = 0; i < mlxp->mlx_nports; ++i) { in mlxcx_setup_ports()
1895 p = &mlxp->mlx_ports[i]; in mlxcx_setup_ports()
1900 DDI_INTR_PRI(mlxp->mlx_intr_pri)); in mlxcx_setup_ports()
1906 ft->mlft_entshift = mlxp->mlx_props.mldp_ftbl_root_size_shift; in mlxcx_setup_ports()
1907 if (ft->mlft_entshift > mlxp->mlx_caps->mlc_max_rx_ft_shift) in mlxcx_setup_ports()
1908 ft->mlft_entshift = mlxp->mlx_caps->mlc_max_rx_ft_shift; in mlxcx_setup_ports()
1920 if (!mlxcx_cmd_create_flow_table(mlxp, ft)) { in mlxcx_setup_ports()
1926 if (!mlxcx_cmd_set_flow_table_root(mlxp, ft)) { in mlxcx_setup_ports()
1945 if (!mlxcx_setup_flow_group(mlxp, ft, fg)) { in mlxcx_setup_ports()
1961 if (!mlxcx_setup_flow_group(mlxp, ft, fg)) { in mlxcx_setup_ports()
1972 if (!mlxcx_setup_flow_group(mlxp, ft, fg)) { in mlxcx_setup_ports()
1993 mlxcx_teardown_ports(mlxp); in mlxcx_setup_ports()
1998 mlxcx_remove_all_vlan_entries(mlxcx_t *mlxp, mlxcx_ring_group_t *g) in mlxcx_remove_all_vlan_entries() argument
2012 (void) mlxcx_cmd_set_flow_table_entry(mlxp, fe); in mlxcx_remove_all_vlan_entries()
2021 (void) mlxcx_cmd_delete_flow_table_entry(mlxp, fe); in mlxcx_remove_all_vlan_entries()
2029 mlxcx_remove_vlan_entry(mlxcx_t *mlxp, mlxcx_ring_group_t *g, in mlxcx_remove_vlan_entry() argument
2066 if (!mlxcx_cmd_set_flow_table_entry(mlxp, fe)) { in mlxcx_remove_vlan_entry()
2079 if (!mlxcx_cmd_delete_flow_table_entry(mlxp, fe)) { in mlxcx_remove_vlan_entry()
2083 (void) mlxcx_cmd_delete_flow_table_entry(mlxp, fe); in mlxcx_remove_vlan_entry()
2098 mlxcx_add_vlan_entry(mlxcx_t *mlxp, mlxcx_ring_group_t *g, boolean_t tagged, in mlxcx_add_vlan_entry() argument
2149 if (!mlxcx_cmd_set_flow_table_entry(mlxp, fe)) { in mlxcx_add_vlan_entry()
2166 (void) mlxcx_cmd_delete_flow_table_entry(mlxp, fe); in mlxcx_add_vlan_entry()
2174 mlxcx_remove_all_umcast_entries(mlxcx_t *mlxp, mlxcx_port_t *port, in mlxcx_remove_all_umcast_entries() argument
2207 (void) mlxcx_cmd_set_flow_table_entry(mlxp, fe); in mlxcx_remove_all_umcast_entries()
2217 (void) mlxcx_cmd_delete_flow_table_entry(mlxp, fe); in mlxcx_remove_all_umcast_entries()
2226 mlxcx_remove_umcast_entry(mlxcx_t *mlxp, mlxcx_port_t *port, in mlxcx_remove_umcast_entry() argument
2266 if (!mlxcx_cmd_set_flow_table_entry(mlxp, fe)) { in mlxcx_remove_umcast_entry()
2279 (void) mlxcx_cmd_delete_flow_table_entry(mlxp, fe); in mlxcx_remove_umcast_entry()
2290 mlxcx_add_umcast_entry(mlxcx_t *mlxp, mlxcx_port_t *port, in mlxcx_add_umcast_entry() argument
2334 if (!mlxcx_cmd_set_flow_table_entry(mlxp, fe)) { in mlxcx_add_umcast_entry()
2356 mlxcx_setup_flow_group(mlxcx_t *mlxp, mlxcx_flow_table_t *ft, in mlxcx_setup_flow_group() argument
2370 if (!mlxcx_cmd_create_flow_group(mlxp, fg)) { in mlxcx_setup_flow_group()
2389 mlxcx_setup_eq(mlxcx_t *mlxp, uint_t vec, uint64_t events) in mlxcx_setup_eq() argument
2391 mlxcx_event_queue_t *mleq = &mlxp->mlx_eqs[vec]; in mlxcx_setup_eq()
2394 if (!mlxcx_eq_alloc_dma(mlxp, mleq)) { in mlxcx_setup_eq()
2399 mleq->mleq_mlx = mlxp; in mlxcx_setup_eq()
2400 mleq->mleq_uar = &mlxp->mlx_uar; in mlxcx_setup_eq()
2404 if (!mlxcx_cmd_create_eq(mlxp, mleq)) { in mlxcx_setup_eq()
2410 if (ddi_intr_enable(mlxp->mlx_intr_handles[vec]) != DDI_SUCCESS) { in mlxcx_setup_eq()
2420 mlxcx_arm_eq(mlxp, mleq); in mlxcx_setup_eq()
2427 mlxcx_eq_set_attached(mlxcx_t *mlxp) in mlxcx_eq_set_attached() argument
2432 for (vec = 0; vec < mlxp->mlx_intr_count; ++vec) { in mlxcx_eq_set_attached()
2433 mleq = &mlxp->mlx_eqs[vec]; in mlxcx_eq_set_attached()
2442 mlxcx_setup_async_eqs(mlxcx_t *mlxp) in mlxcx_setup_async_eqs() argument
2446 ret = mlxcx_setup_eq(mlxp, 0, in mlxcx_setup_async_eqs()
2463 mlxcx_cmd_eq_enable(mlxp); in mlxcx_setup_async_eqs()
2484 mlxcx_setup_eqs(mlxcx_t *mlxp) in mlxcx_setup_eqs() argument
2489 ASSERT3S(mlxp->mlx_intr_count, >, 0); in mlxcx_setup_eqs()
2491 for (i = mlxp->mlx_intr_cq0; i < mlxp->mlx_intr_count; ++i) { in mlxcx_setup_eqs()
2492 mleq = &mlxp->mlx_eqs[i]; in mlxcx_setup_eqs()
2494 if (!mlxcx_eq_alloc_dma(mlxp, mleq)) { in mlxcx_setup_eqs()
2498 mleq->mleq_uar = &mlxp->mlx_uar; in mlxcx_setup_eqs()
2499 if (!mlxcx_cmd_create_eq(mlxp, mleq)) { in mlxcx_setup_eqs()
2504 if (mlxp->mlx_props.mldp_intrmod_period_usec != 0 && in mlxcx_setup_eqs()
2505 !mlxcx_cmd_set_int_mod(mlxp, i, in mlxcx_setup_eqs()
2506 mlxp->mlx_props.mldp_intrmod_period_usec)) { in mlxcx_setup_eqs()
2510 if (ddi_intr_enable(mlxp->mlx_intr_handles[i]) != DDI_SUCCESS) { in mlxcx_setup_eqs()
2515 mlxcx_arm_eq(mlxp, mleq); in mlxcx_setup_eqs()
2519 mlxp->mlx_next_eq = mlxp->mlx_intr_cq0; in mlxcx_setup_eqs()
2529 mlxcx_explore_pcam(mlxcx_t *mlxp, mlxcx_caps_t *c) in mlxcx_explore_pcam() argument
2542 VERIFY(mlxcx_cmd_access_register(mlxp, MLXCX_CMD_ACCESS_REGISTER_READ, in mlxcx_explore_pcam()
2562 mlxcx_init_caps(mlxcx_t *mlxp) in mlxcx_init_caps() argument
2566 mlxp->mlx_caps = c = kmem_zalloc(sizeof (mlxcx_caps_t), KM_SLEEP); in mlxcx_init_caps()
2568 if (!mlxcx_cmd_query_hca_cap(mlxp, MLXCX_HCA_CAP_GENERAL, in mlxcx_init_caps()
2570 mlxcx_warn(mlxp, "failed to obtain current HCA general caps"); in mlxcx_init_caps()
2573 if (!mlxcx_cmd_query_hca_cap(mlxp, MLXCX_HCA_CAP_GENERAL, in mlxcx_init_caps()
2575 mlxcx_warn(mlxp, "failed to obtain maximum HCA general caps"); in mlxcx_init_caps()
2578 if (!mlxcx_cmd_query_hca_cap(mlxp, MLXCX_HCA_CAP_ETHERNET, in mlxcx_init_caps()
2580 mlxcx_warn(mlxp, "failed to obtain current HCA eth caps"); in mlxcx_init_caps()
2583 if (!mlxcx_cmd_query_hca_cap(mlxp, MLXCX_HCA_CAP_ETHERNET, in mlxcx_init_caps()
2585 mlxcx_warn(mlxp, "failed to obtain maximum HCA eth caps"); in mlxcx_init_caps()
2588 if (!mlxcx_cmd_query_hca_cap(mlxp, MLXCX_HCA_CAP_NIC_FLOW, in mlxcx_init_caps()
2590 mlxcx_warn(mlxp, "failed to obtain current HCA flow caps"); in mlxcx_init_caps()
2593 if (!mlxcx_cmd_query_hca_cap(mlxp, MLXCX_HCA_CAP_NIC_FLOW, in mlxcx_init_caps()
2595 mlxcx_warn(mlxp, "failed to obtain maximum HCA flow caps"); in mlxcx_init_caps()
2604 mlxcx_warn(mlxp, "!hardware has page size != 4k " in mlxcx_init_caps()
2609 mlxcx_warn(mlxp, "!hardware does not support CQE v1 " in mlxcx_init_caps()
2615 mlxcx_warn(mlxp, "!hardware has non-ethernet ports"); in mlxcx_init_caps()
2618 mlxp->mlx_nports = gen->mlcap_general_num_ports; in mlxcx_init_caps()
2619 mlxp->mlx_max_sdu = (1 << (gen->mlcap_general_log_max_msg & 0x1F)); in mlxcx_init_caps()
2621 if (mlxp->mlx_type >= MLXCX_DEV_CX5 && in mlxcx_init_caps()
2648 mlxcx_warn(mlxp, "!hardware does not support rx flow tables"); in mlxcx_init_caps()
2653 mlxcx_warn(mlxp, "!hardware does not support modifying rx " in mlxcx_init_caps()
2670 kmem_free(mlxp->mlx_caps, sizeof (mlxcx_caps_t)); in mlxcx_init_caps()
2677 mlxcx_t *mlxp; in mlxcx_detach() local
2682 mlxp = ddi_get_driver_private(dip); in mlxcx_detach()
2683 if (mlxp == NULL) { in mlxcx_detach()
2689 if (mlxp->mlx_attach & MLXCX_ATTACH_MAC_HDL) { in mlxcx_detach()
2690 if (mac_unregister(mlxp->mlx_mac_hdl) != DDI_SUCCESS) { in mlxcx_detach()
2693 mlxp->mlx_attach &= ~MLXCX_ATTACH_MAC_HDL; in mlxcx_detach()
2696 mlxcx_teardown(mlxp); in mlxcx_detach()
2701 mlxcx_calc_rx_ngroups(mlxcx_t *mlxp) in mlxcx_calc_rx_ngroups() argument
2703 size_t ngroups = mlxp->mlx_props.mldp_rx_ngroups_large + in mlxcx_calc_rx_ngroups()
2704 mlxp->mlx_props.mldp_rx_ngroups_small; in mlxcx_calc_rx_ngroups()
2707 tirlim = mlxp->mlx_caps->mlc_max_tir / MLXCX_TIRS_PER_GROUP; in mlxcx_calc_rx_ngroups()
2709 mlxcx_note(mlxp, "limiting number of rx groups to %u based " in mlxcx_calc_rx_ngroups()
2714 flowlim = (1 << mlxp->mlx_caps->mlc_max_rx_ft_shift) - 2; in mlxcx_calc_rx_ngroups()
2716 mlxcx_note(mlxp, "limiting number of rx groups to %u based " in mlxcx_calc_rx_ngroups()
2727 flowlim = (mlxp->mlx_caps->mlc_max_rx_ft - mlxp->mlx_nports) / 2; in mlxcx_calc_rx_ngroups()
2729 mlxcx_note(mlxp, "limiting number of rx groups to %u based " in mlxcx_calc_rx_ngroups()
2736 gflowlim = mlxp->mlx_caps->mlc_max_rx_flows - 16 * ngroups - 2; in mlxcx_calc_rx_ngroups()
2738 mlxcx_note(mlxp, "limiting number of rx groups to %u " in mlxcx_calc_rx_ngroups()
2750 mlxcx_t *mlxp; in mlxcx_attach() local
2763 mlxp = ddi_get_soft_state(mlxcx_softstate, inst); in mlxcx_attach()
2764 if (mlxp == NULL) in mlxcx_attach()
2766 mlxp->mlx_dip = dip; in mlxcx_attach()
2767 mlxp->mlx_inst = inst; in mlxcx_attach()
2768 ddi_set_driver_private(dip, mlxp); in mlxcx_attach()
2770 mlxcx_load_props(mlxp); in mlxcx_attach()
2772 mlxcx_fm_init(mlxp); in mlxcx_attach()
2773 mlxp->mlx_attach |= MLXCX_ATTACH_FM; in mlxcx_attach()
2775 if (pci_config_setup(mlxp->mlx_dip, &mlxp->mlx_cfg_handle) != in mlxcx_attach()
2777 mlxcx_warn(mlxp, "failed to initial PCI config space"); in mlxcx_attach()
2780 mlxcx_get_model(mlxp); in mlxcx_attach()
2781 mlxp->mlx_attach |= MLXCX_ATTACH_PCI_CONFIG; in mlxcx_attach()
2783 if (!mlxcx_regs_map(mlxp)) { in mlxcx_attach()
2786 mlxp->mlx_attach |= MLXCX_ATTACH_REGS; in mlxcx_attach()
2788 if (!mlxcx_cmd_queue_init(mlxp)) { in mlxcx_attach()
2791 mlxp->mlx_attach |= MLXCX_ATTACH_CMD; in mlxcx_attach()
2793 if (!mlxcx_cmd_enable_hca(mlxp)) { in mlxcx_attach()
2796 mlxp->mlx_attach |= MLXCX_ATTACH_ENABLE_HCA; in mlxcx_attach()
2798 if (!mlxcx_check_issi(mlxp)) { in mlxcx_attach()
2806 if (!mlxcx_intr_setup(mlxp)) { in mlxcx_attach()
2809 mlxp->mlx_attach |= MLXCX_ATTACH_INTRS; in mlxcx_attach()
2811 mutex_init(&mlxp->mlx_pagemtx, NULL, MUTEX_DRIVER, in mlxcx_attach()
2812 DDI_INTR_PRI(mlxp->mlx_intr_pri)); in mlxcx_attach()
2813 avl_create(&mlxp->mlx_pages, mlxcx_page_compare, in mlxcx_attach()
2815 mlxp->mlx_attach |= MLXCX_ATTACH_PAGE_LIST; in mlxcx_attach()
2822 ddi_driver_name(mlxp->mlx_dip), mlxp->mlx_inst); in mlxcx_attach()
2823 mlxp->mlx_async_tq = taskq_create(tq_name, 1, minclsyspri, 1, INT_MAX, in mlxcx_attach()
2829 mlxp->mlx_npages_req[i].mla_mlx = mlxp; in mlxcx_attach()
2830 mutex_init(&mlxp->mlx_npages_req[i].mla_mtx, NULL, in mlxcx_attach()
2831 MUTEX_DRIVER, DDI_INTR_PRI(mlxp->mlx_async_intr_pri)); in mlxcx_attach()
2833 mlxp->mlx_attach |= MLXCX_ATTACH_ASYNC_TQ; in mlxcx_attach()
2835 if (!mlxcx_init_pages(mlxp, MLXCX_QUERY_PAGES_OPMOD_BOOT)) { in mlxcx_attach()
2839 if (!mlxcx_init_caps(mlxp)) { in mlxcx_attach()
2842 mlxp->mlx_attach |= MLXCX_ATTACH_CAPS; in mlxcx_attach()
2844 if (!mlxcx_init_pages(mlxp, MLXCX_QUERY_PAGES_OPMOD_INIT)) { in mlxcx_attach()
2848 if (!mlxcx_cmd_init_hca(mlxp)) { in mlxcx_attach()
2851 mlxp->mlx_attach |= MLXCX_ATTACH_INIT_HCA; in mlxcx_attach()
2853 if (!mlxcx_cmd_set_driver_version(mlxp, MLXCX_DRIVER_VERSION)) { in mlxcx_attach()
2857 if (mlxp->mlx_caps->mlc_pcam) { in mlxcx_attach()
2858 mlxcx_explore_pcam(mlxp, mlxp->mlx_caps); in mlxcx_attach()
2865 if (!mlxcx_cmd_alloc_uar(mlxp, &mlxp->mlx_uar)) { in mlxcx_attach()
2869 mutex_init(&mlxp->mlx_uar.mlu_bf[i].mbf_mtx, NULL, in mlxcx_attach()
2870 MUTEX_DRIVER, DDI_INTR_PRI(mlxp->mlx_intr_pri)); in mlxcx_attach()
2872 mlxp->mlx_attach |= MLXCX_ATTACH_UAR_PD_TD; in mlxcx_attach()
2883 if (!mlxcx_setup_async_eqs(mlxp)) { in mlxcx_attach()
2892 if (!mlxcx_cmd_alloc_pd(mlxp, &mlxp->mlx_pd)) { in mlxcx_attach()
2895 if (!mlxcx_cmd_alloc_tdom(mlxp, &mlxp->mlx_tdom)) { in mlxcx_attach()
2903 if (!mlxcx_cmd_query_special_ctxs(mlxp)) { in mlxcx_attach()
2913 if (!mlxcx_setup_ports(mlxp)) { in mlxcx_attach()
2916 mlxp->mlx_attach |= MLXCX_ATTACH_PORTS; in mlxcx_attach()
2918 mlxcx_load_model_props(mlxp); in mlxcx_attach()
2927 if (!mlxcx_setup_eqs(mlxp)) { in mlxcx_attach()
2932 list_create(&mlxp->mlx_cqs, sizeof (mlxcx_completion_queue_t), in mlxcx_attach()
2934 mlxp->mlx_attach |= MLXCX_ATTACH_CQS; in mlxcx_attach()
2937 list_create(&mlxp->mlx_wqs, sizeof (mlxcx_work_queue_t), in mlxcx_attach()
2939 mlxp->mlx_attach |= MLXCX_ATTACH_WQS; in mlxcx_attach()
2945 mlxp->mlx_rx_ngroups = mlxcx_calc_rx_ngroups(mlxp); in mlxcx_attach()
2946 mlxp->mlx_rx_groups_size = mlxp->mlx_rx_ngroups * in mlxcx_attach()
2948 mlxp->mlx_rx_groups = kmem_zalloc(mlxp->mlx_rx_groups_size, KM_SLEEP); in mlxcx_attach()
2950 mlxp->mlx_tx_ngroups = mlxp->mlx_props.mldp_tx_ngroups; in mlxcx_attach()
2951 mlxp->mlx_tx_groups_size = mlxp->mlx_tx_ngroups * in mlxcx_attach()
2953 mlxp->mlx_tx_groups = kmem_zalloc(mlxp->mlx_tx_groups_size, KM_SLEEP); in mlxcx_attach()
2955 mlxp->mlx_attach |= MLXCX_ATTACH_GROUPS; in mlxcx_attach()
2961 if (!mlxcx_setup_bufs(mlxp)) in mlxcx_attach()
2963 mlxp->mlx_attach |= MLXCX_ATTACH_BUFS; in mlxcx_attach()
2971 for (i = 0; i < mlxp->mlx_tx_ngroups; ++i) { in mlxcx_attach()
2972 if (!mlxcx_tx_group_setup(mlxp, &mlxp->mlx_tx_groups[i])) in mlxcx_attach()
2975 for (i = 0; i < mlxp->mlx_rx_ngroups; ++i) { in mlxcx_attach()
2976 if (!mlxcx_rx_group_setup(mlxp, &mlxp->mlx_rx_groups[i])) in mlxcx_attach()
2986 if (!mlxcx_setup_checktimers(mlxp)) { in mlxcx_attach()
2989 mlxp->mlx_attach |= MLXCX_ATTACH_CHKTIMERS; in mlxcx_attach()
2996 if (mlxcx_setup_sensors(mlxp)) { in mlxcx_attach()
2997 mlxp->mlx_attach |= MLXCX_ATTACH_SENSORS; in mlxcx_attach()
3003 if (!mlxcx_register_mac(mlxp)) { in mlxcx_attach()
3006 mlxp->mlx_attach |= MLXCX_ATTACH_MAC_HDL; in mlxcx_attach()
3012 mlxcx_eq_set_attached(mlxp); in mlxcx_attach()
3017 mlxcx_teardown(mlxp); in mlxcx_attach()