Lines Matching refs:i40e
403 i40e_dev_err(i40e_t *i40e, int level, boolean_t console, const char *fmt, in i40e_dev_err() argument
410 if (i40e == NULL) { in i40e_dev_err()
414 dev_err(i40e->i40e_dip, level, (console) ? "%s" : "!%s", in i40e_dev_err()
426 i40e_error(i40e_t *i40e, const char *fmt, ...) in i40e_error() argument
431 i40e_dev_err(i40e, CE_WARN, B_FALSE, fmt, ap); in i40e_error()
437 i40e_log(i40e_t *i40e, const char *fmt, ...) in i40e_log() argument
442 i40e_dev_err(i40e, CE_NOTE, B_FALSE, fmt, ap); in i40e_log()
448 i40e_notice(i40e_t *i40e, const char *fmt, ...) in i40e_notice() argument
453 i40e_dev_err(i40e, CE_NOTE, B_TRUE, fmt, ap); in i40e_notice()
464 i40e_is_x722(i40e_t *i40e) in i40e_is_x722() argument
466 return (i40e->i40e_hw_space.mac.type == I40E_MAC_X722); in i40e_is_x722()
470 i40e_device_rele(i40e_t *i40e) in i40e_device_rele() argument
472 i40e_device_t *idp = i40e->i40e_device; in i40e_device_rele()
479 list_remove(&idp->id_i40e_list, i40e); in i40e_device_rele()
488 i40e->i40e_device = NULL; in i40e_device_rele()
493 i40e_device_find(i40e_t *i40e, dev_info_t *parent, uint_t bus, uint_t device) in i40e_device_find() argument
509 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_device_find()
526 idp->id_rsrcs_alloc = i40e->i40e_switch_rsrc_alloc; in i40e_device_find()
527 idp->id_rsrcs_act = i40e->i40e_switch_rsrc_actual; in i40e_device_find()
530 bcopy(i40e->i40e_switch_rsrcs, idp->id_rsrcs, in i40e_device_find()
538 list_insert_tail(&idp->id_i40e_list, i40e); in i40e_device_find()
545 i40e_link_state_set(i40e_t *i40e, link_state_t state) in i40e_link_state_set() argument
547 if (i40e->i40e_link_state == state) in i40e_link_state_set()
550 i40e->i40e_link_state = state; in i40e_link_state_set()
551 mac_link_update(i40e->i40e_mac_hdl, i40e->i40e_link_state); in i40e_link_state_set()
560 i40e_link_check(i40e_t *i40e) in i40e_link_check() argument
562 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_link_check()
566 ASSERT(MUTEX_HELD(&i40e->i40e_general_lock)); in i40e_link_check()
570 i40e->i40e_s_link_status_errs++; in i40e_link_check()
571 i40e->i40e_s_link_status_lasterr = ret; in i40e_link_check()
589 i40e->i40e_link_speed = 100; in i40e_link_check()
592 i40e->i40e_link_speed = 1000; in i40e_link_check()
595 i40e->i40e_link_speed = 2500; in i40e_link_check()
598 i40e->i40e_link_speed = 5000; in i40e_link_check()
601 i40e->i40e_link_speed = 10000; in i40e_link_check()
604 i40e->i40e_link_speed = 20000; in i40e_link_check()
607 i40e->i40e_link_speed = 40000; in i40e_link_check()
610 i40e->i40e_link_speed = 25000; in i40e_link_check()
613 i40e->i40e_link_speed = 0; in i40e_link_check()
622 i40e->i40e_link_duplex = LINK_DUPLEX_FULL; in i40e_link_check()
623 i40e_link_state_set(i40e, LINK_STATE_UP); in i40e_link_check()
625 i40e->i40e_link_speed = 0; in i40e_link_check()
626 i40e->i40e_link_duplex = 0; in i40e_link_check()
627 i40e_link_state_set(i40e, LINK_STATE_DOWN); in i40e_link_check()
632 i40e_rem_intrs(i40e_t *i40e) in i40e_rem_intrs() argument
636 for (i = 0; i < i40e->i40e_intr_count; i++) { in i40e_rem_intrs()
637 rc = ddi_intr_free(i40e->i40e_intr_handles[i]); in i40e_rem_intrs()
639 i40e_log(i40e, "failed to free interrupt %d: %d", in i40e_rem_intrs()
644 kmem_free(i40e->i40e_intr_handles, i40e->i40e_intr_size); in i40e_rem_intrs()
645 i40e->i40e_intr_handles = NULL; in i40e_rem_intrs()
649 i40e_rem_intr_handlers(i40e_t *i40e) in i40e_rem_intr_handlers() argument
653 for (i = 0; i < i40e->i40e_intr_count; i++) { in i40e_rem_intr_handlers()
654 rc = ddi_intr_remove_handler(i40e->i40e_intr_handles[i]); in i40e_rem_intr_handlers()
656 i40e_log(i40e, "failed to remove interrupt %d: %d", in i40e_rem_intr_handlers()
697 i40e_fm_init(i40e_t *i40e) in i40e_fm_init() argument
701 i40e->i40e_fm_capabilities = ddi_prop_get_int(DDI_DEV_T_ANY, in i40e_fm_init()
702 i40e->i40e_dip, DDI_PROP_DONTPASS, "fm_capable", in i40e_fm_init()
706 if (i40e->i40e_fm_capabilities < 0) { in i40e_fm_init()
707 i40e->i40e_fm_capabilities = 0; in i40e_fm_init()
708 } else if (i40e->i40e_fm_capabilities > 0xf) { in i40e_fm_init()
709 i40e->i40e_fm_capabilities = DDI_FM_EREPORT_CAPABLE | in i40e_fm_init()
717 if (i40e->i40e_fm_capabilities & DDI_FM_ACCCHK_CAPABLE) { in i40e_fm_init()
723 if (i40e->i40e_fm_capabilities) { in i40e_fm_init()
724 ddi_fm_init(i40e->i40e_dip, &i40e->i40e_fm_capabilities, &iblk); in i40e_fm_init()
726 if (DDI_FM_EREPORT_CAP(i40e->i40e_fm_capabilities) || in i40e_fm_init()
727 DDI_FM_ERRCB_CAP(i40e->i40e_fm_capabilities)) { in i40e_fm_init()
728 pci_ereport_setup(i40e->i40e_dip); in i40e_fm_init()
731 if (DDI_FM_ERRCB_CAP(i40e->i40e_fm_capabilities)) { in i40e_fm_init()
732 ddi_fm_handler_register(i40e->i40e_dip, in i40e_fm_init()
733 i40e_fm_error_cb, (void*)i40e); in i40e_fm_init()
737 if (i40e->i40e_fm_capabilities & DDI_FM_DMACHK_CAPABLE) { in i40e_fm_init()
738 i40e_init_dma_attrs(i40e, B_TRUE); in i40e_fm_init()
740 i40e_init_dma_attrs(i40e, B_FALSE); in i40e_fm_init()
745 i40e_fm_fini(i40e_t *i40e) in i40e_fm_fini() argument
747 if (i40e->i40e_fm_capabilities) { in i40e_fm_fini()
749 if (DDI_FM_EREPORT_CAP(i40e->i40e_fm_capabilities) || in i40e_fm_fini()
750 DDI_FM_ERRCB_CAP(i40e->i40e_fm_capabilities)) in i40e_fm_fini()
751 pci_ereport_teardown(i40e->i40e_dip); in i40e_fm_fini()
753 if (DDI_FM_ERRCB_CAP(i40e->i40e_fm_capabilities)) in i40e_fm_fini()
754 ddi_fm_handler_unregister(i40e->i40e_dip); in i40e_fm_fini()
756 ddi_fm_fini(i40e->i40e_dip); in i40e_fm_fini()
761 i40e_fm_ereport(i40e_t *i40e, char *detail) in i40e_fm_ereport() argument
768 if (DDI_FM_EREPORT_CAP(i40e->i40e_fm_capabilities)) { in i40e_fm_ereport()
769 ddi_fm_ereport_post(i40e->i40e_dip, buf, ena, DDI_NOSLEEP, in i40e_fm_ereport()
784 i40e_set_def_vsi_seid(i40e_t *i40e) in i40e_set_def_vsi_seid() argument
786 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_set_def_vsi_seid()
797 i40e_error(i40e, "i40e_aq_get_switch_config() failed %d: %d", in i40e_set_def_vsi_seid()
803 i40e_error(i40e, "encountered multiple (%d) switching units " in i40e_set_def_vsi_seid()
809 I40E_DEF_VSI_SEID(i40e) = sw_config->element[0].seid; in i40e_set_def_vsi_seid()
817 i40e_get_mac_seid(i40e_t *i40e) in i40e_get_mac_seid() argument
819 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_get_mac_seid()
830 i40e_error(i40e, "i40e_aq_get_switch_config() failed %d: %d", in i40e_get_mac_seid()
845 i40e_get_hw_capabilities(i40e_t *i40e, i40e_hw_t *hw) in i40e_get_hw_capabilities() argument
865 i40e_error(i40e, "Capability discovery failed " in i40e_get_hw_capabilities()
873 i40e_error(i40e, "Capability discovery failed: %d", rc); in i40e_get_hw_capabilities()
888 i40e_get_switch_resources(i40e_t *i40e) in i40e_get_switch_resources() argument
890 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_get_switch_resources()
913 i40e_error(i40e, in i40e_get_switch_resources()
921 i40e->i40e_switch_rsrc_alloc = cnt; in i40e_get_switch_resources()
922 i40e->i40e_switch_rsrc_actual = act; in i40e_get_switch_resources()
923 i40e->i40e_switch_rsrcs = buf; in i40e_get_switch_resources()
929 i40e_cleanup_resources(i40e_t *i40e) in i40e_cleanup_resources() argument
931 if (i40e->i40e_uaddrs != NULL) { in i40e_cleanup_resources()
932 kmem_free(i40e->i40e_uaddrs, sizeof (i40e_uaddr_t) * in i40e_cleanup_resources()
933 i40e->i40e_resources.ifr_nmacfilt); in i40e_cleanup_resources()
934 i40e->i40e_uaddrs = NULL; in i40e_cleanup_resources()
937 if (i40e->i40e_maddrs != NULL) { in i40e_cleanup_resources()
938 kmem_free(i40e->i40e_maddrs, sizeof (i40e_maddr_t) * in i40e_cleanup_resources()
939 i40e->i40e_resources.ifr_nmcastfilt); in i40e_cleanup_resources()
940 i40e->i40e_maddrs = NULL; in i40e_cleanup_resources()
943 if (i40e->i40e_switch_rsrcs != NULL) { in i40e_cleanup_resources()
945 i40e->i40e_switch_rsrc_alloc; in i40e_cleanup_resources()
947 kmem_free(i40e->i40e_switch_rsrcs, sz); in i40e_cleanup_resources()
948 i40e->i40e_switch_rsrcs = NULL; in i40e_cleanup_resources()
951 if (i40e->i40e_device != NULL) in i40e_cleanup_resources()
952 i40e_device_rele(i40e); in i40e_cleanup_resources()
956 i40e_get_available_resources(i40e_t *i40e) in i40e_get_available_resources() argument
963 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_get_available_resources()
965 parent = ddi_get_parent(i40e->i40e_dip); in i40e_get_available_resources()
967 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, i40e->i40e_dip, 0, "reg", in i40e_get_available_resources()
982 i40e->i40e_hw_space.bus.func = func; in i40e_get_available_resources()
983 i40e->i40e_hw_space.bus.device = device; in i40e_get_available_resources()
985 if (i40e_get_switch_resources(i40e) == B_FALSE) { in i40e_get_available_resources()
1002 idp = i40e_device_find(i40e, parent, bus, device); in i40e_get_available_resources()
1003 i40e->i40e_device = idp; in i40e_get_available_resources()
1004 i40e->i40e_resources.ifr_nvsis = 0; in i40e_get_available_resources()
1005 i40e->i40e_resources.ifr_nvsis_used = 0; in i40e_get_available_resources()
1006 i40e->i40e_resources.ifr_nmacfilt = 0; in i40e_get_available_resources()
1007 i40e->i40e_resources.ifr_nmacfilt_used = 0; in i40e_get_available_resources()
1008 i40e->i40e_resources.ifr_nmcastfilt = 0; in i40e_get_available_resources()
1009 i40e->i40e_resources.ifr_nmcastfilt_used = 0; in i40e_get_available_resources()
1011 for (i = 0; i < i40e->i40e_switch_rsrc_actual; i++) { in i40e_get_available_resources()
1012 i40e_switch_rsrc_t *srp = &i40e->i40e_switch_rsrcs[i]; in i40e_get_available_resources()
1016 i40e->i40e_resources.ifr_nvsis += in i40e_get_available_resources()
1018 i40e->i40e_resources.ifr_nvsis_used = LE_16(srp->used); in i40e_get_available_resources()
1021 i40e->i40e_resources.ifr_nmacfilt += in i40e_get_available_resources()
1023 i40e->i40e_resources.ifr_nmacfilt_used = in i40e_get_available_resources()
1027 i40e->i40e_resources.ifr_nmcastfilt += in i40e_get_available_resources()
1029 i40e->i40e_resources.ifr_nmcastfilt_used = in i40e_get_available_resources()
1038 i40e_switch_rsrc_t *srp = &i40e->i40e_switch_rsrcs[i]; in i40e_get_available_resources()
1041 i40e->i40e_resources.ifr_nvsis += in i40e_get_available_resources()
1045 i40e->i40e_resources.ifr_nmacfilt += in i40e_get_available_resources()
1049 i40e->i40e_resources.ifr_nmcastfilt += in i40e_get_available_resources()
1056 i40e->i40e_resources.ifr_nrx_queue = hw->func_caps.num_rx_qp; in i40e_get_available_resources()
1057 i40e->i40e_resources.ifr_ntx_queue = hw->func_caps.num_tx_qp; in i40e_get_available_resources()
1059 i40e->i40e_uaddrs = kmem_zalloc(sizeof (i40e_uaddr_t) * in i40e_get_available_resources()
1060 i40e->i40e_resources.ifr_nmacfilt, KM_SLEEP); in i40e_get_available_resources()
1061 i40e->i40e_maddrs = kmem_zalloc(sizeof (i40e_maddr_t) * in i40e_get_available_resources()
1062 i40e->i40e_resources.ifr_nmcastfilt, KM_SLEEP); in i40e_get_available_resources()
1068 for (i = 0; i < i40e->i40e_resources.ifr_nmacfilt; i++) in i40e_get_available_resources()
1069 i40e->i40e_uaddrs[i].iua_mac[0] = 0x01; in i40e_get_available_resources()
1075 i40e_enable_interrupts(i40e_t *i40e) in i40e_enable_interrupts() argument
1079 if (i40e->i40e_intr_cap & DDI_INTR_FLAG_BLOCK) { in i40e_enable_interrupts()
1080 rc = ddi_intr_block_enable(i40e->i40e_intr_handles, in i40e_enable_interrupts()
1081 i40e->i40e_intr_count); in i40e_enable_interrupts()
1083 i40e_error(i40e, "Interrupt block-enable failed: %d", in i40e_enable_interrupts()
1088 for (i = 0; i < i40e->i40e_intr_count; i++) { in i40e_enable_interrupts()
1089 rc = ddi_intr_enable(i40e->i40e_intr_handles[i]); in i40e_enable_interrupts()
1091 i40e_error(i40e, in i40e_enable_interrupts()
1095 i40e->i40e_intr_handles[i]); in i40e_enable_interrupts()
1106 i40e_disable_interrupts(i40e_t *i40e) in i40e_disable_interrupts() argument
1110 if (i40e->i40e_intr_cap & DDI_INTR_FLAG_BLOCK) { in i40e_disable_interrupts()
1111 rc = ddi_intr_block_disable(i40e->i40e_intr_handles, in i40e_disable_interrupts()
1112 i40e->i40e_intr_count); in i40e_disable_interrupts()
1114 i40e_error(i40e, in i40e_disable_interrupts()
1119 for (i = 0; i < i40e->i40e_intr_count; i++) { in i40e_disable_interrupts()
1120 rc = ddi_intr_disable(i40e->i40e_intr_handles[i]); in i40e_disable_interrupts()
1122 i40e_error(i40e, in i40e_disable_interrupts()
1137 i40e_free_trqpairs(i40e_t *i40e) in i40e_free_trqpairs() argument
1141 if (i40e->i40e_rx_groups != NULL) { in i40e_free_trqpairs()
1142 kmem_free(i40e->i40e_rx_groups, in i40e_free_trqpairs()
1143 sizeof (i40e_rx_group_t) * i40e->i40e_num_rx_groups); in i40e_free_trqpairs()
1144 i40e->i40e_rx_groups = NULL; in i40e_free_trqpairs()
1147 if (i40e->i40e_trqpairs != NULL) { in i40e_free_trqpairs()
1148 for (uint_t i = 0; i < i40e->i40e_num_trqpairs; i++) { in i40e_free_trqpairs()
1149 itrq = &i40e->i40e_trqpairs[i]; in i40e_free_trqpairs()
1160 kmem_free(i40e->i40e_trqpairs, in i40e_free_trqpairs()
1161 sizeof (i40e_trqpair_t) * i40e->i40e_num_trqpairs); in i40e_free_trqpairs()
1162 i40e->i40e_trqpairs = NULL; in i40e_free_trqpairs()
1165 cv_destroy(&i40e->i40e_rx_pending_cv); in i40e_free_trqpairs()
1166 mutex_destroy(&i40e->i40e_rx_pending_lock); in i40e_free_trqpairs()
1167 mutex_destroy(&i40e->i40e_general_lock); in i40e_free_trqpairs()
1175 i40e_alloc_trqpairs(i40e_t *i40e) in i40e_alloc_trqpairs() argument
1177 void *mutexpri = DDI_INTR_PRI(i40e->i40e_intr_pri); in i40e_alloc_trqpairs()
1183 mutex_init(&i40e->i40e_general_lock, NULL, MUTEX_DRIVER, mutexpri); in i40e_alloc_trqpairs()
1184 mutex_init(&i40e->i40e_rx_pending_lock, NULL, MUTEX_DRIVER, mutexpri); in i40e_alloc_trqpairs()
1185 cv_init(&i40e->i40e_rx_pending_cv, NULL, CV_DRIVER, NULL); in i40e_alloc_trqpairs()
1187 i40e->i40e_trqpairs = kmem_zalloc(sizeof (i40e_trqpair_t) * in i40e_alloc_trqpairs()
1188 i40e->i40e_num_trqpairs, KM_SLEEP); in i40e_alloc_trqpairs()
1189 for (uint_t i = 0; i < i40e->i40e_num_trqpairs; i++) { in i40e_alloc_trqpairs()
1190 i40e_trqpair_t *itrq = &i40e->i40e_trqpairs[i]; in i40e_alloc_trqpairs()
1192 itrq->itrq_i40e = i40e; in i40e_alloc_trqpairs()
1204 for (uint_t i = 0; i < i40e->i40e_num_trqpairs; i++) { in i40e_alloc_trqpairs()
1209 if (!i40e_stats_trqpair_init(&i40e->i40e_trqpairs[i])) { in i40e_alloc_trqpairs()
1210 i40e_free_trqpairs(i40e); in i40e_alloc_trqpairs()
1215 i40e->i40e_rx_groups = kmem_zalloc(sizeof (i40e_rx_group_t) * in i40e_alloc_trqpairs()
1216 i40e->i40e_num_rx_groups, KM_SLEEP); in i40e_alloc_trqpairs()
1218 for (uint_t i = 0; i < i40e->i40e_num_rx_groups; i++) { in i40e_alloc_trqpairs()
1219 i40e_rx_group_t *rxg = &i40e->i40e_rx_groups[i]; in i40e_alloc_trqpairs()
1222 rxg->irg_i40e = i40e; in i40e_alloc_trqpairs()
1236 i40e_hw_to_instance(i40e_t *i40e, i40e_hw_t *hw) in i40e_hw_to_instance() argument
1238 if (i40e->i40e_num_trqpairs_per_vsi == 0) { in i40e_hw_to_instance()
1239 if (i40e_is_x722(i40e)) { in i40e_hw_to_instance()
1240 i40e->i40e_num_trqpairs_per_vsi = in i40e_hw_to_instance()
1243 i40e->i40e_num_trqpairs_per_vsi = in i40e_hw_to_instance()
1248 if (i40e->i40e_num_rx_groups == 0) { in i40e_hw_to_instance()
1249 i40e->i40e_num_rx_groups = I40E_DEF_NUM_RX_GROUPS; in i40e_hw_to_instance()
1257 i40e_common_code_fini(i40e_t *i40e) in i40e_common_code_fini() argument
1259 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_common_code_fini()
1264 i40e_error(i40e, "failed to shutdown LAN hmc: %d", rc); in i40e_common_code_fini()
1268 i40e_error(i40e, "failed to shutdown admin queue: %d", rc); in i40e_common_code_fini()
1277 i40e_common_code_init(i40e_t *i40e, i40e_hw_t *hw) in i40e_common_code_init() argument
1284 i40e_error(i40e, "failed to reset hardware: %d", rc); in i40e_common_code_init()
1285 i40e_fm_ereport(i40e, DDI_FM_DEVICE_NO_RESPONSE); in i40e_common_code_init()
1291 i40e_error(i40e, "failed to initialize i40e core: %d", rc); in i40e_common_code_init()
1302 i40e_error(i40e, "failed to initialize firmware admin queue: " in i40e_common_code_init()
1304 i40e_fm_ereport(i40e, DDI_FM_DEVICE_INVAL_STATE); in i40e_common_code_init()
1310 i40e_log(i40e, "The driver for the device detected a newer " in i40e_common_code_init()
1317 i40e_log(i40e, "The driver for the device detected an older" in i40e_common_code_init()
1330 if (!i40e_get_hw_capabilities(i40e, hw)) { in i40e_common_code_init()
1331 i40e_error(i40e, "failed to obtain hardware capabilities"); in i40e_common_code_init()
1335 if (i40e_get_available_resources(i40e) == B_FALSE) { in i40e_common_code_init()
1336 i40e_error(i40e, "failed to obtain hardware resources"); in i40e_common_code_init()
1340 i40e_hw_to_instance(i40e, hw); in i40e_common_code_init()
1345 i40e_error(i40e, "failed to initialize hardware memory cache: " in i40e_common_code_init()
1352 i40e_error(i40e, "failed to configure hardware memory cache: " in i40e_common_code_init()
1361 i40e_error(i40e, "failed to retrieve hardware mac address: %d", in i40e_common_code_init()
1368 i40e_error(i40e, "failed to validate internal mac address: " in i40e_common_code_init()
1375 i40e_error(i40e, "failed to retrieve port mac address: %d", in i40e_common_code_init()
1384 if (!i40e_set_def_vsi_seid(i40e)) { in i40e_common_code_init()
1385 i40e_error(i40e, "failed to obtain Default VSI SEID"); in i40e_common_code_init()
1393 i40e_unconfigure(dev_info_t *devinfo, i40e_t *i40e) in i40e_unconfigure() argument
1397 if (i40e->i40e_attach_progress & I40E_ATTACH_ENABLE_INTR) in i40e_unconfigure()
1398 (void) i40e_disable_interrupts(i40e); in i40e_unconfigure()
1400 if ((i40e->i40e_attach_progress & I40E_ATTACH_LINK_TIMER) && in i40e_unconfigure()
1401 i40e->i40e_periodic_id != 0) { in i40e_unconfigure()
1402 ddi_periodic_delete(i40e->i40e_periodic_id); in i40e_unconfigure()
1403 i40e->i40e_periodic_id = 0; in i40e_unconfigure()
1406 if (i40e->i40e_attach_progress & I40E_ATTACH_UFM_INIT) in i40e_unconfigure()
1407 ddi_ufm_fini(i40e->i40e_ufmh); in i40e_unconfigure()
1409 if (i40e->i40e_attach_progress & I40E_ATTACH_MAC) { in i40e_unconfigure()
1410 rc = mac_unregister(i40e->i40e_mac_hdl); in i40e_unconfigure()
1412 i40e_error(i40e, "failed to unregister from mac: %d", in i40e_unconfigure()
1417 if (i40e->i40e_attach_progress & I40E_ATTACH_STATS) { in i40e_unconfigure()
1418 i40e_stats_fini(i40e); in i40e_unconfigure()
1421 if (i40e->i40e_attach_progress & I40E_ATTACH_ADD_INTR) in i40e_unconfigure()
1422 i40e_rem_intr_handlers(i40e); in i40e_unconfigure()
1424 if (i40e->i40e_attach_progress & I40E_ATTACH_ALLOC_RINGSLOCKS) in i40e_unconfigure()
1425 i40e_free_trqpairs(i40e); in i40e_unconfigure()
1427 if (i40e->i40e_attach_progress & I40E_ATTACH_ALLOC_INTR) in i40e_unconfigure()
1428 i40e_rem_intrs(i40e); in i40e_unconfigure()
1430 if (i40e->i40e_attach_progress & I40E_ATTACH_COMMON_CODE) in i40e_unconfigure()
1431 i40e_common_code_fini(i40e); in i40e_unconfigure()
1433 i40e_cleanup_resources(i40e); in i40e_unconfigure()
1435 if (i40e->i40e_attach_progress & I40E_ATTACH_PROPS) in i40e_unconfigure()
1438 if (i40e->i40e_attach_progress & I40E_ATTACH_REGS_MAP && in i40e_unconfigure()
1439 i40e->i40e_osdep_space.ios_reg_handle != NULL) { in i40e_unconfigure()
1440 ddi_regs_map_free(&i40e->i40e_osdep_space.ios_reg_handle); in i40e_unconfigure()
1441 i40e->i40e_osdep_space.ios_reg_handle = NULL; in i40e_unconfigure()
1444 if ((i40e->i40e_attach_progress & I40E_ATTACH_PCI_CONFIG) && in i40e_unconfigure()
1445 i40e->i40e_osdep_space.ios_cfg_handle != NULL) { in i40e_unconfigure()
1446 pci_config_teardown(&i40e->i40e_osdep_space.ios_cfg_handle); in i40e_unconfigure()
1447 i40e->i40e_osdep_space.ios_cfg_handle = NULL; in i40e_unconfigure()
1450 if (i40e->i40e_attach_progress & I40E_ATTACH_FM_INIT) in i40e_unconfigure()
1451 i40e_fm_fini(i40e); in i40e_unconfigure()
1453 kmem_free(i40e->i40e_aqbuf, I40E_ADMINQ_BUFSZ); in i40e_unconfigure()
1454 kmem_free(i40e, sizeof (i40e_t)); in i40e_unconfigure()
1460 i40e_final_init(i40e_t *i40e) in i40e_final_init() argument
1462 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_final_init()
1471 i40e_log(i40e, "failed to read PBA string: %d", irc); in i40e_final_init()
1473 (void) ddi_prop_update_string(DDI_DEV_T_NONE, i40e->i40e_dip, in i40e_final_init()
1487 (void) ddi_prop_update_string(DDI_DEV_T_NONE, i40e->i40e_dip, in i40e_final_init()
1490 (void) ddi_prop_update_string(DDI_DEV_T_NONE, i40e->i40e_dip, in i40e_final_init()
1494 (void) ddi_prop_update_string(DDI_DEV_T_NONE, i40e->i40e_dip, in i40e_final_init()
1501 ddi_fm_service_impact(i40e->i40e_dip, DDI_SERVICE_LOST); in i40e_final_init()
1509 i40e_identify_hardware(i40e_t *i40e) in i40e_identify_hardware() argument
1511 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_identify_hardware()
1512 struct i40e_osdep *osdep = &i40e->i40e_osdep_space; in i40e_identify_hardware()
1532 i40e_regs_map(i40e_t *i40e) in i40e_regs_map() argument
1534 dev_info_t *devinfo = i40e->i40e_dip; in i40e_regs_map()
1535 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_regs_map()
1536 struct i40e_osdep *osdep = &i40e->i40e_osdep_space; in i40e_regs_map()
1542 i40e_error(i40e, "Used invalid register set to map PCIe regs"); in i40e_regs_map()
1549 i40e_error(i40e, "failed to map device registers: %d", ret); in i40e_regs_map()
1563 i40e_update_mtu(i40e_t *i40e) in i40e_update_mtu() argument
1567 i40e->i40e_frame_max = i40e->i40e_sdu + in i40e_update_mtu()
1570 rx = i40e->i40e_frame_max + I40E_BUF_IPHDR_ALIGNMENT; in i40e_update_mtu()
1571 i40e->i40e_rx_buf_size = ((rx >> 10) + in i40e_update_mtu()
1574 tx = i40e->i40e_frame_max; in i40e_update_mtu()
1575 i40e->i40e_tx_buf_size = ((tx >> 10) + in i40e_update_mtu()
1580 i40e_get_prop(i40e_t *i40e, char *prop, int min, int max, int def) in i40e_get_prop() argument
1584 val = ddi_prop_get_int(DDI_DEV_T_ANY, i40e->i40e_dip, DDI_PROP_DONTPASS, in i40e_get_prop()
1594 i40e_init_properties(i40e_t *i40e) in i40e_init_properties() argument
1596 i40e->i40e_sdu = i40e_get_prop(i40e, "default_mtu", in i40e_init_properties()
1599 i40e->i40e_intr_force = i40e_get_prop(i40e, "intr_force", in i40e_init_properties()
1602 i40e->i40e_mr_enable = i40e_get_prop(i40e, "mr_enable", in i40e_init_properties()
1605 i40e->i40e_tx_ring_size = i40e_get_prop(i40e, "tx_ring_size", in i40e_init_properties()
1608 if ((i40e->i40e_tx_ring_size % I40E_DESC_ALIGN) != 0) { in i40e_init_properties()
1609 i40e->i40e_tx_ring_size = P2ROUNDUP(i40e->i40e_tx_ring_size, in i40e_init_properties()
1613 i40e->i40e_tx_block_thresh = i40e_get_prop(i40e, "tx_resched_threshold", in i40e_init_properties()
1615 i40e->i40e_tx_ring_size - I40E_TX_MAX_COOKIE, in i40e_init_properties()
1618 i40e->i40e_num_rx_groups = i40e_get_prop(i40e, "rx_num_groups", in i40e_init_properties()
1622 i40e->i40e_rx_ring_size = i40e_get_prop(i40e, "rx_ring_size", in i40e_init_properties()
1625 if ((i40e->i40e_rx_ring_size % I40E_DESC_ALIGN) != 0) { in i40e_init_properties()
1626 i40e->i40e_rx_ring_size = P2ROUNDUP(i40e->i40e_rx_ring_size, in i40e_init_properties()
1630 i40e->i40e_rx_limit_per_intr = i40e_get_prop(i40e, "rx_limit_per_intr", in i40e_init_properties()
1634 i40e->i40e_tx_hcksum_enable = i40e_get_prop(i40e, "tx_hcksum_enable", in i40e_init_properties()
1637 i40e->i40e_tx_lso_enable = i40e_get_prop(i40e, "tx_lso_enable", in i40e_init_properties()
1640 i40e->i40e_rx_hcksum_enable = i40e_get_prop(i40e, "rx_hcksum_enable", in i40e_init_properties()
1643 i40e->i40e_rx_dma_min = i40e_get_prop(i40e, "rx_dma_threshold", in i40e_init_properties()
1647 i40e->i40e_tx_dma_min = i40e_get_prop(i40e, "tx_dma_threshold", in i40e_init_properties()
1651 i40e->i40e_tx_itr = i40e_get_prop(i40e, "tx_intr_throttle", in i40e_init_properties()
1654 i40e->i40e_rx_itr = i40e_get_prop(i40e, "rx_intr_throttle", in i40e_init_properties()
1657 i40e->i40e_other_itr = i40e_get_prop(i40e, "other_intr_throttle", in i40e_init_properties()
1660 if (!i40e->i40e_mr_enable) { in i40e_init_properties()
1661 i40e->i40e_num_trqpairs = I40E_TRQPAIR_NOMSIX; in i40e_init_properties()
1662 i40e->i40e_num_rx_groups = I40E_GROUP_NOMSIX; in i40e_init_properties()
1665 i40e_update_mtu(i40e); in i40e_init_properties()
1682 i40e_alloc_intr_handles(i40e_t *i40e, dev_info_t *devinfo, int intr_type) in i40e_alloc_intr_handles() argument
1684 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_alloc_intr_handles()
1685 ddi_acc_handle_t rh = i40e->i40e_osdep_space.ios_reg_handle; in i40e_alloc_intr_handles()
1697 if (!i40e->i40e_mr_enable) { in i40e_alloc_intr_handles()
1707 ddi_fm_service_impact(i40e->i40e_dip, in i40e_alloc_intr_handles()
1722 i40e_log(i40e, "Get interrupt number failed, " in i40e_alloc_intr_handles()
1729 i40e_log(i40e, "Get AVAILABLE interrupt number failed, " in i40e_alloc_intr_handles()
1735 i40e->i40e_intr_count = 0; in i40e_alloc_intr_handles()
1736 i40e->i40e_intr_count_max = 0; in i40e_alloc_intr_handles()
1737 i40e->i40e_intr_count_min = 0; in i40e_alloc_intr_handles()
1739 i40e->i40e_intr_size = request * sizeof (ddi_intr_handle_t); in i40e_alloc_intr_handles()
1740 ASSERT(i40e->i40e_intr_size != 0); in i40e_alloc_intr_handles()
1741 i40e->i40e_intr_handles = kmem_alloc(i40e->i40e_intr_size, KM_SLEEP); in i40e_alloc_intr_handles()
1743 rc = ddi_intr_alloc(devinfo, i40e->i40e_intr_handles, intr_type, 0, in i40e_alloc_intr_handles()
1746 i40e_log(i40e, "Interrupt allocation failed with %d.", rc); in i40e_alloc_intr_handles()
1750 i40e->i40e_intr_count = actual; in i40e_alloc_intr_handles()
1751 i40e->i40e_intr_count_max = request; in i40e_alloc_intr_handles()
1752 i40e->i40e_intr_count_min = min; in i40e_alloc_intr_handles()
1755 i40e_log(i40e, "actual (%d) is less than minimum (%d).", in i40e_alloc_intr_handles()
1765 rc = ddi_intr_get_pri(i40e->i40e_intr_handles[0], &i40e->i40e_intr_pri); in i40e_alloc_intr_handles()
1767 i40e_log(i40e, in i40e_alloc_intr_handles()
1772 rc = ddi_intr_get_cap(i40e->i40e_intr_handles[0], &i40e->i40e_intr_cap); in i40e_alloc_intr_handles()
1774 i40e_log(i40e, in i40e_alloc_intr_handles()
1779 i40e->i40e_intr_type = intr_type; in i40e_alloc_intr_handles()
1784 i40e_rem_intrs(i40e); in i40e_alloc_intr_handles()
1789 i40e_alloc_intrs(i40e_t *i40e, dev_info_t *devinfo) in i40e_alloc_intrs() argument
1791 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_alloc_intrs()
1795 if (i40e_is_x722(i40e)) { in i40e_alloc_intrs()
1803 i40e_error(i40e, "failed to get supported interrupt types: %d", in i40e_alloc_intrs()
1808 i40e->i40e_intr_type = 0; in i40e_alloc_intrs()
1818 (i40e->i40e_intr_force <= I40E_INTR_MSIX) && in i40e_alloc_intrs()
1819 (i40e_alloc_intr_handles(i40e, devinfo, DDI_INTR_TYPE_MSIX))) { in i40e_alloc_intrs()
1831 n = MIN(i40e->i40e_intr_count - 1, max_trqpairs); in i40e_alloc_intrs()
1853 i40e->i40e_num_trqpairs_per_vsi = n; in i40e_alloc_intrs()
1859 ASSERT3U(i40e->i40e_num_rx_groups, >, 0); in i40e_alloc_intrs()
1861 num_trqpairs = i40e->i40e_num_trqpairs_per_vsi * in i40e_alloc_intrs()
1862 i40e->i40e_num_rx_groups; in i40e_alloc_intrs()
1864 i40e->i40e_num_rx_groups = MAX(1, qp_cap / in i40e_alloc_intrs()
1865 i40e->i40e_num_trqpairs_per_vsi); in i40e_alloc_intrs()
1866 num_trqpairs = i40e->i40e_num_trqpairs_per_vsi * in i40e_alloc_intrs()
1867 i40e->i40e_num_rx_groups; in i40e_alloc_intrs()
1868 i40e_log(i40e, "Rx groups restricted to %u", in i40e_alloc_intrs()
1869 i40e->i40e_num_rx_groups); in i40e_alloc_intrs()
1872 i40e->i40e_num_trqpairs = num_trqpairs; in i40e_alloc_intrs()
1881 i40e->i40e_num_trqpairs = I40E_TRQPAIR_NOMSIX; in i40e_alloc_intrs()
1882 i40e->i40e_num_trqpairs_per_vsi = i40e->i40e_num_trqpairs; in i40e_alloc_intrs()
1883 i40e->i40e_num_rx_groups = I40E_GROUP_NOMSIX; in i40e_alloc_intrs()
1886 (i40e->i40e_intr_force <= I40E_INTR_MSI)) { in i40e_alloc_intrs()
1887 if (i40e_alloc_intr_handles(i40e, devinfo, DDI_INTR_TYPE_MSI)) in i40e_alloc_intrs()
1892 if (i40e_alloc_intr_handles(i40e, devinfo, DDI_INTR_TYPE_FIXED)) in i40e_alloc_intrs()
1903 i40e_map_intrs_to_vectors(i40e_t *i40e) in i40e_map_intrs_to_vectors() argument
1905 if (i40e->i40e_intr_type != DDI_INTR_TYPE_MSIX) { in i40e_map_intrs_to_vectors()
1914 for (uint_t i = 0; i < i40e->i40e_num_trqpairs; i++) { in i40e_map_intrs_to_vectors()
1915 uint_t vector = i % (i40e->i40e_intr_count - 1); in i40e_map_intrs_to_vectors()
1917 i40e->i40e_trqpairs[i].itrq_rx_intrvec = vector + 1; in i40e_map_intrs_to_vectors()
1918 i40e->i40e_trqpairs[i].itrq_tx_intrvec = vector + 1; in i40e_map_intrs_to_vectors()
1925 i40e_add_intr_handlers(i40e_t *i40e) in i40e_add_intr_handlers() argument
1929 switch (i40e->i40e_intr_type) { in i40e_add_intr_handlers()
1931 for (vector = 0; vector < i40e->i40e_intr_count; vector++) { in i40e_add_intr_handlers()
1933 i40e->i40e_intr_handles[vector], in i40e_add_intr_handlers()
1934 (ddi_intr_handler_t *)i40e_intr_msix, i40e, in i40e_add_intr_handlers()
1937 i40e_log(i40e, "Add interrupt handler (MSI-X) " in i40e_add_intr_handlers()
1941 i40e->i40e_intr_handles[vector]); in i40e_add_intr_handlers()
1948 rc = ddi_intr_add_handler(i40e->i40e_intr_handles[0], in i40e_add_intr_handlers()
1949 (ddi_intr_handler_t *)i40e_intr_msi, i40e, NULL); in i40e_add_intr_handlers()
1951 i40e_log(i40e, "Add interrupt handler (MSI) failed: " in i40e_add_intr_handlers()
1957 rc = ddi_intr_add_handler(i40e->i40e_intr_handles[0], in i40e_add_intr_handlers()
1958 (ddi_intr_handler_t *)i40e_intr_legacy, i40e, NULL); in i40e_add_intr_handlers()
1960 i40e_log(i40e, "Add interrupt handler (legacy) failed:" in i40e_add_intr_handlers()
1968 (void *)i40e, i40e->i40e_intr_type); in i40e_add_intr_handlers()
1986 i40e_t *i40e = arg; in i40e_timer() local
1988 mutex_enter(&i40e->i40e_general_lock); in i40e_timer()
1989 i40e_link_check(i40e); in i40e_timer()
1990 mutex_exit(&i40e->i40e_general_lock); in i40e_timer()
1997 i40e_get_hw_state(i40e_t *i40e, i40e_hw_t *hw) in i40e_get_hw_state() argument
2001 ASSERT(MUTEX_HELD(&i40e->i40e_general_lock)); in i40e_get_hw_state()
2004 i40e_link_check(i40e); in i40e_get_hw_state()
2010 rc = i40e_aq_get_phy_capabilities(hw, false, true, &i40e->i40e_phy, in i40e_get_hw_state()
2015 &i40e->i40e_phy, NULL); in i40e_get_hw_state()
2020 i40e_error(i40e, "encountered unknown PHY type, " in i40e_get_hw_state()
2023 i40e_error(i40e, "error getting physical capabilities: " in i40e_get_hw_state()
2030 i40e_error(i40e, "failed to update link information: %d", rc); in i40e_get_hw_state()
2039 i40e_error(i40e, "failed to update phy link mask: %d", rc); in i40e_get_hw_state()
2052 i40e_init_macaddrs(i40e_t *i40e, i40e_hw_t *hw) in i40e_init_macaddrs() argument
2062 i40e_set_shared_vsi_props(i40e_t *i40e, in i40e_set_shared_vsi_props() argument
2081 vsi_qp_base = vsi_idx * i40e->i40e_num_trqpairs_per_vsi; in i40e_set_shared_vsi_props()
2100 tc_queues = ddi_fls(i40e->i40e_num_trqpairs_per_vsi - 1); in i40e_set_shared_vsi_props()
2135 i40e_delete_vsi(i40e_t *i40e, uint_t idx) in i40e_delete_vsi() argument
2137 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_delete_vsi()
2138 uint16_t seid = i40e->i40e_vsis[idx].iv_seid; in i40e_delete_vsi()
2146 i40e_error(i40e, "Failed to delete VSI %d: %d", in i40e_delete_vsi()
2150 i40e->i40e_vsis[idx].iv_seid = 0; in i40e_delete_vsi()
2158 i40e_add_vsi(i40e_t *i40e, i40e_hw_t *hw, uint_t idx) in i40e_add_vsi() argument
2171 ctx.uplink_seid = i40e->i40e_veb_seid; in i40e_add_vsi()
2175 i40e_set_shared_vsi_props(i40e, &ctx.info, idx); in i40e_add_vsi()
2179 i40e_error(i40e, "i40e_aq_add_vsi() failed %d: %d", rc, in i40e_add_vsi()
2184 rxg = &i40e->i40e_rx_groups[idx]; in i40e_add_vsi()
2186 i40e->i40e_vsis[idx].iv_number = ctx.vsi_number; in i40e_add_vsi()
2187 i40e->i40e_vsis[idx].iv_seid = ctx.seid; in i40e_add_vsi()
2188 i40e->i40e_vsis[idx].iv_stats_id = LE_16(ctx.info.stat_counter_idx); in i40e_add_vsi()
2190 if (i40e_stat_vsi_init(i40e, idx) == B_FALSE) in i40e_add_vsi()
2200 i40e_config_def_vsi(i40e_t *i40e, i40e_hw_t *hw) in i40e_config_def_vsi() argument
2208 ctx.seid = I40E_DEF_VSI_SEID(i40e); in i40e_config_def_vsi()
2212 i40e_error(i40e, "get VSI params failed with %d", err); in i40e_config_def_vsi()
2217 i40e->i40e_vsis[0].iv_number = ctx.vsi_number; in i40e_config_def_vsi()
2218 i40e->i40e_vsis[0].iv_stats_id = LE_16(ctx.info.stat_counter_idx); in i40e_config_def_vsi()
2219 if (i40e_stat_vsi_init(i40e, 0) == B_FALSE) in i40e_config_def_vsi()
2222 i40e_set_shared_vsi_props(i40e, &ctx.info, I40E_DEF_VSI_IDX); in i40e_config_def_vsi()
2226 i40e_error(i40e, "Update VSI params failed with %d", err); in i40e_config_def_vsi()
2230 def_rxg = &i40e->i40e_rx_groups[0]; in i40e_config_def_vsi()
2231 def_rxg->irg_vsi_seid = I40E_DEF_VSI_SEID(i40e); in i40e_config_def_vsi()
2265 ASSERT3U(i40e->i40e_resources.ifr_nmacfilt_used, <=, 1); in i40e_config_def_vsi()
2266 i40e_log(i40e, "Num L2 filters: %u", in i40e_config_def_vsi()
2267 i40e->i40e_resources.ifr_nmacfilt_used); in i40e_config_def_vsi()
2269 err = i40e_aq_remove_macvlan(hw, I40E_DEF_VSI_SEID(i40e), &filt, 1, in i40e_config_def_vsi()
2272 i40e_log(i40e, in i40e_config_def_vsi()
2274 I40E_DEF_VSI_SEID(i40e)); in i40e_config_def_vsi()
2276 i40e_log(i40e, in i40e_config_def_vsi()
2278 I40E_DEF_VSI_SEID(i40e)); in i40e_config_def_vsi()
2280 i40e_error(i40e, "Failed to remove L2 filter from" in i40e_config_def_vsi()
2282 I40E_DEF_VSI_SEID(i40e), err, hw->aq.asq_last_status); in i40e_config_def_vsi()
2307 if (i40e->i40e_resources.ifr_nmacfilt_used == 1) { in i40e_config_def_vsi()
2308 i40e->i40e_resources.ifr_nmacfilt_used--; in i40e_config_def_vsi()
2310 if (i40e->i40e_resources.ifr_nmacfilt_used != 0) { in i40e_config_def_vsi()
2311 i40e_error(i40e, "Unexpected L2 filter count: %u" in i40e_config_def_vsi()
2313 i40e->i40e_resources.ifr_nmacfilt_used); in i40e_config_def_vsi()
2322 i40e_config_rss_key_x722(i40e_t *i40e, i40e_hw_t *hw) in i40e_config_rss_key_x722() argument
2324 for (uint_t i = 0; i < i40e->i40e_num_rx_groups; i++) { in i40e_config_rss_key_x722()
2329 uint16_t vsi_number = i40e->i40e_vsis[i].iv_number; in i40e_config_rss_key_x722()
2346 i40e_error(i40e, "failed to set RSS key for VSI %u: %d", in i40e_config_rss_key_x722()
2361 i40e_config_rss_key(i40e_t *i40e, i40e_hw_t *hw) in i40e_config_rss_key() argument
2363 if (i40e_is_x722(i40e)) { in i40e_config_rss_key()
2364 if (!i40e_config_rss_key_x722(i40e, hw)) in i40e_config_rss_key()
2390 i40e_config_rss_hlut(i40e_t *i40e, i40e_hw_t *hw) in i40e_config_rss_hlut() argument
2403 i40e_error(i40e, "i40e_config_rss() buffer allocation failed"); in i40e_config_rss_hlut()
2411 if (i40e_is_x722(i40e)) { in i40e_config_rss_hlut()
2419 (i % i40e->i40e_num_trqpairs_per_vsi) & lut_mask; in i40e_config_rss_hlut()
2422 if (i40e_is_x722(i40e)) { in i40e_config_rss_hlut()
2429 i40e_error(i40e, "failed to set RSS LUT %d: %d", in i40e_config_rss_hlut()
2451 i40e_config_rss(i40e_t *i40e, i40e_hw_t *hw) in i40e_config_rss() argument
2458 if (!i40e_config_rss_key(i40e, hw)) in i40e_config_rss()
2479 if (i40e_is_x722(i40e)) { in i40e_config_rss()
2494 return (i40e_config_rss_hlut(i40e, hw)); in i40e_config_rss()
2501 i40e_chip_start(i40e_t *i40e) in i40e_chip_start() argument
2503 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_chip_start()
2513 i40e_error(i40e, "failed to restart link: admin queue " in i40e_chip_start()
2520 i40e_get_hw_state(i40e, hw); in i40e_chip_start()
2526 i40e_error(i40e, "Setting flow control failed, returned %d" in i40e_chip_start()
2532 i40e_init_macaddrs(i40e, hw); in i40e_chip_start()
2546 i40e_error(i40e, "i40e_set_filter_control() returned %d", rc); in i40e_chip_start()
2550 i40e_intr_chip_init(i40e); in i40e_chip_start()
2552 rc = i40e_get_mac_seid(i40e); in i40e_chip_start()
2554 i40e_error(i40e, "failed to obtain MAC Uplink SEID"); in i40e_chip_start()
2557 i40e->i40e_mac_seid = (uint16_t)rc; in i40e_chip_start()
2565 rc = i40e_aq_add_veb(hw, i40e->i40e_mac_seid, I40E_DEF_VSI_SEID(i40e), in i40e_chip_start()
2566 0x1, true, &i40e->i40e_veb_seid, false, NULL); in i40e_chip_start()
2568 i40e_error(i40e, "i40e_aq_add_veb() failed %d: %d", rc, in i40e_chip_start()
2573 if (!i40e_config_def_vsi(i40e, hw)) in i40e_chip_start()
2576 for (uint_t i = 1; i < i40e->i40e_num_rx_groups; i++) { in i40e_chip_start()
2577 if (!i40e_add_vsi(i40e, hw, i)) in i40e_chip_start()
2581 if (!i40e_config_rss(i40e, hw)) in i40e_chip_start()
2595 i40e_t *i40e = itrq->itrq_i40e; in i40e_shutdown_rx_ring() local
2596 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_shutdown_rx_ring()
2631 i40e_t *i40e = itrq->itrq_i40e; in i40e_shutdown_tx_ring() local
2632 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_shutdown_tx_ring()
2671 i40e_t *i40e = itrq->itrq_i40e; in i40e_shutdown_ring_wait() local
2672 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_shutdown_ring_wait()
2684 i40e_error(i40e, "timed out disabling rx queue %d", in i40e_shutdown_ring_wait()
2697 i40e_error(i40e, "timed out disabling tx queue %d", in i40e_shutdown_ring_wait()
2756 i40e_shutdown_rings(i40e_t *i40e) in i40e_shutdown_rings() argument
2761 for (i = 0; i < i40e->i40e_num_trqpairs; i++) { in i40e_shutdown_rings()
2762 if (!i40e_shutdown_ring(&i40e->i40e_trqpairs[i])) in i40e_shutdown_rings()
2792 i40e_t *i40e = itrq->itrq_i40e; in i40e_setup_rx_hmc() local
2793 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_setup_rx_hmc()
2802 VERIFY(i40e->i40e_rx_buf_size >= I40E_HMC_RX_DBUFF_MIN); in i40e_setup_rx_hmc()
2803 VERIFY(i40e->i40e_rx_buf_size <= I40E_HMC_RX_DBUFF_MAX); in i40e_setup_rx_hmc()
2804 rctx.dbuff = i40e->i40e_rx_buf_size >> I40E_RXQ_CTX_DBUFF_SHIFT; in i40e_setup_rx_hmc()
2814 rctx.rxmax = i40e->i40e_frame_max; in i40e_setup_rx_hmc()
2828 i40e_error(i40e, "failed to clear rx queue %d context: %d", in i40e_setup_rx_hmc()
2835 i40e_error(i40e, "failed to set rx queue %d context: %d", in i40e_setup_rx_hmc()
2851 i40e_t *i40e = itrq->itrq_i40e; in i40e_setup_rx_ring() local
2852 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_setup_rx_ring()
2899 i40e_error(i40e, "failed to enable rx queue %d, timed " in i40e_setup_rx_ring()
2910 i40e_t *i40e = itrq->itrq_i40e; in i40e_setup_tx_hmc() local
2911 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_setup_tx_hmc()
2948 context.seid = I40E_DEF_VSI_SEID(i40e); in i40e_setup_tx_hmc()
2952 i40e_error(i40e, "get VSI params failed with %d", err); in i40e_setup_tx_hmc()
2959 i40e_error(i40e, "failed to clear tx queue %d context: %d", in i40e_setup_tx_hmc()
2966 i40e_error(i40e, "failed to set tx queue %d context: %d", in i40e_setup_tx_hmc()
2981 i40e_t *i40e = itrq->itrq_i40e; in i40e_setup_tx_ring() local
2982 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_setup_tx_ring()
3030 i40e_error(i40e, "failed to enable tx queue %d, timed " in i40e_setup_tx_ring()
3041 i40e_t *i40e = itrq->itrq_i40e; in i40e_setup_ring() local
3045 i40e_error(i40e, "Failed to allocate ring memory"); in i40e_setup_ring()
3066 if (i40e_check_acc_handle(i40e->i40e_osdep_space.ios_reg_handle) != in i40e_setup_ring()
3082 ddi_fm_service_impact(i40e->i40e_dip, DDI_SERVICE_LOST); in i40e_setup_ring()
3088 i40e_stop(i40e_t *i40e) in i40e_stop() argument
3091 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_stop()
3093 ASSERT(MUTEX_HELD(&i40e->i40e_general_lock)); in i40e_stop()
3118 i40e_intr_io_disable_all(i40e); in i40e_stop()
3119 i40e_intr_io_clear_cause(i40e); in i40e_stop()
3121 if (!i40e_shutdown_rings(i40e)) in i40e_stop()
3122 ddi_fm_service_impact(i40e->i40e_dip, DDI_SERVICE_LOST); in i40e_stop()
3130 for (i = 1; i < i40e->i40e_num_rx_groups; i++) { in i40e_stop()
3131 i40e_delete_vsi(i40e, i); in i40e_stop()
3134 if (i40e->i40e_veb_seid != 0) { in i40e_stop()
3135 int rc = i40e_aq_delete_element(hw, i40e->i40e_veb_seid, NULL); in i40e_stop()
3138 i40e_error(i40e, "Failed to delete VEB %d: %d", rc, in i40e_stop()
3142 i40e->i40e_veb_seid = 0; in i40e_stop()
3145 i40e_intr_chip_fini(i40e); in i40e_stop()
3147 if (i40e_check_acc_handle(i40e->i40e_osdep_space.ios_cfg_handle) != in i40e_stop()
3149 ddi_fm_service_impact(i40e->i40e_dip, DDI_SERVICE_LOST); in i40e_stop()
3152 for (i = 0; i < i40e->i40e_num_rx_groups; i++) { in i40e_stop()
3153 i40e_stat_vsi_fini(i40e, i); in i40e_stop()
3156 i40e->i40e_link_speed = 0; in i40e_stop()
3157 i40e->i40e_link_duplex = 0; in i40e_stop()
3158 i40e_link_state_set(i40e, LINK_STATE_UNKNOWN); in i40e_stop()
3162 i40e_start(i40e_t *i40e) in i40e_start() argument
3164 i40e_hw_t *hw = &i40e->i40e_hw_space; in i40e_start()
3168 ASSERT(MUTEX_HELD(&i40e->i40e_general_lock)); in i40e_start()
3170 if (!i40e_chip_start(i40e)) { in i40e_start()
3171 i40e_fm_ereport(i40e, DDI_FM_DEVICE_INVAL_STATE); in i40e_start()
3180 err = i40e_aq_set_vsi_broadcast(hw, I40E_DEF_VSI_SEID(i40e), true, in i40e_start()
3183 i40e_error(i40e, "failed to set default VSI: %d", err); in i40e_start()
3188 err = i40e_aq_set_mac_config(hw, i40e->i40e_frame_max, true, 0, in i40e_start()
3191 i40e_error(i40e, "failed to set MAC config: %d", err); in i40e_start()
3199 if (i40e_check_acc_handle(i40e->i40e_osdep_space.ios_reg_handle) != in i40e_start()
3206 atomic_and_32(&i40e->i40e_state, in i40e_start()
3209 i40e_intr_io_enable_all(i40e); in i40e_start()
3213 i40e_stop(i40e); in i40e_start()
3214 ddi_fm_service_impact(i40e->i40e_dip, DDI_SERVICE_LOST); in i40e_start()
3225 i40e_drain_rx(i40e_t *i40e) in i40e_drain_rx() argument
3227 mutex_enter(&i40e->i40e_rx_pending_lock); in i40e_drain_rx()
3228 while (i40e->i40e_rx_pending > 0) { in i40e_drain_rx()
3229 if (cv_reltimedwait(&i40e->i40e_rx_pending_cv, in i40e_drain_rx()
3230 &i40e->i40e_rx_pending_lock, in i40e_drain_rx()
3232 mutex_exit(&i40e->i40e_rx_pending_lock); in i40e_drain_rx()
3236 mutex_exit(&i40e->i40e_rx_pending_lock); in i40e_drain_rx()
3261 i40e_t *i40e = (i40e_t *)arg; in i40e_ufm_fill_slot() local
3268 ddi_prop_lookup_string(DDI_DEV_T_ANY, i40e->i40e_dip, flags, in i40e_ufm_fill_slot()
3270 ddi_prop_lookup_string(DDI_DEV_T_ANY, i40e->i40e_dip, flags, in i40e_ufm_fill_slot()
3272 ddi_prop_lookup_string(DDI_DEV_T_ANY, i40e->i40e_dip, flags, in i40e_ufm_fill_slot()
3323 i40e_t *i40e; in i40e_attach() local
3332 i40e = kmem_zalloc(sizeof (i40e_t), KM_SLEEP); in i40e_attach()
3334 i40e->i40e_aqbuf = kmem_zalloc(I40E_ADMINQ_BUFSZ, KM_SLEEP); in i40e_attach()
3335 i40e->i40e_instance = instance; in i40e_attach()
3336 i40e->i40e_dip = devinfo; in i40e_attach()
3338 hw = &i40e->i40e_hw_space; in i40e_attach()
3339 osdep = &i40e->i40e_osdep_space; in i40e_attach()
3341 osdep->ios_i40e = i40e; in i40e_attach()
3343 ddi_set_driver_private(devinfo, i40e); in i40e_attach()
3345 i40e_fm_init(i40e); in i40e_attach()
3346 i40e->i40e_attach_progress |= I40E_ATTACH_FM_INIT; in i40e_attach()
3349 i40e_error(i40e, "Failed to map PCI configurations."); in i40e_attach()
3352 i40e->i40e_attach_progress |= I40E_ATTACH_PCI_CONFIG; in i40e_attach()
3354 i40e_identify_hardware(i40e); in i40e_attach()
3356 if (!i40e_regs_map(i40e)) { in i40e_attach()
3357 i40e_error(i40e, "Failed to map device registers."); in i40e_attach()
3360 i40e->i40e_attach_progress |= I40E_ATTACH_REGS_MAP; in i40e_attach()
3362 i40e_init_properties(i40e); in i40e_attach()
3363 i40e->i40e_attach_progress |= I40E_ATTACH_PROPS; in i40e_attach()
3365 if (!i40e_common_code_init(i40e, hw)) in i40e_attach()
3367 i40e->i40e_attach_progress |= I40E_ATTACH_COMMON_CODE; in i40e_attach()
3373 if (!i40e_alloc_intrs(i40e, devinfo)) { in i40e_attach()
3374 i40e_error(i40e, "Failed to allocate interrupts."); in i40e_attach()
3377 i40e->i40e_attach_progress |= I40E_ATTACH_ALLOC_INTR; in i40e_attach()
3379 if (!i40e_alloc_trqpairs(i40e)) { in i40e_attach()
3380 i40e_error(i40e, in i40e_attach()
3384 i40e->i40e_attach_progress |= I40E_ATTACH_ALLOC_RINGSLOCKS; in i40e_attach()
3386 if (!i40e_map_intrs_to_vectors(i40e)) { in i40e_attach()
3387 i40e_error(i40e, "Failed to map interrupts to vectors."); in i40e_attach()
3391 if (!i40e_add_intr_handlers(i40e)) { in i40e_attach()
3392 i40e_error(i40e, "Failed to add the interrupt handlers."); in i40e_attach()
3395 i40e->i40e_attach_progress |= I40E_ATTACH_ADD_INTR; in i40e_attach()
3397 if (!i40e_final_init(i40e)) { in i40e_attach()
3398 i40e_error(i40e, "Final initialization failed."); in i40e_attach()
3401 i40e->i40e_attach_progress |= I40E_ATTACH_INIT; in i40e_attach()
3403 if (i40e_check_acc_handle(i40e->i40e_osdep_space.ios_cfg_handle) != in i40e_attach()
3405 ddi_fm_service_impact(i40e->i40e_dip, DDI_SERVICE_LOST); in i40e_attach()
3409 if (!i40e_stats_init(i40e)) { in i40e_attach()
3410 i40e_error(i40e, "Stats initialization failed."); in i40e_attach()
3413 i40e->i40e_attach_progress |= I40E_ATTACH_STATS; in i40e_attach()
3415 if (!i40e_register_mac(i40e)) { in i40e_attach()
3416 i40e_error(i40e, "Failed to register to MAC/GLDv3"); in i40e_attach()
3419 i40e->i40e_attach_progress |= I40E_ATTACH_MAC; in i40e_attach()
3421 i40e->i40e_periodic_id = ddi_periodic_add(i40e_timer, i40e, in i40e_attach()
3423 if (i40e->i40e_periodic_id == 0) { in i40e_attach()
3424 i40e_error(i40e, "Failed to add the link-check timer"); in i40e_attach()
3427 i40e->i40e_attach_progress |= I40E_ATTACH_LINK_TIMER; in i40e_attach()
3429 if (!i40e_enable_interrupts(i40e)) { in i40e_attach()
3430 i40e_error(i40e, "Failed to enable DDI interrupts"); in i40e_attach()
3433 i40e->i40e_attach_progress |= I40E_ATTACH_ENABLE_INTR; in i40e_attach()
3435 if (i40e->i40e_hw_space.bus.func == 0) { in i40e_attach()
3436 if (ddi_ufm_init(i40e->i40e_dip, DDI_UFM_CURRENT_VERSION, in i40e_attach()
3437 &i40e_ufm_ops, &i40e->i40e_ufmh, i40e) != 0) { in i40e_attach()
3438 i40e_error(i40e, "failed to initialize UFM subsystem"); in i40e_attach()
3441 ddi_ufm_update(i40e->i40e_ufmh); in i40e_attach()
3442 i40e->i40e_attach_progress |= I40E_ATTACH_UFM_INIT; in i40e_attach()
3445 atomic_or_32(&i40e->i40e_state, I40E_INITIALIZED); in i40e_attach()
3448 list_insert_tail(&i40e_glist, i40e); in i40e_attach()
3454 i40e_unconfigure(devinfo, i40e); in i40e_attach()
3461 i40e_t *i40e; in i40e_detach() local
3466 i40e = (i40e_t *)ddi_get_driver_private(devinfo); in i40e_detach()
3467 if (i40e == NULL) { in i40e_detach()
3472 if (i40e_drain_rx(i40e) == B_FALSE) { in i40e_detach()
3473 i40e_log(i40e, "timed out draining DMA resources, %d buffers " in i40e_detach()
3474 "remain", i40e->i40e_rx_pending); in i40e_detach()
3479 list_remove(&i40e_glist, i40e); in i40e_detach()
3482 i40e_unconfigure(devinfo, i40e); in i40e_detach()