aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c413
1 files changed, 195 insertions, 218 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 8f45bbc42126..17d7dc05149b 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -84,22 +84,21 @@ lpfc_adjust_queue_depth(struct lpfc_hba *phba)
84 * SCSI command completion. 84 * SCSI command completion.
85 */ 85 */
86static inline void 86static inline void
87lpfc_rampup_queue_depth(struct lpfc_hba *phba, 87lpfc_rampup_queue_depth(struct lpfc_vport *vport,
88 struct scsi_device *sdev) 88 struct scsi_device *sdev)
89{ 89{
90 unsigned long flags; 90 unsigned long flags;
91 struct lpfc_hba *phba = vport->phba;
91 atomic_inc(&phba->num_cmd_success); 92 atomic_inc(&phba->num_cmd_success);
92 93
93 if (phba->cfg_lun_queue_depth <= sdev->queue_depth) 94 if (vport->cfg_lun_queue_depth <= sdev->queue_depth)
94 return; 95 return;
95
96 spin_lock_irqsave(&phba->hbalock, flags); 96 spin_lock_irqsave(&phba->hbalock, flags);
97 if (((phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) > jiffies) || 97 if (((phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) > jiffies) ||
98 ((phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL ) > jiffies)) { 98 ((phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL ) > jiffies)) {
99 spin_unlock_irqrestore(&phba->hbalock, flags); 99 spin_unlock_irqrestore(&phba->hbalock, flags);
100 return; 100 return;
101 } 101 }
102
103 phba->last_ramp_up_time = jiffies; 102 phba->last_ramp_up_time = jiffies;
104 spin_unlock_irqrestore(&phba->hbalock, flags); 103 spin_unlock_irqrestore(&phba->hbalock, flags);
105 104
@@ -119,43 +118,40 @@ lpfc_rampup_queue_depth(struct lpfc_hba *phba,
119void 118void
120lpfc_ramp_down_queue_handler(struct lpfc_hba *phba) 119lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
121{ 120{
122 struct lpfc_vport *vport; 121 struct lpfc_vport **vports;
123 struct Scsi_Host *host; 122 struct Scsi_Host *shost;
124 struct scsi_device *sdev; 123 struct scsi_device *sdev;
125 unsigned long new_queue_depth; 124 unsigned long new_queue_depth;
126 unsigned long num_rsrc_err, num_cmd_success; 125 unsigned long num_rsrc_err, num_cmd_success;
126 int i;
127 127
128 num_rsrc_err = atomic_read(&phba->num_rsrc_err); 128 num_rsrc_err = atomic_read(&phba->num_rsrc_err);
129 num_cmd_success = atomic_read(&phba->num_cmd_success); 129 num_cmd_success = atomic_read(&phba->num_cmd_success);
130 130
131 spin_lock_irq(&phba->hbalock); 131 vports = lpfc_create_vport_work_array(phba);
132 list_for_each_entry(vport, &phba->port_list, listentry) { 132 if (vports != NULL)
133 host = lpfc_shost_from_vport(vport); 133 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
134 if (!scsi_host_get(host)) 134 shost = lpfc_shost_from_vport(vports[i]);
135 continue; 135 shost_for_each_device(sdev, shost) {
136
137 spin_unlock_irq(&phba->hbalock);
138
139 shost_for_each_device(sdev, host) {
140 new_queue_depth = sdev->queue_depth * num_rsrc_err /
141 (num_rsrc_err + num_cmd_success);
142 if (!new_queue_depth)
143 new_queue_depth = sdev->queue_depth - 1;
144 else
145 new_queue_depth = 136 new_queue_depth =
146 sdev->queue_depth - new_queue_depth; 137 sdev->queue_depth * num_rsrc_err /
147 138 (num_rsrc_err + num_cmd_success);
148 if (sdev->ordered_tags) 139 if (!new_queue_depth)
149 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, 140 new_queue_depth = sdev->queue_depth - 1;
150 new_queue_depth); 141 else
151 else 142 new_queue_depth = sdev->queue_depth -
152 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 143 new_queue_depth;
153 new_queue_depth); 144 if (sdev->ordered_tags)
145 scsi_adjust_queue_depth(sdev,
146 MSG_ORDERED_TAG,
147 new_queue_depth);
148 else
149 scsi_adjust_queue_depth(sdev,
150 MSG_SIMPLE_TAG,
151 new_queue_depth);
152 }
154 } 153 }
155 spin_lock_irq(&phba->hbalock); 154 lpfc_destroy_vport_work_array(vports);
156 scsi_host_put(host);
157 }
158 spin_unlock_irq(&phba->hbalock);
159 atomic_set(&phba->num_rsrc_err, 0); 155 atomic_set(&phba->num_rsrc_err, 0);
160 atomic_set(&phba->num_cmd_success, 0); 156 atomic_set(&phba->num_cmd_success, 0);
161} 157}
@@ -163,29 +159,27 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
163void 159void
164lpfc_ramp_up_queue_handler(struct lpfc_hba *phba) 160lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
165{ 161{
166 struct lpfc_vport *vport; 162 struct lpfc_vport **vports;
167 struct Scsi_Host *host; 163 struct Scsi_Host *shost;
168 struct scsi_device *sdev; 164 struct scsi_device *sdev;
169 165 int i;
170 spin_lock_irq(&phba->hbalock); 166
171 list_for_each_entry(vport, &phba->port_list, listentry) { 167 vports = lpfc_create_vport_work_array(phba);
172 host = lpfc_shost_from_vport(vport); 168 if (vports != NULL)
173 if (!scsi_host_get(host)) 169 for(i = 0; i < LPFC_MAX_VPORTS && vports[i] != NULL; i++) {
174 continue; 170 shost = lpfc_shost_from_vport(vports[i]);
175 171 shost_for_each_device(sdev, shost) {
176 spin_unlock_irq(&phba->hbalock); 172 if (sdev->ordered_tags)
177 shost_for_each_device(sdev, host) { 173 scsi_adjust_queue_depth(sdev,
178 if (sdev->ordered_tags) 174 MSG_ORDERED_TAG,
179 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, 175 sdev->queue_depth+1);
180 sdev->queue_depth+1); 176 else
181 else 177 scsi_adjust_queue_depth(sdev,
182 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, 178 MSG_SIMPLE_TAG,
183 sdev->queue_depth+1); 179 sdev->queue_depth+1);
180 }
184 } 181 }
185 spin_lock_irq(&phba->hbalock); 182 lpfc_destroy_vport_work_array(vports);
186 scsi_host_put(host);
187 }
188 spin_unlock_irq(&phba->hbalock);
189 atomic_set(&phba->num_rsrc_err, 0); 183 atomic_set(&phba->num_rsrc_err, 0);
190 atomic_set(&phba->num_cmd_success, 0); 184 atomic_set(&phba->num_cmd_success, 0);
191} 185}
@@ -411,9 +405,7 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
411 struct scsi_cmnd *cmnd = lpfc_cmd->pCmd; 405 struct scsi_cmnd *cmnd = lpfc_cmd->pCmd;
412 struct fcp_cmnd *fcpcmd = lpfc_cmd->fcp_cmnd; 406 struct fcp_cmnd *fcpcmd = lpfc_cmd->fcp_cmnd;
413 struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp; 407 struct fcp_rsp *fcprsp = lpfc_cmd->fcp_rsp;
414 struct lpfc_hba *phba = vport->phba;
415 uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm; 408 uint32_t fcpi_parm = rsp_iocb->iocb.un.fcpi.fcpi_parm;
416 uint32_t vpi = vport->vpi;
417 uint32_t resp_info = fcprsp->rspStatus2; 409 uint32_t resp_info = fcprsp->rspStatus2;
418 uint32_t scsi_status = fcprsp->rspStatus3; 410 uint32_t scsi_status = fcprsp->rspStatus3;
419 uint32_t *lp; 411 uint32_t *lp;
@@ -445,15 +437,15 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
445 if (!scsi_status && (resp_info & RESID_UNDER)) 437 if (!scsi_status && (resp_info & RESID_UNDER))
446 logit = LOG_FCP; 438 logit = LOG_FCP;
447 439
448 lpfc_printf_log(phba, KERN_WARNING, logit, 440 lpfc_printf_vlog(vport, KERN_WARNING, logit,
449 "%d (%d):0730 FCP command x%x failed: x%x SNS x%x x%x " 441 "0730 FCP command x%x failed: x%x SNS x%x x%x "
450 "Data: x%x x%x x%x x%x x%x\n", 442 "Data: x%x x%x x%x x%x x%x\n",
451 phba->brd_no, vpi, cmnd->cmnd[0], scsi_status, 443 cmnd->cmnd[0], scsi_status,
452 be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info, 444 be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info,
453 be32_to_cpu(fcprsp->rspResId), 445 be32_to_cpu(fcprsp->rspResId),
454 be32_to_cpu(fcprsp->rspSnsLen), 446 be32_to_cpu(fcprsp->rspSnsLen),
455 be32_to_cpu(fcprsp->rspRspLen), 447 be32_to_cpu(fcprsp->rspRspLen),
456 fcprsp->rspInfo3); 448 fcprsp->rspInfo3);
457 449
458 if (resp_info & RSP_LEN_VALID) { 450 if (resp_info & RSP_LEN_VALID) {
459 rsplen = be32_to_cpu(fcprsp->rspRspLen); 451 rsplen = be32_to_cpu(fcprsp->rspRspLen);
@@ -468,12 +460,12 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
468 if (resp_info & RESID_UNDER) { 460 if (resp_info & RESID_UNDER) {
469 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId)); 461 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId));
470 462
471 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 463 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
472 "%d (%d):0716 FCP Read Underrun, expected %d, " 464 "0716 FCP Read Underrun, expected %d, "
473 "residual %d Data: x%x x%x x%x\n", 465 "residual %d Data: x%x x%x x%x\n",
474 phba->brd_no, vpi, be32_to_cpu(fcpcmd->fcpDl), 466 be32_to_cpu(fcpcmd->fcpDl),
475 scsi_get_resid(cmnd), fcpi_parm, cmnd->cmnd[0], 467 scsi_get_resid(cmnd), fcpi_parm, cmnd->cmnd[0],
476 cmnd->underflow); 468 cmnd->underflow);
477 469
478 /* 470 /*
479 * If there is an under run check if under run reported by 471 * If there is an under run check if under run reported by
@@ -483,14 +475,13 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
483 if ((cmnd->sc_data_direction == DMA_FROM_DEVICE) && 475 if ((cmnd->sc_data_direction == DMA_FROM_DEVICE) &&
484 fcpi_parm && 476 fcpi_parm &&
485 (scsi_get_resid(cmnd) != fcpi_parm)) { 477 (scsi_get_resid(cmnd) != fcpi_parm)) {
486 lpfc_printf_log(phba, KERN_WARNING, 478 lpfc_printf_vlog(vport, KERN_WARNING,
487 LOG_FCP | LOG_FCP_ERROR, 479 LOG_FCP | LOG_FCP_ERROR,
488 "%d (%d):0735 FCP Read Check Error " 480 "0735 FCP Read Check Error "
489 "and Underrun Data: x%x x%x x%x x%x\n", 481 "and Underrun Data: x%x x%x x%x x%x\n",
490 phba->brd_no, vpi, 482 be32_to_cpu(fcpcmd->fcpDl),
491 be32_to_cpu(fcpcmd->fcpDl), 483 scsi_get_resid(cmnd), fcpi_parm,
492 scsi_get_resid(cmnd), fcpi_parm, 484 cmnd->cmnd[0]);
493 cmnd->cmnd[0]);
494 scsi_set_resid(cmnd, scsi_bufflen(cmnd)); 485 scsi_set_resid(cmnd, scsi_bufflen(cmnd));
495 host_status = DID_ERROR; 486 host_status = DID_ERROR;
496 } 487 }
@@ -504,21 +495,19 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
504 (scsi_status == SAM_STAT_GOOD) && 495 (scsi_status == SAM_STAT_GOOD) &&
505 (scsi_bufflen(cmnd) - scsi_get_resid(cmnd) 496 (scsi_bufflen(cmnd) - scsi_get_resid(cmnd)
506 < cmnd->underflow)) { 497 < cmnd->underflow)) {
507 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 498 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
508 "%d (%d):0717 FCP command x%x residual " 499 "0717 FCP command x%x residual "
509 "underrun converted to error " 500 "underrun converted to error "
510 "Data: x%x x%x x%x\n", 501 "Data: x%x x%x x%x\n",
511 phba->brd_no, vpi, cmnd->cmnd[0], 502 cmnd->cmnd[0], scsi_bufflen(cmnd),
512 scsi_bufflen(cmnd), 503 scsi_get_resid(cmnd), cmnd->underflow);
513 scsi_get_resid(cmnd), cmnd->underflow);
514 host_status = DID_ERROR; 504 host_status = DID_ERROR;
515 } 505 }
516 } else if (resp_info & RESID_OVER) { 506 } else if (resp_info & RESID_OVER) {
517 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 507 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
518 "%d (%d):0720 FCP command x%x residual " 508 "0720 FCP command x%x residual overrun error. "
519 "overrun error. Data: x%x x%x \n", 509 "Data: x%x x%x \n", cmnd->cmnd[0],
520 phba->brd_no, vpi, cmnd->cmnd[0], 510 scsi_bufflen(cmnd), scsi_get_resid(cmnd));
521 scsi_bufflen(cmnd), scsi_get_resid(cmnd));
522 host_status = DID_ERROR; 511 host_status = DID_ERROR;
523 512
524 /* 513 /*
@@ -527,13 +516,12 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
527 */ 516 */
528 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm && 517 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm &&
529 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) { 518 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) {
530 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR, 519 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR,
531 "%d (%d):0734 FCP Read Check Error Data: " 520 "0734 FCP Read Check Error Data: "
532 "x%x x%x x%x x%x\n", 521 "x%x x%x x%x x%x\n",
533 phba->brd_no, vpi, 522 be32_to_cpu(fcpcmd->fcpDl),
534 be32_to_cpu(fcpcmd->fcpDl), 523 be32_to_cpu(fcprsp->rspResId),
535 be32_to_cpu(fcprsp->rspResId), 524 fcpi_parm, cmnd->cmnd[0]);
536 fcpi_parm, cmnd->cmnd[0]);
537 host_status = DID_ERROR; 525 host_status = DID_ERROR;
538 scsi_set_resid(cmnd, scsi_bufflen(cmnd)); 526 scsi_set_resid(cmnd, scsi_bufflen(cmnd));
539 } 527 }
@@ -552,9 +540,6 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
552 struct lpfc_rport_data *rdata = lpfc_cmd->rdata; 540 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
553 struct lpfc_nodelist *pnode = rdata->pnode; 541 struct lpfc_nodelist *pnode = rdata->pnode;
554 struct scsi_cmnd *cmd = lpfc_cmd->pCmd; 542 struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
555 uint32_t vpi = (lpfc_cmd->cur_iocbq.vport
556 ? lpfc_cmd->cur_iocbq.vport->vpi
557 : 0);
558 int result; 543 int result;
559 struct scsi_device *sdev, *tmp_sdev; 544 struct scsi_device *sdev, *tmp_sdev;
560 int depth = 0; 545 int depth = 0;
@@ -569,15 +554,15 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
569 else if (lpfc_cmd->status >= IOSTAT_CNT) 554 else if (lpfc_cmd->status >= IOSTAT_CNT)
570 lpfc_cmd->status = IOSTAT_DEFAULT; 555 lpfc_cmd->status = IOSTAT_DEFAULT;
571 556
572 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 557 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
573 "%d (%d):0729 FCP cmd x%x failed <%d/%d> " 558 "0729 FCP cmd x%x failed <%d/%d> "
574 "status: x%x result: x%x Data: x%x x%x\n", 559 "status: x%x result: x%x Data: x%x x%x\n",
575 phba->brd_no, vpi, cmd->cmnd[0], 560 cmd->cmnd[0],
576 cmd->device ? cmd->device->id : 0xffff, 561 cmd->device ? cmd->device->id : 0xffff,
577 cmd->device ? cmd->device->lun : 0xffff, 562 cmd->device ? cmd->device->lun : 0xffff,
578 lpfc_cmd->status, lpfc_cmd->result, 563 lpfc_cmd->status, lpfc_cmd->result,
579 pIocbOut->iocb.ulpContext, 564 pIocbOut->iocb.ulpContext,
580 lpfc_cmd->cur_iocbq.iocb.ulpIoTag); 565 lpfc_cmd->cur_iocbq.iocb.ulpIoTag);
581 566
582 switch (lpfc_cmd->status) { 567 switch (lpfc_cmd->status) {
583 case IOSTAT_FCP_RSP_ERROR: 568 case IOSTAT_FCP_RSP_ERROR:
@@ -610,13 +595,12 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
610 if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) { 595 if (cmd->result || lpfc_cmd->fcp_rsp->rspSnsLen) {
611 uint32_t *lp = (uint32_t *)cmd->sense_buffer; 596 uint32_t *lp = (uint32_t *)cmd->sense_buffer;
612 597
613 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 598 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
614 "%d (%d):0710 Iodone <%d/%d> cmd %p, error " 599 "0710 Iodone <%d/%d> cmd %p, error "
615 "x%x SNS x%x x%x Data: x%x x%x\n", 600 "x%x SNS x%x x%x Data: x%x x%x\n",
616 phba->brd_no, vpi, cmd->device->id, 601 cmd->device->id, cmd->device->lun, cmd,
617 cmd->device->lun, cmd, cmd->result, 602 cmd->result, *lp, *(lp + 3), cmd->retries,
618 *lp, *(lp + 3), cmd->retries, 603 scsi_get_resid(cmd));
619 scsi_get_resid(cmd));
620 } 604 }
621 605
622 result = cmd->result; 606 result = cmd->result;
@@ -631,16 +615,16 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
631 615
632 616
633 if (!result) 617 if (!result)
634 lpfc_rampup_queue_depth(phba, sdev); 618 lpfc_rampup_queue_depth(vport, sdev);
635 619
636 if (!result && pnode != NULL && 620 if (!result && pnode != NULL &&
637 ((jiffies - pnode->last_ramp_up_time) > 621 ((jiffies - pnode->last_ramp_up_time) >
638 LPFC_Q_RAMP_UP_INTERVAL * HZ) && 622 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
639 ((jiffies - pnode->last_q_full_time) > 623 ((jiffies - pnode->last_q_full_time) >
640 LPFC_Q_RAMP_UP_INTERVAL * HZ) && 624 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
641 (phba->cfg_lun_queue_depth > sdev->queue_depth)) { 625 (vport->cfg_lun_queue_depth > sdev->queue_depth)) {
642 shost_for_each_device(tmp_sdev, sdev->host) { 626 shost_for_each_device(tmp_sdev, sdev->host) {
643 if (phba->cfg_lun_queue_depth > tmp_sdev->queue_depth) { 627 if (vport->cfg_lun_queue_depth > tmp_sdev->queue_depth){
644 if (tmp_sdev->id != sdev->id) 628 if (tmp_sdev->id != sdev->id)
645 continue; 629 continue;
646 if (tmp_sdev->ordered_tags) 630 if (tmp_sdev->ordered_tags)
@@ -680,10 +664,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
680 depth = sdev->host->cmd_per_lun; 664 depth = sdev->host->cmd_per_lun;
681 665
682 if (depth) { 666 if (depth) {
683 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 667 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
684 "%d (%d):0711 detected queue full - " 668 "0711 detected queue full - lun queue "
685 "lun queue depth adjusted to %d.\n", 669 "depth adjusted to %d.\n", depth);
686 phba->brd_no, vpi, depth);
687 } 670 }
688 } 671 }
689 672
@@ -853,12 +836,9 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf *lpfc_cmd, struct lpfc_vport *vport,
853 return FAILED; 836 return FAILED;
854 837
855 /* Issue Target Reset to TGT <num> */ 838 /* Issue Target Reset to TGT <num> */
856 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 839 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
857 "%d (%d):0702 Issue Target Reset to TGT %d " 840 "0702 Issue Target Reset to TGT %d Data: x%x x%x\n",
858 "Data: x%x x%x\n", 841 tgt_id, rdata->pnode->nlp_rpi, rdata->pnode->nlp_flag);
859 phba->brd_no, vport->vpi, tgt_id,
860 rdata->pnode->nlp_rpi, rdata->pnode->nlp_flag);
861
862 ret = lpfc_sli_issue_iocb_wait(phba, 842 ret = lpfc_sli_issue_iocb_wait(phba,
863 &phba->sli.ring[phba->sli.fcp_ring], 843 &phba->sli.ring[phba->sli.fcp_ring],
864 iocbq, iocbqrsp, lpfc_cmd->timeout); 844 iocbq, iocbqrsp, lpfc_cmd->timeout);
@@ -965,10 +945,9 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
965 if (lpfc_cmd == NULL) { 945 if (lpfc_cmd == NULL) {
966 lpfc_adjust_queue_depth(phba); 946 lpfc_adjust_queue_depth(phba);
967 947
968 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 948 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
969 "%d (%d):0707 driver's buffer pool is empty, " 949 "0707 driver's buffer pool is empty, "
970 "IO busied\n", 950 "IO busied\n");
971 phba->brd_no, vport->vpi);
972 goto out_host_busy; 951 goto out_host_busy;
973 } 952 }
974 953
@@ -1103,28 +1082,25 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
1103 1082
1104 schedule_timeout_uninterruptible(LPFC_ABORT_WAIT * HZ); 1083 schedule_timeout_uninterruptible(LPFC_ABORT_WAIT * HZ);
1105 if (++loop_count 1084 if (++loop_count
1106 > (2 * phba->cfg_devloss_tmo)/LPFC_ABORT_WAIT) 1085 > (2 * vport->cfg_devloss_tmo)/LPFC_ABORT_WAIT)
1107 break; 1086 break;
1108 } 1087 }
1109 1088
1110 if (lpfc_cmd->pCmd == cmnd) { 1089 if (lpfc_cmd->pCmd == cmnd) {
1111 ret = FAILED; 1090 ret = FAILED;
1112 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1091 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1113 "%d (%d):0748 abort handler timed out waiting " 1092 "0748 abort handler timed out waiting "
1114 "for abort to complete: ret %#x, ID %d, " 1093 "for abort to complete: ret %#x, ID %d, "
1115 "LUN %d, snum %#lx\n", 1094 "LUN %d, snum %#lx\n",
1116 phba->brd_no, vport->vpi, ret, 1095 ret, cmnd->device->id, cmnd->device->lun,
1117 cmnd->device->id, cmnd->device->lun, 1096 cmnd->serial_number);
1118 cmnd->serial_number);
1119 } 1097 }
1120 1098
1121 out: 1099 out:
1122 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 1100 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
1123 "%d (%d):0749 SCSI Layer I/O Abort Request " 1101 "0749 SCSI Layer I/O Abort Request Status x%x ID %d "
1124 "Status x%x ID %d LUN %d snum %#lx\n", 1102 "LUN %d snum %#lx\n", ret, cmnd->device->id,
1125 phba->brd_no, vport->vpi, ret, cmnd->device->id, 1103 cmnd->device->lun, cmnd->serial_number);
1126 cmnd->device->lun, cmnd->serial_number);
1127
1128 return ret; 1104 return ret;
1129} 1105}
1130 1106
@@ -1158,12 +1134,11 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
1158 loopcnt++; 1134 loopcnt++;
1159 rdata = cmnd->device->hostdata; 1135 rdata = cmnd->device->hostdata;
1160 if (!rdata || 1136 if (!rdata ||
1161 (loopcnt > ((phba->cfg_devloss_tmo * 2) + 1))) { 1137 (loopcnt > ((vport->cfg_devloss_tmo * 2) + 1))){
1162 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1138 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1163 "%d (%d):0721 LUN Reset rport " 1139 "0721 LUN Reset rport "
1164 "failure: cnt x%x rdata x%p\n", 1140 "failure: cnt x%x rdata x%p\n",
1165 phba->brd_no, vport->vpi, 1141 loopcnt, rdata);
1166 loopcnt, rdata);
1167 goto out; 1142 goto out;
1168 } 1143 }
1169 pnode = rdata->pnode; 1144 pnode = rdata->pnode;
@@ -1193,12 +1168,10 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
1193 if (iocbqrsp == NULL) 1168 if (iocbqrsp == NULL)
1194 goto out_free_scsi_buf; 1169 goto out_free_scsi_buf;
1195 1170
1196 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 1171 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
1197 "%d (%d):0703 Issue target reset to TGT %d LUN %d " 1172 "0703 Issue target reset to TGT %d LUN %d "
1198 "rpi x%x nlp_flag x%x\n", 1173 "rpi x%x nlp_flag x%x\n", cmnd->device->id,
1199 phba->brd_no, vport->vpi, cmnd->device->id, 1174 cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag);
1200 cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag);
1201
1202 iocb_status = lpfc_sli_issue_iocb_wait(phba, 1175 iocb_status = lpfc_sli_issue_iocb_wait(phba,
1203 &phba->sli.ring[phba->sli.fcp_ring], 1176 &phba->sli.ring[phba->sli.fcp_ring],
1204 iocbq, iocbqrsp, lpfc_cmd->timeout); 1177 iocbq, iocbqrsp, lpfc_cmd->timeout);
@@ -1221,33 +1194,28 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
1221 * Unfortunately, some targets do not abide by this forcing the driver 1194 * Unfortunately, some targets do not abide by this forcing the driver
1222 * to double check. 1195 * to double check.
1223 */ 1196 */
1224 cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 1197 cnt = lpfc_sli_sum_iocb(vport, cmnd->device->id, cmnd->device->lun,
1225 cmnd->device->id, cmnd->device->lun,
1226 LPFC_CTX_LUN); 1198 LPFC_CTX_LUN);
1227 if (cnt) 1199 if (cnt)
1228 lpfc_sli_abort_iocb(phba, 1200 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring],
1229 &phba->sli.ring[phba->sli.fcp_ring],
1230 cmnd->device->id, cmnd->device->lun, 1201 cmnd->device->id, cmnd->device->lun,
1231 0, LPFC_CTX_LUN); 1202 LPFC_CTX_LUN);
1232 loopcnt = 0; 1203 loopcnt = 0;
1233 while(cnt) { 1204 while(cnt) {
1234 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); 1205 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
1235 1206
1236 if (++loopcnt 1207 if (++loopcnt
1237 > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT) 1208 > (2 * vport->cfg_devloss_tmo)/LPFC_RESET_WAIT)
1238 break; 1209 break;
1239 1210
1240 cnt = lpfc_sli_sum_iocb(phba, 1211 cnt = lpfc_sli_sum_iocb(vport, cmnd->device->id,
1241 &phba->sli.ring[phba->sli.fcp_ring], 1212 cmnd->device->lun, LPFC_CTX_LUN);
1242 cmnd->device->id, cmnd->device->lun,
1243 LPFC_CTX_LUN);
1244 } 1213 }
1245 1214
1246 if (cnt) { 1215 if (cnt) {
1247 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1216 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1248 "%d (%d):0719 device reset I/O flush failure: " 1217 "0719 device reset I/O flush failure: "
1249 "cnt x%x\n", 1218 "cnt x%x\n", cnt);
1250 phba->brd_no, vport->vpi, cnt);
1251 ret = FAILED; 1219 ret = FAILED;
1252 } 1220 }
1253 1221
@@ -1255,12 +1223,11 @@ out_free_scsi_buf:
1255 if (iocb_status != IOCB_TIMEDOUT) { 1223 if (iocb_status != IOCB_TIMEDOUT) {
1256 lpfc_release_scsi_buf(phba, lpfc_cmd); 1224 lpfc_release_scsi_buf(phba, lpfc_cmd);
1257 } 1225 }
1258 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1226 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1259 "%d (%d):0713 SCSI layer issued device reset (%d, %d) " 1227 "0713 SCSI layer issued device reset (%d, %d) "
1260 "return x%x status x%x result x%x\n", 1228 "return x%x status x%x result x%x\n",
1261 phba->brd_no, vport->vpi, cmnd->device->id, 1229 cmnd->device->id, cmnd->device->lun, ret,
1262 cmnd->device->lun, ret, cmd_status, cmd_result); 1230 cmd_status, cmd_result);
1263
1264out: 1231out:
1265 return ret; 1232 return ret;
1266} 1233}
@@ -1311,10 +1278,9 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
1311 cmnd->device->lun, 1278 cmnd->device->lun,
1312 ndlp->rport->dd_data); 1279 ndlp->rport->dd_data);
1313 if (ret != SUCCESS) { 1280 if (ret != SUCCESS) {
1314 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1281 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1315 "%d (%d):0700 Bus Reset on target %d " 1282 "0700 Bus Reset on target %d failed\n",
1316 "failed\n", 1283 i);
1317 phba->brd_no, vport->vpi, i);
1318 err_count++; 1284 err_count++;
1319 break; 1285 break;
1320 } 1286 }
@@ -1333,35 +1299,30 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
1333 * the targets. Unfortunately, some targets do not abide by 1299 * the targets. Unfortunately, some targets do not abide by
1334 * this forcing the driver to double check. 1300 * this forcing the driver to double check.
1335 */ 1301 */
1336 cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 1302 cnt = lpfc_sli_sum_iocb(vport, 0, 0, LPFC_CTX_HOST);
1337 0, 0, LPFC_CTX_HOST);
1338 if (cnt) 1303 if (cnt)
1339 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 1304 lpfc_sli_abort_iocb(vport, &phba->sli.ring[phba->sli.fcp_ring],
1340 0, 0, 0, LPFC_CTX_HOST); 1305 0, 0, LPFC_CTX_HOST);
1341 loopcnt = 0; 1306 loopcnt = 0;
1342 while(cnt) { 1307 while(cnt) {
1343 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); 1308 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
1344 1309
1345 if (++loopcnt 1310 if (++loopcnt
1346 > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT) 1311 > (2 * vport->cfg_devloss_tmo)/LPFC_RESET_WAIT)
1347 break; 1312 break;
1348 1313
1349 cnt = lpfc_sli_sum_iocb(phba, 1314 cnt = lpfc_sli_sum_iocb(vport, 0, 0, LPFC_CTX_HOST);
1350 &phba->sli.ring[phba->sli.fcp_ring],
1351 0, 0, LPFC_CTX_HOST);
1352 } 1315 }
1353 1316
1354 if (cnt) { 1317 if (cnt) {
1355 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1318 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1356 "%d (%d):0715 Bus Reset I/O flush failure: " 1319 "0715 Bus Reset I/O flush failure: "
1357 "cnt x%x left x%x\n", 1320 "cnt x%x left x%x\n", cnt, i);
1358 phba->brd_no, vport->vpi, cnt, i);
1359 ret = FAILED; 1321 ret = FAILED;
1360 } 1322 }
1361 1323
1362 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1324 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1363 "%d (%d):0714 SCSI layer issued Bus Reset Data: x%x\n", 1325 "0714 SCSI layer issued Bus Reset Data: x%x\n", ret);
1364 phba->brd_no, vport->vpi, ret);
1365out: 1326out:
1366 return ret; 1327 return ret;
1367} 1328}
@@ -1390,36 +1351,32 @@ lpfc_slave_alloc(struct scsi_device *sdev)
1390 * extra. This list of scsi bufs exists for the lifetime of the driver. 1351 * extra. This list of scsi bufs exists for the lifetime of the driver.
1391 */ 1352 */
1392 total = phba->total_scsi_bufs; 1353 total = phba->total_scsi_bufs;
1393 num_to_alloc = phba->cfg_lun_queue_depth + 2; 1354 num_to_alloc = vport->cfg_lun_queue_depth + 2;
1394 1355
1395 /* Allow some exchanges to be available always to complete discovery */ 1356 /* Allow some exchanges to be available always to complete discovery */
1396 if (total >= phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) { 1357 if (total >= phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) {
1397 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 1358 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
1398 "%d (%d):0704 At limitation of %d " 1359 "0704 At limitation of %d preallocated "
1399 "preallocated command buffers\n", 1360 "command buffers\n", total);
1400 phba->brd_no, vport->vpi, total);
1401 return 0; 1361 return 0;
1402
1403 /* Allow some exchanges to be available always to complete discovery */ 1362 /* Allow some exchanges to be available always to complete discovery */
1404 } else if (total + num_to_alloc > 1363 } else if (total + num_to_alloc >
1405 phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) { 1364 phba->cfg_hba_queue_depth - LPFC_DISC_IOCB_BUFF_COUNT ) {
1406 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 1365 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
1407 "%d (%d):0705 Allocation request of %d " 1366 "0705 Allocation request of %d "
1408 "command buffers will exceed max of %d. " 1367 "command buffers will exceed max of %d. "
1409 "Reducing allocation request to %d.\n", 1368 "Reducing allocation request to %d.\n",
1410 phba->brd_no, vport->vpi, num_to_alloc, 1369 num_to_alloc, phba->cfg_hba_queue_depth,
1411 phba->cfg_hba_queue_depth, 1370 (phba->cfg_hba_queue_depth - total));
1412 (phba->cfg_hba_queue_depth - total));
1413 num_to_alloc = phba->cfg_hba_queue_depth - total; 1371 num_to_alloc = phba->cfg_hba_queue_depth - total;
1414 } 1372 }
1415 1373
1416 for (i = 0; i < num_to_alloc; i++) { 1374 for (i = 0; i < num_to_alloc; i++) {
1417 scsi_buf = lpfc_new_scsi_buf(vport); 1375 scsi_buf = lpfc_new_scsi_buf(vport);
1418 if (!scsi_buf) { 1376 if (!scsi_buf) {
1419 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1377 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
1420 "%d (%d):0706 Failed to allocate " 1378 "0706 Failed to allocate "
1421 "command buffer\n", 1379 "command buffer\n");
1422 phba->brd_no, vport->vpi);
1423 break; 1380 break;
1424 } 1381 }
1425 1382
@@ -1439,9 +1396,9 @@ lpfc_slave_configure(struct scsi_device *sdev)
1439 struct fc_rport *rport = starget_to_rport(sdev->sdev_target); 1396 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
1440 1397
1441 if (sdev->tagged_supported) 1398 if (sdev->tagged_supported)
1442 scsi_activate_tcq(sdev, phba->cfg_lun_queue_depth); 1399 scsi_activate_tcq(sdev, vport->cfg_lun_queue_depth);
1443 else 1400 else
1444 scsi_deactivate_tcq(sdev, phba->cfg_lun_queue_depth); 1401 scsi_deactivate_tcq(sdev, vport->cfg_lun_queue_depth);
1445 1402
1446 /* 1403 /*
1447 * Initialize the fc transport attributes for the target 1404 * Initialize the fc transport attributes for the target
@@ -1449,7 +1406,7 @@ lpfc_slave_configure(struct scsi_device *sdev)
1449 * target pointer is stored in the starget_data for the 1406 * target pointer is stored in the starget_data for the
1450 * driver's sysfs entry point functions. 1407 * driver's sysfs entry point functions.
1451 */ 1408 */
1452 rport->dev_loss_tmo = phba->cfg_devloss_tmo; 1409 rport->dev_loss_tmo = vport->cfg_devloss_tmo;
1453 1410
1454 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 1411 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
1455 lpfc_sli_poll_fcp_ring(phba); 1412 lpfc_sli_poll_fcp_ring(phba);
@@ -1487,3 +1444,23 @@ struct scsi_host_template lpfc_template = {
1487 .shost_attrs = lpfc_hba_attrs, 1444 .shost_attrs = lpfc_hba_attrs,
1488 .max_sectors = 0xFFFF, 1445 .max_sectors = 0xFFFF,
1489}; 1446};
1447
1448struct scsi_host_template lpfc_vport_template = {
1449 .module = THIS_MODULE,
1450 .name = LPFC_DRIVER_NAME,
1451 .info = lpfc_info,
1452 .queuecommand = lpfc_queuecommand,
1453 .eh_abort_handler = lpfc_abort_handler,
1454 .eh_device_reset_handler= lpfc_device_reset_handler,
1455 .eh_bus_reset_handler = lpfc_bus_reset_handler,
1456 .slave_alloc = lpfc_slave_alloc,
1457 .slave_configure = lpfc_slave_configure,
1458 .slave_destroy = lpfc_slave_destroy,
1459 .scan_finished = lpfc_scan_finished,
1460 .this_id = -1,
1461 .sg_tablesize = LPFC_SG_SEG_CNT,
1462 .cmd_per_lun = LPFC_CMD_PER_LUN,
1463 .use_clustering = ENABLE_CLUSTERING,
1464 .shost_attrs = lpfc_vport_attrs,
1465 .max_sectors = 0xFFFF,
1466};