2611 again:
2612 rval = vhci_do_scsi_cmd(new_pkt);
2613 if (rval != 1) {
2614 if ((new_pkt->pkt_reason == CMD_CMPLT) &&
2615 (SCBP_C(new_pkt) == STATUS_CHECK) &&
2616 (new_pkt->pkt_state & STATE_ARQ_DONE)) {
2617 sns = (uint8_t *)
2618 &(((struct scsi_arq_status *)(uintptr_t)
2619 (new_pkt->pkt_scbp))->sts_sensedata);
2620 skey = scsi_sense_key(sns);
2621 if ((skey == KEY_UNIT_ATTENTION) ||
2622 (skey == KEY_NOT_READY)) {
2623 int max_retry;
2624 struct scsi_failover_ops *fops;
2625 fops = vlun->svl_fops;
2626 rval = fops->sfo_analyze_sense(svp->svp_psd,
2627 sns, vlun->svl_fops_ctpriv);
2628 if (rval == SCSI_SENSE_NOT_READY) {
2629 max_retry = vhci_prout_not_ready_retry;
2630 retry = nr_retry++;
2631 delay(1*drv_usectohz(1000000));
2632 } else {
2633 /* chk for state change and update */
2634 if (rval == SCSI_SENSE_STATE_CHANGED) {
2635 int held;
2636 VHCI_HOLD_LUN(vlun,
2637 VH_NOSLEEP, held);
2638 if (!held) {
2639 rval = TRAN_BUSY;
2640 } else {
2641 /* chk for alua first */
2642 vhci_update_pathstates(
2643 (void *)vlun);
2644 }
2645 }
2646 retry = ua_retry++;
2647 max_retry = VHCI_MAX_PGR_RETRIES;
2648 }
2649 if (retry < max_retry) {
2650 VHCI_DEBUG(4, (CE_WARN, NULL,
2651 "!vhci_do_prout retry 0x%x "
5320 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip);
5321 if (svp == NULL) {
5322 /*
5323 * mdi_pathinfo node in INIT state can have vHCI private
5324 * information set to null
5325 */
5326 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: "
5327 "svp is NULL for pip 0x%p\n", (void *)pip));
5328 return (MDI_SUCCESS);
5329 }
5330
5331 psd = svp->svp_psd;
5332 ASSERT(psd != NULL);
5333
5334 mutex_enter(&svp->svp_mutex);
5335
5336 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: "
5337 "%d cmds pending on path: 0x%p\n", svp->svp_cmds, (void *)pip));
5338 while (svp->svp_cmds != 0) {
5339 if (cv_reltimedwait(&svp->svp_cv, &svp->svp_mutex,
5340 drv_usectohz(vhci_path_quiesce_timeout * 1000000),
5341 TR_CLOCK_TICK) == -1) {
5342 /*
5343 * The timeout time reached without the condition
5344 * being signaled.
5345 */
5346 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: "
5347 "Timeout reached on path 0x%p without the cond\n",
5348 (void *)pip));
5349 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: "
5350 "%d cmds still pending on path: 0x%p\n",
5351 svp->svp_cmds, (void *)pip));
5352 break;
5353 }
5354 }
5355 mutex_exit(&svp->svp_mutex);
5356
5357 /*
5358 * Check to see if this vlun has an active SCSI-II RESERVE. And this
5359 * is the pip for the path that has been reserved.
5360 * If so clear the reservation by sending a reset, so the host will not
5361 * get a reservation conflict. Reset the flag VLUN_RESERVE_ACTIVE_FLG
5362 * for this lun. Also a reset notify is sent to the target driver
5363 * just in case the POR check condition is cleared by some other layer
5364 * in the stack.
5365 */
5366 if (svp->svp_svl->svl_flags & VLUN_RESERVE_ACTIVE_FLG) {
5367 if (pip == svp->svp_svl->svl_resrv_pip) {
5368 if (vhci_recovery_reset(svp->svp_svl,
5369 &svp->svp_psd->sd_address, TRUE,
5370 VHCI_DEPTH_TARGET) == 0) {
5371 VHCI_DEBUG(1, (CE_NOTE, NULL,
5372 "!vhci_pathinfo_offline (pip:%p):"
5373 "reset failed, retrying\n", (void *)pip));
5374 delay(1*drv_usectohz(1000000));
5375 if (vhci_recovery_reset(svp->svp_svl,
5376 &svp->svp_psd->sd_address, TRUE,
5377 VHCI_DEPTH_TARGET) == 0) {
5378 VHCI_DEBUG(1, (CE_NOTE, NULL,
5379 "!vhci_pathinfo_offline "
5380 "(pip:%p): reset failed, "
5381 "giving up!\n", (void *)pip));
5382 }
5383 }
5384 svp->svp_svl->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG;
5385 }
5386 }
5387
5388 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_OFFLINE);
5389 vhci_mpapi_set_path_state(vdip, pip, MP_DRVR_PATH_STATE_REMOVED);
5390
5391 VHCI_DEBUG(1, (CE_NOTE, NULL,
5392 "!vhci_pathinfo_offline: offlined path 0x%p\n", (void *)pip));
5393 return (MDI_SUCCESS);
5394 }
7494 uint32_t p_ext_state;
7495 int circular;
7496
7497 cdip = vlun->svl_dip;
7498 pip = spip = NULL;
7499 ndi_devi_enter(cdip, &circular);
7500 pip = mdi_get_next_phci_path(cdip, NULL);
7501 while (pip != NULL) {
7502 (void) mdi_pi_get_state2(pip, &pstate, &p_ext_state);
7503 if (pstate != MDI_PATHINFO_STATE_ONLINE) {
7504 spip = pip;
7505 pip = mdi_get_next_phci_path(cdip, spip);
7506 continue;
7507 }
7508 mdi_hold_path(pip);
7509 ndi_devi_exit(cdip, circular);
7510 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip);
7511 mutex_enter(&svp->svp_mutex);
7512 while (svp->svp_cmds != 0) {
7513 if (cv_reltimedwait(&svp->svp_cv, &svp->svp_mutex,
7514 drv_usectohz(vhci_path_quiesce_timeout * 1000000),
7515 TR_CLOCK_TICK) == -1) {
7516 mutex_exit(&svp->svp_mutex);
7517 mdi_rele_path(pip);
7518 VHCI_DEBUG(1, (CE_WARN, NULL,
7519 "Quiesce of lun is not successful "
7520 "vlun: 0x%p.", (void *)vlun));
7521 return (0);
7522 }
7523 }
7524 mutex_exit(&svp->svp_mutex);
7525 ndi_devi_enter(cdip, &circular);
7526 spip = pip;
7527 pip = mdi_get_next_phci_path(cdip, spip);
7528 mdi_rele_path(spip);
7529 }
7530 ndi_devi_exit(cdip, circular);
7531 return (1);
7532 }
7533
7534 static int
8342 rqpkt->pkt_comp = vhci_uscsi_iodone;
8343 rqpkt->pkt_private = mp_uscmdp;
8344
8345 /*
8346 * NOTE: This code path is related to MPAPI uscsi(7I), so path
8347 * selection is not based on path_instance.
8348 */
8349 if (scsi_pkt_allocated_correctly(rqpkt))
8350 rqpkt->pkt_path_instance = 0;
8351
8352 /* get her done */
8353 switch (scsi_transport(rqpkt)) {
8354 case TRAN_ACCEPT:
8355 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: "
8356 "transport accepted."));
8357 break;
8358 case TRAN_BUSY:
8359 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: "
8360 "transport busy, setting timeout."));
8361 vhci_restart_timeid = timeout(vhci_uscsi_restart_sense, rqpkt,
8362 (drv_usectohz(5 * 1000000)));
8363 break;
8364 default:
8365 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: "
8366 "transport failed"));
8367 scsi_free_consistent_buf(rqbp);
8368 scsi_destroy_pkt(rqpkt);
8369 rval = -1;
8370 }
8371
8372 return (rval);
8373 }
8374
8375 /*
8376 * done routine for the mpapi uscsi command - this is behaving as though
8377 * FLAG_DIAGNOSE is set meaning there are no retries except for a manual
8378 * request sense.
8379 */
8380 void
8381 vhci_uscsi_iodone(struct scsi_pkt *pkt)
8382 {
|
2611 again:
2612 rval = vhci_do_scsi_cmd(new_pkt);
2613 if (rval != 1) {
2614 if ((new_pkt->pkt_reason == CMD_CMPLT) &&
2615 (SCBP_C(new_pkt) == STATUS_CHECK) &&
2616 (new_pkt->pkt_state & STATE_ARQ_DONE)) {
2617 sns = (uint8_t *)
2618 &(((struct scsi_arq_status *)(uintptr_t)
2619 (new_pkt->pkt_scbp))->sts_sensedata);
2620 skey = scsi_sense_key(sns);
2621 if ((skey == KEY_UNIT_ATTENTION) ||
2622 (skey == KEY_NOT_READY)) {
2623 int max_retry;
2624 struct scsi_failover_ops *fops;
2625 fops = vlun->svl_fops;
2626 rval = fops->sfo_analyze_sense(svp->svp_psd,
2627 sns, vlun->svl_fops_ctpriv);
2628 if (rval == SCSI_SENSE_NOT_READY) {
2629 max_retry = vhci_prout_not_ready_retry;
2630 retry = nr_retry++;
2631 delay(drv_sectohz(1));
2632 } else {
2633 /* chk for state change and update */
2634 if (rval == SCSI_SENSE_STATE_CHANGED) {
2635 int held;
2636 VHCI_HOLD_LUN(vlun,
2637 VH_NOSLEEP, held);
2638 if (!held) {
2639 rval = TRAN_BUSY;
2640 } else {
2641 /* chk for alua first */
2642 vhci_update_pathstates(
2643 (void *)vlun);
2644 }
2645 }
2646 retry = ua_retry++;
2647 max_retry = VHCI_MAX_PGR_RETRIES;
2648 }
2649 if (retry < max_retry) {
2650 VHCI_DEBUG(4, (CE_WARN, NULL,
2651 "!vhci_do_prout retry 0x%x "
5320 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip);
5321 if (svp == NULL) {
5322 /*
5323 * mdi_pathinfo node in INIT state can have vHCI private
5324 * information set to null
5325 */
5326 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: "
5327 "svp is NULL for pip 0x%p\n", (void *)pip));
5328 return (MDI_SUCCESS);
5329 }
5330
5331 psd = svp->svp_psd;
5332 ASSERT(psd != NULL);
5333
5334 mutex_enter(&svp->svp_mutex);
5335
5336 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: "
5337 "%d cmds pending on path: 0x%p\n", svp->svp_cmds, (void *)pip));
5338 while (svp->svp_cmds != 0) {
5339 if (cv_reltimedwait(&svp->svp_cv, &svp->svp_mutex,
5340 drv_sectohz(vhci_path_quiesce_timeout),
5341 TR_CLOCK_TICK) == -1) {
5342 /*
5343 * The timeout time reached without the condition
5344 * being signaled.
5345 */
5346 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: "
5347 "Timeout reached on path 0x%p without the cond\n",
5348 (void *)pip));
5349 VHCI_DEBUG(1, (CE_NOTE, vdip, "!vhci_pathinfo_offline: "
5350 "%d cmds still pending on path: 0x%p\n",
5351 svp->svp_cmds, (void *)pip));
5352 break;
5353 }
5354 }
5355 mutex_exit(&svp->svp_mutex);
5356
5357 /*
5358 * Check to see if this vlun has an active SCSI-II RESERVE. And this
5359 * is the pip for the path that has been reserved.
5360 * If so clear the reservation by sending a reset, so the host will not
5361 * get a reservation conflict. Reset the flag VLUN_RESERVE_ACTIVE_FLG
5362 * for this lun. Also a reset notify is sent to the target driver
5363 * just in case the POR check condition is cleared by some other layer
5364 * in the stack.
5365 */
5366 if (svp->svp_svl->svl_flags & VLUN_RESERVE_ACTIVE_FLG) {
5367 if (pip == svp->svp_svl->svl_resrv_pip) {
5368 if (vhci_recovery_reset(svp->svp_svl,
5369 &svp->svp_psd->sd_address, TRUE,
5370 VHCI_DEPTH_TARGET) == 0) {
5371 VHCI_DEBUG(1, (CE_NOTE, NULL,
5372 "!vhci_pathinfo_offline (pip:%p):"
5373 "reset failed, retrying\n", (void *)pip));
5374 delay(drv_sectohz(1));
5375 if (vhci_recovery_reset(svp->svp_svl,
5376 &svp->svp_psd->sd_address, TRUE,
5377 VHCI_DEPTH_TARGET) == 0) {
5378 VHCI_DEBUG(1, (CE_NOTE, NULL,
5379 "!vhci_pathinfo_offline "
5380 "(pip:%p): reset failed, "
5381 "giving up!\n", (void *)pip));
5382 }
5383 }
5384 svp->svp_svl->svl_flags &= ~VLUN_RESERVE_ACTIVE_FLG;
5385 }
5386 }
5387
5388 mdi_pi_set_state(pip, MDI_PATHINFO_STATE_OFFLINE);
5389 vhci_mpapi_set_path_state(vdip, pip, MP_DRVR_PATH_STATE_REMOVED);
5390
5391 VHCI_DEBUG(1, (CE_NOTE, NULL,
5392 "!vhci_pathinfo_offline: offlined path 0x%p\n", (void *)pip));
5393 return (MDI_SUCCESS);
5394 }
7494 uint32_t p_ext_state;
7495 int circular;
7496
7497 cdip = vlun->svl_dip;
7498 pip = spip = NULL;
7499 ndi_devi_enter(cdip, &circular);
7500 pip = mdi_get_next_phci_path(cdip, NULL);
7501 while (pip != NULL) {
7502 (void) mdi_pi_get_state2(pip, &pstate, &p_ext_state);
7503 if (pstate != MDI_PATHINFO_STATE_ONLINE) {
7504 spip = pip;
7505 pip = mdi_get_next_phci_path(cdip, spip);
7506 continue;
7507 }
7508 mdi_hold_path(pip);
7509 ndi_devi_exit(cdip, circular);
7510 svp = (scsi_vhci_priv_t *)mdi_pi_get_vhci_private(pip);
7511 mutex_enter(&svp->svp_mutex);
7512 while (svp->svp_cmds != 0) {
7513 if (cv_reltimedwait(&svp->svp_cv, &svp->svp_mutex,
7514 drv_sectohz(vhci_path_quiesce_timeout),
7515 TR_CLOCK_TICK) == -1) {
7516 mutex_exit(&svp->svp_mutex);
7517 mdi_rele_path(pip);
7518 VHCI_DEBUG(1, (CE_WARN, NULL,
7519 "Quiesce of lun is not successful "
7520 "vlun: 0x%p.", (void *)vlun));
7521 return (0);
7522 }
7523 }
7524 mutex_exit(&svp->svp_mutex);
7525 ndi_devi_enter(cdip, &circular);
7526 spip = pip;
7527 pip = mdi_get_next_phci_path(cdip, spip);
7528 mdi_rele_path(spip);
7529 }
7530 ndi_devi_exit(cdip, circular);
7531 return (1);
7532 }
7533
7534 static int
8342 rqpkt->pkt_comp = vhci_uscsi_iodone;
8343 rqpkt->pkt_private = mp_uscmdp;
8344
8345 /*
8346 * NOTE: This code path is related to MPAPI uscsi(7I), so path
8347 * selection is not based on path_instance.
8348 */
8349 if (scsi_pkt_allocated_correctly(rqpkt))
8350 rqpkt->pkt_path_instance = 0;
8351
8352 /* get her done */
8353 switch (scsi_transport(rqpkt)) {
8354 case TRAN_ACCEPT:
8355 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: "
8356 "transport accepted."));
8357 break;
8358 case TRAN_BUSY:
8359 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: "
8360 "transport busy, setting timeout."));
8361 vhci_restart_timeid = timeout(vhci_uscsi_restart_sense, rqpkt,
8362 drv_sectohz(5));
8363 break;
8364 default:
8365 VHCI_DEBUG(1, (CE_NOTE, NULL, "vhci_uscsi_send_sense: "
8366 "transport failed"));
8367 scsi_free_consistent_buf(rqbp);
8368 scsi_destroy_pkt(rqpkt);
8369 rval = -1;
8370 }
8371
8372 return (rval);
8373 }
8374
8375 /*
8376 * done routine for the mpapi uscsi command - this is behaving as though
8377 * FLAG_DIAGNOSE is set meaning there are no retries except for a manual
8378 * request sense.
8379 */
8380 void
8381 vhci_uscsi_iodone(struct scsi_pkt *pkt)
8382 {
|