Lines Matching refs:sp
67 sfxge_cfg_build(sfxge_t *sp) in sfxge_cfg_build() argument
69 const efx_nic_cfg_t *encp = efx_nic_cfg_get(sp->s_enp); in sfxge_cfg_build()
70 (void) snprintf(sp->s_cfg_kstat.buf.sck_mac, 64, in sfxge_cfg_build()
80 sfxge_t *sp; in sfxge_create() local
87 sp = kmem_zalloc(sizeof (*sp), KM_SLEEP); in sfxge_create()
88 sp->s_dip = dip; in sfxge_create()
89 ddi_set_driver_private(dip, sp); in sfxge_create()
91 mutex_init(&(sp->s_state_lock), NULL, MUTEX_DRIVER, NULL); in sfxge_create()
92 sp->s_state = SFXGE_UNINITIALIZED; in sfxge_create()
95 sp->s_mtu = ddi_prop_get_int(DDI_DEV_T_ANY, sp->s_dip, in sfxge_create()
98 sp->s_action_on_hw_err = ddi_prop_get_int(DDI_DEV_T_ANY, sp->s_dip, in sfxge_create()
101 rxq_size = ddi_prop_get_int(DDI_DEV_T_ANY, sp->s_dip, in sfxge_create()
106 sp->s_rxq_size = (uint16_t)max(rxq_size, EFX_RXQ_MINNDESCS); in sfxge_create()
109 rxq_poll_usec = ddi_prop_get_int(DDI_DEV_T_ANY, sp->s_dip, in sfxge_create()
113 sp->s_rxq_poll_usec = rxq_poll_usec; in sfxge_create()
116 sp->s_mcdi_logging = ddi_prop_get_int(DDI_DEV_T_ANY, sp->s_dip, in sfxge_create()
121 sp->s_tqp = ddi_taskq_create(dip, "tq", 1, TASKQ_DEFAULTPRI, 0); in sfxge_create()
122 if (sp->s_tqp == NULL) { in sfxge_create()
128 if ((rc = sfxge_pci_init(sp)) != 0) in sfxge_create()
132 if ((rc = sfxge_bar_init(sp)) != 0) in sfxge_create()
136 mutex_init(&(sp->s_nic_lock), NULL, MUTEX_DRIVER, NULL); in sfxge_create()
138 if ((rc = efx_nic_create(sp->s_family, (efsys_identifier_t *)sp, in sfxge_create()
139 &(sp->s_bar), &(sp->s_nic_lock), &enp)) != 0) in sfxge_create()
142 sp->s_enp = enp; in sfxge_create()
145 if ((rc = sfxge_mcdi_init(sp)) != 0) in sfxge_create()
152 switch (sp->s_family) { in sfxge_create()
154 sfxge_pcie_check_link(sp, 8, 3); /* PCI 8x Gen3 */ in sfxge_create()
158 sfxge_pcie_check_link(sp, 8, 2); /* PCI 8x Gen2 */ in sfxge_create()
174 sfxge_sram_init(sp); in sfxge_create()
176 if ((rc = sfxge_intr_init(sp)) != 0) in sfxge_create()
179 if ((rc = sfxge_ev_init(sp)) != 0) in sfxge_create()
182 if ((rc = sfxge_mac_init(sp)) != 0) in sfxge_create()
185 if ((rc = sfxge_rx_init(sp)) != 0) in sfxge_create()
188 if ((rc = sfxge_tx_init(sp)) != 0) in sfxge_create()
191 if ((rc = sfxge_mon_init(sp)) != 0) in sfxge_create()
194 mutex_init(&(sp->s_tx_flush_lock), NULL, MUTEX_DRIVER, in sfxge_create()
195 DDI_INTR_PRI(sp->s_intr.si_intr_pri)); in sfxge_create()
196 cv_init(&(sp->s_tx_flush_kv), NULL, CV_DRIVER, NULL); in sfxge_create()
198 sp->s_state = SFXGE_INITIALIZED; in sfxge_create()
200 *spp = sp; in sfxge_create()
205 sfxge_tx_fini(sp); in sfxge_create()
209 sfxge_rx_fini(sp); in sfxge_create()
213 sfxge_mac_fini(sp); in sfxge_create()
217 sfxge_ev_fini(sp); in sfxge_create()
221 sfxge_intr_fini(sp); in sfxge_create()
225 sfxge_sram_fini(sp); in sfxge_create()
226 (void) efx_nic_reset(sp->s_enp); in sfxge_create()
242 sfxge_mcdi_fini(sp); in sfxge_create()
246 sp->s_enp = NULL; in sfxge_create()
251 mutex_destroy(&(sp->s_nic_lock)); in sfxge_create()
252 sfxge_bar_fini(sp); in sfxge_create()
256 sfxge_pci_fini(sp); in sfxge_create()
260 ddi_taskq_destroy(sp->s_tqp); in sfxge_create()
261 sp->s_tqp = NULL; in sfxge_create()
267 sp->s_mtu = 0; in sfxge_create()
269 mutex_destroy(&(sp->s_state_lock)); in sfxge_create()
272 sp->s_dip = NULL; in sfxge_create()
274 SFXGE_OBJ_CHECK(sp, sfxge_t); in sfxge_create()
275 kmem_free(sp, sizeof (*sp)); in sfxge_create()
282 sfxge_start_locked(sfxge_t *sp, boolean_t restart) in sfxge_start_locked() argument
286 ASSERT(mutex_owned(&(sp->s_state_lock))); in sfxge_start_locked()
288 if (sp->s_state == SFXGE_STARTED) in sfxge_start_locked()
291 if (sp->s_state != SFXGE_REGISTERED) { in sfxge_start_locked()
295 sp->s_state = SFXGE_STARTING; in sfxge_start_locked()
298 efx_mcdi_new_epoch(sp->s_enp); in sfxge_start_locked()
300 if ((rc = efx_nic_reset(sp->s_enp)) != 0) in sfxge_start_locked()
303 if ((rc = efx_nic_init(sp->s_enp)) != 0) in sfxge_start_locked()
306 if ((rc = efx_filter_init(sp->s_enp)) != 0) in sfxge_start_locked()
309 if ((rc = sfxge_sram_start(sp)) != 0) in sfxge_start_locked()
312 if ((rc = sfxge_intr_start(sp)) != 0) in sfxge_start_locked()
315 if ((rc = sfxge_ev_start(sp)) != 0) in sfxge_start_locked()
318 if ((rc = sfxge_mac_start(sp, restart)) != 0) in sfxge_start_locked()
321 if ((rc = sfxge_rx_start(sp)) != 0) in sfxge_start_locked()
324 if ((rc = sfxge_tx_start(sp)) != 0) in sfxge_start_locked()
327 if ((rc = sfxge_mon_start(sp)) != 0) in sfxge_start_locked()
330 ASSERT3U(sp->s_state, ==, SFXGE_STARTING); in sfxge_start_locked()
331 sp->s_state = SFXGE_STARTED; in sfxge_start_locked()
334 sfxge_gld_mtu_update(sp); in sfxge_start_locked()
341 sfxge_tx_stop(sp); in sfxge_start_locked()
345 sfxge_rx_stop(sp); in sfxge_start_locked()
349 sfxge_mac_stop(sp); in sfxge_start_locked()
353 sfxge_ev_stop(sp); in sfxge_start_locked()
357 sfxge_intr_stop(sp); in sfxge_start_locked()
361 sfxge_sram_stop(sp); in sfxge_start_locked()
365 efx_filter_fini(sp->s_enp); in sfxge_start_locked()
369 efx_nic_fini(sp->s_enp); in sfxge_start_locked()
373 (void) efx_nic_reset(sp->s_enp); in sfxge_start_locked()
378 ASSERT3U(sp->s_state, ==, SFXGE_STARTING); in sfxge_start_locked()
379 sp->s_state = SFXGE_REGISTERED; in sfxge_start_locked()
389 sfxge_start(sfxge_t *sp, boolean_t restart) in sfxge_start() argument
393 mutex_enter(&(sp->s_state_lock)); in sfxge_start()
394 rc = sfxge_start_locked(sp, restart); in sfxge_start()
395 mutex_exit(&(sp->s_state_lock)); in sfxge_start()
401 sfxge_stop_locked(sfxge_t *sp) in sfxge_stop_locked() argument
403 ASSERT(mutex_owned(&(sp->s_state_lock))); in sfxge_stop_locked()
405 if (sp->s_state != SFXGE_STARTED) { in sfxge_stop_locked()
408 sp->s_state = SFXGE_STOPPING; in sfxge_stop_locked()
410 sfxge_mon_stop(sp); in sfxge_stop_locked()
411 sfxge_tx_stop(sp); in sfxge_stop_locked()
412 sfxge_rx_stop(sp); in sfxge_stop_locked()
413 sfxge_mac_stop(sp); in sfxge_stop_locked()
416 sfxge_ev_stop(sp); in sfxge_stop_locked()
417 sfxge_intr_stop(sp); /* cope with late flush/soft events until here */ in sfxge_stop_locked()
418 sfxge_sram_stop(sp); in sfxge_stop_locked()
420 efx_filter_fini(sp->s_enp); in sfxge_stop_locked()
422 efx_nic_fini(sp->s_enp); in sfxge_stop_locked()
423 (void) efx_nic_reset(sp->s_enp); in sfxge_stop_locked()
425 ASSERT3U(sp->s_state, ==, SFXGE_STOPPING); in sfxge_stop_locked()
426 sp->s_state = SFXGE_REGISTERED; in sfxge_stop_locked()
430 sfxge_stop(sfxge_t *sp) in sfxge_stop() argument
432 mutex_enter(&(sp->s_state_lock)); in sfxge_stop()
433 sfxge_stop_locked(sp); in sfxge_stop()
434 mutex_exit(&(sp->s_state_lock)); in sfxge_stop()
440 sfxge_t *sp = arg; in _sfxge_restart() local
444 mutex_enter(&(sp->s_state_lock)); in _sfxge_restart()
447 if (sp->s_state != SFXGE_STARTED) in _sfxge_restart()
451 if (sp->s_hw_err && sp->s_action_on_hw_err != SFXGE_INVISIBLE) { in _sfxge_restart()
452 sp->s_mac.sm_link_mode = EFX_LINK_DOWN; in _sfxge_restart()
453 sfxge_gld_link_update(sp); in _sfxge_restart()
457 sfxge_stop_locked(sp); in _sfxge_restart()
459 if (sp->s_hw_err && sp->s_action_on_hw_err == SFXGE_LEAVE_DEAD) { in _sfxge_restart()
460 dev_err(sp->s_dip, CE_WARN, SFXGE_CMN_ERR in _sfxge_restart()
464 (void) atomic_swap_32(&(sp->s_nested_restarts), 0); in _sfxge_restart()
465 mutex_exit(&(sp->s_state_lock)); in _sfxge_restart()
468 sp->s_hw_err = SFXGE_HW_OK; in _sfxge_restart()
471 if ((rc = sfxge_start_locked(sp, B_TRUE)) != 0) in _sfxge_restart()
475 (void) atomic_swap_32(&(sp->s_nested_restarts), 0); in _sfxge_restart()
476 mutex_exit(&(sp->s_state_lock)); in _sfxge_restart()
477 dev_err(sp->s_dip, CE_WARN, SFXGE_CMN_ERR "NIC restart complete"); in _sfxge_restart()
482 dev_err(sp->s_dip, CE_WARN, in _sfxge_restart()
485 (void) atomic_swap_32(&(sp->s_nested_restarts), 0); in _sfxge_restart()
486 mutex_exit(&(sp->s_state_lock)); in _sfxge_restart()
490 sfxge_restart_dispatch(sfxge_t *sp, uint_t cflags, sfxge_hw_err_t hw_err, in sfxge_restart_dispatch() argument
494 sp->s_num_restarts++; in sfxge_restart_dispatch()
496 sp->s_hw_err = hw_err; in sfxge_restart_dispatch()
497 sp->s_num_restarts_hw_err++; in sfxge_restart_dispatch()
500 if (atomic_inc_32_nv(&(sp->s_nested_restarts)) > 1) { in sfxge_restart_dispatch()
508 dev_err(sp->s_dip, CE_WARN, SFXGE_CMN_ERR "NIC restart due to %s:%d", in sfxge_restart_dispatch()
512 return (ddi_taskq_dispatch(sp->s_tqp, _sfxge_restart, sp, cflags)); in sfxge_restart_dispatch()
517 sfxge_can_destroy(sfxge_t *sp) in sfxge_can_destroy() argument
527 index = EFX_ARRAY_SIZE(sp->s_stp); in sfxge_can_destroy()
529 sfxge_txq_t *stp = sp->s_stp[index]; in sfxge_can_destroy()
536 return (sfxge_rx_loaned(sp)); in sfxge_can_destroy()
541 sfxge_destroy(sfxge_t *sp) in sfxge_destroy() argument
547 ASSERT3U(sp->s_state, ==, SFXGE_INITIALIZED); in sfxge_destroy()
548 enp = sp->s_enp; in sfxge_destroy()
550 if (sfxge_can_destroy(sp) != 0) { in sfxge_destroy()
555 sp->s_state = SFXGE_UNINITIALIZED; in sfxge_destroy()
557 cv_destroy(&(sp->s_tx_flush_kv)); in sfxge_destroy()
558 mutex_destroy(&(sp->s_tx_flush_lock)); in sfxge_destroy()
560 sfxge_mon_fini(sp); in sfxge_destroy()
561 sfxge_tx_fini(sp); in sfxge_destroy()
562 sfxge_rx_fini(sp); in sfxge_destroy()
563 sfxge_mac_fini(sp); in sfxge_destroy()
564 sfxge_ev_fini(sp); in sfxge_destroy()
565 sfxge_intr_fini(sp); in sfxge_destroy()
566 sfxge_sram_fini(sp); in sfxge_destroy()
572 sfxge_mcdi_fini(sp); in sfxge_destroy()
575 sp->s_enp = NULL; in sfxge_destroy()
578 mutex_destroy(&(sp->s_nic_lock)); in sfxge_destroy()
581 sfxge_bar_fini(sp); in sfxge_destroy()
584 sfxge_pci_fini(sp); in sfxge_destroy()
587 tqp = sp->s_tqp; in sfxge_destroy()
588 sp->s_tqp = NULL; in sfxge_destroy()
591 mutex_destroy(&(sp->s_state_lock)); in sfxge_destroy()
594 sp->s_mtu = 0; in sfxge_destroy()
597 sp->s_dip = NULL; in sfxge_destroy()
599 SFXGE_OBJ_CHECK(sp, sfxge_t); in sfxge_destroy()
600 kmem_free(sp, sizeof (*sp)); in sfxge_destroy()
611 sfxge_ioctl(sfxge_t *sp, queue_t *wq, mblk_t *mp) in sfxge_ioctl() argument
621 mutex_enter(&(sp->s_state_lock)); in sfxge_ioctl()
661 if ((rc = sfxge_nvram_ioctl(sp, snip)) != 0) in sfxge_ioctl()
669 if ((rc = sfxge_mcdi_ioctl(sp, smip)) != 0) in sfxge_ioctl()
679 if ((rc = sfxge_mcdi2_ioctl(sp, smip)) != 0) in sfxge_ioctl()
689 (void) sfxge_restart_dispatch(sp, DDI_SLEEP, SFXGE_HW_OK, in sfxge_ioctl()
698 if ((rc = sfxge_vpd_ioctl(sp, svip)) != 0) in sfxge_ioctl()
707 mutex_exit(&(sp->s_state_lock)); in sfxge_ioctl()
715 ddi_taskq_wait(sp->s_tqp); in sfxge_ioctl()
732 mutex_exit(&(sp->s_state_lock)); in sfxge_ioctl()
739 sfxge_register(sfxge_t *sp) in sfxge_register() argument
743 ASSERT3U(sp->s_state, ==, SFXGE_INITIALIZED); in sfxge_register()
745 if ((rc = sfxge_gld_register(sp)) != 0) in sfxge_register()
748 sp->s_state = SFXGE_REGISTERED; in sfxge_register()
759 sfxge_unregister(sfxge_t *sp) in sfxge_unregister() argument
763 ASSERT3U(sp->s_state, ==, SFXGE_REGISTERED); in sfxge_unregister()
766 ddi_taskq_wait(sp->s_tqp); in sfxge_unregister()
768 if ((rc = sfxge_gld_unregister(sp)) != 0) in sfxge_unregister()
771 sp->s_state = SFXGE_INITIALIZED; in sfxge_unregister()
782 _sfxge_vpd_kstat_init(sfxge_t *sp, caddr_t vpd, size_t size, efx_vpd_tag_t tag, in _sfxge_vpd_kstat_init() argument
786 efx_nic_t *enp = sp->s_enp; in _sfxge_vpd_kstat_init()
787 sfxge_vpd_kstat_t *svkp = &(sp->s_vpd_kstat); in _sfxge_vpd_kstat_init()
808 sfxge_vpd_kstat_init(sfxge_t *sp) in sfxge_vpd_kstat_init() argument
810 efx_nic_t *enp = sp->s_enp; in sfxge_vpd_kstat_init()
811 sfxge_vpd_kstat_t *svkp = &(sp->s_vpd_kstat); in sfxge_vpd_kstat_init()
812 dev_info_t *dip = sp->s_dip; in sfxge_vpd_kstat_init()
849 _sfxge_vpd_kstat_init(sp, vpd, size, EFX_VPD_ID, "ID", SFXGE_VPD_ID); in sfxge_vpd_kstat_init()
850 _sfxge_vpd_kstat_init(sp, vpd, size, EFX_VPD_RO, "PN", SFXGE_VPD_PN); in sfxge_vpd_kstat_init()
851 _sfxge_vpd_kstat_init(sp, vpd, size, EFX_VPD_RO, "SN", SFXGE_VPD_SN); in sfxge_vpd_kstat_init()
852 _sfxge_vpd_kstat_init(sp, vpd, size, EFX_VPD_RO, "EC", SFXGE_VPD_EC); in sfxge_vpd_kstat_init()
853 _sfxge_vpd_kstat_init(sp, vpd, size, EFX_VPD_RO, "MN", SFXGE_VPD_MN); in sfxge_vpd_kstat_init()
854 _sfxge_vpd_kstat_init(sp, vpd, size, EFX_VPD_RO, "VD", SFXGE_VPD_VD); in sfxge_vpd_kstat_init()
855 _sfxge_vpd_kstat_init(sp, vpd, size, EFX_VPD_RO, "VE", SFXGE_VPD_VE); in sfxge_vpd_kstat_init()
880 sfxge_vpd_kstat_fini(sfxge_t *sp) in sfxge_vpd_kstat_fini() argument
882 sfxge_vpd_kstat_t *svkp = &(sp->s_vpd_kstat); in sfxge_vpd_kstat_fini()
902 sfxge_cfg_kstat_init(sfxge_t *sp) in sfxge_cfg_kstat_init() argument
904 dev_info_t *dip = sp->s_dip; in sfxge_cfg_kstat_init()
910 sfxge_cfg_build(sp); in sfxge_cfg_kstat_init()
923 sp->s_cfg_ksp = ksp; in sfxge_cfg_kstat_init()
925 ksp->ks_data = sckp = &(sp->s_cfg_kstat); in sfxge_cfg_kstat_init()
946 sfxge_cfg_kstat_fini(sfxge_t *sp) in sfxge_cfg_kstat_fini() argument
948 if (sp->s_cfg_ksp == NULL) in sfxge_cfg_kstat_fini()
951 kstat_delete(sp->s_cfg_ksp); in sfxge_cfg_kstat_fini()
952 sp->s_cfg_ksp = NULL; in sfxge_cfg_kstat_fini()
954 bzero(&(sp->s_cfg_kstat), sizeof (sfxge_cfg_kstat_t)); in sfxge_cfg_kstat_fini()
958 sfxge_resume(sfxge_t *sp) in sfxge_resume() argument
963 if ((rc = sfxge_start(sp, B_FALSE)) != 0) in sfxge_resume()
977 sfxge_t *sp; in sfxge_attach() local
985 if ((sp = ddi_get_driver_private(dip)) == NULL) in sfxge_attach()
987 return (sfxge_resume(sp)); in sfxge_attach()
994 if ((rc = sfxge_create(dip, &sp)) != 0) in sfxge_attach()
998 if ((rc = sfxge_cfg_kstat_init(sp)) != 0) in sfxge_attach()
1002 if ((rc = sfxge_vpd_kstat_init(sp)) != 0) { in sfxge_attach()
1008 if ((rc = sfxge_register(sp)) != 0) in sfxge_attach()
1020 sfxge_vpd_kstat_fini(sp); in sfxge_attach()
1026 sfxge_cfg_kstat_fini(sp); in sfxge_attach()
1032 (void) sfxge_destroy(sp); in sfxge_attach()
1041 sfxge_suspend(sfxge_t *sp) in sfxge_suspend() argument
1044 sfxge_stop(sp); in sfxge_suspend()
1052 sfxge_t *sp = ddi_get_driver_private(dip); in sfxge_detach() local
1057 if (sp == NULL) in sfxge_detach()
1062 if (sp == NULL) in sfxge_detach()
1064 return (sfxge_suspend(sp)); in sfxge_detach()
1070 ASSERT(sp != NULL); in sfxge_detach()
1073 ddi_taskq_wait(sp->s_tqp); in sfxge_detach()
1080 mutex_enter(&(sp->s_state_lock)); in sfxge_detach()
1081 if (sp->s_state == SFXGE_STARTED) { in sfxge_detach()
1084 sfxge_stop_locked(sp); in sfxge_detach()
1085 ASSERT3U(sp->s_state, ==, SFXGE_REGISTERED); in sfxge_detach()
1087 mutex_exit(&(sp->s_state_lock)); in sfxge_detach()
1089 ASSERT(sp->s_state == SFXGE_REGISTERED || in sfxge_detach()
1090 sp->s_state == SFXGE_INITIALIZED); in sfxge_detach()
1092 if (sp->s_state != SFXGE_REGISTERED) in sfxge_detach()
1096 if ((rc = sfxge_unregister(sp)) != 0) in sfxge_detach()
1101 sfxge_vpd_kstat_fini(sp); in sfxge_detach()
1104 sfxge_cfg_kstat_fini(sp); in sfxge_detach()
1110 if ((rc = sfxge_destroy(sp)) != 0) in sfxge_detach()