Lines Matching refs:pptr

415 static struct fcp_tgt *fcp_port_create_tgt(struct fcp_port *pptr,
427 static void fcp_handle_devices(struct fcp_port *pptr,
430 static int fcp_handle_mapflags(struct fcp_port *pptr,
434 static int fcp_send_els(struct fcp_port *pptr, struct fcp_tgt *ptgt,
436 static void fcp_update_state(struct fcp_port *pptr, uint32_t state,
444 static int fcp_unsol_prli(struct fcp_port *pptr, fc_unsol_buf_t *buf);
445 static struct fcp_ipkt *fcp_icmd_alloc(struct fcp_port *pptr,
448 static void fcp_icmd_free(struct fcp_port *pptr, struct fcp_ipkt *icmd);
449 static int fcp_alloc_dma(struct fcp_port *pptr, struct fcp_ipkt *icmd,
451 static void fcp_free_dma(struct fcp_port *pptr, struct fcp_ipkt *icmd);
452 static struct fcp_tgt *fcp_lookup_target(struct fcp_port *pptr,
454 static struct fcp_tgt *fcp_get_target_by_did(struct fcp_port *pptr,
466 static int fcp_finish_tgt(struct fcp_port *pptr, struct fcp_tgt *ptgt,
468 static void fcp_finish_init(struct fcp_port *pptr);
473 static int fcp_offline_target(struct fcp_port *pptr, struct fcp_tgt *ptgt,
475 static void fcp_offline_target_now(struct fcp_port *pptr,
485 static void fcp_scan_offline_luns(struct fcp_port *pptr);
486 static void fcp_scan_offline_tgts(struct fcp_port *pptr);
490 fcp_port *pptr);
494 struct fcp_port *pptr);
495 static int fcp_device_changed(struct fcp_port *pptr, struct fcp_tgt *ptgt,
499 static struct fcp_tgt *fcp_alloc_tgt(struct fcp_port *pptr,
502 static void fcp_queue_ipkt(struct fcp_port *pptr, fc_packet_t *fpkt);
508 static int fcp_handle_port_detach(struct fcp_port *pptr, int flag,
510 static void fcp_cleanup_port(struct fcp_port *pptr, int instance);
515 static int fcp_alloc_cmd_resp(struct fcp_port *pptr, fc_packet_t *fpkt,
517 static void fcp_free_cmd_resp(struct fcp_port *pptr, fc_packet_t *fpkt);
523 static int fcp_linkreset(struct fcp_port *pptr, struct scsi_address *ap,
527 static void fcp_cp_pinfo(struct fcp_port *pptr, fc_ulp_port_info_t *pinfo);
543 static void fcp_check_reset_delay(struct fcp_port *pptr);
544 static void fcp_abort_all(struct fcp_port *pptr, struct fcp_tgt *ttgt,
546 struct fcp_port *fcp_soft_state_unlink(struct fcp_port *pptr);
547 static struct fcp_lun *fcp_lookup_lun(struct fcp_port *pptr,
549 static void fcp_prepare_pkt(struct fcp_port *pptr, struct fcp_pkt *cmd,
552 static int fcp_dopoll(struct fcp_port *pptr, struct fcp_pkt *cmd);
554 struct fcp_lun *fcp_get_lun_from_cip(struct fcp_port *pptr,
556 static int fcp_pass_to_hp_and_wait(struct fcp_port *pptr,
559 static struct fcp_hp_elem *fcp_pass_to_hp(struct fcp_port *pptr,
562 static void fcp_retransport_cmd(struct fcp_port *pptr,
566 static void fcp_queue_pkt(struct fcp_port *pptr, struct fcp_pkt *cmd);
567 static void fcp_update_targets(struct fcp_port *pptr,
569 static int fcp_call_finish_init(struct fcp_port *pptr,
571 static int fcp_call_finish_init_held(struct fcp_port *pptr,
574 static void fcp_free_targets(struct fcp_port *pptr);
577 static int fcp_create_on_demand(struct fcp_port *pptr, uchar_t *pwwn);
581 static int fcp_handle_ipkt_errors(struct fcp_port *pptr,
584 static fc_portmap_t *fcp_construct_map(struct fcp_port *pptr,
586 static void fcp_offline_all(struct fcp_port *pptr, int lcount, int cause);
593 static int fcp_do_ns_registry(struct fcp_port *pptr, uint32_t s_id);
594 static void fcp_retry_ns_registry(struct fcp_port *pptr, uint32_t s_id);
598 static void fcp_reconfig_wait(struct fcp_port *pptr);
611 static void fcp_update_mpxio_path_verifybusy(struct fcp_port *pptr);
1441 struct fcp_port *pptr; in fcp_setup_device_data_ioctl() local
1485 pptr = fcp_port_head; in fcp_setup_device_data_ioctl()
1486 while (pptr) { in fcp_setup_device_data_ioctl()
1487 if (pptr->port_instance == (uint32_t)fioctl.fp_minor) { in fcp_setup_device_data_ioctl()
1490 pptr = pptr->port_next; in fcp_setup_device_data_ioctl()
1494 if (pptr == NULL) { in fcp_setup_device_data_ioctl()
1497 mutex_enter(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1502 mutex_exit(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1509 mutex_exit(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1512 link_cnt = pptr->port_link_cnt; in fcp_setup_device_data_ioctl()
1516 if (bcmp(wwn_ptr->raw_wwn, pptr->port_pwwn.raw_wwn, in fcp_setup_device_data_ioctl()
1519 mutex_exit(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1562 if (pptr->port_state & (FCP_STATE_INIT | FCP_STATE_OFFLINE)) { in fcp_setup_device_data_ioctl()
1564 mutex_exit(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1568 for (i = 0; (i < fioctl.listlen) && (link_cnt == pptr->port_link_cnt); in fcp_setup_device_data_ioctl()
1577 if ((ptgt = fcp_lookup_target(pptr, in fcp_setup_device_data_ioctl()
1579 mutex_exit(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1580 if (fc_ulp_get_remote_port(pptr->port_fp_handle, in fcp_setup_device_data_ioctl()
1583 mutex_enter(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1589 mutex_enter(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1637 mutex_exit(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1658 fcp_create_on_demand(pptr, in fcp_setup_device_data_ioctl()
1670 fcp_log(CE_WARN, pptr->port_dip, in fcp_setup_device_data_ioctl()
1681 mutex_enter(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1690 fcp_log(CE_WARN, pptr->port_dip, in fcp_setup_device_data_ioctl()
1697 mutex_exit(&pptr->port_mutex); in fcp_setup_device_data_ioctl()
1747 struct fcp_port *pptr; in fcp_get_target_mappings() local
1793 pptr = fcp_port_head; in fcp_get_target_mappings()
1794 while (pptr) { in fcp_get_target_mappings()
1795 if (pptr->port_instance == (uint32_t)fioctl.fp_minor) { in fcp_get_target_mappings()
1798 pptr = pptr->port_next; in fcp_get_target_mappings()
1802 if (pptr == NULL) { in fcp_get_target_mappings()
1829 mutex_enter(&pptr->port_mutex); in fcp_get_target_mappings()
1832 for (ptgt = pptr->port_tgt_hash_table[i]; ptgt != NULL; in fcp_get_target_mappings()
1908 mutex_exit(&pptr->port_mutex); in fcp_get_target_mappings()
2294 struct fcp_port *pptr = NULL; in fcp_send_scsi_ioctl() local
2366 pptr = fcp_port_head; in fcp_send_scsi_ioctl()
2367 while (pptr) { in fcp_send_scsi_ioctl()
2368 if (pptr->port_instance == in fcp_send_scsi_ioctl()
2372 pptr = pptr->port_next; in fcp_send_scsi_ioctl()
2376 if (pptr == NULL) { in fcp_send_scsi_ioctl()
2384 ret = fc_ulp_busy_port(pptr->port_fp_handle); in fcp_send_scsi_ioctl()
2397 fcp_reconfig_wait(pptr); in fcp_send_scsi_ioctl()
2401 mutex_enter(&pptr->port_mutex); in fcp_send_scsi_ioctl()
2406 nodma = (pptr->port_fcp_dma == FC_NO_DVMA_SPACE) in fcp_send_scsi_ioctl()
2416 if (pptr->port_state & (FCP_STATE_INIT | in fcp_send_scsi_ioctl()
2419 } else if (pptr->port_state & FCP_STATE_ONLINING) { in fcp_send_scsi_ioctl()
2429 ptgt = fcp_lookup_target(pptr, in fcp_send_scsi_ioctl()
2440 mutex_exit(&pptr->port_mutex); in fcp_send_scsi_ioctl()
2441 ptgt = fcp_port_create_tgt(pptr, in fcp_send_scsi_ioctl()
2445 mutex_enter(&pptr->port_mutex); in fcp_send_scsi_ioctl()
2486 lcount = pptr->port_link_cnt; in fcp_send_scsi_ioctl()
2495 mutex_exit(&pptr->port_mutex); in fcp_send_scsi_ioctl()
2512 mutex_enter(&pptr->port_mutex); in fcp_send_scsi_ioctl()
2529 } else if ((plun = fcp_lookup_lun(pptr, (uchar_t *)wwn_ptr, in fcp_send_scsi_ioctl()
2541 mutex_exit(&pptr->port_mutex); in fcp_send_scsi_ioctl()
2555 icmd = fcp_icmd_alloc(pptr, ptgt, in fcp_send_scsi_ioctl()
2622 hp->s_id = pptr->port_id; in fcp_send_scsi_ioctl()
2658 fc_ulp_transport(pptr->port_fp_handle, in fcp_send_scsi_ioctl()
2686 if (fcp_validate_fcp_response(rsp, pptr) != FC_SUCCESS) { in fcp_send_scsi_ioctl()
2687 fcp_log(CE_WARN, pptr->port_dip, in fcp_send_scsi_ioctl()
2836 fc_ulp_idle_port(pptr->port_fp_handle); in fcp_send_scsi_ioctl()
2878 fcp_port_t *pptr = ptgt->tgt_port; in fcp_is_reconfig_needed() local
3028 struct fcp_port *pptr = NULL; in fcp_get_statec_count() local
3031 &pptr)) != 0) { in fcp_get_statec_count()
3035 ASSERT(pptr != NULL); in fcp_get_statec_count()
3041 mutex_enter(&pptr->port_mutex); in fcp_get_statec_count()
3042 if (pptr->port_state & FCP_STATE_OFFLINE) { in fcp_get_statec_count()
3043 mutex_exit(&pptr->port_mutex); in fcp_get_statec_count()
3055 if ((pptr->port_state & FCP_STATE_INIT) && pptr->port_tmp_cnt) { in fcp_get_statec_count()
3056 mutex_exit(&pptr->port_mutex); in fcp_get_statec_count()
3060 link_cnt = pptr->port_link_cnt; in fcp_get_statec_count()
3061 mutex_exit(&pptr->port_mutex); in fcp_get_statec_count()
3106 struct fcp_ioctl *fioctl, struct fcp_port **pptr) in fcp_copyin_fcp_ioctl_data() argument
3153 *pptr = t_pptr; in fcp_copyin_fcp_ioctl_data()
3183 fcp_port_create_tgt(struct fcp_port *pptr, la_wwn_t *pwwn, int *ret_val, in fcp_port_create_tgt() argument
3196 if (fc_ulp_get_remote_port(pptr->port_fp_handle, pwwn, in fcp_port_create_tgt()
3200 if (fc_ulp_pwwn_to_portmap(pptr->port_fp_handle, pwwn, in fcp_port_create_tgt()
3211 lcount = pptr->port_link_cnt; in fcp_port_create_tgt()
3212 ptgt = fcp_alloc_tgt(pptr, &devlist, lcount); in fcp_port_create_tgt()
3214 fcp_log(CE_WARN, pptr->port_dip, in fcp_port_create_tgt()
3280 struct fcp_port *pptr; in fcp_tgt_send_plogi() local
3291 pptr = ptgt->tgt_port; in fcp_tgt_send_plogi()
3293 lcount = pptr->port_link_cnt; in fcp_tgt_send_plogi()
3297 icmd = fcp_icmd_alloc(pptr, ptgt, sizeof (la_els_logi_t), in fcp_tgt_send_plogi()
3299 pptr->port_state & FCP_STATE_FCA_IS_NODMA, in fcp_tgt_send_plogi()
3332 hp->s_id = pptr->port_id; /* source ID */ in fcp_tgt_send_plogi()
3358 fc_ulp_login(pptr->port_fp_handle, &fpkt, 1); in fcp_tgt_send_plogi()
3558 struct fcp_port *pptr; in fcp_ipkt_sema_cleanup() local
3561 pptr = icmd->ipkt_port; in fcp_ipkt_sema_cleanup()
3577 fcp_icmd_free(pptr, icmd); in fcp_ipkt_sema_cleanup()
3664 struct fcp_port *pptr; in fcp_port_detach() local
3667 pptr = ddi_get_soft_state(fcp_softstate, instance); in fcp_port_detach()
3698 return (fcp_handle_port_detach(pptr, flag, instance)); in fcp_port_detach()
3719 struct fcp_port *pptr = NULL; /* our soft state */ in fcp_port_ioctl() local
3746 if ((pptr = fcp_get_port(port_handle)) == NULL) { in fcp_port_ioctl()
3752 is_mpxio = pptr->port_mpxio; in fcp_port_ioctl()
3781 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_port_ioctl()
3792 ASSERT(pptr != NULL); in fcp_port_ioctl()
3794 mdi_devi_enter(pptr->port_dip, &enteredv); in fcp_port_ioctl()
3796 ndi_devi_enter(pptr->port_dip); in fcp_port_ioctl()
3800 if ((cdip = ndi_devi_find(pptr->port_dip, ndi_nm, in fcp_port_ioctl()
3803 pip = mdi_pi_find(pptr->port_dip, NULL, ndi_addr); in fcp_port_ioctl()
3825 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_port_ioctl()
3851 ASSERT(pptr != NULL); in fcp_port_ioctl()
3854 mutex_enter(&pptr->port_mutex); in fcp_port_ioctl()
3858 if ((plun = fcp_get_lun_from_cip(pptr, cip)) == NULL) { in fcp_port_ioctl()
3859 mutex_exit(&pptr->port_mutex); in fcp_port_ioctl()
3868 lcount = pptr->port_link_cnt; in fcp_port_ioctl()
3870 mutex_exit(&pptr->port_mutex); in fcp_port_ioctl()
3877 mdi_devi_exit(pptr->port_dip, enteredv); in fcp_port_ioctl()
3879 ndi_devi_exit(pptr->port_dip); in fcp_port_ioctl()
3883 *rval = fcp_pass_to_hp_and_wait(pptr, plun, cip, in fcp_port_ioctl()
3912 if (FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_port_ioctl()
3928 ASSERT(pptr != NULL); in fcp_port_ioctl()
3930 mutex_enter(&pptr->port_mutex); in fcp_port_ioctl()
3934 if ((plun = fcp_get_lun_from_cip(pptr, cip)) == NULL) { in fcp_port_ioctl()
3935 mutex_exit(&pptr->port_mutex); in fcp_port_ioctl()
3939 lcount = pptr->port_link_cnt; in fcp_port_ioctl()
3941 mutex_exit(&pptr->port_mutex); in fcp_port_ioctl()
3954 mdi_devi_exit(pptr->port_dip, enteredv); in fcp_port_ioctl()
3956 ndi_devi_exit(pptr->port_dip); in fcp_port_ioctl()
3960 *rval = fcp_pass_to_hp_and_wait(pptr, plun, cip, in fcp_port_ioctl()
3985 *rval = ndi_dc_devi_create(dcp, pptr->port_dip, in fcp_port_ioctl()
4002 *rval = fcp_create_on_demand(pptr, bytes); in fcp_port_ioctl()
4004 mutex_enter(&pptr->port_mutex); in fcp_port_ioctl()
4005 ptgt = fcp_lookup_target(pptr, (uchar_t *)bytes); in fcp_port_ioctl()
4028 mutex_exit(&pptr->port_mutex); in fcp_port_ioctl()
4118 fcp_log(CE_WARN, pptr->port_dip, in fcp_port_ioctl()
4133 ASSERT(pptr != NULL); in fcp_port_ioctl()
4134 mutex_enter(&pptr->port_mutex); in fcp_port_ioctl()
4138 if ((plun = fcp_get_lun_from_cip(pptr, cip)) == NULL) { in fcp_port_ioctl()
4139 mutex_exit(&pptr->port_mutex); in fcp_port_ioctl()
4143 mutex_exit(&pptr->port_mutex); in fcp_port_ioctl()
4174 ASSERT(pptr != NULL); in fcp_port_ioctl()
4175 ASSERT(pptr->port_dip != NULL); in fcp_port_ioctl()
4176 if (ndi_dc_return_bus_state(pptr->port_dip, dcp) != in fcp_port_ioctl()
4189 ASSERT(pptr != NULL); in fcp_port_ioctl()
4190 (void) fcp_linkreset(pptr, NULL, KM_SLEEP); in fcp_port_ioctl()
4202 mdi_devi_exit(pptr->port_dip, enteredv); in fcp_port_ioctl()
4204 ndi_devi_exit(pptr->port_dip); in fcp_port_ioctl()
4223 struct fcp_port *pptr; in fcp_els_callback() local
4225 if ((pptr = fcp_get_port(port_handle)) == NULL || claimed) { in fcp_els_callback()
4229 mutex_enter(&pptr->port_mutex); in fcp_els_callback()
4230 if (pptr->port_state & (FCP_STATE_DETACHING | in fcp_els_callback()
4232 mutex_exit(&pptr->port_mutex); in fcp_els_callback()
4235 mutex_exit(&pptr->port_mutex); in fcp_els_callback()
4251 if (fcp_unsol_prli(pptr, buf) == FC_SUCCESS) { in fcp_els_callback()
4303 struct fcp_port *pptr; in fcp_statec_callback() local
4306 if ((pptr = fcp_get_port(port_handle)) == NULL) { in fcp_statec_callback()
4311 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_statec_callback()
4317 mutex_enter(&pptr->port_mutex); in fcp_statec_callback()
4322 if (pptr->port_state & (FCP_STATE_DETACHING | in fcp_statec_callback()
4324 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4335 pptr->port_state |= FCP_STATE_IN_CB_DEVC; in fcp_statec_callback()
4348 pptr->port_phys_state = port_state; in fcp_statec_callback()
4351 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4356 fcp_log(CE_WARN, pptr->port_dip, in fcp_statec_callback()
4359 pptr->port_instance); in fcp_statec_callback()
4361 mutex_enter(&pptr->port_mutex); in fcp_statec_callback()
4362 pptr->port_state &= ~FCP_STATE_IN_CB_DEVC; in fcp_statec_callback()
4363 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4368 mutex_enter(&pptr->port_mutex); in fcp_statec_callback()
4371 if (pptr->port_id != port_sid) { in fcp_statec_callback()
4372 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_statec_callback()
4374 "fcp: Port S_ID=0x%x => 0x%x", pptr->port_id, in fcp_statec_callback()
4383 pptr->port_id = port_sid; in fcp_statec_callback()
4393 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_statec_callback()
4396 if ((pptr->port_state & FCP_STATE_OFFLINE) && dev_cnt) { in fcp_statec_callback()
4402 pptr->port_tmp_cnt += dev_cnt; in fcp_statec_callback()
4403 pptr->port_state &= ~FCP_STATE_OFFLINE; in fcp_statec_callback()
4404 pptr->port_state |= FCP_STATE_INIT; in fcp_statec_callback()
4405 link_count = pptr->port_link_cnt; in fcp_statec_callback()
4406 fcp_handle_devices(pptr, devlist, dev_cnt, in fcp_statec_callback()
4409 pptr->port_link_cnt++; in fcp_statec_callback()
4410 ASSERT(!(pptr->port_state & FCP_STATE_SUSPENDED)); in fcp_statec_callback()
4411 fcp_update_state(pptr, (FCP_LUN_BUSY | in fcp_statec_callback()
4413 if (pptr->port_mpxio) { in fcp_statec_callback()
4414 fcp_update_mpxio_path_verifybusy(pptr); in fcp_statec_callback()
4416 pptr->port_state |= FCP_STATE_OFFLINE; in fcp_statec_callback()
4417 pptr->port_state &= in fcp_statec_callback()
4419 pptr->port_tmp_cnt = 0; in fcp_statec_callback()
4421 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4430 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_statec_callback()
4434 pptr->port_link_cnt++; in fcp_statec_callback()
4436 while (pptr->port_ipkt_cnt) { in fcp_statec_callback()
4437 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4439 mutex_enter(&pptr->port_mutex); in fcp_statec_callback()
4442 pptr->port_topology = port_top; in fcp_statec_callback()
4448 fcp_update_state(pptr, FCP_LUN_BUSY | FCP_LUN_MARK, in fcp_statec_callback()
4451 pptr->port_state &= ~(FCP_STATE_INIT | FCP_STATE_OFFLINE); in fcp_statec_callback()
4452 pptr->port_state |= FCP_STATE_ONLINING; in fcp_statec_callback()
4453 pptr->port_tmp_cnt = dev_cnt; in fcp_statec_callback()
4454 link_count = pptr->port_link_cnt; in fcp_statec_callback()
4456 pptr->port_deadline = fcp_watchdog_time + in fcp_statec_callback()
4464 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_statec_callback()
4468 pptr->port_state &= ~FCP_STATE_ONLINING; in fcp_statec_callback()
4469 pptr->port_state |= FCP_STATE_ONLINE; in fcp_statec_callback()
4478 if (pptr->port_state & FCP_STATE_NS_REG_FAILED) { in fcp_statec_callback()
4479 fcp_retry_ns_registry(pptr, port_sid); in fcp_statec_callback()
4482 fcp_handle_devices(pptr, devlist, dev_cnt, link_count, in fcp_statec_callback()
4491 if (pptr->port_state & FCP_STATE_NS_REG_FAILED) { in fcp_statec_callback()
4492 pptr->port_state &= ~FCP_STATE_NS_REG_FAILED; in fcp_statec_callback()
4495 pptr->port_tmp_cnt -= dev_cnt; in fcp_statec_callback()
4496 fcp_log(CE_WARN, pptr->port_dip, in fcp_statec_callback()
4500 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_statec_callback()
4504 scsi_hba_reset_notify_callback(&pptr->port_mutex, in fcp_statec_callback()
4505 &pptr->port_reset_notify_listf); in fcp_statec_callback()
4507 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4512 ASSERT(pptr->port_state & FCP_STATE_OFFLINE); in fcp_statec_callback()
4513 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_statec_callback()
4516 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4524 if (pptr->port_state & (FCP_STATE_OFFLINE | in fcp_statec_callback()
4535 pptr->port_state &= ~FCP_STATE_IN_CB_DEVC; in fcp_statec_callback()
4536 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4540 if (pptr->port_state & FCP_STATE_NS_REG_FAILED) { in fcp_statec_callback()
4541 fcp_retry_ns_registry(pptr, port_sid); in fcp_statec_callback()
4548 if (!pptr->port_ipkt_cnt) { in fcp_statec_callback()
4549 pptr->port_deadline = fcp_watchdog_time + in fcp_statec_callback()
4564 fcp_update_targets(pptr, devlist, dev_cnt, in fcp_statec_callback()
4567 link_count = pptr->port_link_cnt; in fcp_statec_callback()
4569 fcp_handle_devices(pptr, devlist, dev_cnt, in fcp_statec_callback()
4572 pptr->port_state &= ~FCP_STATE_IN_CB_DEVC; in fcp_statec_callback()
4574 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4578 if (pptr->port_state & FCP_STATE_NS_REG_FAILED) { in fcp_statec_callback()
4579 fcp_retry_ns_registry(pptr, port_sid); in fcp_statec_callback()
4583 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4587 fcp_log(CE_WARN, pptr->port_dip, in fcp_statec_callback()
4589 mutex_exit(&pptr->port_mutex); in fcp_statec_callback()
4620 fcp_handle_devices(struct fcp_port *pptr, fc_portmap_t devlist[], in fcp_handle_devices() argument
4628 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_devices()
4650 for (i = 0; (i < dev_cnt) && (pptr->port_link_cnt == link_cnt); i++) { in fcp_handle_devices()
4657 ptgt = fcp_lookup_target(pptr, in fcp_handle_devices()
4680 for (ptgt = pptr->port_tgt_hash_table[i]; ptgt != NULL; in fcp_handle_devices()
4686 fcp_offline_target_now(pptr, ptgt, in fcp_handle_devices()
4701 for (i = 0; (i < dev_cnt) && (pptr->port_link_cnt == link_cnt); i++) { in fcp_handle_devices()
4705 (void) fcp_call_finish_init_held(pptr, ptgt, link_cnt, in fcp_handle_devices()
4724 ptgt = fcp_lookup_target(pptr, in fcp_handle_devices()
4734 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_devices()
4748 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_devices()
4763 if (fcp_handle_mapflags(pptr, ptgt, map_entry, in fcp_handle_devices()
4785 mutex_exit(&pptr->port_mutex); in fcp_handle_devices()
4797 mutex_enter(&pptr->port_mutex); in fcp_handle_devices()
4800 (void) fcp_offline_target(pptr, ptgt, in fcp_handle_devices()
4816 (void) fcp_offline_target(pptr, ptgt, in fcp_handle_devices()
4829 if (fcp_device_changed(pptr, ptgt, in fcp_handle_devices()
4835 if (fcp_handle_mapflags(pptr, ptgt, in fcp_handle_devices()
4843 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_devices()
4850 if (check_finish_init && pptr->port_link_cnt == link_cnt) { in fcp_handle_devices()
4852 (void) fcp_call_finish_init_held(pptr, ptgt, link_cnt, in fcp_handle_devices()
4854 } else if (dev_cnt == 0 && pptr->port_link_cnt == link_cnt) { in fcp_handle_devices()
4855 fcp_offline_all(pptr, link_cnt, cause); in fcp_handle_devices()
4863 struct fcp_port *pptr; in fcp_handle_reportlun_changed() local
4869 pptr = ptgt->tgt_port; in fcp_handle_reportlun_changed()
4878 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_reportlun_changed()
4900 rscn_count = fc_ulp_get_rscn_count(pptr->port_fp_handle); in fcp_handle_reportlun_changed()
4902 sizeof (struct fcp_reportlun_resp), pptr->port_link_cnt, in fcp_handle_reportlun_changed()
4904 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_reportlun_changed()
4936 fcp_handle_mapflags(struct fcp_port *pptr, struct fcp_tgt *ptgt, in fcp_handle_mapflags() argument
4948 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_handle_mapflags()
4958 mutex_exit(&pptr->port_mutex); in fcp_handle_mapflags()
4959 ptgt = fcp_alloc_tgt(pptr, map_entry, link_cnt); in fcp_handle_mapflags()
4960 mutex_enter(&pptr->port_mutex); in fcp_handle_mapflags()
4963 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_mapflags()
5017 mutex_exit(&pptr->port_mutex); in fcp_handle_mapflags()
5021 mutex_enter(&pptr->port_mutex); in fcp_handle_mapflags()
5033 if (FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_handle_mapflags()
5037 } else if (FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_handle_mapflags()
5061 if (FC_TOP_EXTERNAL(pptr->port_topology) && pptr->port_boot_wwn[0]) { in fcp_handle_mapflags()
5062 if (bcmp((caddr_t)pptr->port_boot_wwn, in fcp_handle_mapflags()
5070 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_mapflags()
5088 mutex_exit(&pptr->port_mutex); in fcp_handle_mapflags()
5101 icmd = fcp_icmd_alloc(pptr, ptgt, alloc, alloc, 0, in fcp_handle_mapflags()
5102 pptr->port_state & FCP_STATE_FCA_IS_NODMA, lcount, tcount, in fcp_handle_mapflags()
5111 mutex_enter(&pptr->port_mutex); in fcp_handle_mapflags()
5118 if ((fcp_send_els(pptr, ptgt, icmd, opcode, in fcp_handle_mapflags()
5122 fcp_icmd_free(pptr, icmd); in fcp_handle_mapflags()
5125 mutex_enter(&pptr->port_mutex); in fcp_handle_mapflags()
5148 fcp_send_els(struct fcp_port *pptr, struct fcp_tgt *ptgt, in fcp_send_els() argument
5161 ASSERT(ptgt->tgt_port == pptr); in fcp_send_els()
5163 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_send_els()
5180 icmd = fcp_icmd_alloc(pptr, ptgt, alloc, alloc, 0, in fcp_send_els()
5181 pptr->port_state & FCP_STATE_FCA_IS_NODMA, in fcp_send_els()
5208 hp->s_id = pptr->port_id; /* source ID */ in fcp_send_els()
5245 mutex_enter(&pptr->port_mutex); in fcp_send_els()
5248 mutex_exit(&pptr->port_mutex); in fcp_send_els()
5250 rval = fc_ulp_login(pptr->port_fp_handle, &fpkt, 1); in fcp_send_els()
5258 res = fcp_handle_ipkt_errors(pptr, ptgt, icmd, in fcp_send_els()
5261 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_send_els()
5265 mutex_exit(&pptr->port_mutex); in fcp_send_els()
5319 mutex_enter(&pptr->port_mutex); in fcp_send_els()
5322 mutex_exit(&pptr->port_mutex); in fcp_send_els()
5324 rval = fc_ulp_issue_els(pptr->port_fp_handle, fpkt); in fcp_send_els()
5332 res = fcp_handle_ipkt_errors(pptr, ptgt, icmd, in fcp_send_els()
5335 mutex_exit(&pptr->port_mutex); in fcp_send_els()
5346 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_send_els()
5352 fcp_icmd_free(pptr, icmd); in fcp_send_els()
5371 fcp_update_state(struct fcp_port *pptr, uint32_t state, int cause) in fcp_update_state() argument
5376 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_update_state()
5379 for (ptgt = pptr->port_tgt_hash_table[i]; ptgt != NULL; in fcp_update_state()
5394 fcp_offline_all(struct fcp_port *pptr, int lcount, int cause) in fcp_offline_all() argument
5400 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_offline_all()
5403 for (ptgt = pptr->port_tgt_hash_table[i]; ptgt != NULL; in fcp_offline_all()
5412 pptr->port_tmp_cnt = ndevs; in fcp_offline_all()
5415 for (ptgt = pptr->port_tgt_hash_table[i]; ptgt != NULL; in fcp_offline_all()
5417 (void) fcp_call_finish_init_held(pptr, ptgt, in fcp_offline_all()
5533 struct fcp_port *pptr; in fcp_get_port() local
5538 for (pptr = fcp_port_head; pptr != NULL; pptr = pptr->port_next) { in fcp_get_port()
5539 if (pptr->port_fp_handle == port_handle) { in fcp_get_port()
5545 return (pptr); in fcp_get_port()
5553 struct fcp_port *pptr = icmd->ipkt_port; in fcp_unsol_callback() local
5561 fcp_log(CE_WARN, pptr->port_dip, in fcp_unsol_callback()
5567 fcp_icmd_free(pptr, icmd); in fcp_unsol_callback()
5598 fcp_unsol_prli(struct fcp_port *pptr, fc_unsol_buf_t *buf) in fcp_unsol_prli() argument
5612 if ((ptgt = fcp_get_target_by_did(pptr, buf->ub_frame.s_id)) != in fcp_unsol_prli()
5619 mutex_enter(&pptr->port_mutex); in fcp_unsol_prli()
5620 lcount = pptr->port_link_cnt; in fcp_unsol_prli()
5621 mutex_exit(&pptr->port_mutex); in fcp_unsol_prli()
5623 if ((icmd = fcp_icmd_alloc(pptr, ptgt, sizeof (la_els_prli_t), in fcp_unsol_prli()
5625 pptr->port_state & FCP_STATE_FCA_IS_NODMA, in fcp_unsol_prli()
5680 mutex_enter(&pptr->port_mutex); in fcp_unsol_prli()
5681 if (!FCP_LINK_STATE_CHANGED(pptr, icmd)) { in fcp_unsol_prli()
5683 mutex_exit(&pptr->port_mutex); in fcp_unsol_prli()
5685 if ((rval = fc_ulp_issue_els(pptr->port_fp_handle, fpkt)) != in fcp_unsol_prli()
5689 fcp_queue_ipkt(pptr, fpkt); in fcp_unsol_prli()
5693 fcp_icmd_free(pptr, icmd); in fcp_unsol_prli()
5697 mutex_exit(&pptr->port_mutex); in fcp_unsol_prli()
5698 fcp_icmd_free(pptr, icmd); in fcp_unsol_prli()
5702 (void) fc_ulp_ubrelease(pptr->port_fp_handle, 1, &buf->ub_token); in fcp_unsol_prli()
5734 fcp_icmd_alloc(struct fcp_port *pptr, struct fcp_tgt *ptgt, int cmd_len, in fcp_icmd_alloc() argument
5743 pptr->port_dmacookie_sz + pptr->port_priv_pkt_len, in fcp_icmd_alloc()
5746 fcp_log(CE_WARN, pptr->port_dip, in fcp_icmd_alloc()
5762 mutex_enter(&pptr->port_mutex); in fcp_icmd_alloc()
5763 icmd->ipkt_port = pptr; in fcp_icmd_alloc()
5764 mutex_exit(&pptr->port_mutex); in fcp_icmd_alloc()
5780 pptr->port_dmacookie_sz); in fcp_icmd_alloc()
5816 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_alloc()
5829 if (fcp_alloc_dma(pptr, icmd, nodma, KM_NOSLEEP) != FC_SUCCESS) { in fcp_icmd_alloc()
5844 if (fc_ulp_init_packet(pptr->port_fp_handle, fpkt, KM_NOSLEEP) in fcp_icmd_alloc()
5846 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_alloc()
5854 if (fc_ulp_init_packet(pptr->port_fp_handle, fpkt, KM_NOSLEEP) in fcp_icmd_alloc()
5856 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_alloc()
5863 mutex_enter(&pptr->port_mutex); in fcp_icmd_alloc()
5864 if (pptr->port_state & (FCP_STATE_DETACHING | in fcp_icmd_alloc()
5868 mutex_exit(&pptr->port_mutex); in fcp_icmd_alloc()
5870 rval = fc_ulp_uninit_packet(pptr->port_fp_handle, fpkt); in fcp_icmd_alloc()
5882 pptr->port_ipkt_cnt++; in fcp_icmd_alloc()
5884 mutex_exit(&pptr->port_mutex); in fcp_icmd_alloc()
5896 fcp_free_dma(pptr, icmd); in fcp_icmd_alloc()
5898 kmem_free(icmd, sizeof (struct fcp_ipkt) + pptr->port_priv_pkt_len + in fcp_icmd_alloc()
5899 (size_t)pptr->port_dmacookie_sz); in fcp_icmd_alloc()
5915 fcp_icmd_free(struct fcp_port *pptr, struct fcp_ipkt *icmd) in fcp_icmd_free() argument
5920 (void) fc_ulp_uninit_packet(pptr->port_fp_handle, in fcp_icmd_free()
5928 fcp_free_dma(pptr, icmd); in fcp_icmd_free()
5930 kmem_free(icmd, sizeof (struct fcp_ipkt) + pptr->port_priv_pkt_len + in fcp_icmd_free()
5931 (size_t)pptr->port_dmacookie_sz); in fcp_icmd_free()
5933 mutex_enter(&pptr->port_mutex); in fcp_icmd_free()
5941 pptr->port_ipkt_cnt--; in fcp_icmd_free()
5942 mutex_exit(&pptr->port_mutex); in fcp_icmd_free()
5960 fcp_alloc_dma(struct fcp_port *pptr, struct fcp_ipkt *icmd, in fcp_alloc_dma() argument
5993 rval = fcp_alloc_cmd_resp(pptr, fpkt, flags); in fcp_alloc_dma()
6003 !(pptr->port_state & FCP_STATE_FCA_IS_NODMA)) { in fcp_alloc_dma()
6007 if (ddi_dma_alloc_handle(pptr->port_dip, in fcp_alloc_dma()
6008 &pptr->port_data_dma_attr, DDI_DMA_DONTWAIT, in fcp_alloc_dma()
6014 &pptr->port_dma_acc_attr, DDI_DMA_CONSISTENT, in fcp_alloc_dma()
6034 if (ccount > pptr->port_data_dma_attr.dma_attr_sgllen) { in fcp_alloc_dma()
6089 fcp_free_cmd_resp(pptr, fpkt); in fcp_alloc_dma()
6098 fcp_free_dma(struct fcp_port *pptr, struct fcp_ipkt *icmd) in fcp_free_dma() argument
6127 fcp_free_cmd_resp(pptr, fpkt); in fcp_free_dma()
6147 fcp_lookup_target(struct fcp_port *pptr, uchar_t *wwn) in fcp_lookup_target() argument
6152 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_lookup_target()
6156 for (ptgt = pptr->port_tgt_hash_table[hash]; ptgt != NULL; in fcp_lookup_target()
6173 fcp_get_target_by_did(struct fcp_port *pptr, uint32_t d_id) in fcp_get_target_by_did() argument
6181 if (fc_ulp_get_pwwn_by_did(pptr->port_fp_handle, port_id, in fcp_get_target_by_did()
6183 mutex_enter(&pptr->port_mutex); in fcp_get_target_by_did()
6184 ptgt = fcp_lookup_target(pptr, pwwn.raw_wwn); in fcp_get_target_by_did()
6185 mutex_exit(&pptr->port_mutex); in fcp_get_target_by_did()
6204 struct fcp_port *pptr; in fcp_icmd_callback() local
6220 pptr = icmd->ipkt_port; in fcp_icmd_callback()
6231 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_callback()
6257 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_callback()
6268 if (fcp_send_els(pptr, ptgt, icmd, LA_ELS_PRLI, in fcp_icmd_callback()
6278 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_callback()
6306 fc_ulp_disable_relogin(pptr->port_fp_handle, in fcp_icmd_callback()
6311 mutex_enter(&pptr->port_mutex); in fcp_icmd_callback()
6317 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_callback()
6322 mutex_exit(&pptr->port_mutex); in fcp_icmd_callback()
6326 mutex_exit(&pptr->port_mutex); in fcp_icmd_callback()
6345 fcp_log(CE_WARN, pptr->port_dip, in fcp_icmd_callback()
6383 mutex_enter(&pptr->port_mutex); in fcp_icmd_callback()
6385 fcp_log(CE_WARN, pptr->port_dip, in fcp_icmd_callback()
6390 pptr->port_instbuf, fcp_trace, in fcp_icmd_callback()
6396 mutex_exit(&pptr->port_mutex); in fcp_icmd_callback()
6404 fcp_icmd_free(pptr, icmd); in fcp_icmd_callback()
6409 fcp_log(CE_WARN, pptr->port_dip, in fcp_icmd_callback()
6427 fcp_queue_ipkt(pptr, fpkt); in fcp_icmd_callback()
6431 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_callback()
6441 mutex_enter(&pptr->port_mutex); in fcp_icmd_callback()
6445 mutex_exit(&pptr->port_mutex); in fcp_icmd_callback()
6454 rval = fc_ulp_issue_els(pptr->port_fp_handle, in fcp_icmd_callback()
6462 fcp_queue_ipkt(pptr, fpkt); in fcp_icmd_callback()
6467 fcp_log(CE_NOTE, pptr->port_dip, in fcp_icmd_callback()
6472 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_callback()
6476 mutex_exit(&pptr->port_mutex); in fcp_icmd_callback()
6483 fcp_queue_ipkt(pptr, fpkt); in fcp_icmd_callback()
6487 mutex_enter(&pptr->port_mutex); in fcp_icmd_callback()
6490 mutex_exit(&pptr->port_mutex); in fcp_icmd_callback()
6493 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_icmd_callback()
6497 mutex_exit(&pptr->port_mutex); in fcp_icmd_callback()
6503 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_icmd_callback()
6505 fcp_icmd_free(pptr, icmd); in fcp_icmd_callback()
6524 struct fcp_port *pptr; in fcp_send_scsi() local
6536 pptr = ptgt->tgt_port; in fcp_send_scsi()
6537 ASSERT(pptr != NULL); in fcp_send_scsi()
6539 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_send_scsi()
6543 nodma = (pptr->port_fcp_dma == FC_NO_DVMA_SPACE) ? 1 : 0; in fcp_send_scsi()
6544 icmd = fcp_icmd_alloc(pptr, ptgt, sizeof (struct fcp_cmd), in fcp_send_scsi()
6569 hp->s_id = pptr->port_id; in fcp_send_scsi()
6638 fca_dev = fc_ulp_get_fca_device(pptr->port_fp_handle, d_id); in fcp_send_scsi()
6660 fcp_log(CE_WARN, pptr->port_dip, in fcp_send_scsi()
6670 mutex_enter(&pptr->port_mutex); in fcp_send_scsi()
6673 mutex_exit(&pptr->port_mutex); in fcp_send_scsi()
6674 if (fcp_transport(pptr->port_fp_handle, fpkt, 1) != in fcp_send_scsi()
6676 fcp_icmd_free(pptr, icmd); in fcp_send_scsi()
6681 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_send_scsi()
6685 mutex_exit(&pptr->port_mutex); in fcp_send_scsi()
6686 fcp_icmd_free(pptr, icmd); in fcp_send_scsi()
6705 struct fcp_port *pptr = ptgt->tgt_port; in fcp_check_reportlun() local
6842 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_check_reportlun()
6864 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_check_reportlun()
6869 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_check_reportlun()
6878 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_check_reportlun()
6905 struct fcp_port *pptr; in fcp_scsi_callback() local
6911 pptr = ptgt->tgt_port; in fcp_scsi_callback()
6922 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_callback()
6960 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_callback()
6985 mutex_enter(&pptr->port_mutex); in fcp_scsi_callback()
6987 if (!FCP_STATE_CHANGED(pptr, ptgt, icmd)) { in fcp_scsi_callback()
6989 mutex_exit(&pptr->port_mutex); in fcp_scsi_callback()
6992 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_callback()
6997 mutex_exit(&pptr->port_mutex); in fcp_scsi_callback()
6999 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_scsi_callback()
7001 fcp_icmd_free(pptr, icmd); in fcp_scsi_callback()
7007 mutex_enter(&pptr->port_mutex); in fcp_scsi_callback()
7009 if (FCP_STATE_CHANGED(pptr, ptgt, icmd)) { in fcp_scsi_callback()
7010 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_callback()
7015 mutex_exit(&pptr->port_mutex); in fcp_scsi_callback()
7016 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_scsi_callback()
7018 fcp_icmd_free(pptr, icmd); in fcp_scsi_callback()
7024 mutex_exit(&pptr->port_mutex); in fcp_scsi_callback()
7035 if (fcp_validate_fcp_response(rsp, pptr) != FC_SUCCESS) { in fcp_scsi_callback()
7042 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_callback()
7052 fcp_queue_ipkt(pptr, fpkt); in fcp_scsi_callback()
7066 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_callback()
7098 (void) fcp_call_finish_init(pptr, ptgt, in fcp_scsi_callback()
7101 fcp_icmd_free(pptr, icmd); in fcp_scsi_callback()
7132 (void) fcp_call_finish_init(pptr, ptgt, in fcp_scsi_callback()
7135 fcp_icmd_free(pptr, icmd); in fcp_scsi_callback()
7151 if (!(pptr->port_state & FCP_STATE_FCA_IS_NODMA)) { in fcp_scsi_callback()
7175 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_scsi_callback()
7177 fcp_icmd_free(pptr, icmd); in fcp_scsi_callback()
7189 struct fcp_port *pptr = ptgt->tgt_port; in fcp_retry_scsi_cmd() local
7193 mutex_enter(&pptr->port_mutex); in fcp_retry_scsi_cmd()
7195 mutex_exit(&pptr->port_mutex); in fcp_retry_scsi_cmd()
7196 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_retry_scsi_cmd()
7203 fcp_queue_ipkt(pptr, fpkt); in fcp_retry_scsi_cmd()
7205 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_retry_scsi_cmd()
7209 mutex_exit(&pptr->port_mutex); in fcp_retry_scsi_cmd()
7210 (void) fcp_call_finish_init(pptr, ptgt, in fcp_retry_scsi_cmd()
7213 fcp_icmd_free(pptr, icmd); in fcp_retry_scsi_cmd()
7217 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_retry_scsi_cmd()
7219 fcp_icmd_free(pptr, icmd); in fcp_retry_scsi_cmd()
7240 struct fcp_port *pptr; in fcp_handle_page83() local
7251 pptr = icmd->ipkt_port; in fcp_handle_page83()
7261 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_page83()
7265 pptr->port_instance, ptgt->tgt_d_id, in fcp_handle_page83()
7335 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_page83()
7347 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_page83()
7355 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_page83()
7387 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_page83()
7396 mutex_enter(&pptr->port_mutex); in fcp_handle_page83()
7409 if (fail || pptr->port_mpxio == 0) { in fcp_handle_page83()
7416 mutex_exit(&pptr->port_mutex); in fcp_handle_page83()
7423 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_handle_page83()
7426 fcp_icmd_free(pptr, icmd); in fcp_handle_page83()
7443 struct fcp_port *pptr; in fcp_handle_inquiry() local
7452 pptr = icmd->ipkt_port; in fcp_handle_inquiry()
7462 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_inquiry()
7465 "dtype=0x%x pqual: 0x%x", pptr->port_instance, ptgt->tgt_d_id, in fcp_handle_inquiry()
7472 fcp_log(CE_CONT, pptr->port_dip, in fcp_handle_inquiry()
7477 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_inquiry()
7485 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_handle_inquiry()
7487 fcp_icmd_free(pptr, icmd); in fcp_handle_inquiry()
7506 mutex_enter(&pptr->port_mutex); in fcp_handle_inquiry()
7507 if (!pptr->port_notify) { in fcp_handle_inquiry()
7513 pptr->port_notify = 1; in fcp_handle_inquiry()
7514 mutex_exit(&pptr->port_mutex); in fcp_handle_inquiry()
7515 (void) fc_ulp_port_notify(pptr->port_fp_handle, cmd); in fcp_handle_inquiry()
7516 mutex_enter(&pptr->port_mutex); in fcp_handle_inquiry()
7521 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_inquiry()
7525 mutex_exit(&pptr->port_mutex); in fcp_handle_inquiry()
7528 (void) fcp_call_finish_init(pptr, ptgt, in fcp_handle_inquiry()
7531 fcp_icmd_free(pptr, icmd); in fcp_handle_inquiry()
7535 mutex_exit(&pptr->port_mutex); in fcp_handle_inquiry()
7551 (void) fcp_call_finish_init(pptr, ptgt, in fcp_handle_inquiry()
7560 fcp_icmd_free(pptr, icmd); in fcp_handle_inquiry()
7583 struct fcp_port *pptr; in fcp_handle_reportlun() local
7588 pptr = icmd->ipkt_port; in fcp_handle_reportlun()
7594 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_handle_reportlun()
7596 fcp_icmd_free(pptr, icmd); in fcp_handle_reportlun()
7603 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_reportlun()
7606 pptr->port_instance, ptgt->tgt_d_id); in fcp_handle_reportlun()
7625 fcp_log(CE_NOTE, pptr->port_dip, "!Can not support" in fcp_handle_reportlun()
7629 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_handle_reportlun()
7631 fcp_icmd_free(pptr, icmd); in fcp_handle_reportlun()
7654 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_reportlun()
7672 (void) fcp_call_finish_init(pptr, ptgt, in fcp_handle_reportlun()
7677 fcp_icmd_free(pptr, icmd); in fcp_handle_reportlun()
7682 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_reportlun()
7734 mutex_enter(&pptr->port_mutex); in fcp_handle_reportlun()
7736 if (!FCP_STATE_CHANGED(pptr, ptgt, icmd)) { in fcp_handle_reportlun()
7745 mutex_exit(&pptr->port_mutex); in fcp_handle_reportlun()
7748 fcp_log(CE_NOTE, pptr->port_dip, in fcp_handle_reportlun()
7754 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_reportlun()
7759 mutex_exit(&pptr->port_mutex); in fcp_handle_reportlun()
7761 (void) fcp_call_finish_init(pptr, ptgt, in fcp_handle_reportlun()
7764 fcp_icmd_free(pptr, icmd); in fcp_handle_reportlun()
7780 fcp_log(CE_NOTE, pptr->port_dip, in fcp_handle_reportlun()
7792 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_reportlun()
7795 pptr->port_instance, ptgt->tgt_d_id, nluns_claimed); in fcp_handle_reportlun()
7803 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_reportlun()
7831 fcp_log(CE_NOTE, pptr->port_dip, in fcp_handle_reportlun()
7867 mutex_enter(&pptr->port_mutex); in fcp_handle_reportlun()
7869 if (!FCP_STATE_CHANGED(pptr, ptgt, icmd)) { in fcp_handle_reportlun()
7870 fcp_log(CE_NOTE, pptr->port_dip, in fcp_handle_reportlun()
7876 pptr->port_instbuf, fcp_trace, in fcp_handle_reportlun()
7883 mutex_exit(&pptr->port_mutex); in fcp_handle_reportlun()
7901 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_handle_reportlun()
7906 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_reportlun()
7908 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_handle_reportlun()
7913 fcp_icmd_free(pptr, icmd); in fcp_handle_reportlun()
7948 fcp_finish_tgt(struct fcp_port *pptr, struct fcp_tgt *ptgt, in fcp_finish_tgt() argument
7952 ASSERT(pptr != NULL); in fcp_finish_tgt()
7955 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_finish_tgt()
7960 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_finish_tgt()
7962 if ((pptr->port_link_cnt != link_cnt) || in fcp_finish_tgt()
7988 rval = fcp_offline_target(pptr, ptgt, link_cnt, in fcp_finish_tgt()
8028 fcp_finish_init(struct fcp_port *pptr) in fcp_finish_init() argument
8031 bzero(pptr->port_finish_stack, sizeof (pptr->port_finish_stack)); in fcp_finish_init()
8032 pptr->port_finish_depth = getpcstack(pptr->port_finish_stack, in fcp_finish_init()
8036 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_finish_init()
8038 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_finish_init()
8040 " entering; ipkt count=%d", pptr->port_ipkt_cnt); in fcp_finish_init()
8042 if ((pptr->port_state & FCP_STATE_ONLINING) && in fcp_finish_init()
8043 !(pptr->port_state & (FCP_STATE_SUSPENDED | in fcp_finish_init()
8045 pptr->port_state &= ~FCP_STATE_ONLINING; in fcp_finish_init()
8046 pptr->port_state |= FCP_STATE_ONLINE; in fcp_finish_init()
8050 cv_broadcast(&pptr->port_config_cv); in fcp_finish_init()
8063 struct fcp_port *pptr; in fcp_create_luns() local
8069 pptr = ptgt->tgt_port; in fcp_create_luns()
8071 ASSERT(pptr != NULL); in fcp_create_luns()
8080 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_create_luns()
8095 (!fcp_pass_to_hp(pptr, plun, plun->lun_cip, in fcp_create_luns()
8098 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_create_luns()
8113 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_create_luns()
8127 if (!fcp_pass_to_hp(pptr, plun, cip, FCP_ONLINE, in fcp_create_luns()
8136 if (!fcp_pass_to_hp(pptr, plun, cip, FCP_ONLINE, in fcp_create_luns()
8138 fcp_log(CE_CONT, pptr->port_dip, in fcp_create_luns()
8157 struct fcp_port *pptr = plun->lun_tgt->tgt_port; in fcp_trigger_lun() local
8158 int is_mpxio = pptr->port_mpxio; in fcp_trigger_lun()
8167 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_trigger_lun()
8173 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_trigger_lun()
8239 if (fc_ulp_busy_port(pptr->port_fp_handle) != 0) { in fcp_trigger_lun()
8244 mdi_devi_enter(pptr->port_dip, &enteredv); in fcp_trigger_lun()
8246 ndi_devi_enter(pptr->port_dip); in fcp_trigger_lun()
8249 mutex_enter(&pptr->port_mutex); in fcp_trigger_lun()
8266 fc_ulp_log_device_event(pptr->port_fp_handle, in fcp_trigger_lun()
8270 fc_ulp_log_device_event(pptr->port_fp_handle, in fcp_trigger_lun()
8275 mutex_exit(&pptr->port_mutex); in fcp_trigger_lun()
8278 mdi_devi_exit(pptr->port_dip, enteredv); in fcp_trigger_lun()
8280 ndi_devi_exit(pptr->port_dip); in fcp_trigger_lun()
8283 fc_ulp_idle_port(pptr->port_fp_handle); in fcp_trigger_lun()
8294 fcp_offline_target(struct fcp_port *pptr, struct fcp_tgt *ptgt, in fcp_offline_target() argument
8299 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_offline_target()
8304 if (link_cnt != pptr->port_link_cnt || (tgt_cnt && tgt_cnt != in fcp_offline_target()
8330 elem->next = pptr->port_offline_tgts; in fcp_offline_target()
8331 pptr->port_offline_tgts = elem; in fcp_offline_target()
8333 fcp_offline_target_now(pptr, ptgt, link_cnt, tgt_cnt, flags); in fcp_offline_target()
8341 fcp_offline_target_now(struct fcp_port *pptr, struct fcp_tgt *ptgt, in fcp_offline_target_now() argument
8344 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_offline_target_now()
8347 fc_ulp_enable_relogin(pptr->port_fp_handle, &ptgt->tgt_port_wwn); in fcp_offline_target_now()
8382 struct fcp_port *pptr = plun->lun_tgt->tgt_port; in fcp_offline_lun() local
8402 elem->next = pptr->port_offline_luns; in fcp_offline_lun()
8403 pptr->port_offline_luns = elem; in fcp_offline_lun()
8478 fcp_scan_offline_luns(struct fcp_port *pptr) in fcp_scan_offline_luns() argument
8484 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_scan_offline_luns()
8487 elem = pptr->port_offline_luns; in fcp_scan_offline_luns()
8495 if (pptr->port_link_cnt == elem->link_cnt && in fcp_scan_offline_luns()
8512 pptr->port_offline_luns = next; in fcp_scan_offline_luns()
8523 fcp_scan_offline_tgts(struct fcp_port *pptr) in fcp_scan_offline_tgts() argument
8529 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_scan_offline_tgts()
8532 elem = pptr->port_offline_tgts; in fcp_scan_offline_tgts()
8545 pptr->port_link_cnt == elem->link_cnt + 1 && in fcp_scan_offline_tgts()
8559 fcp_offline_target_now(pptr, in fcp_scan_offline_tgts()
8571 pptr->port_offline_tgts = next; in fcp_scan_offline_tgts()
8584 struct fcp_port *pptr = LUN_PORT; in fcp_update_offline_flags() local
8606 pptr->port_ndi_event_hdl, cdip, FCAL_REMOVE_EVENT, in fcp_update_offline_flags()
8609 pptr->port_ndi_event_hdl, cdip, in fcp_update_offline_flags()
8626 struct fcp_port *pptr = LUN_PORT; in fcp_scan_commands() local
8637 mutex_enter(&pptr->port_pkt_mutex); in fcp_scan_commands()
8638 for (cmd = pptr->port_pkt_head; cmd != NULL; cmd = ncmd) { in fcp_scan_commands()
8655 ASSERT(pptr->port_pkt_head != cmd); in fcp_scan_commands()
8658 ASSERT(cmd == pptr->port_pkt_head); in fcp_scan_commands()
8659 pptr->port_pkt_head = cmd->cmd_next; in fcp_scan_commands()
8662 if (cmd == pptr->port_pkt_tail) { in fcp_scan_commands()
8663 pptr->port_pkt_tail = pcmd; in fcp_scan_commands()
8679 mutex_exit(&pptr->port_pkt_mutex); in fcp_scan_commands()
8681 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_scan_commands()
8693 fcp_abort_commands(struct fcp_pkt *head, struct fcp_port *pptr) in fcp_abort_commands() argument
8698 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_abort_commands()
8726 mutex_exit(&pptr->port_mutex); in fcp_abort_commands()
8728 mutex_enter(&pptr->port_mutex); in fcp_abort_commands()
8741 struct fcp_port *pptr = ADDR2FCP(&pkt->pkt_address); in fcp_cmd_callback() local
8754 fcp_log(CE_CONT, pptr->port_dip, in fcp_cmd_callback()
8763 mutex_enter(&pptr->port_pkt_mutex); in fcp_cmd_callback()
8764 pptr->port_npkts--; in fcp_cmd_callback()
8765 mutex_exit(&pptr->port_pkt_mutex); in fcp_cmd_callback()
8779 struct fcp_port *pptr = ADDR2FCP(&pkt->pkt_address); in fcp_complete_pkt() local
8792 if (pptr->port_fcp_dma != FC_NO_DVMA_SPACE) { in fcp_complete_pkt()
8848 if (fcp_validate_fcp_response(rsp, pptr) != in fcp_complete_pkt()
8853 fcp_log(CE_WARN, pptr->port_dip, in fcp_complete_pkt()
8867 if (pptr->port_fcp_dma != FC_NO_DVMA_SPACE) { in fcp_complete_pkt()
8883 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_complete_pkt()
8911 if (fcp_validate_fcp_response(rsp, pptr) != in fcp_complete_pkt()
8916 fcp_log(CE_WARN, pptr->port_dip, in fcp_complete_pkt()
8933 if (pptr->port_fcp_dma != FC_NO_DVMA_SPACE) { in fcp_complete_pkt()
8955 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_complete_pkt()
8960 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_complete_pkt()
8985 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_complete_pkt()
9055 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_complete_pkt()
9072 pptr->port_ndi_event_hdl, cdip, in fcp_complete_pkt()
9076 pptr->port_ndi_event_hdl, cdip, in fcp_complete_pkt()
9136 pptr->port_ndi_event_hdl, cdip, in fcp_complete_pkt()
9141 pptr->port_ndi_event_hdl, in fcp_complete_pkt()
9179 if (pptr->port_fcp_dma != FC_NO_DVMA_SPACE) { in fcp_complete_pkt()
9217 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_complete_pkt()
9226 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_complete_pkt()
9238 fcp_validate_fcp_response(struct fcp_rsp *rsp, struct fcp_port *pptr) in fcp_validate_fcp_response() argument
9255 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_validate_fcp_response()
9287 fcp_device_changed(struct fcp_port *pptr, struct fcp_tgt *ptgt, in fcp_device_changed() argument
9290 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_device_changed()
9292 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_device_changed()
9301 (FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_device_changed()
9307 (void) fcp_offline_target(pptr, ptgt, link_cnt, in fcp_device_changed()
9312 fcp_log(CE_NOTE, pptr->port_dip, in fcp_device_changed()
9319 return (fcp_handle_mapflags(pptr, ptgt, map_entry, in fcp_device_changed()
9407 fcp_alloc_tgt(struct fcp_port *pptr, fc_portmap_t *map_entry, int link_cnt) in fcp_alloc_tgt() argument
9415 mutex_enter(&pptr->port_mutex); in fcp_alloc_tgt()
9416 if (link_cnt != pptr->port_link_cnt) { in fcp_alloc_tgt()
9421 mutex_exit(&pptr->port_mutex); in fcp_alloc_tgt()
9436 ptgt->tgt_next = pptr->port_tgt_hash_table[hash]; in fcp_alloc_tgt()
9437 pptr->port_tgt_hash_table[hash] = ptgt; in fcp_alloc_tgt()
9440 ptgt->tgt_port = pptr; in fcp_alloc_tgt()
9451 mutex_exit(&pptr->port_mutex); in fcp_alloc_tgt()
9492 fcp_queue_ipkt(struct fcp_port *pptr, fc_packet_t *fpkt) in fcp_queue_ipkt() argument
9497 mutex_enter(&pptr->port_mutex); in fcp_queue_ipkt()
9499 if (FCP_STATE_CHANGED(pptr, ptgt, icmd)) { in fcp_queue_ipkt()
9500 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_queue_ipkt()
9505 mutex_exit(&pptr->port_mutex); in fcp_queue_ipkt()
9506 (void) fcp_call_finish_init(pptr, ptgt, icmd->ipkt_link_cnt, in fcp_queue_ipkt()
9508 fcp_icmd_free(pptr, icmd); in fcp_queue_ipkt()
9515 if (pptr->port_ipkt_list != NULL) { in fcp_queue_ipkt()
9517 pptr->port_ipkt_list->ipkt_prev = icmd; in fcp_queue_ipkt()
9518 icmd->ipkt_next = pptr->port_ipkt_list; in fcp_queue_ipkt()
9519 pptr->port_ipkt_list = icmd; in fcp_queue_ipkt()
9523 pptr->port_ipkt_list = icmd; in fcp_queue_ipkt()
9527 mutex_exit(&pptr->port_mutex); in fcp_queue_ipkt()
9625 struct fcp_port *pptr; in fcp_transport() local
9629 pptr = ADDR2FCP(&cmd->cmd_pkt->pkt_address); in fcp_transport()
9632 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_transport()
9638 fcp_queue_pkt(pptr, cmd); in fcp_transport()
9672 fcp_retry_ns_registry(struct fcp_port *pptr, uint32_t s_id) in fcp_retry_ns_registry() argument
9676 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_retry_ns_registry()
9678 if (((pptr->port_state & FCP_STATE_NS_REG_FAILED) == 0) || in fcp_retry_ns_registry()
9679 ((pptr->port_topology != FC_TOP_FABRIC) && in fcp_retry_ns_registry()
9680 (pptr->port_topology != FC_TOP_PUBLIC_LOOP))) { in fcp_retry_ns_registry()
9681 if (pptr->port_state & FCP_STATE_NS_REG_FAILED) { in fcp_retry_ns_registry()
9682 pptr->port_state &= ~FCP_STATE_NS_REG_FAILED; in fcp_retry_ns_registry()
9686 mutex_exit(&pptr->port_mutex); in fcp_retry_ns_registry()
9687 rval = fcp_do_ns_registry(pptr, s_id); in fcp_retry_ns_registry()
9688 mutex_enter(&pptr->port_mutex); in fcp_retry_ns_registry()
9692 pptr->port_state &= ~(FCP_STATE_NS_REG_FAILED); in fcp_retry_ns_registry()
9700 fcp_do_ns_registry(struct fcp_port *pptr, uint32_t s_id) in fcp_do_ns_registry() argument
9730 if (fc_ulp_port_ns(pptr->port_fp_handle, NULL, &ns_cmd)) { in fcp_do_ns_registry()
9731 fcp_log(CE_WARN, pptr->port_dip, in fcp_do_ns_registry()
9774 struct fcp_port *pptr; in fcp_handle_port_attach() local
9795 if ((pptr = ddi_get_soft_state(fcp_softstate, instance)) == NULL) { in fcp_handle_port_attach()
9802 (void) sprintf(pptr->port_instbuf, "fcp(%d)", instance); in fcp_handle_port_attach()
9808 (void) fcp_cp_pinfo(pptr, pinfo); in fcp_handle_port_attach()
9815 if ((manual_cfg = ddi_prop_get_int(DDI_DEV_T_ANY, pptr->port_dip, in fcp_handle_port_attach()
9822 (void) ddi_pathname(pptr->port_dip, pathname); in fcp_handle_port_attach()
9826 ddi_driver_name(pptr->port_dip), in fcp_handle_port_attach()
9827 ddi_get_instance(pptr->port_dip), in fcp_handle_port_attach()
9829 ddi_driver_name(pptr->port_dip)); in fcp_handle_port_attach()
9834 _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(pptr->port_link_cnt)); in fcp_handle_port_attach()
9835 pptr->port_link_cnt = 1; in fcp_handle_port_attach()
9836 _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(pptr->port_link_cnt)); in fcp_handle_port_attach()
9837 pptr->port_id = s_id; in fcp_handle_port_attach()
9838 pptr->port_instance = instance; in fcp_handle_port_attach()
9839 _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(pptr->port_state)); in fcp_handle_port_attach()
9840 pptr->port_state = FCP_STATE_INIT; in fcp_handle_port_attach()
9845 pptr->port_state |= FCP_STATE_FCA_IS_NODMA; in fcp_handle_port_attach()
9848 _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(pptr->port_state)); in fcp_handle_port_attach()
9850 if (!(pptr->port_state & FCP_STATE_FCA_IS_NODMA)) { in fcp_handle_port_attach()
9855 pptr->port_dmacookie_sz = sizeof (ddi_dma_cookie_t) * in fcp_handle_port_attach()
9856 pptr->port_data_dma_attr.dma_attr_sgllen; in fcp_handle_port_attach()
9865 mutex_init(&pptr->port_mutex, NULL, MUTEX_DRIVER, NULL); in fcp_handle_port_attach()
9866 mutex_init(&pptr->port_pkt_mutex, NULL, MUTEX_DRIVER, NULL); in fcp_handle_port_attach()
9872 if ((tran = scsi_hba_tran_alloc(pptr->port_dip, 0)) == NULL) { in fcp_handle_port_attach()
9873 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_port_attach()
9879 pptr->port_tran = tran; in fcp_handle_port_attach()
9880 tran->tran_hba_private = pptr; in fcp_handle_port_attach()
9915 tran->tran_hba_len = pptr->port_priv_pkt_len + in fcp_handle_port_attach()
9916 sizeof (struct fcp_pkt) + pptr->port_dmacookie_sz; in fcp_handle_port_attach()
9917 if (pptr->port_state & FCP_STATE_FCA_IS_NODMA) { in fcp_handle_port_attach()
9931 pptr->port_data_dma_attr = pseudo_fca_dma_attr; in fcp_handle_port_attach()
9937 pptr->port_ndi_event_defs = (ndi_event_definition_t *) in fcp_handle_port_attach()
9940 bcopy(fcp_ndi_event_defs, pptr->port_ndi_event_defs, in fcp_handle_port_attach()
9943 (void) ndi_event_alloc_hdl(pptr->port_dip, NULL, in fcp_handle_port_attach()
9944 &pptr->port_ndi_event_hdl, NDI_SLEEP); in fcp_handle_port_attach()
9946 pptr->port_ndi_events.ndi_events_version = NDI_EVENTS_REV1; in fcp_handle_port_attach()
9947 pptr->port_ndi_events.ndi_n_events = FCP_N_NDI_EVENTS; in fcp_handle_port_attach()
9948 pptr->port_ndi_events.ndi_event_defs = pptr->port_ndi_event_defs; in fcp_handle_port_attach()
9950 if (DEVI_IS_ATTACHING(pptr->port_dip) && in fcp_handle_port_attach()
9951 (ndi_event_bind_set(pptr->port_ndi_event_hdl, in fcp_handle_port_attach()
9952 &pptr->port_ndi_events, NDI_SLEEP) != NDI_SUCCESS)) { in fcp_handle_port_attach()
9957 if (scsi_hba_attach_setup(pptr->port_dip, &pptr->port_data_dma_attr, in fcp_handle_port_attach()
9960 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_port_attach()
9966 pptr->port_mpxio = 0; in fcp_handle_port_attach()
9967 if (mdi_phci_register(MDI_HCI_CLASS_SCSI, pptr->port_dip, 0) == in fcp_handle_port_attach()
9969 pptr->port_mpxio++; in fcp_handle_port_attach()
9994 pptr->port_next = fcp_port_head; in fcp_handle_port_attach()
9995 fcp_port_head = pptr; in fcp_handle_port_attach()
10014 if (fcp_do_ns_registry(pptr, s_id)) { in fcp_handle_port_attach()
10015 mutex_enter(&pptr->port_mutex); in fcp_handle_port_attach()
10016 pptr->port_state |= FCP_STATE_NS_REG_FAILED; in fcp_handle_port_attach()
10017 mutex_exit(&pptr->port_mutex); in fcp_handle_port_attach()
10019 mutex_enter(&pptr->port_mutex); in fcp_handle_port_attach()
10020 pptr->port_state &= ~(FCP_STATE_NS_REG_FAILED); in fcp_handle_port_attach()
10021 mutex_exit(&pptr->port_mutex); in fcp_handle_port_attach()
10033 bcopy(boot_wwn, pptr->port_boot_wwn, FC_WWN_SIZE); in fcp_handle_port_attach()
10043 switch (FC_PORT_STATE_MASK(pptr->port_phys_state)) { in fcp_handle_port_attach()
10055 pptr->port_state |= FCP_STATE_OFFLINE; in fcp_handle_port_attach()
10059 if (pptr->port_topology == FC_TOP_UNKNOWN) { in fcp_handle_port_attach()
10060 (void) fcp_linkreset(pptr, NULL, KM_NOSLEEP); in fcp_handle_port_attach()
10068 ASSERT(pptr->port_topology != FC_TOP_UNKNOWN); in fcp_handle_port_attach()
10079 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_port_attach()
10100 if ((res = fc_ulp_getportmap(pptr->port_fp_handle, in fcp_handle_port_attach()
10114 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_port_attach()
10133 fcp_statec_callback(ulph, pptr->port_fp_handle, in fcp_handle_port_attach()
10134 pptr->port_phys_state, pptr->port_topology, tmp_list, in fcp_handle_port_attach()
10135 max_cnt, pptr->port_id); in fcp_handle_port_attach()
10143 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_port_attach()
10145 instance, pptr->port_phys_state); in fcp_handle_port_attach()
10147 mutex_enter(&pptr->port_mutex); in fcp_handle_port_attach()
10148 pptr->port_phys_state = FCP_STATE_OFFLINE; in fcp_handle_port_attach()
10149 mutex_exit(&pptr->port_mutex); in fcp_handle_port_attach()
10161 pptr->port_attach_time = ddi_get_lbolt64(); in fcp_handle_port_attach()
10168 fcp_log(CE_WARN, pptr->port_dip, "!failed to attach to port"); in fcp_handle_port_attach()
10172 (void) fcp_soft_state_unlink(pptr); in fcp_handle_port_attach()
10176 if (pptr->port_ndi_event_hdl) { in fcp_handle_port_attach()
10178 (void) ndi_event_unbind_set(pptr->port_ndi_event_hdl, in fcp_handle_port_attach()
10179 &pptr->port_ndi_events, NDI_SLEEP); in fcp_handle_port_attach()
10181 (void) ndi_event_free_hdl(pptr->port_ndi_event_hdl); in fcp_handle_port_attach()
10184 if (pptr->port_ndi_event_defs) { in fcp_handle_port_attach()
10185 (void) kmem_free(pptr->port_ndi_event_defs, in fcp_handle_port_attach()
10192 if (pptr->port_mpxio) { in fcp_handle_port_attach()
10193 (void) mdi_phci_unregister(pptr->port_dip, 0); in fcp_handle_port_attach()
10194 pptr->port_mpxio--; in fcp_handle_port_attach()
10199 (void) scsi_hba_detach(pptr->port_dip); in fcp_handle_port_attach()
10201 if (pptr->port_tran != NULL) { in fcp_handle_port_attach()
10202 scsi_hba_tran_free(pptr->port_tran); in fcp_handle_port_attach()
10228 mutex_destroy(&pptr->port_mutex); in fcp_handle_port_attach()
10229 mutex_destroy(&pptr->port_pkt_mutex); in fcp_handle_port_attach()
10244 fcp_handle_port_detach(struct fcp_port *pptr, int flag, int instance) in fcp_handle_port_detach() argument
10248 mutex_enter(&pptr->port_mutex); in fcp_handle_port_detach()
10255 if (pptr->port_state & (FCP_STATE_POWER_DOWN | in fcp_handle_port_detach()
10257 pptr->port_state |= flag; in fcp_handle_port_detach()
10258 mutex_exit(&pptr->port_mutex); in fcp_handle_port_detach()
10263 if (pptr->port_state & FCP_STATE_IN_MDI) { in fcp_handle_port_detach()
10264 mutex_exit(&pptr->port_mutex); in fcp_handle_port_detach()
10268 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_port_detach()
10272 pptr->port_state |= flag; in fcp_handle_port_detach()
10280 while (pptr->port_tmp_cnt || pptr->port_ipkt_cnt || in fcp_handle_port_detach()
10281 (pptr->port_state & FCP_STATE_IN_WATCHDOG)) { in fcp_handle_port_detach()
10289 mutex_exit(&pptr->port_mutex); in fcp_handle_port_detach()
10291 mutex_enter(&pptr->port_mutex); in fcp_handle_port_detach()
10298 if (pptr->port_tmp_cnt || pptr->port_ipkt_cnt || in fcp_handle_port_detach()
10299 (pptr->port_state & FCP_STATE_IN_WATCHDOG)) { in fcp_handle_port_detach()
10300 pptr->port_state &= ~flag; in fcp_handle_port_detach()
10301 mutex_exit(&pptr->port_mutex); in fcp_handle_port_detach()
10306 pptr = fcp_soft_state_unlink(pptr); in fcp_handle_port_detach()
10307 ASSERT(pptr != NULL); in fcp_handle_port_detach()
10310 pptr->port_link_cnt++; in fcp_handle_port_detach()
10311 pptr->port_state |= FCP_STATE_OFFLINE; in fcp_handle_port_detach()
10312 pptr->port_state &= ~(FCP_STATE_ONLINING | FCP_STATE_ONLINE); in fcp_handle_port_detach()
10314 fcp_update_state(pptr, (FCP_LUN_BUSY | FCP_LUN_MARK), in fcp_handle_port_detach()
10316 mutex_exit(&pptr->port_mutex); in fcp_handle_port_detach()
10330 fcp_cleanup_port(pptr, instance); in fcp_handle_port_detach()
10338 fcp_cleanup_port(struct fcp_port *pptr, int instance) in fcp_cleanup_port() argument
10340 ASSERT(pptr != NULL); in fcp_cleanup_port()
10343 if (pptr->port_ndi_event_hdl) { in fcp_cleanup_port()
10344 (void) ndi_event_unbind_set(pptr->port_ndi_event_hdl, in fcp_cleanup_port()
10345 &pptr->port_ndi_events, NDI_SLEEP); in fcp_cleanup_port()
10346 (void) ndi_event_free_hdl(pptr->port_ndi_event_hdl); in fcp_cleanup_port()
10349 if (pptr->port_ndi_event_defs) { in fcp_cleanup_port()
10350 (void) kmem_free(pptr->port_ndi_event_defs, in fcp_cleanup_port()
10355 fcp_free_targets(pptr); in fcp_cleanup_port()
10360 if (pptr->port_mpxio) { in fcp_cleanup_port()
10361 (void) mdi_phci_unregister(pptr->port_dip, 0); in fcp_cleanup_port()
10362 pptr->port_mpxio--; in fcp_cleanup_port()
10366 (void) scsi_hba_detach(pptr->port_dip); in fcp_cleanup_port()
10367 if (pptr->port_tran != NULL) { in fcp_cleanup_port()
10368 scsi_hba_tran_free(pptr->port_tran); in fcp_cleanup_port()
10373 if (pptr->fcp_ksp != NULL) { in fcp_cleanup_port()
10374 kstat_delete(pptr->fcp_ksp); in fcp_cleanup_port()
10379 mutex_destroy(&pptr->port_mutex); in fcp_cleanup_port()
10380 mutex_destroy(&pptr->port_pkt_mutex); in fcp_cleanup_port()
10476 struct fcp_port *pptr; in fcp_kmem_cache_constructor() local
10479 pptr = (struct fcp_port *)tran->tran_hba_private; in fcp_kmem_cache_constructor()
10491 sizeof (struct fcp_pkt) + pptr->port_dmacookie_sz); in fcp_kmem_cache_constructor()
10499 if (pptr->port_fcp_dma == FC_NO_DVMA_SPACE) { in fcp_kmem_cache_constructor()
10517 if (fcp_alloc_cmd_resp(pptr, fpkt, kmflags) != FC_SUCCESS) { in fcp_kmem_cache_constructor()
10544 struct fcp_port *pptr; in fcp_kmem_cache_destructor() local
10546 pptr = (struct fcp_port *)(tran->tran_hba_private); in fcp_kmem_cache_destructor()
10549 if (pptr->port_fcp_dma != FC_NO_DVMA_SPACE) { in fcp_kmem_cache_destructor()
10554 fcp_free_cmd_resp(pptr, cmd->cmd_fp_pkt); in fcp_kmem_cache_destructor()
10579 fcp_alloc_cmd_resp(struct fcp_port *pptr, fc_packet_t *fpkt, int flags) in fcp_alloc_cmd_resp() argument
10598 if (ddi_dma_alloc_handle(pptr->port_dip, &pptr->port_cmd_dma_attr, in fcp_alloc_cmd_resp()
10605 &pptr->port_dma_acc_attr, DDI_DMA_CONSISTENT, cb, NULL, in fcp_alloc_cmd_resp()
10631 pptr->port_cmd_dma_attr.dma_attr_sgllen) { in fcp_alloc_cmd_resp()
10669 if (ddi_dma_alloc_handle(pptr->port_dip, &pptr->port_resp_dma_attr, in fcp_alloc_cmd_resp()
10678 &pptr->port_dma_acc_attr, DDI_DMA_CONSISTENT, cb, NULL, in fcp_alloc_cmd_resp()
10719 pptr->port_resp_dma_attr.dma_attr_sgllen) { in fcp_alloc_cmd_resp()
10777 fcp_free_cmd_resp(struct fcp_port *pptr, fc_packet_t *fpkt) in fcp_free_cmd_resp() argument
10822 struct fcp_port *pptr = (struct fcp_port *) in fcp_phys_tgt_init() local
10825 ASSERT(pptr != NULL); in fcp_phys_tgt_init()
10827 FCP_DTRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_phys_tgt_init()
10838 FCP_DTRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_phys_tgt_init()
10856 FCP_DTRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_phys_tgt_init()
10866 mutex_enter(&pptr->port_mutex); in fcp_phys_tgt_init()
10867 if ((plun = fcp_lookup_lun(pptr, bytes, lun_num)) == NULL) { in fcp_phys_tgt_init()
10868 mutex_exit(&pptr->port_mutex); in fcp_phys_tgt_init()
10869 FCP_DTRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_phys_tgt_init()
10893 mutex_exit(&pptr->port_mutex); in fcp_phys_tgt_init()
10908 struct fcp_port *pptr = (struct fcp_port *) in fcp_virt_tgt_init() local
10912 ASSERT(pptr != NULL); in fcp_virt_tgt_init()
10914 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_virt_tgt_init()
10922 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_virt_tgt_init()
10947 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_virt_tgt_init()
10957 mutex_enter(&pptr->port_mutex); in fcp_virt_tgt_init()
10958 if ((plun = fcp_lookup_lun(pptr, bytes, lun_num)) == NULL) { in fcp_virt_tgt_init()
10959 mutex_exit(&pptr->port_mutex); in fcp_virt_tgt_init()
10960 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_virt_tgt_init()
10984 mutex_exit(&pptr->port_mutex); in fcp_virt_tgt_init()
11000 struct fcp_port *pptr = (struct fcp_port *) in fcp_scsi_tgt_init() local
11004 ASSERT(pptr != NULL); in fcp_scsi_tgt_init()
11069 struct fcp_port *pptr = ADDR2FCP(ap); in fcp_scsi_start() local
11078 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_start()
11086 mutex_enter(&pptr->port_mutex); in fcp_scsi_start()
11097 mutex_exit(&pptr->port_mutex); in fcp_scsi_start()
11129 if (((plun->lun_state & FCP_LUN_BUSY) && (!(pptr->port_state & in fcp_scsi_start()
11131 (pptr->port_state & (FCP_STATE_ONLINING | FCP_STATE_IN_CB_DEVC)) || in fcp_scsi_start()
11145 mutex_exit(&pptr->port_mutex); in fcp_scsi_start()
11153 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_start()
11159 mutex_enter(&pptr->port_pkt_mutex); in fcp_scsi_start()
11160 pptr->port_npkts++; in fcp_scsi_start()
11161 mutex_exit(&pptr->port_pkt_mutex); in fcp_scsi_start()
11165 fcp_queue_pkt(pptr, cmd); in fcp_scsi_start()
11171 mutex_exit(&pptr->port_mutex); in fcp_scsi_start()
11181 fcp_reconfig_wait(pptr); in fcp_scsi_start()
11188 fcp_prepare_pkt(pptr, cmd, plun); in fcp_scsi_start()
11202 return (fcp_dopoll(pptr, cmd)); in fcp_scsi_start()
11206 mutex_enter(&pptr->port_pkt_mutex); in fcp_scsi_start()
11207 pptr->port_npkts++; in fcp_scsi_start()
11208 mutex_exit(&pptr->port_pkt_mutex); in fcp_scsi_start()
11211 rval = fcp_transport(pptr->port_fp_handle, cmd->cmd_fp_pkt, 0); in fcp_scsi_start()
11213 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_start()
11222 mutex_enter(&pptr->port_pkt_mutex); in fcp_scsi_start()
11223 pptr->port_npkts--; in fcp_scsi_start()
11224 mutex_exit(&pptr->port_pkt_mutex); in fcp_scsi_start()
11244 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_start()
11252 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_scsi_start()
11259 fcp_queue_pkt(pptr, cmd); in fcp_scsi_start()
11276 struct fcp_port *pptr = ADDR2FCP(ap); in fcp_scsi_abort() local
11285 fcp_abort_all(pptr, ptgt, plun, tgt_cnt); in fcp_scsi_abort()
11300 struct fcp_port *pptr = ADDR2FCP(ap); in fcp_scsi_reset() local
11305 if (fcp_linkreset(pptr, ap, KM_NOSLEEP) == FC_SUCCESS) { in fcp_scsi_reset()
11380 struct fcp_port *pptr; in fcp_pkt_setup() local
11387 pptr = ADDR2FCP(&pkt->pkt_address); in fcp_pkt_setup()
11424 if (pptr->port_state & FCP_STATE_OFFLINE) { in fcp_pkt_setup()
11431 if (fc_ulp_init_packet(pptr->port_fp_handle, fpkt, kf) in fcp_pkt_setup()
11490 struct fcp_port *pptr = ADDR2FCP(&pkt->pkt_address); in fcp_pkt_teardown() local
11515 (void) fc_ulp_uninit_packet(pptr->port_fp_handle, cmd->cmd_fp_pkt); in fcp_pkt_teardown()
11527 struct fcp_port *pptr = ADDR2FCP(ap); in fcp_scsi_reset_notify() local
11530 &pptr->port_mutex, &pptr->port_reset_notify_listf)); in fcp_scsi_reset_notify()
11538 struct fcp_port *pptr = fcp_dip2port(dip); in fcp_scsi_bus_get_eventcookie() local
11540 if (pptr == NULL) { in fcp_scsi_bus_get_eventcookie()
11544 return (ndi_event_retrieve_cookie(pptr->port_ndi_event_hdl, rdip, name, in fcp_scsi_bus_get_eventcookie()
11554 struct fcp_port *pptr = fcp_dip2port(dip); in fcp_scsi_bus_add_eventcall() local
11556 if (pptr == NULL) { in fcp_scsi_bus_add_eventcall()
11560 return (ndi_event_add_callback(pptr->port_ndi_event_hdl, rdip, in fcp_scsi_bus_add_eventcall()
11569 struct fcp_port *pptr = fcp_dip2port(dip); in fcp_scsi_bus_remove_eventcall() local
11571 if (pptr == NULL) { in fcp_scsi_bus_remove_eventcall()
11574 return (ndi_event_remove_callback(pptr->port_ndi_event_hdl, cb_id)); in fcp_scsi_bus_remove_eventcall()
11585 struct fcp_port *pptr = fcp_dip2port(dip); in fcp_scsi_bus_post_event() local
11587 if (pptr == NULL) { in fcp_scsi_bus_post_event()
11591 return (ndi_event_run_callbacks(pptr->port_ndi_event_hdl, rdip, in fcp_scsi_bus_post_event()
11623 struct fcp_port *pptr = ADDR2FCP(ap); in fcp_reset_target() local
11683 fcp_prepare_pkt(pptr, cmd, plun); in fcp_reset_target()
11691 (void) fc_ulp_busy_port(pptr->port_fp_handle); in fcp_reset_target()
11692 bval = fcp_dopoll(pptr, cmd); in fcp_reset_target()
11693 fc_ulp_idle_port(pptr->port_fp_handle); in fcp_reset_target()
11704 if (fcp_validate_fcp_response(rsp, pptr) == in fcp_reset_target()
11706 if (pptr->port_fcp_dma != FC_NO_DVMA_SPACE) { in fcp_reset_target()
11725 fcp_log(CE_WARN, pptr->port_dip, in fcp_reset_target()
11732 fcp_log(CE_WARN, pptr->port_dip, in fcp_reset_target()
11741 fcp_log(CE_WARN, pptr->port_dip, in fcp_reset_target()
11755 fcp_log(CE_WARN, pptr->port_dip, in fcp_reset_target()
11776 mutex_enter(&pptr->port_mutex); in fcp_reset_target()
11787 p->next = pptr->port_reset_list; in fcp_reset_target()
11788 pptr->port_reset_list = p; in fcp_reset_target()
11790 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_reset_target()
11794 scsi_hba_reset_notify_callback(&pptr->port_mutex, in fcp_reset_target()
11795 &pptr->port_reset_notify_listf); in fcp_reset_target()
11797 mutex_exit(&pptr->port_mutex); in fcp_reset_target()
11812 struct fcp_port *pptr = ADDR2FCP(ap); in fcp_commoncap() local
11819 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_commoncap()
11858 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_commoncap()
11865 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_commoncap()
11877 rval = (int)pptr->port_data_dma_attr.dma_attr_maxxfer; in fcp_commoncap()
11894 rval = pptr->port_id; in fcp_commoncap()
11908 if (FC_TOP_EXTERNAL(pptr->port_topology) || in fcp_commoncap()
11922 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_commoncap()
11929 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_commoncap()
11965 struct fcp_port *pptr; in fcp_scsi_get_name() local
11972 pptr = ddi_get_soft_state(fcp_softstate, in fcp_scsi_get_name()
11974 if (pptr == NULL) { in fcp_scsi_get_name()
12005 mutex_enter(&pptr->port_mutex); in fcp_scsi_get_name()
12006 if ((plun = fcp_lookup_lun(pptr, barray, lun_num)) == NULL) { in fcp_scsi_get_name()
12007 mutex_exit(&pptr->port_mutex); in fcp_scsi_get_name()
12011 mutex_exit(&pptr->port_mutex); in fcp_scsi_get_name()
12016 if (!FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_scsi_get_name()
12048 fcp_log(CE_WARN, pptr->port_dip, in fcp_scsi_get_name()
12102 fcp_linkreset(struct fcp_port *pptr, struct scsi_address *ap, int sleep) in fcp_linkreset() argument
12109 mutex_enter(&pptr->port_mutex); in fcp_linkreset()
12111 if (pptr->port_state & (FCP_STATE_SUSPENDED | in fcp_linkreset()
12113 mutex_exit(&pptr->port_mutex); in fcp_linkreset()
12114 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_linkreset()
12118 ddi_get_instance(pptr->port_dip)); in fcp_linkreset()
12122 if (pptr->port_state & (FCP_STATE_OFFLINE | FCP_STATE_ONLINING)) { in fcp_linkreset()
12123 mutex_exit(&pptr->port_mutex); in fcp_linkreset()
12127 FCP_DTRACE(fcp_logq, pptr->port_instbuf, in fcp_linkreset()
12133 if (FC_TOP_EXTERNAL(pptr->port_topology) && (ap != NULL)) { in fcp_linkreset()
12140 mutex_exit(&pptr->port_mutex); in fcp_linkreset()
12142 return (fc_ulp_linkreset(pptr->port_fp_handle, &wwn, sleep)); in fcp_linkreset()
12159 struct fcp_port *pptr; /* port state ptr */ in fcp_handle_port_resume() local
12168 if ((pptr = ddi_get_soft_state(fcp_softstate, instance)) == NULL) { in fcp_handle_port_resume()
12173 mutex_enter(&pptr->port_mutex); in fcp_handle_port_resume()
12176 ASSERT((pptr->port_state & FCP_STATE_POWER_DOWN) == 0); in fcp_handle_port_resume()
12177 pptr->port_state &= ~FCP_STATE_SUSPENDED; in fcp_handle_port_resume()
12185 if (pptr->port_state & FCP_STATE_SUSPENDED) { in fcp_handle_port_resume()
12186 pptr->port_state &= ~FCP_STATE_POWER_DOWN; in fcp_handle_port_resume()
12187 mutex_exit(&pptr->port_mutex); in fcp_handle_port_resume()
12190 pptr->port_state &= ~FCP_STATE_POWER_DOWN; in fcp_handle_port_resume()
12192 pptr->port_id = s_id; in fcp_handle_port_resume()
12193 pptr->port_state = FCP_STATE_INIT; in fcp_handle_port_resume()
12194 mutex_exit(&pptr->port_mutex); in fcp_handle_port_resume()
12200 (void) fcp_cp_pinfo(pptr, pinfo); in fcp_handle_port_resume()
12214 switch (FC_PORT_STATE_MASK(pptr->port_phys_state)) { in fcp_handle_port_resume()
12225 if (pptr->port_topology == FC_TOP_UNKNOWN) { in fcp_handle_port_resume()
12226 (void) fcp_linkreset(pptr, NULL, KM_NOSLEEP); in fcp_handle_port_resume()
12231 if (FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_handle_port_resume()
12233 tmp_list = fcp_construct_map(pptr, &alloc_cnt); in fcp_handle_port_resume()
12242 ASSERT(pptr->port_topology != FC_TOP_UNKNOWN); in fcp_handle_port_resume()
12249 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_port_resume()
12256 if ((res = fc_ulp_getportmap(pptr->port_fp_handle, in fcp_handle_port_resume()
12263 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_port_resume()
12268 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_port_resume()
12281 fcp_statec_callback(ulph, pptr->port_fp_handle, in fcp_handle_port_resume()
12282 pptr->port_phys_state, pptr->port_topology, tmp_list, in fcp_handle_port_resume()
12283 max_cnt, pptr->port_id); in fcp_handle_port_resume()
12289 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_port_resume()
12291 instance, pptr->port_phys_state); in fcp_handle_port_resume()
12293 mutex_enter(&pptr->port_mutex); in fcp_handle_port_resume()
12294 pptr->port_phys_state = FCP_STATE_OFFLINE; in fcp_handle_port_resume()
12295 mutex_exit(&pptr->port_mutex); in fcp_handle_port_resume()
12310 fcp_cp_pinfo(struct fcp_port *pptr, fc_ulp_port_info_t *pinfo) in fcp_cp_pinfo() argument
12312 pptr->port_fp_modlinkage = *pinfo->port_linkage; in fcp_cp_pinfo()
12313 pptr->port_dip = pinfo->port_dip; in fcp_cp_pinfo()
12314 pptr->port_fp_handle = pinfo->port_handle; in fcp_cp_pinfo()
12319 pptr->port_data_dma_attr = *pinfo->port_data_dma_attr; in fcp_cp_pinfo()
12320 pptr->port_cmd_dma_attr = *pinfo->port_cmd_dma_attr; in fcp_cp_pinfo()
12321 pptr->port_resp_dma_attr = *pinfo->port_resp_dma_attr; in fcp_cp_pinfo()
12322 pptr->port_dma_acc_attr = *pinfo->port_acc_attr; in fcp_cp_pinfo()
12324 pptr->port_priv_pkt_len = pinfo->port_fca_pkt_size; in fcp_cp_pinfo()
12325 pptr->port_max_exch = pinfo->port_fca_max_exch; in fcp_cp_pinfo()
12326 pptr->port_phys_state = pinfo->port_state; in fcp_cp_pinfo()
12327 pptr->port_topology = pinfo->port_flags; in fcp_cp_pinfo()
12328 pptr->port_reset_action = pinfo->port_reset_action; in fcp_cp_pinfo()
12329 pptr->port_cmds_dma_flags = pinfo->port_dma_behavior; in fcp_cp_pinfo()
12330 pptr->port_fcp_dma = pinfo->port_fcp_dma; in fcp_cp_pinfo()
12331 bcopy(&pinfo->port_nwwn, &pptr->port_nwwn, sizeof (la_wwn_t)); in fcp_cp_pinfo()
12332 bcopy(&pinfo->port_pwwn, &pptr->port_pwwn, sizeof (la_wwn_t)); in fcp_cp_pinfo()
12335 if (pptr->port_cmd_dma_attr.dma_attr_flags & DDI_DMA_FLAGERR) in fcp_cp_pinfo()
12336 pptr->port_cmd_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR; in fcp_cp_pinfo()
12337 if (pptr->port_data_dma_attr.dma_attr_flags & DDI_DMA_FLAGERR) in fcp_cp_pinfo()
12338 pptr->port_data_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR; in fcp_cp_pinfo()
12339 if (pptr->port_resp_dma_attr.dma_attr_flags & DDI_DMA_FLAGERR) in fcp_cp_pinfo()
12340 pptr->port_resp_dma_attr.dma_attr_flags &= ~DDI_DMA_FLAGERR; in fcp_cp_pinfo()
12377 struct fcp_port *pptr = elem->port; in fcp_hp_task() local
12385 mutex_enter(&pptr->port_mutex); in fcp_hp_task()
12389 pptr->port_state & (FCP_STATE_SUSPENDED | in fcp_hp_task()
12392 mutex_exit(&pptr->port_mutex); in fcp_hp_task()
12397 mutex_exit(&pptr->port_mutex); in fcp_hp_task()
12412 struct fcp_port *pptr = plun->lun_tgt->tgt_port; in fcp_get_cip() local
12414 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_get_cip()
12419 if (pptr->port_mpxio == 0 || plun->lun_mpxio == 0) { in fcp_get_cip()
12508 struct fcp_port *pptr = ptgt->tgt_port; in fcp_create_dip() local
12509 dev_info_t *pdip = pptr->port_dip; in fcp_create_dip()
12519 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_create_dip()
12569 mutex_exit(&pptr->port_mutex); in fcp_create_dip()
12572 (void) fcp_pass_to_hp(pptr, plun, CIP(old_dip), FCP_OFFLINE, in fcp_create_dip()
12578 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_create_dip()
12583 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_create_dip()
12589 mutex_enter(&pptr->port_mutex); in fcp_create_dip()
12595 if (ndi_devi_alloc(pptr->port_dip, nname, in fcp_create_dip()
12646 if (!FC_TOP_EXTERNAL(pptr->port_topology) && ptgt->tgt_hard_addr != 0) { in fcp_create_dip()
12706 struct fcp_port *pptr = ptgt->tgt_port; in fcp_create_pip() local
12707 dev_info_t *pdip = pptr->port_dip; in fcp_create_pip()
12717 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_create_pip()
12759 mutex_exit(&pptr->port_mutex); in fcp_create_pip()
12762 (void) fcp_pass_to_hp(pptr, plun, CIP(old_pip), in fcp_create_pip()
12768 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_create_pip()
12773 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_create_pip()
12779 mutex_enter(&pptr->port_mutex); in fcp_create_pip()
12814 pptr->port_state |= FCP_STATE_IN_MDI; in fcp_create_pip()
12816 mutex_exit(&pptr->port_mutex); in fcp_create_pip()
12819 fcp_log(CE_WARN, pptr->port_dip, in fcp_create_pip()
12821 mutex_enter(&pptr->port_mutex); in fcp_create_pip()
12823 pptr->port_state &= ~FCP_STATE_IN_MDI; in fcp_create_pip()
12827 mutex_enter(&pptr->port_mutex); in fcp_create_pip()
12829 pptr->port_state &= ~FCP_STATE_IN_MDI; in fcp_create_pip()
12864 if (!FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_create_pip()
12896 mutex_exit(&pptr->port_mutex); in fcp_create_pip()
12898 mutex_enter(&pptr->port_mutex); in fcp_create_pip()
12917 struct fcp_port *pptr = ptgt->tgt_port; in fcp_find_existing_dip() local
12991 if (!FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_find_existing_dip()
13093 struct fcp_port *pptr = ptgt->tgt_port; in fcp_find_existing_pip() local
13095 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_find_existing_pip()
13111 struct fcp_port *pptr = plun->lun_tgt->tgt_port; in fcp_online_child() local
13115 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_online_child()
13119 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_online_child()
13131 mutex_exit(&pptr->port_mutex); in fcp_online_child()
13133 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_online_child()
13147 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_online_child()
13165 fcp_log(CE_NOTE, pptr->port_dip, in fcp_online_child()
13171 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_online_child()
13181 mutex_exit(&pptr->port_mutex); in fcp_online_child()
13183 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_online_child()
13193 mdi_devi_exit_phci(pptr->port_dip); in fcp_online_child()
13197 mdi_devi_enter_phci(pptr->port_dip); in fcp_online_child()
13218 mutex_enter(&pptr->port_mutex); in fcp_online_child()
13225 fcp_log(CE_WARN, pptr->port_dip, in fcp_online_child()
13234 mutex_exit(&pptr->port_mutex); in fcp_online_child()
13241 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_online_child()
13247 mutex_exit(&pptr->port_mutex); in fcp_online_child()
13252 mutex_enter(&pptr->port_mutex); in fcp_online_child()
13258 fcp_log(CE_NOTE, pptr->port_dip, in fcp_online_child()
13271 pptr->port_ndi_event_hdl, cdip, FCAL_INSERT_EVENT, in fcp_online_child()
13273 (void) ndi_event_run_callbacks(pptr->port_ndi_event_hdl, in fcp_online_child()
13277 mutex_enter(&pptr->port_mutex); in fcp_online_child()
13289 struct fcp_port *pptr = plun->lun_tgt->tgt_port; in fcp_offline_child() local
13294 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_offline_child()
13297 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_offline_child()
13315 mutex_exit(&pptr->port_mutex); in fcp_offline_child()
13318 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_offline_child()
13326 mutex_exit(&pptr->port_mutex); in fcp_offline_child()
13333 mdi_devi_exit_phci(pptr->port_dip); in fcp_offline_child()
13337 mdi_devi_enter_phci(pptr->port_dip); in fcp_offline_child()
13387 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_offline_child()
13394 mutex_enter(&pptr->port_mutex); in fcp_offline_child()
13398 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_offline_child()
13484 struct fcp_port *pptr; in fcp_watch() local
13500 for (pptr = fcp_port_head; pptr != NULL; pptr = pptr->port_next) { in fcp_watch()
13502 pptr->port_state |= FCP_STATE_IN_WATCHDOG; in fcp_watch()
13505 mutex_enter(&pptr->port_mutex); in fcp_watch()
13506 if (pptr->port_ipkt_list == NULL && in fcp_watch()
13507 (pptr->port_state & (FCP_STATE_SUSPENDED | in fcp_watch()
13509 pptr->port_state &= ~FCP_STATE_IN_WATCHDOG; in fcp_watch()
13510 mutex_exit(&pptr->port_mutex); in fcp_watch()
13518 if (pptr->port_offline_tgts) { in fcp_watch()
13519 fcp_scan_offline_tgts(pptr); in fcp_watch()
13525 if (pptr->port_offline_luns) { in fcp_watch()
13526 fcp_scan_offline_luns(pptr); in fcp_watch()
13532 if (pptr->port_reset_list) { in fcp_watch()
13533 fcp_check_reset_delay(pptr); in fcp_watch()
13536 mutex_exit(&pptr->port_mutex); in fcp_watch()
13542 mutex_enter(&pptr->port_pkt_mutex); in fcp_watch()
13543 tail = pptr->port_pkt_tail; in fcp_watch()
13545 for (pcmd = NULL, cmd = pptr->port_pkt_head; in fcp_watch()
13569 if (cmd == pptr->port_pkt_head) { in fcp_watch()
13571 pptr->port_pkt_head = cmd->cmd_next; in fcp_watch()
13577 if (cmd == pptr->port_pkt_tail) { in fcp_watch()
13579 pptr->port_pkt_tail = pcmd; in fcp_watch()
13595 save_head = pptr->port_pkt_head; in fcp_watch()
13596 mutex_exit(&pptr->port_pkt_mutex); in fcp_watch()
13607 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_watch()
13617 fcp_retransport_cmd(pptr, cmd); in fcp_watch()
13619 mutex_enter(&pptr->port_pkt_mutex); in fcp_watch()
13620 if (save_head && save_head != pptr->port_pkt_head) { in fcp_watch()
13641 mutex_exit(&pptr->port_pkt_mutex); in fcp_watch()
13643 mutex_enter(&pptr->port_mutex); in fcp_watch()
13644 for (icmd = pptr->port_ipkt_list; icmd != NULL; icmd = nicmd) { in fcp_watch()
13655 if (icmd == pptr->port_ipkt_list) { in fcp_watch()
13656 pptr->port_ipkt_list = icmd->ipkt_next; in fcp_watch()
13657 if (pptr->port_ipkt_list) { in fcp_watch()
13658 pptr->port_ipkt_list->ipkt_prev = in fcp_watch()
13670 mutex_exit(&pptr->port_mutex); in fcp_watch()
13677 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_watch()
13690 fc_ulp_get_rscn_count(pptr-> in fcp_watch()
13694 mutex_enter(&pptr->port_mutex); in fcp_watch()
13696 if (!FCP_STATE_CHANGED(pptr, ptgt, icmd)) { in fcp_watch()
13698 mutex_exit(&pptr->port_mutex); in fcp_watch()
13703 pptr->port_fp_handle, in fcp_watch()
13707 &pptr->port_mutex); in fcp_watch()
13711 pptr, ptgt, icmd, rval, in fcp_watch()
13714 &pptr->port_mutex); in fcp_watch()
13721 pptr->port_fp_handle, in fcp_watch()
13725 &pptr->port_mutex); in fcp_watch()
13729 pptr, ptgt, icmd, rval, in fcp_watch()
13732 &pptr->port_mutex); in fcp_watch()
13739 pptr->port_fp_handle, in fcp_watch()
13743 &pptr->port_mutex); in fcp_watch()
13747 pptr, ptgt, icmd, rval, in fcp_watch()
13750 &pptr->port_mutex); in fcp_watch()
13757 mutex_exit(&pptr->port_mutex); in fcp_watch()
13763 (void) fcp_call_finish_init(pptr, ptgt, in fcp_watch()
13766 fcp_icmd_free(pptr, icmd); in fcp_watch()
13767 mutex_enter(&pptr->port_mutex); in fcp_watch()
13770 pptr->port_state &= ~FCP_STATE_IN_WATCHDOG; in fcp_watch()
13771 mutex_exit(&pptr->port_mutex); in fcp_watch()
13793 fcp_check_reset_delay(struct fcp_port *pptr) in fcp_check_reset_delay() argument
13803 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_check_reset_delay()
13805 next = pptr->port_reset_list; in fcp_check_reset_delay()
13833 if (cur == pptr->port_reset_list) { in fcp_check_reset_delay()
13834 pptr->port_reset_list = next; in fcp_check_reset_delay()
13838 which = pptr->port_reset_list; in fcp_check_reset_delay()
13862 mutex_exit(&pptr->port_mutex); in fcp_check_reset_delay()
13863 fcp_abort_all(pptr, ptgt, plun, tgt_cnt); in fcp_check_reset_delay()
13864 mutex_enter(&pptr->port_mutex); in fcp_check_reset_delay()
13871 fcp_abort_all(struct fcp_port *pptr, struct fcp_tgt *ttgt, in fcp_abort_all() argument
13880 mutex_enter(&pptr->port_pkt_mutex); in fcp_abort_all()
13881 for (cmd = pptr->port_pkt_head; cmd != NULL; cmd = ncmd) { in fcp_abort_all()
13893 ASSERT(pptr->port_pkt_head != cmd); in fcp_abort_all()
13896 ASSERT(cmd == pptr->port_pkt_head); in fcp_abort_all()
13897 pptr->port_pkt_head = ncmd; in fcp_abort_all()
13899 if (pptr->port_pkt_tail == cmd) { in fcp_abort_all()
13901 pptr->port_pkt_tail = pcmd; in fcp_abort_all()
13916 mutex_exit(&pptr->port_pkt_mutex); in fcp_abort_all()
13924 mutex_enter(&pptr->port_mutex); in fcp_abort_all()
13926 mutex_exit(&pptr->port_mutex); in fcp_abort_all()
13933 mutex_exit(&pptr->port_mutex); in fcp_abort_all()
13942 if (pptr->port_reset_action == FC_RESET_RETURN_ALL) { in fcp_abort_all()
13983 rval = fc_ulp_abort(pptr->port_fp_handle, in fcp_abort_all()
14008 fcp_log(CE_WARN, pptr->port_dip, in fcp_abort_all()
14026 mutex_enter(&pptr->port_pkt_mutex); in fcp_abort_all()
14027 if (pptr->port_pkt_head) { in fcp_abort_all()
14028 ASSERT(pptr->port_pkt_tail in fcp_abort_all()
14030 pptr->port_pkt_tail->cmd_next in fcp_abort_all()
14032 pptr->port_pkt_tail = cmd; in fcp_abort_all()
14034 ASSERT(pptr->port_pkt_tail in fcp_abort_all()
14036 pptr->port_pkt_head = in fcp_abort_all()
14037 pptr->port_pkt_tail in fcp_abort_all()
14041 mutex_exit(&pptr->port_pkt_mutex); in fcp_abort_all()
14055 mutex_enter(&pptr->port_mutex); in fcp_abort_all()
14057 mutex_exit(&pptr->port_mutex); in fcp_abort_all()
14060 mutex_exit(&pptr->port_mutex); in fcp_abort_all()
14072 fcp_soft_state_unlink(struct fcp_port *pptr) in fcp_soft_state_unlink() argument
14081 if (hptr == pptr) { in fcp_soft_state_unlink()
14106 fcp_lookup_lun(struct fcp_port *pptr, uchar_t *wwn, uint16_t lun) in fcp_lookup_lun() argument
14112 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_lookup_lun()
14115 for (ptgt = pptr->port_tgt_hash_table[hash]; ptgt != NULL; in fcp_lookup_lun()
14150 fcp_prepare_pkt(struct fcp_port *pptr, struct fcp_pkt *cmd, in fcp_prepare_pkt() argument
14175 pptr->port_data_dma_attr.dma_attr_sgllen); in fcp_prepare_pkt()
14203 if (pptr->port_fcp_dma != FC_NO_DVMA_SPACE) { in fcp_prepare_pkt()
14228 mutex_enter(&pptr->port_mutex); in fcp_prepare_pkt()
14229 if (pptr->port_state & FCP_STATE_SUSPENDED) { in fcp_prepare_pkt()
14232 mutex_exit(&pptr->port_mutex); in fcp_prepare_pkt()
14235 fpkt->pkt_cmd_fhdr.s_id = pptr->port_id; in fcp_prepare_pkt()
14258 fcp_dopoll(struct fcp_port *pptr, struct fcp_pkt *cmd) in fcp_dopoll() argument
14263 mutex_enter(&pptr->port_pkt_mutex); in fcp_dopoll()
14264 pptr->port_npkts++; in fcp_dopoll()
14265 mutex_exit(&pptr->port_pkt_mutex); in fcp_dopoll()
14278 rval = fc_ulp_transport(pptr->port_fp_handle, cmd->cmd_fp_pkt); in fcp_dopoll()
14281 mutex_enter(&pptr->port_pkt_mutex); in fcp_dopoll()
14282 pptr->port_npkts--; in fcp_dopoll()
14283 mutex_exit(&pptr->port_pkt_mutex); in fcp_dopoll()
14334 fcp_get_lun_from_cip(struct fcp_port *pptr, child_info_t *cip) in fcp_get_lun_from_cip() argument
14341 ASSERT(mutex_owned(&pptr->port_mutex)); in fcp_get_lun_from_cip()
14344 for (ptgt = pptr->port_tgt_hash_table[i]; in fcp_get_lun_from_cip()
14375 fcp_pass_to_hp_and_wait(struct fcp_port *pptr, struct fcp_lun *plun, in fcp_pass_to_hp_and_wait() argument
14382 if ((elem = fcp_pass_to_hp(pptr, plun, cip, in fcp_pass_to_hp_and_wait()
14385 fcp_log(CE_CONT, pptr->port_dip, in fcp_pass_to_hp_and_wait()
14421 fcp_pass_to_hp(struct fcp_port *pptr, struct fcp_lun *plun, in fcp_pass_to_hp() argument
14427 ASSERT(pptr != NULL); in fcp_pass_to_hp()
14441 elem->port = pptr; in fcp_pass_to_hp()
14454 pdip = pptr->port_dip; in fcp_pass_to_hp()
14477 fcp_retransport_cmd(struct fcp_port *pptr, struct fcp_pkt *cmd) in fcp_retransport_cmd() argument
14493 mutex_enter(&pptr->port_mutex); in fcp_retransport_cmd()
14496 (!(pptr->port_state & FCP_STATE_ONLINING))) { in fcp_retransport_cmd()
14518 mutex_exit(&pptr->port_mutex); in fcp_retransport_cmd()
14524 fcp_prepare_pkt(pptr, cmd, plun); in fcp_retransport_cmd()
14534 fc_ulp_get_rscn_count(pptr-> in fcp_retransport_cmd()
14538 rval = fcp_transport(pptr->port_fp_handle, in fcp_retransport_cmd()
14547 mutex_exit(&pptr->port_mutex); in fcp_retransport_cmd()
14550 fcp_queue_pkt(pptr, cmd); in fcp_retransport_cmd()
14583 fcp_queue_pkt(struct fcp_port *pptr, struct fcp_pkt *cmd) in fcp_queue_pkt() argument
14587 mutex_enter(&pptr->port_pkt_mutex); in fcp_queue_pkt()
14608 if (pptr->port_pkt_head) { in fcp_queue_pkt()
14609 ASSERT(pptr->port_pkt_tail != NULL); in fcp_queue_pkt()
14611 pptr->port_pkt_tail->cmd_next = cmd; in fcp_queue_pkt()
14612 pptr->port_pkt_tail = cmd; in fcp_queue_pkt()
14614 ASSERT(pptr->port_pkt_tail == NULL); in fcp_queue_pkt()
14616 pptr->port_pkt_head = pptr->port_pkt_tail = cmd; in fcp_queue_pkt()
14619 mutex_exit(&pptr->port_pkt_mutex); in fcp_queue_pkt()
14640 fcp_update_targets(struct fcp_port *pptr, fc_portmap_t *dev_list, in fcp_update_targets() argument
14646 ASSERT(MUTEX_HELD(&pptr->port_mutex)); in fcp_update_targets()
14650 ptgt = fcp_lookup_target(pptr, in fcp_update_targets()
14667 fcp_call_finish_init(struct fcp_port *pptr, struct fcp_tgt *ptgt, in fcp_call_finish_init() argument
14672 mutex_enter(&pptr->port_mutex); in fcp_call_finish_init()
14673 rval = fcp_call_finish_init_held(pptr, ptgt, lcount, tcount, cause); in fcp_call_finish_init()
14674 mutex_exit(&pptr->port_mutex); in fcp_call_finish_init()
14681 fcp_call_finish_init_held(struct fcp_port *pptr, struct fcp_tgt *ptgt, in fcp_call_finish_init_held() argument
14695 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_call_finish_init_held()
14699 pptr->port_link_cnt, lcount, ptgt->tgt_change_cnt, tcount, in fcp_call_finish_init_held()
14700 pptr->port_tmp_cnt, ptgt->tgt_tmp_cnt, cause, in fcp_call_finish_init_held()
14723 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_call_finish_init_held()
14745 (void) fcp_finish_tgt(pptr, ptgt, lcount, tcount, cause); in fcp_call_finish_init_held()
14748 if (finish_init && lcount == pptr->port_link_cnt) { in fcp_call_finish_init_held()
14749 ASSERT(pptr->port_tmp_cnt > 0); in fcp_call_finish_init_held()
14750 if (--pptr->port_tmp_cnt == 0) { in fcp_call_finish_init_held()
14751 fcp_finish_init(pptr); in fcp_call_finish_init_held()
14753 } else if (lcount != pptr->port_link_cnt) { in fcp_call_finish_init_held()
14754 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_call_finish_init_held()
14769 struct fcp_port *pptr = ptgt->tgt_port; in fcp_reconfigure_luns() local
14782 fcp_log(CE_WARN, pptr->port_dip, in fcp_reconfigure_luns()
14784 pptr->port_instance); in fcp_reconfigure_luns()
14800 fcp_statec_callback(NULL, pptr->port_fp_handle, FC_STATE_DEVICE_CHANGE, in fcp_reconfigure_luns()
14801 pptr->port_topology, devlist, dev_cnt, pptr->port_id); in fcp_reconfigure_luns()
14816 fcp_free_targets(struct fcp_port *pptr) in fcp_free_targets() argument
14821 mutex_enter(&pptr->port_mutex); in fcp_free_targets()
14823 ptgt = pptr->port_tgt_hash_table[i]; in fcp_free_targets()
14831 mutex_exit(&pptr->port_mutex); in fcp_free_targets()
14910 fcp_create_on_demand(struct fcp_port *pptr, uchar_t *pwwn) in fcp_create_on_demand() argument
14936 mutex_enter(&pptr->port_mutex); in fcp_create_on_demand()
14937 pptr->port_deadline = fcp_watchdog_time + FCP_ICMD_DEADLINE; in fcp_create_on_demand()
14938 mutex_exit(&pptr->port_mutex); in fcp_create_on_demand()
14944 pd = fc_ulp_get_remote_port(pptr->port_fp_handle, in fcp_create_on_demand()
14956 ret = fc_ulp_pwwn_to_portmap(pptr->port_fp_handle, in fcp_create_on_demand()
14969 mutex_enter(&pptr->port_mutex); in fcp_create_on_demand()
14975 ptgt = fcp_lookup_target(pptr, pwwn); in fcp_create_on_demand()
14977 lcount = pptr->port_link_cnt; in fcp_create_on_demand()
14978 mutex_exit(&pptr->port_mutex); in fcp_create_on_demand()
14980 ptgt = fcp_alloc_tgt(pptr, devlist, lcount); in fcp_create_on_demand()
14982 fcp_log(CE_WARN, pptr->port_dip, in fcp_create_on_demand()
14987 mutex_enter(&pptr->port_mutex); in fcp_create_on_demand()
14999 if (FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_create_on_demand()
15007 fcp_update_targets(pptr, devlist, 1, in fcp_create_on_demand()
15010 lcount = pptr->port_link_cnt; in fcp_create_on_demand()
15013 if (fcp_handle_mapflags(pptr, ptgt, devlist, lcount, in fcp_create_on_demand()
15015 if (FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_create_on_demand()
15022 if (pptr->port_link_cnt != lcount || in fcp_create_on_demand()
15026 mutex_exit(&pptr->port_mutex); in fcp_create_on_demand()
15028 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_create_on_demand()
15033 ptgt, lcount, pptr->port_link_cnt, in fcp_create_on_demand()
15051 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_create_on_demand()
15057 ntries, ptgt, lcount, pptr->port_link_cnt, in fcp_create_on_demand()
15062 while (ntries-- != 0 && pptr->port_link_cnt == lcount && in fcp_create_on_demand()
15065 mutex_exit(&pptr->port_mutex); in fcp_create_on_demand()
15069 mutex_enter(&pptr->port_mutex); in fcp_create_on_demand()
15074 if (pptr->port_link_cnt != lcount || ptgt->tgt_change_cnt != tcount) { in fcp_create_on_demand()
15083 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_create_on_demand()
15089 ntries, ptgt, lcount, pptr->port_link_cnt, in fcp_create_on_demand()
15094 if (FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_create_on_demand()
15099 mutex_exit(&pptr->port_mutex); in fcp_create_on_demand()
15102 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_create_on_demand()
15108 ntries, ptgt, lcount, pptr->port_link_cnt, in fcp_create_on_demand()
15119 lcount = pptr->port_link_cnt; in fcp_create_on_demand()
15131 mutex_exit(&pptr->port_mutex); in fcp_create_on_demand()
15144 rval = fcp_pass_to_hp_and_wait(pptr, plun, cip, in fcp_create_on_demand()
15149 pptr->port_instbuf, fcp_trace, in fcp_create_on_demand()
15170 if (FC_TOP_EXTERNAL(pptr->port_topology) && in fcp_create_on_demand()
15222 struct fcp_port *pptr; in fcp_print_error() local
15230 pptr = ptgt->tgt_port; in fcp_print_error()
15288 if (fcp_validate_fcp_response(rsp, pptr) != FC_SUCCESS) { in fcp_print_error()
15294 fcp_log(CE_WARN, pptr->port_dip, buf, in fcp_print_error()
15342 fcp_log(CE_WARN, pptr->port_dip, buf, in fcp_print_error()
15349 fcp_log(CE_WARN, pptr->port_dip, buf, in fcp_print_error()
15363 fcp_log(CE_WARN, pptr->port_dip, buf, in fcp_print_error()
15366 fcp_log(CE_WARN, pptr->port_dip, buf, in fcp_print_error()
15376 fcp_handle_ipkt_errors(struct fcp_port *pptr, struct fcp_tgt *ptgt, in fcp_handle_ipkt_errors() argument
15403 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_handle_ipkt_errors()
15415 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_handle_ipkt_errors()
15421 fcp_queue_ipkt(pptr, icmd->ipkt_fpkt); in fcp_handle_ipkt_errors()
15440 FCP_TRACE(fcp_logq, pptr->port_instbuf, fcp_trace, in fcp_handle_ipkt_errors()
15446 fcp_queue_ipkt(pptr, icmd->ipkt_fpkt); in fcp_handle_ipkt_errors()
15453 mutex_enter(&pptr->port_mutex); in fcp_handle_ipkt_errors()
15455 if (!FCP_STATE_CHANGED(pptr, ptgt, icmd)) { in fcp_handle_ipkt_errors()
15457 mutex_exit(&pptr->port_mutex); in fcp_handle_ipkt_errors()
15460 fcp_log(CE_WARN, pptr->port_dip, in fcp_handle_ipkt_errors()
15464 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_handle_ipkt_errors()
15469 mutex_exit(&pptr->port_mutex); in fcp_handle_ipkt_errors()
15503 fcp_construct_map(struct fcp_port *pptr, uint32_t *dev_cnt) in fcp_construct_map() argument
15510 mutex_enter(&pptr->port_mutex); in fcp_construct_map()
15512 for (ptgt = pptr->port_tgt_hash_table[i]; ptgt != NULL; in fcp_construct_map()
15523 mutex_exit(&pptr->port_mutex); in fcp_construct_map()
15524 fcp_log(CE_WARN, pptr->port_dip, in fcp_construct_map()
15526 pptr->port_instance); in fcp_construct_map()
15531 for (ptgt = pptr->port_tgt_hash_table[i]; ptgt != NULL; in fcp_construct_map()
15537 pptr->port_fp_handle, in fcp_construct_map()
15565 mutex_exit(&pptr->port_mutex); in fcp_construct_map()
15573 fcp_update_mpxio_path_verifybusy(struct fcp_port *pptr) in fcp_update_mpxio_path_verifybusy() argument
15580 for (ptgt = pptr->port_tgt_hash_table[i]; ptgt != NULL; in fcp_update_mpxio_path_verifybusy()
15587 if (!fcp_pass_to_hp(pptr, plun, in fcp_update_mpxio_path_verifybusy()
15590 pptr->port_link_cnt, in fcp_update_mpxio_path_verifybusy()
15593 pptr->port_instbuf, in fcp_update_mpxio_path_verifybusy()
15713 struct fcp_port *pptr = fcp_dip2port(parent); in fcp_scsi_bus_config() local
15716 (ddi_get_lbolt64() - pptr->port_attach_time); in fcp_scsi_bus_config()
15754 mutex_enter(&pptr->port_mutex); in fcp_scsi_bus_config()
15755 while ((reset_delay > 0) && pptr->port_tmp_cnt) { in fcp_scsi_bus_config()
15756 (void) cv_timedwait(&pptr->port_config_cv, in fcp_scsi_bus_config()
15757 &pptr->port_mutex, in fcp_scsi_bus_config()
15761 (ddi_get_lbolt64() - pptr->port_attach_time); in fcp_scsi_bus_config()
15763 mutex_exit(&pptr->port_mutex); in fcp_scsi_bus_config()
15860 fcp_reconfig_wait(struct fcp_port *pptr) in fcp_reconfig_wait() argument
15869 mutex_enter(&pptr->port_mutex); in fcp_reconfig_wait()
15870 if (pptr->port_tmp_cnt == 0) { in fcp_reconfig_wait()
15871 mutex_exit(&pptr->port_mutex); in fcp_reconfig_wait()
15874 mutex_exit(&pptr->port_mutex); in fcp_reconfig_wait()
15884 mutex_enter(&pptr->port_mutex); in fcp_reconfig_wait()
15887 pptr->port_tmp_cnt) { in fcp_reconfig_wait()
15889 (void) cv_timedwait(&pptr->port_config_cv, &pptr->port_mutex, in fcp_reconfig_wait()
15893 mutex_exit(&pptr->port_mutex); in fcp_reconfig_wait()
16121 fcp_port_t *pptr = ADDR2FCP(ap); in fcp_pseudo_init_pkt() local
16129 pkt = scsi_hba_pkt_alloc(pptr->port_dip, ap, cmdlen, statuslen, in fcp_pseudo_init_pkt()
16130 tgtlen, sizeof (fcp_pkt_t) + pptr->port_priv_pkt_len, in fcp_pseudo_init_pkt()
16177 FCP_TRACE(fcp_logq, pptr->port_instbuf, in fcp_pseudo_init_pkt()
16218 fcp_port_t *pptr = ADDR2FCP(ap); in fcp_pseudo_destroy_pkt() local
16223 (void) fc_ulp_uninit_packet(pptr->port_fp_handle, in fcp_pseudo_destroy_pkt()
16243 fcp_port_t *pptr = ADDR2FCP(ap); in fcp_pseudo_start() local
16252 (void) fc_ulp_init_packet(pptr->port_fp_handle, cmd->cmd_fp_pkt, 1); in fcp_pseudo_start()
16284 fpkt->pkt_cmd_fhdr.s_id = pptr->port_id; in fcp_pseudo_start()
16315 return (fcp_dopoll(pptr, cmd)); in fcp_pseudo_start()
16319 rval = fcp_transport(pptr->port_fp_handle, fpkt, 0); in fcp_pseudo_start()