aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_scsi.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/scsi/lpfc/lpfc_scsi.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c490
1 files changed, 274 insertions, 216 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index c88f59f0ce30..dccdb822328c 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -19,6 +19,7 @@
19 * included with this package. * 19 * included with this package. *
20 *******************************************************************/ 20 *******************************************************************/
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/slab.h>
22#include <linux/interrupt.h> 23#include <linux/interrupt.h>
23#include <linux/delay.h> 24#include <linux/delay.h>
24#include <asm/unaligned.h> 25#include <asm/unaligned.h>
@@ -59,22 +60,26 @@ static char *dif_op_str[] = {
59}; 60};
60static void 61static void
61lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb); 62lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb);
63static void
64lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb);
62 65
63static void 66static void
64lpfc_debug_save_data(struct scsi_cmnd *cmnd) 67lpfc_debug_save_data(struct lpfc_hba *phba, struct scsi_cmnd *cmnd)
65{ 68{
66 void *src, *dst; 69 void *src, *dst;
67 struct scatterlist *sgde = scsi_sglist(cmnd); 70 struct scatterlist *sgde = scsi_sglist(cmnd);
68 71
69 if (!_dump_buf_data) { 72 if (!_dump_buf_data) {
70 printk(KERN_ERR "BLKGRD ERROR %s _dump_buf_data is NULL\n", 73 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
74 "9050 BLKGRD: ERROR %s _dump_buf_data is NULL\n",
71 __func__); 75 __func__);
72 return; 76 return;
73 } 77 }
74 78
75 79
76 if (!sgde) { 80 if (!sgde) {
77 printk(KERN_ERR "BLKGRD ERROR: data scatterlist is null\n"); 81 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
82 "9051 BLKGRD: ERROR: data scatterlist is null\n");
78 return; 83 return;
79 } 84 }
80 85
@@ -88,19 +93,21 @@ lpfc_debug_save_data(struct scsi_cmnd *cmnd)
88} 93}
89 94
90static void 95static void
91lpfc_debug_save_dif(struct scsi_cmnd *cmnd) 96lpfc_debug_save_dif(struct lpfc_hba *phba, struct scsi_cmnd *cmnd)
92{ 97{
93 void *src, *dst; 98 void *src, *dst;
94 struct scatterlist *sgde = scsi_prot_sglist(cmnd); 99 struct scatterlist *sgde = scsi_prot_sglist(cmnd);
95 100
96 if (!_dump_buf_dif) { 101 if (!_dump_buf_dif) {
97 printk(KERN_ERR "BLKGRD ERROR %s _dump_buf_data is NULL\n", 102 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
103 "9052 BLKGRD: ERROR %s _dump_buf_data is NULL\n",
98 __func__); 104 __func__);
99 return; 105 return;
100 } 106 }
101 107
102 if (!sgde) { 108 if (!sgde) {
103 printk(KERN_ERR "BLKGRD ERROR: prot scatterlist is null\n"); 109 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
110 "9053 BLKGRD: ERROR: prot scatterlist is null\n");
104 return; 111 return;
105 } 112 }
106 113
@@ -242,6 +249,36 @@ lpfc_send_sdev_queuedepth_change_event(struct lpfc_hba *phba,
242} 249}
243 250
244/** 251/**
252 * lpfc_change_queue_depth - Alter scsi device queue depth
253 * @sdev: Pointer the scsi device on which to change the queue depth.
254 * @qdepth: New queue depth to set the sdev to.
255 * @reason: The reason for the queue depth change.
256 *
257 * This function is called by the midlayer and the LLD to alter the queue
258 * depth for a scsi device. This function sets the queue depth to the new
259 * value and sends an event out to log the queue depth change.
260 **/
261int
262lpfc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
263{
264 struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata;
265 struct lpfc_hba *phba = vport->phba;
266 struct lpfc_rport_data *rdata;
267 unsigned long new_queue_depth, old_queue_depth;
268
269 old_queue_depth = sdev->queue_depth;
270 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
271 new_queue_depth = sdev->queue_depth;
272 rdata = sdev->hostdata;
273 if (rdata)
274 lpfc_send_sdev_queuedepth_change_event(phba, vport,
275 rdata->pnode, sdev->lun,
276 old_queue_depth,
277 new_queue_depth);
278 return sdev->queue_depth;
279}
280
281/**
245 * lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread 282 * lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread
246 * @phba: The Hba for which this call is being executed. 283 * @phba: The Hba for which this call is being executed.
247 * 284 *
@@ -305,8 +342,10 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
305 if (vport->cfg_lun_queue_depth <= queue_depth) 342 if (vport->cfg_lun_queue_depth <= queue_depth)
306 return; 343 return;
307 spin_lock_irqsave(&phba->hbalock, flags); 344 spin_lock_irqsave(&phba->hbalock, flags);
308 if (((phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) > jiffies) || 345 if (time_before(jiffies,
309 ((phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL ) > jiffies)) { 346 phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) ||
347 time_before(jiffies,
348 phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL)) {
310 spin_unlock_irqrestore(&phba->hbalock, flags); 349 spin_unlock_irqrestore(&phba->hbalock, flags);
311 return; 350 return;
312 } 351 }
@@ -338,10 +377,9 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
338 struct lpfc_vport **vports; 377 struct lpfc_vport **vports;
339 struct Scsi_Host *shost; 378 struct Scsi_Host *shost;
340 struct scsi_device *sdev; 379 struct scsi_device *sdev;
341 unsigned long new_queue_depth, old_queue_depth; 380 unsigned long new_queue_depth;
342 unsigned long num_rsrc_err, num_cmd_success; 381 unsigned long num_rsrc_err, num_cmd_success;
343 int i; 382 int i;
344 struct lpfc_rport_data *rdata;
345 383
346 num_rsrc_err = atomic_read(&phba->num_rsrc_err); 384 num_rsrc_err = atomic_read(&phba->num_rsrc_err);
347 num_cmd_success = atomic_read(&phba->num_cmd_success); 385 num_cmd_success = atomic_read(&phba->num_cmd_success);
@@ -359,22 +397,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
359 else 397 else
360 new_queue_depth = sdev->queue_depth - 398 new_queue_depth = sdev->queue_depth -
361 new_queue_depth; 399 new_queue_depth;
362 old_queue_depth = sdev->queue_depth; 400 lpfc_change_queue_depth(sdev, new_queue_depth,
363 if (sdev->ordered_tags) 401 SCSI_QDEPTH_DEFAULT);
364 scsi_adjust_queue_depth(sdev,
365 MSG_ORDERED_TAG,
366 new_queue_depth);
367 else
368 scsi_adjust_queue_depth(sdev,
369 MSG_SIMPLE_TAG,
370 new_queue_depth);
371 rdata = sdev->hostdata;
372 if (rdata)
373 lpfc_send_sdev_queuedepth_change_event(
374 phba, vports[i],
375 rdata->pnode,
376 sdev->lun, old_queue_depth,
377 new_queue_depth);
378 } 402 }
379 } 403 }
380 lpfc_destroy_vport_work_array(phba, vports); 404 lpfc_destroy_vport_work_array(phba, vports);
@@ -398,7 +422,6 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
398 struct Scsi_Host *shost; 422 struct Scsi_Host *shost;
399 struct scsi_device *sdev; 423 struct scsi_device *sdev;
400 int i; 424 int i;
401 struct lpfc_rport_data *rdata;
402 425
403 vports = lpfc_create_vport_work_array(phba); 426 vports = lpfc_create_vport_work_array(phba);
404 if (vports != NULL) 427 if (vports != NULL)
@@ -408,22 +431,9 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
408 if (vports[i]->cfg_lun_queue_depth <= 431 if (vports[i]->cfg_lun_queue_depth <=
409 sdev->queue_depth) 432 sdev->queue_depth)
410 continue; 433 continue;
411 if (sdev->ordered_tags) 434 lpfc_change_queue_depth(sdev,
412 scsi_adjust_queue_depth(sdev, 435 sdev->queue_depth+1,
413 MSG_ORDERED_TAG, 436 SCSI_QDEPTH_RAMP_UP);
414 sdev->queue_depth+1);
415 else
416 scsi_adjust_queue_depth(sdev,
417 MSG_SIMPLE_TAG,
418 sdev->queue_depth+1);
419 rdata = sdev->hostdata;
420 if (rdata)
421 lpfc_send_sdev_queuedepth_change_event(
422 phba, vports[i],
423 rdata->pnode,
424 sdev->lun,
425 sdev->queue_depth - 1,
426 sdev->queue_depth);
427 } 437 }
428 } 438 }
429 lpfc_destroy_vport_work_array(phba, vports); 439 lpfc_destroy_vport_work_array(phba, vports);
@@ -589,7 +599,7 @@ lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc)
589 iocb->ulpClass = CLASS3; 599 iocb->ulpClass = CLASS3;
590 psb->status = IOSTAT_SUCCESS; 600 psb->status = IOSTAT_SUCCESS;
591 /* Put it back into the SCSI buffer list */ 601 /* Put it back into the SCSI buffer list */
592 lpfc_release_scsi_buf_s4(phba, psb); 602 lpfc_release_scsi_buf_s3(phba, psb);
593 603
594 } 604 }
595 605
@@ -611,22 +621,40 @@ lpfc_sli4_fcp_xri_aborted(struct lpfc_hba *phba,
611 uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri); 621 uint16_t xri = bf_get(lpfc_wcqe_xa_xri, axri);
612 struct lpfc_scsi_buf *psb, *next_psb; 622 struct lpfc_scsi_buf *psb, *next_psb;
613 unsigned long iflag = 0; 623 unsigned long iflag = 0;
624 struct lpfc_iocbq *iocbq;
625 int i;
614 626
615 spin_lock_irqsave(&phba->sli4_hba.abts_scsi_buf_list_lock, iflag); 627 spin_lock_irqsave(&phba->hbalock, iflag);
628 spin_lock(&phba->sli4_hba.abts_scsi_buf_list_lock);
616 list_for_each_entry_safe(psb, next_psb, 629 list_for_each_entry_safe(psb, next_psb,
617 &phba->sli4_hba.lpfc_abts_scsi_buf_list, list) { 630 &phba->sli4_hba.lpfc_abts_scsi_buf_list, list) {
618 if (psb->cur_iocbq.sli4_xritag == xri) { 631 if (psb->cur_iocbq.sli4_xritag == xri) {
619 list_del(&psb->list); 632 list_del(&psb->list);
633 psb->exch_busy = 0;
620 psb->status = IOSTAT_SUCCESS; 634 psb->status = IOSTAT_SUCCESS;
621 spin_unlock_irqrestore( 635 spin_unlock(
622 &phba->sli4_hba.abts_scsi_buf_list_lock, 636 &phba->sli4_hba.abts_scsi_buf_list_lock);
623 iflag); 637 spin_unlock_irqrestore(&phba->hbalock, iflag);
624 lpfc_release_scsi_buf_s4(phba, psb); 638 lpfc_release_scsi_buf_s4(phba, psb);
625 return; 639 return;
626 } 640 }
627 } 641 }
628 spin_unlock_irqrestore(&phba->sli4_hba.abts_scsi_buf_list_lock, 642 spin_unlock(&phba->sli4_hba.abts_scsi_buf_list_lock);
629 iflag); 643 for (i = 1; i <= phba->sli.last_iotag; i++) {
644 iocbq = phba->sli.iocbq_lookup[i];
645
646 if (!(iocbq->iocb_flag & LPFC_IO_FCP) ||
647 (iocbq->iocb_flag & LPFC_IO_LIBDFC))
648 continue;
649 if (iocbq->sli4_xritag != xri)
650 continue;
651 psb = container_of(iocbq, struct lpfc_scsi_buf, cur_iocbq);
652 psb->exch_busy = 0;
653 spin_unlock_irqrestore(&phba->hbalock, iflag);
654 return;
655
656 }
657 spin_unlock_irqrestore(&phba->hbalock, iflag);
630} 658}
631 659
632/** 660/**
@@ -679,11 +707,12 @@ lpfc_sli4_repost_scsi_sgl_list(struct lpfc_hba *phba)
679 list); 707 list);
680 if (status) { 708 if (status) {
681 /* Put this back on the abort scsi list */ 709 /* Put this back on the abort scsi list */
682 psb->status = IOSTAT_LOCAL_REJECT; 710 psb->exch_busy = 1;
683 psb->result = IOERR_ABORT_REQUESTED;
684 rc++; 711 rc++;
685 } else 712 } else {
713 psb->exch_busy = 0;
686 psb->status = IOSTAT_SUCCESS; 714 psb->status = IOSTAT_SUCCESS;
715 }
687 /* Put it back into the SCSI buffer list */ 716 /* Put it back into the SCSI buffer list */
688 lpfc_release_scsi_buf_s4(phba, psb); 717 lpfc_release_scsi_buf_s4(phba, psb);
689 } 718 }
@@ -787,19 +816,17 @@ lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc)
787 */ 816 */
788 sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_cmd)); 817 sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_cmd));
789 sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_cmd)); 818 sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_cmd));
790 bf_set(lpfc_sli4_sge_len, sgl, sizeof(struct fcp_cmnd));
791 bf_set(lpfc_sli4_sge_last, sgl, 0); 819 bf_set(lpfc_sli4_sge_last, sgl, 0);
792 sgl->word2 = cpu_to_le32(sgl->word2); 820 sgl->word2 = cpu_to_le32(sgl->word2);
793 sgl->word3 = cpu_to_le32(sgl->word3); 821 sgl->sge_len = cpu_to_le32(sizeof(struct fcp_cmnd));
794 sgl++; 822 sgl++;
795 823
796 /* Setup the physical region for the FCP RSP */ 824 /* Setup the physical region for the FCP RSP */
797 sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_rsp)); 825 sgl->addr_hi = cpu_to_le32(putPaddrHigh(pdma_phys_fcp_rsp));
798 sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_rsp)); 826 sgl->addr_lo = cpu_to_le32(putPaddrLow(pdma_phys_fcp_rsp));
799 bf_set(lpfc_sli4_sge_len, sgl, sizeof(struct fcp_rsp));
800 bf_set(lpfc_sli4_sge_last, sgl, 1); 827 bf_set(lpfc_sli4_sge_last, sgl, 1);
801 sgl->word2 = cpu_to_le32(sgl->word2); 828 sgl->word2 = cpu_to_le32(sgl->word2);
802 sgl->word3 = cpu_to_le32(sgl->word3); 829 sgl->sge_len = cpu_to_le32(sizeof(struct fcp_rsp));
803 830
804 /* 831 /*
805 * Since the IOCB for the FCP I/O is built into this 832 * Since the IOCB for the FCP I/O is built into this
@@ -830,11 +857,12 @@ lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc)
830 psb->cur_iocbq.sli4_xritag); 857 psb->cur_iocbq.sli4_xritag);
831 if (status) { 858 if (status) {
832 /* Put this back on the abort scsi list */ 859 /* Put this back on the abort scsi list */
833 psb->status = IOSTAT_LOCAL_REJECT; 860 psb->exch_busy = 1;
834 psb->result = IOERR_ABORT_REQUESTED;
835 rc++; 861 rc++;
836 } else 862 } else {
863 psb->exch_busy = 0;
837 psb->status = IOSTAT_SUCCESS; 864 psb->status = IOSTAT_SUCCESS;
865 }
838 /* Put it back into the SCSI buffer list */ 866 /* Put it back into the SCSI buffer list */
839 lpfc_release_scsi_buf_s4(phba, psb); 867 lpfc_release_scsi_buf_s4(phba, psb);
840 break; 868 break;
@@ -848,11 +876,12 @@ lpfc_new_scsi_buf_s4(struct lpfc_vport *vport, int num_to_alloc)
848 list); 876 list);
849 if (status) { 877 if (status) {
850 /* Put this back on the abort scsi list */ 878 /* Put this back on the abort scsi list */
851 psb->status = IOSTAT_LOCAL_REJECT; 879 psb->exch_busy = 1;
852 psb->result = IOERR_ABORT_REQUESTED;
853 rc++; 880 rc++;
854 } else 881 } else {
882 psb->exch_busy = 0;
855 psb->status = IOSTAT_SUCCESS; 883 psb->status = IOSTAT_SUCCESS;
884 }
856 /* Put it back into the SCSI buffer list */ 885 /* Put it back into the SCSI buffer list */
857 lpfc_release_scsi_buf_s4(phba, psb); 886 lpfc_release_scsi_buf_s4(phba, psb);
858 } 887 }
@@ -942,8 +971,7 @@ lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb)
942{ 971{
943 unsigned long iflag = 0; 972 unsigned long iflag = 0;
944 973
945 if (psb->status == IOSTAT_LOCAL_REJECT 974 if (psb->exch_busy) {
946 && psb->result == IOERR_ABORT_REQUESTED) {
947 spin_lock_irqsave(&phba->sli4_hba.abts_scsi_buf_list_lock, 975 spin_lock_irqsave(&phba->sli4_hba.abts_scsi_buf_list_lock,
948 iflag); 976 iflag);
949 psb->pCmd = NULL; 977 psb->pCmd = NULL;
@@ -996,6 +1024,7 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
996 struct scatterlist *sgel = NULL; 1024 struct scatterlist *sgel = NULL;
997 struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd; 1025 struct fcp_cmnd *fcp_cmnd = lpfc_cmd->fcp_cmnd;
998 struct ulp_bde64 *bpl = lpfc_cmd->fcp_bpl; 1026 struct ulp_bde64 *bpl = lpfc_cmd->fcp_bpl;
1027 struct lpfc_iocbq *iocbq = &lpfc_cmd->cur_iocbq;
999 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb; 1028 IOCB_t *iocb_cmd = &lpfc_cmd->cur_iocbq.iocb;
1000 struct ulp_bde64 *data_bde = iocb_cmd->unsli3.fcp_ext.dbde; 1029 struct ulp_bde64 *data_bde = iocb_cmd->unsli3.fcp_ext.dbde;
1001 dma_addr_t physaddr; 1030 dma_addr_t physaddr;
@@ -1024,7 +1053,8 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1024 1053
1025 lpfc_cmd->seg_cnt = nseg; 1054 lpfc_cmd->seg_cnt = nseg;
1026 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { 1055 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
1027 printk(KERN_ERR "%s: Too many sg segments from " 1056 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1057 "9064 BLKGRD: %s: Too many sg segments from "
1028 "dma_map_sg. Config %d, seg_cnt %d\n", 1058 "dma_map_sg. Config %d, seg_cnt %d\n",
1029 __func__, phba->cfg_sg_seg_cnt, 1059 __func__, phba->cfg_sg_seg_cnt,
1030 lpfc_cmd->seg_cnt); 1060 lpfc_cmd->seg_cnt);
@@ -1045,6 +1075,7 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1045 physaddr = sg_dma_address(sgel); 1075 physaddr = sg_dma_address(sgel);
1046 if (phba->sli_rev == 3 && 1076 if (phba->sli_rev == 3 &&
1047 !(phba->sli3_options & LPFC_SLI3_BG_ENABLED) && 1077 !(phba->sli3_options & LPFC_SLI3_BG_ENABLED) &&
1078 !(iocbq->iocb_flag & DSS_SECURITY_OP) &&
1048 nseg <= LPFC_EXT_DATA_BDE_COUNT) { 1079 nseg <= LPFC_EXT_DATA_BDE_COUNT) {
1049 data_bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64; 1080 data_bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
1050 data_bde->tus.f.bdeSize = sg_dma_len(sgel); 1081 data_bde->tus.f.bdeSize = sg_dma_len(sgel);
@@ -1071,7 +1102,8 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1071 * explicitly reinitialized since all iocb memory resources are reused. 1102 * explicitly reinitialized since all iocb memory resources are reused.
1072 */ 1103 */
1073 if (phba->sli_rev == 3 && 1104 if (phba->sli_rev == 3 &&
1074 !(phba->sli3_options & LPFC_SLI3_BG_ENABLED)) { 1105 !(phba->sli3_options & LPFC_SLI3_BG_ENABLED) &&
1106 !(iocbq->iocb_flag & DSS_SECURITY_OP)) {
1075 if (num_bde > LPFC_EXT_DATA_BDE_COUNT) { 1107 if (num_bde > LPFC_EXT_DATA_BDE_COUNT) {
1076 /* 1108 /*
1077 * The extended IOCB format can only fit 3 BDE or a BPL. 1109 * The extended IOCB format can only fit 3 BDE or a BPL.
@@ -1096,6 +1128,7 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1096 } else { 1128 } else {
1097 iocb_cmd->un.fcpi64.bdl.bdeSize = 1129 iocb_cmd->un.fcpi64.bdl.bdeSize =
1098 ((num_bde + 2) * sizeof(struct ulp_bde64)); 1130 ((num_bde + 2) * sizeof(struct ulp_bde64));
1131 iocb_cmd->unsli3.fcp_ext.ebde_count = (num_bde + 1);
1099 } 1132 }
1100 fcp_cmnd->fcpDl = cpu_to_be32(scsi_bufflen(scsi_cmnd)); 1133 fcp_cmnd->fcpDl = cpu_to_be32(scsi_bufflen(scsi_cmnd));
1101 1134
@@ -1112,7 +1145,7 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1112 * with the cmd 1145 * with the cmd
1113 */ 1146 */
1114static int 1147static int
1115lpfc_sc_to_sli_prof(struct scsi_cmnd *sc) 1148lpfc_sc_to_sli_prof(struct lpfc_hba *phba, struct scsi_cmnd *sc)
1116{ 1149{
1117 uint8_t guard_type = scsi_host_get_guard(sc->device->host); 1150 uint8_t guard_type = scsi_host_get_guard(sc->device->host);
1118 uint8_t ret_prof = LPFC_PROF_INVALID; 1151 uint8_t ret_prof = LPFC_PROF_INVALID;
@@ -1136,7 +1169,8 @@ lpfc_sc_to_sli_prof(struct scsi_cmnd *sc)
1136 1169
1137 case SCSI_PROT_NORMAL: 1170 case SCSI_PROT_NORMAL:
1138 default: 1171 default:
1139 printk(KERN_ERR "Bad op/guard:%d/%d combination\n", 1172 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1173 "9063 BLKGRD:Bad op/guard:%d/%d combination\n",
1140 scsi_get_prot_op(sc), guard_type); 1174 scsi_get_prot_op(sc), guard_type);
1141 break; 1175 break;
1142 1176
@@ -1157,7 +1191,8 @@ lpfc_sc_to_sli_prof(struct scsi_cmnd *sc)
1157 case SCSI_PROT_WRITE_STRIP: 1191 case SCSI_PROT_WRITE_STRIP:
1158 case SCSI_PROT_NORMAL: 1192 case SCSI_PROT_NORMAL:
1159 default: 1193 default:
1160 printk(KERN_ERR "Bad op/guard:%d/%d combination\n", 1194 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1195 "9075 BLKGRD: Bad op/guard:%d/%d combination\n",
1161 scsi_get_prot_op(sc), guard_type); 1196 scsi_get_prot_op(sc), guard_type);
1162 break; 1197 break;
1163 } 1198 }
@@ -1259,7 +1294,7 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1259 uint16_t apptagmask, apptagval; 1294 uint16_t apptagmask, apptagval;
1260 1295
1261 pde1 = (struct lpfc_pde *) bpl; 1296 pde1 = (struct lpfc_pde *) bpl;
1262 prof = lpfc_sc_to_sli_prof(sc); 1297 prof = lpfc_sc_to_sli_prof(phba, sc);
1263 1298
1264 if (prof == LPFC_PROF_INVALID) 1299 if (prof == LPFC_PROF_INVALID)
1265 goto out; 1300 goto out;
@@ -1359,7 +1394,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1359 return 0; 1394 return 0;
1360 } 1395 }
1361 1396
1362 prof = lpfc_sc_to_sli_prof(sc); 1397 prof = lpfc_sc_to_sli_prof(phba, sc);
1363 if (prof == LPFC_PROF_INVALID) 1398 if (prof == LPFC_PROF_INVALID)
1364 goto out; 1399 goto out;
1365 1400
@@ -1408,7 +1443,8 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1408 subtotal = 0; /* total bytes processed for current prot grp */ 1443 subtotal = 0; /* total bytes processed for current prot grp */
1409 while (!pgdone) { 1444 while (!pgdone) {
1410 if (!sgde) { 1445 if (!sgde) {
1411 printk(KERN_ERR "%s Invalid data segment\n", 1446 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1447 "9065 BLKGRD:%s Invalid data segment\n",
1412 __func__); 1448 __func__);
1413 return 0; 1449 return 0;
1414 } 1450 }
@@ -1462,7 +1498,8 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1462 reftag += protgrp_blks; 1498 reftag += protgrp_blks;
1463 } else { 1499 } else {
1464 /* if we're here, we have a bug */ 1500 /* if we're here, we have a bug */
1465 printk(KERN_ERR "BLKGRD: bug in %s\n", __func__); 1501 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1502 "9054 BLKGRD: bug in %s\n", __func__);
1466 } 1503 }
1467 1504
1468 } while (!alldone); 1505 } while (!alldone);
@@ -1544,8 +1581,10 @@ lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba,
1544 1581
1545 lpfc_cmd->seg_cnt = datasegcnt; 1582 lpfc_cmd->seg_cnt = datasegcnt;
1546 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { 1583 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
1547 printk(KERN_ERR "%s: Too many sg segments from " 1584 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1548 "dma_map_sg. Config %d, seg_cnt %d\n", 1585 "9067 BLKGRD: %s: Too many sg segments"
1586 " from dma_map_sg. Config %d, seg_cnt"
1587 " %d\n",
1549 __func__, phba->cfg_sg_seg_cnt, 1588 __func__, phba->cfg_sg_seg_cnt,
1550 lpfc_cmd->seg_cnt); 1589 lpfc_cmd->seg_cnt);
1551 scsi_dma_unmap(scsi_cmnd); 1590 scsi_dma_unmap(scsi_cmnd);
@@ -1558,7 +1597,7 @@ lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba,
1558 case LPFC_PG_TYPE_NO_DIF: 1597 case LPFC_PG_TYPE_NO_DIF:
1559 num_bde = lpfc_bg_setup_bpl(phba, scsi_cmnd, bpl, 1598 num_bde = lpfc_bg_setup_bpl(phba, scsi_cmnd, bpl,
1560 datasegcnt); 1599 datasegcnt);
1561 /* we shoud have 2 or more entries in buffer list */ 1600 /* we should have 2 or more entries in buffer list */
1562 if (num_bde < 2) 1601 if (num_bde < 2)
1563 goto err; 1602 goto err;
1564 break; 1603 break;
@@ -1579,8 +1618,9 @@ lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba,
1579 lpfc_cmd->prot_seg_cnt = protsegcnt; 1618 lpfc_cmd->prot_seg_cnt = protsegcnt;
1580 if (lpfc_cmd->prot_seg_cnt 1619 if (lpfc_cmd->prot_seg_cnt
1581 > phba->cfg_prot_sg_seg_cnt) { 1620 > phba->cfg_prot_sg_seg_cnt) {
1582 printk(KERN_ERR "%s: Too many prot sg segments " 1621 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1583 "from dma_map_sg. Config %d," 1622 "9068 BLKGRD: %s: Too many prot sg "
1623 "segments from dma_map_sg. Config %d,"
1584 "prot_seg_cnt %d\n", __func__, 1624 "prot_seg_cnt %d\n", __func__,
1585 phba->cfg_prot_sg_seg_cnt, 1625 phba->cfg_prot_sg_seg_cnt,
1586 lpfc_cmd->prot_seg_cnt); 1626 lpfc_cmd->prot_seg_cnt);
@@ -1594,7 +1634,7 @@ lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba,
1594 1634
1595 num_bde = lpfc_bg_setup_bpl_prot(phba, scsi_cmnd, bpl, 1635 num_bde = lpfc_bg_setup_bpl_prot(phba, scsi_cmnd, bpl,
1596 datasegcnt, protsegcnt); 1636 datasegcnt, protsegcnt);
1597 /* we shoud have 3 or more entries in buffer list */ 1637 /* we should have 3 or more entries in buffer list */
1598 if (num_bde < 3) 1638 if (num_bde < 3)
1599 goto err; 1639 goto err;
1600 break; 1640 break;
@@ -1671,23 +1711,26 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1671 uint32_t bgstat = bgf->bgstat; 1711 uint32_t bgstat = bgf->bgstat;
1672 uint64_t failing_sector = 0; 1712 uint64_t failing_sector = 0;
1673 1713
1674 printk(KERN_ERR "BG ERROR in cmd 0x%x lba 0x%llx blk cnt 0x%x " 1714 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9069 BLKGRD: BG ERROR in cmd"
1715 " 0x%x lba 0x%llx blk cnt 0x%x "
1675 "bgstat=0x%x bghm=0x%x\n", 1716 "bgstat=0x%x bghm=0x%x\n",
1676 cmd->cmnd[0], (unsigned long long)scsi_get_lba(cmd), 1717 cmd->cmnd[0], (unsigned long long)scsi_get_lba(cmd),
1677 blk_rq_sectors(cmd->request), bgstat, bghm); 1718 blk_rq_sectors(cmd->request), bgstat, bghm);
1678 1719
1679 spin_lock(&_dump_buf_lock); 1720 spin_lock(&_dump_buf_lock);
1680 if (!_dump_buf_done) { 1721 if (!_dump_buf_done) {
1681 printk(KERN_ERR "Saving Data for %u blocks to debugfs\n", 1722 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9070 BLKGRD: Saving"
1723 " Data for %u blocks to debugfs\n",
1682 (cmd->cmnd[7] << 8 | cmd->cmnd[8])); 1724 (cmd->cmnd[7] << 8 | cmd->cmnd[8]));
1683 lpfc_debug_save_data(cmd); 1725 lpfc_debug_save_data(phba, cmd);
1684 1726
1685 /* If we have a prot sgl, save the DIF buffer */ 1727 /* If we have a prot sgl, save the DIF buffer */
1686 if (lpfc_prot_group_type(phba, cmd) == 1728 if (lpfc_prot_group_type(phba, cmd) ==
1687 LPFC_PG_TYPE_DIF_BUF) { 1729 LPFC_PG_TYPE_DIF_BUF) {
1688 printk(KERN_ERR "Saving DIF for %u blocks to debugfs\n", 1730 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9071 BLKGRD: "
1689 (cmd->cmnd[7] << 8 | cmd->cmnd[8])); 1731 "Saving DIF for %u blocks to debugfs\n",
1690 lpfc_debug_save_dif(cmd); 1732 (cmd->cmnd[7] << 8 | cmd->cmnd[8]));
1733 lpfc_debug_save_dif(phba, cmd);
1691 } 1734 }
1692 1735
1693 _dump_buf_done = 1; 1736 _dump_buf_done = 1;
@@ -1696,15 +1739,17 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1696 1739
1697 if (lpfc_bgs_get_invalid_prof(bgstat)) { 1740 if (lpfc_bgs_get_invalid_prof(bgstat)) {
1698 cmd->result = ScsiResult(DID_ERROR, 0); 1741 cmd->result = ScsiResult(DID_ERROR, 0);
1699 printk(KERN_ERR "Invalid BlockGuard profile. bgstat:0x%x\n", 1742 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9072 BLKGRD: Invalid"
1700 bgstat); 1743 " BlockGuard profile. bgstat:0x%x\n",
1744 bgstat);
1701 ret = (-1); 1745 ret = (-1);
1702 goto out; 1746 goto out;
1703 } 1747 }
1704 1748
1705 if (lpfc_bgs_get_uninit_dif_block(bgstat)) { 1749 if (lpfc_bgs_get_uninit_dif_block(bgstat)) {
1706 cmd->result = ScsiResult(DID_ERROR, 0); 1750 cmd->result = ScsiResult(DID_ERROR, 0);
1707 printk(KERN_ERR "Invalid BlockGuard DIF Block. bgstat:0x%x\n", 1751 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9073 BLKGRD: "
1752 "Invalid BlockGuard DIF Block. bgstat:0x%x\n",
1708 bgstat); 1753 bgstat);
1709 ret = (-1); 1754 ret = (-1);
1710 goto out; 1755 goto out;
@@ -1718,7 +1763,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1718 cmd->result = DRIVER_SENSE << 24 1763 cmd->result = DRIVER_SENSE << 24
1719 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION); 1764 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION);
1720 phba->bg_guard_err_cnt++; 1765 phba->bg_guard_err_cnt++;
1721 printk(KERN_ERR "BLKGRD: guard_tag error\n"); 1766 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1767 "9055 BLKGRD: guard_tag error\n");
1722 } 1768 }
1723 1769
1724 if (lpfc_bgs_get_reftag_err(bgstat)) { 1770 if (lpfc_bgs_get_reftag_err(bgstat)) {
@@ -1730,7 +1776,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1730 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION); 1776 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION);
1731 1777
1732 phba->bg_reftag_err_cnt++; 1778 phba->bg_reftag_err_cnt++;
1733 printk(KERN_ERR "BLKGRD: ref_tag error\n"); 1779 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1780 "9056 BLKGRD: ref_tag error\n");
1734 } 1781 }
1735 1782
1736 if (lpfc_bgs_get_apptag_err(bgstat)) { 1783 if (lpfc_bgs_get_apptag_err(bgstat)) {
@@ -1742,7 +1789,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1742 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION); 1789 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION);
1743 1790
1744 phba->bg_apptag_err_cnt++; 1791 phba->bg_apptag_err_cnt++;
1745 printk(KERN_ERR "BLKGRD: app_tag error\n"); 1792 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1793 "9061 BLKGRD: app_tag error\n");
1746 } 1794 }
1747 1795
1748 if (lpfc_bgs_get_hi_water_mark_present(bgstat)) { 1796 if (lpfc_bgs_get_hi_water_mark_present(bgstat)) {
@@ -1763,7 +1811,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1763 if (!ret) { 1811 if (!ret) {
1764 /* No error was reported - problem in FW? */ 1812 /* No error was reported - problem in FW? */
1765 cmd->result = ScsiResult(DID_ERROR, 0); 1813 cmd->result = ScsiResult(DID_ERROR, 0);
1766 printk(KERN_ERR "BLKGRD: no errors reported!\n"); 1814 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1815 "9057 BLKGRD: no errors reported!\n");
1767 } 1816 }
1768 1817
1769out: 1818out:
@@ -1822,9 +1871,10 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1822 1871
1823 lpfc_cmd->seg_cnt = nseg; 1872 lpfc_cmd->seg_cnt = nseg;
1824 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { 1873 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
1825 printk(KERN_ERR "%s: Too many sg segments from " 1874 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9074 BLKGRD:"
1826 "dma_map_sg. Config %d, seg_cnt %d\n", 1875 " %s: Too many sg segments from "
1827 __func__, phba->cfg_sg_seg_cnt, 1876 "dma_map_sg. Config %d, seg_cnt %d\n",
1877 __func__, phba->cfg_sg_seg_cnt,
1828 lpfc_cmd->seg_cnt); 1878 lpfc_cmd->seg_cnt);
1829 scsi_dma_unmap(scsi_cmnd); 1879 scsi_dma_unmap(scsi_cmnd);
1830 return 1; 1880 return 1;
@@ -1842,7 +1892,6 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1842 scsi_for_each_sg(scsi_cmnd, sgel, nseg, num_bde) { 1892 scsi_for_each_sg(scsi_cmnd, sgel, nseg, num_bde) {
1843 physaddr = sg_dma_address(sgel); 1893 physaddr = sg_dma_address(sgel);
1844 dma_len = sg_dma_len(sgel); 1894 dma_len = sg_dma_len(sgel);
1845 bf_set(lpfc_sli4_sge_len, sgl, sg_dma_len(sgel));
1846 sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr)); 1895 sgl->addr_lo = cpu_to_le32(putPaddrLow(physaddr));
1847 sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr)); 1896 sgl->addr_hi = cpu_to_le32(putPaddrHigh(physaddr));
1848 if ((num_bde + 1) == nseg) 1897 if ((num_bde + 1) == nseg)
@@ -1851,7 +1900,7 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1851 bf_set(lpfc_sli4_sge_last, sgl, 0); 1900 bf_set(lpfc_sli4_sge_last, sgl, 0);
1852 bf_set(lpfc_sli4_sge_offset, sgl, dma_offset); 1901 bf_set(lpfc_sli4_sge_offset, sgl, dma_offset);
1853 sgl->word2 = cpu_to_le32(sgl->word2); 1902 sgl->word2 = cpu_to_le32(sgl->word2);
1854 sgl->word3 = cpu_to_le32(sgl->word3); 1903 sgl->sge_len = cpu_to_le32(dma_len);
1855 dma_offset += dma_len; 1904 dma_offset += dma_len;
1856 sgl++; 1905 sgl++;
1857 } 1906 }
@@ -2050,6 +2099,31 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
2050 goto out; 2099 goto out;
2051 } 2100 }
2052 2101
2102 if (resp_info & RSP_LEN_VALID) {
2103 rsplen = be32_to_cpu(fcprsp->rspRspLen);
2104 if (rsplen != 0 && rsplen != 4 && rsplen != 8) {
2105 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
2106 "2719 Invalid response length: "
2107 "tgt x%x lun x%x cmnd x%x rsplen x%x\n",
2108 cmnd->device->id,
2109 cmnd->device->lun, cmnd->cmnd[0],
2110 rsplen);
2111 host_status = DID_ERROR;
2112 goto out;
2113 }
2114 if (fcprsp->rspInfo3 != RSP_NO_FAILURE) {
2115 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
2116 "2757 Protocol failure detected during "
2117 "processing of FCP I/O op: "
2118 "tgt x%x lun x%x cmnd x%x rspInfo3 x%x\n",
2119 cmnd->device->id,
2120 cmnd->device->lun, cmnd->cmnd[0],
2121 fcprsp->rspInfo3);
2122 host_status = DID_ERROR;
2123 goto out;
2124 }
2125 }
2126
2053 if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) { 2127 if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
2054 uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen); 2128 uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
2055 if (snslen > SCSI_SENSE_BUFFERSIZE) 2129 if (snslen > SCSI_SENSE_BUFFERSIZE)
@@ -2074,15 +2148,6 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
2074 be32_to_cpu(fcprsp->rspRspLen), 2148 be32_to_cpu(fcprsp->rspRspLen),
2075 fcprsp->rspInfo3); 2149 fcprsp->rspInfo3);
2076 2150
2077 if (resp_info & RSP_LEN_VALID) {
2078 rsplen = be32_to_cpu(fcprsp->rspRspLen);
2079 if ((rsplen != 0 && rsplen != 4 && rsplen != 8) ||
2080 (fcprsp->rspInfo3 != RSP_NO_FAILURE)) {
2081 host_status = DID_ERROR;
2082 goto out;
2083 }
2084 }
2085
2086 scsi_set_resid(cmnd, 0); 2151 scsi_set_resid(cmnd, 0);
2087 if (resp_info & RESID_UNDER) { 2152 if (resp_info & RESID_UNDER) {
2088 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId)); 2153 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId));
@@ -2180,7 +2245,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
2180 struct scsi_cmnd *cmd = lpfc_cmd->pCmd; 2245 struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
2181 int result; 2246 int result;
2182 struct scsi_device *tmp_sdev; 2247 struct scsi_device *tmp_sdev;
2183 int depth = 0; 2248 int depth;
2184 unsigned long flags; 2249 unsigned long flags;
2185 struct lpfc_fast_path_event *fast_path_evt; 2250 struct lpfc_fast_path_event *fast_path_evt;
2186 struct Scsi_Host *shost = cmd->device->host; 2251 struct Scsi_Host *shost = cmd->device->host;
@@ -2188,6 +2253,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
2188 2253
2189 lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; 2254 lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4];
2190 lpfc_cmd->status = pIocbOut->iocb.ulpStatus; 2255 lpfc_cmd->status = pIocbOut->iocb.ulpStatus;
2256 /* pick up SLI4 exhange busy status from HBA */
2257 lpfc_cmd->exch_busy = pIocbOut->iocb_flag & LPFC_EXCHANGE_BUSY;
2258
2191 if (pnode && NLP_CHK_NODE_ACT(pnode)) 2259 if (pnode && NLP_CHK_NODE_ACT(pnode))
2192 atomic_dec(&pnode->cmd_pending); 2260 atomic_dec(&pnode->cmd_pending);
2193 2261
@@ -2264,7 +2332,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
2264 lpfc_printf_vlog(vport, KERN_WARNING, 2332 lpfc_printf_vlog(vport, KERN_WARNING,
2265 LOG_BG, 2333 LOG_BG,
2266 "9031 non-zero BGSTAT " 2334 "9031 non-zero BGSTAT "
2267 "on unprotected cmd"); 2335 "on unprotected cmd\n");
2268 } 2336 }
2269 } 2337 }
2270 2338
@@ -2347,67 +2415,29 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
2347 return; 2415 return;
2348 } 2416 }
2349 2417
2350
2351 if (!result) 2418 if (!result)
2352 lpfc_rampup_queue_depth(vport, queue_depth); 2419 lpfc_rampup_queue_depth(vport, queue_depth);
2353 2420
2354 if (!result && pnode && NLP_CHK_NODE_ACT(pnode) &&
2355 ((jiffies - pnode->last_ramp_up_time) >
2356 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
2357 ((jiffies - pnode->last_q_full_time) >
2358 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
2359 (vport->cfg_lun_queue_depth > queue_depth)) {
2360 shost_for_each_device(tmp_sdev, shost) {
2361 if (vport->cfg_lun_queue_depth > tmp_sdev->queue_depth){
2362 if (tmp_sdev->id != scsi_id)
2363 continue;
2364 if (tmp_sdev->ordered_tags)
2365 scsi_adjust_queue_depth(tmp_sdev,
2366 MSG_ORDERED_TAG,
2367 tmp_sdev->queue_depth+1);
2368 else
2369 scsi_adjust_queue_depth(tmp_sdev,
2370 MSG_SIMPLE_TAG,
2371 tmp_sdev->queue_depth+1);
2372
2373 pnode->last_ramp_up_time = jiffies;
2374 }
2375 }
2376 lpfc_send_sdev_queuedepth_change_event(phba, vport, pnode,
2377 0xFFFFFFFF,
2378 queue_depth , queue_depth + 1);
2379 }
2380
2381 /* 2421 /*
2382 * Check for queue full. If the lun is reporting queue full, then 2422 * Check for queue full. If the lun is reporting queue full, then
2383 * back off the lun queue depth to prevent target overloads. 2423 * back off the lun queue depth to prevent target overloads.
2384 */ 2424 */
2385 if (result == SAM_STAT_TASK_SET_FULL && pnode && 2425 if (result == SAM_STAT_TASK_SET_FULL && pnode &&
2386 NLP_CHK_NODE_ACT(pnode)) { 2426 NLP_CHK_NODE_ACT(pnode)) {
2387 pnode->last_q_full_time = jiffies;
2388
2389 shost_for_each_device(tmp_sdev, shost) { 2427 shost_for_each_device(tmp_sdev, shost) {
2390 if (tmp_sdev->id != scsi_id) 2428 if (tmp_sdev->id != scsi_id)
2391 continue; 2429 continue;
2392 depth = scsi_track_queue_full(tmp_sdev, 2430 depth = scsi_track_queue_full(tmp_sdev,
2393 tmp_sdev->queue_depth - 1); 2431 tmp_sdev->queue_depth-1);
2394 } 2432 if (depth <= 0)
2395 /* 2433 continue;
2396 * The queue depth cannot be lowered any more.
2397 * Modify the returned error code to store
2398 * the final depth value set by
2399 * scsi_track_queue_full.
2400 */
2401 if (depth == -1)
2402 depth = shost->cmd_per_lun;
2403
2404 if (depth) {
2405 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP, 2434 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
2406 "0711 detected queue full - lun queue " 2435 "0711 detected queue full - lun queue "
2407 "depth adjusted to %d.\n", depth); 2436 "depth adjusted to %d.\n", depth);
2408 lpfc_send_sdev_queuedepth_change_event(phba, vport, 2437 lpfc_send_sdev_queuedepth_change_event(phba, vport,
2409 pnode, 0xFFFFFFFF, 2438 pnode,
2410 depth+1, depth); 2439 tmp_sdev->lun,
2440 depth+1, depth);
2411 } 2441 }
2412 } 2442 }
2413 2443
@@ -2642,6 +2672,7 @@ lpfc_scsi_api_table_setup(struct lpfc_hba *phba, uint8_t dev_grp)
2642 } 2672 }
2643 phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf; 2673 phba->lpfc_get_scsi_buf = lpfc_get_scsi_buf;
2644 phba->lpfc_rampdown_queue_depth = lpfc_rampdown_queue_depth; 2674 phba->lpfc_rampdown_queue_depth = lpfc_rampdown_queue_depth;
2675 phba->lpfc_scsi_cmd_iocb_cmpl = lpfc_scsi_cmd_iocb_cmpl;
2645 return 0; 2676 return 0;
2646} 2677}
2647 2678
@@ -2700,6 +2731,13 @@ lpfc_info(struct Scsi_Host *host)
2700 " port %s", 2731 " port %s",
2701 phba->Port); 2732 phba->Port);
2702 } 2733 }
2734 len = strlen(lpfcinfobuf);
2735 if (phba->sli4_hba.link_state.logical_speed) {
2736 snprintf(lpfcinfobuf + len,
2737 384-len,
2738 " Logical Link Speed: %d Mbps",
2739 phba->sli4_hba.link_state.logical_speed * 10);
2740 }
2703 } 2741 }
2704 return lpfcinfobuf; 2742 return lpfcinfobuf;
2705} 2743}
@@ -2745,7 +2783,9 @@ void lpfc_poll_timeout(unsigned long ptr)
2745 struct lpfc_hba *phba = (struct lpfc_hba *) ptr; 2783 struct lpfc_hba *phba = (struct lpfc_hba *) ptr;
2746 2784
2747 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 2785 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
2748 lpfc_sli_poll_fcp_ring (phba); 2786 lpfc_sli_handle_fast_ring_event(phba,
2787 &phba->sli.ring[LPFC_FCP_RING], HA_R0RE_REQ);
2788
2749 if (phba->cfg_poll & DISABLE_FCP_RING_INT) 2789 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
2750 lpfc_poll_rearm_timer(phba); 2790 lpfc_poll_rearm_timer(phba);
2751 } 2791 }
@@ -2771,7 +2811,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2771 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 2811 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2772 struct lpfc_hba *phba = vport->phba; 2812 struct lpfc_hba *phba = vport->phba;
2773 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 2813 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
2774 struct lpfc_nodelist *ndlp = rdata->pnode; 2814 struct lpfc_nodelist *ndlp;
2775 struct lpfc_scsi_buf *lpfc_cmd; 2815 struct lpfc_scsi_buf *lpfc_cmd;
2776 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); 2816 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
2777 int err; 2817 int err;
@@ -2781,13 +2821,15 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2781 cmnd->result = err; 2821 cmnd->result = err;
2782 goto out_fail_command; 2822 goto out_fail_command;
2783 } 2823 }
2824 ndlp = rdata->pnode;
2784 2825
2785 if (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED) && 2826 if (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED) &&
2786 scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) { 2827 scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) {
2787 2828
2788 printk(KERN_ERR "BLKGRD ERROR: rcvd protected cmd:%02x op:%02x " 2829 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
2789 "str=%s without registering for BlockGuard - " 2830 "9058 BLKGRD: ERROR: rcvd protected cmd:%02x"
2790 "Rejecting command\n", 2831 " op:%02x str=%s without registering for"
2832 " BlockGuard - Rejecting command\n",
2791 cmnd->cmnd[0], scsi_get_prot_op(cmnd), 2833 cmnd->cmnd[0], scsi_get_prot_op(cmnd),
2792 dif_op_str[scsi_get_prot_op(cmnd)]); 2834 dif_op_str[scsi_get_prot_op(cmnd)]);
2793 goto out_fail_command; 2835 goto out_fail_command;
@@ -2827,61 +2869,66 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2827 cmnd->scsi_done = done; 2869 cmnd->scsi_done = done;
2828 2870
2829 if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) { 2871 if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) {
2830 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2872 if (vport->phba->cfg_enable_bg) {
2873 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2831 "9033 BLKGRD: rcvd protected cmd:%02x op:%02x " 2874 "9033 BLKGRD: rcvd protected cmd:%02x op:%02x "
2832 "str=%s\n", 2875 "str=%s\n",
2833 cmnd->cmnd[0], scsi_get_prot_op(cmnd), 2876 cmnd->cmnd[0], scsi_get_prot_op(cmnd),
2834 dif_op_str[scsi_get_prot_op(cmnd)]); 2877 dif_op_str[scsi_get_prot_op(cmnd)]);
2835 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2878 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2836 "9034 BLKGRD: CDB: %02x %02x %02x %02x %02x " 2879 "9034 BLKGRD: CDB: %02x %02x %02x %02x %02x "
2837 "%02x %02x %02x %02x %02x\n", 2880 "%02x %02x %02x %02x %02x\n",
2838 cmnd->cmnd[0], cmnd->cmnd[1], cmnd->cmnd[2], 2881 cmnd->cmnd[0], cmnd->cmnd[1], cmnd->cmnd[2],
2839 cmnd->cmnd[3], cmnd->cmnd[4], cmnd->cmnd[5], 2882 cmnd->cmnd[3], cmnd->cmnd[4], cmnd->cmnd[5],
2840 cmnd->cmnd[6], cmnd->cmnd[7], cmnd->cmnd[8], 2883 cmnd->cmnd[6], cmnd->cmnd[7], cmnd->cmnd[8],
2841 cmnd->cmnd[9]); 2884 cmnd->cmnd[9]);
2842 if (cmnd->cmnd[0] == READ_10) 2885 if (cmnd->cmnd[0] == READ_10)
2843 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2886 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2844 "9035 BLKGRD: READ @ sector %llu, " 2887 "9035 BLKGRD: READ @ sector %llu, "
2845 "count %u\n", 2888 "count %u\n",
2846 (unsigned long long)scsi_get_lba(cmnd), 2889 (unsigned long long)scsi_get_lba(cmnd),
2847 blk_rq_sectors(cmnd->request)); 2890 blk_rq_sectors(cmnd->request));
2848 else if (cmnd->cmnd[0] == WRITE_10) 2891 else if (cmnd->cmnd[0] == WRITE_10)
2849 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2892 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2850 "9036 BLKGRD: WRITE @ sector %llu, " 2893 "9036 BLKGRD: WRITE @ sector %llu, "
2851 "count %u cmd=%p\n", 2894 "count %u cmd=%p\n",
2852 (unsigned long long)scsi_get_lba(cmnd), 2895 (unsigned long long)scsi_get_lba(cmnd),
2853 blk_rq_sectors(cmnd->request), 2896 blk_rq_sectors(cmnd->request),
2854 cmnd); 2897 cmnd);
2898 }
2855 2899
2856 err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd); 2900 err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd);
2857 } else { 2901 } else {
2858 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2902 if (vport->phba->cfg_enable_bg) {
2859 "9038 BLKGRD: rcvd unprotected cmd:%02x op:%02x"
2860 " str=%s\n",
2861 cmnd->cmnd[0], scsi_get_prot_op(cmnd),
2862 dif_op_str[scsi_get_prot_op(cmnd)]);
2863 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2864 "9039 BLKGRD: CDB: %02x %02x %02x %02x %02x "
2865 "%02x %02x %02x %02x %02x\n",
2866 cmnd->cmnd[0], cmnd->cmnd[1], cmnd->cmnd[2],
2867 cmnd->cmnd[3], cmnd->cmnd[4], cmnd->cmnd[5],
2868 cmnd->cmnd[6], cmnd->cmnd[7], cmnd->cmnd[8],
2869 cmnd->cmnd[9]);
2870 if (cmnd->cmnd[0] == READ_10)
2871 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2903 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2872 "9040 dbg: READ @ sector %llu, " 2904 "9038 BLKGRD: rcvd unprotected cmd:"
2873 "count %u\n", 2905 "%02x op:%02x str=%s\n",
2874 (unsigned long long)scsi_get_lba(cmnd), 2906 cmnd->cmnd[0], scsi_get_prot_op(cmnd),
2907 dif_op_str[scsi_get_prot_op(cmnd)]);
2908 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2909 "9039 BLKGRD: CDB: %02x %02x %02x "
2910 "%02x %02x %02x %02x %02x %02x %02x\n",
2911 cmnd->cmnd[0], cmnd->cmnd[1],
2912 cmnd->cmnd[2], cmnd->cmnd[3],
2913 cmnd->cmnd[4], cmnd->cmnd[5],
2914 cmnd->cmnd[6], cmnd->cmnd[7],
2915 cmnd->cmnd[8], cmnd->cmnd[9]);
2916 if (cmnd->cmnd[0] == READ_10)
2917 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2918 "9040 dbg: READ @ sector %llu, "
2919 "count %u\n",
2920 (unsigned long long)scsi_get_lba(cmnd),
2875 blk_rq_sectors(cmnd->request)); 2921 blk_rq_sectors(cmnd->request));
2876 else if (cmnd->cmnd[0] == WRITE_10) 2922 else if (cmnd->cmnd[0] == WRITE_10)
2877 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2923 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2878 "9041 dbg: WRITE @ sector %llu, " 2924 "9041 dbg: WRITE @ sector %llu, "
2879 "count %u cmd=%p\n", 2925 "count %u cmd=%p\n",
2880 (unsigned long long)scsi_get_lba(cmnd), 2926 (unsigned long long)scsi_get_lba(cmnd),
2881 blk_rq_sectors(cmnd->request), cmnd); 2927 blk_rq_sectors(cmnd->request), cmnd);
2882 else 2928 else
2883 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2929 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2884 "9042 dbg: parser not implemented\n"); 2930 "9042 dbg: parser not implemented\n");
2931 }
2885 err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd); 2932 err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
2886 } 2933 }
2887 2934
@@ -2898,7 +2945,11 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2898 goto out_host_busy_free_buf; 2945 goto out_host_busy_free_buf;
2899 } 2946 }
2900 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 2947 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
2901 lpfc_sli_poll_fcp_ring(phba); 2948 spin_unlock(shost->host_lock);
2949 lpfc_sli_handle_fast_ring_event(phba,
2950 &phba->sli.ring[LPFC_FCP_RING], HA_R0RE_REQ);
2951
2952 spin_lock(shost->host_lock);
2902 if (phba->cfg_poll & DISABLE_FCP_RING_INT) 2953 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
2903 lpfc_poll_rearm_timer(phba); 2954 lpfc_poll_rearm_timer(phba);
2904 } 2955 }
@@ -2917,28 +2968,6 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2917} 2968}
2918 2969
2919/** 2970/**
2920 * lpfc_block_error_handler - Routine to block error handler
2921 * @cmnd: Pointer to scsi_cmnd data structure.
2922 *
2923 * This routine blocks execution till fc_rport state is not FC_PORSTAT_BLCOEKD.
2924 **/
2925static void
2926lpfc_block_error_handler(struct scsi_cmnd *cmnd)
2927{
2928 struct Scsi_Host *shost = cmnd->device->host;
2929 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
2930
2931 spin_lock_irq(shost->host_lock);
2932 while (rport->port_state == FC_PORTSTATE_BLOCKED) {
2933 spin_unlock_irq(shost->host_lock);
2934 msleep(1000);
2935 spin_lock_irq(shost->host_lock);
2936 }
2937 spin_unlock_irq(shost->host_lock);
2938 return;
2939}
2940
2941/**
2942 * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point 2971 * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point
2943 * @cmnd: Pointer to scsi_cmnd data structure. 2972 * @cmnd: Pointer to scsi_cmnd data structure.
2944 * 2973 *
@@ -2961,7 +2990,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
2961 int ret = SUCCESS; 2990 int ret = SUCCESS;
2962 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq); 2991 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq);
2963 2992
2964 lpfc_block_error_handler(cmnd); 2993 fc_block_scsi_eh(cmnd);
2965 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; 2994 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble;
2966 BUG_ON(!lpfc_cmd); 2995 BUG_ON(!lpfc_cmd);
2967 2996
@@ -3001,6 +3030,11 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
3001 3030
3002 icmd->ulpLe = 1; 3031 icmd->ulpLe = 1;
3003 icmd->ulpClass = cmd->ulpClass; 3032 icmd->ulpClass = cmd->ulpClass;
3033
3034 /* ABTS WQE must go to the same WQ as the WQE to be aborted */
3035 abtsiocb->fcp_wqidx = iocb->fcp_wqidx;
3036 abtsiocb->iocb_flag |= LPFC_USE_FCPWQIDX;
3037
3004 if (lpfc_is_link_up(phba)) 3038 if (lpfc_is_link_up(phba))
3005 icmd->ulpCommand = CMD_ABORT_XRI_CN; 3039 icmd->ulpCommand = CMD_ABORT_XRI_CN;
3006 else 3040 else
@@ -3016,7 +3050,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
3016 } 3050 }
3017 3051
3018 if (phba->cfg_poll & DISABLE_FCP_RING_INT) 3052 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
3019 lpfc_sli_poll_fcp_ring (phba); 3053 lpfc_sli_handle_fast_ring_event(phba,
3054 &phba->sli.ring[LPFC_FCP_RING], HA_R0RE_REQ);
3020 3055
3021 lpfc_cmd->waitq = &waitq; 3056 lpfc_cmd->waitq = &waitq;
3022 /* Wait for abort to complete */ 3057 /* Wait for abort to complete */
@@ -3166,9 +3201,15 @@ static int
3166lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd) 3201lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd)
3167{ 3202{
3168 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 3203 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
3169 struct lpfc_nodelist *pnode = rdata->pnode; 3204 struct lpfc_nodelist *pnode;
3170 unsigned long later; 3205 unsigned long later;
3171 3206
3207 if (!rdata) {
3208 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
3209 "0797 Tgt Map rport failure: rdata x%p\n", rdata);
3210 return FAILED;
3211 }
3212 pnode = rdata->pnode;
3172 /* 3213 /*
3173 * If target is not in a MAPPED state, delay until 3214 * If target is not in a MAPPED state, delay until
3174 * target is rediscovered or devloss timeout expires. 3215 * target is rediscovered or devloss timeout expires.
@@ -3253,13 +3294,19 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
3253 struct Scsi_Host *shost = cmnd->device->host; 3294 struct Scsi_Host *shost = cmnd->device->host;
3254 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 3295 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3255 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 3296 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
3256 struct lpfc_nodelist *pnode = rdata->pnode; 3297 struct lpfc_nodelist *pnode;
3257 unsigned tgt_id = cmnd->device->id; 3298 unsigned tgt_id = cmnd->device->id;
3258 unsigned int lun_id = cmnd->device->lun; 3299 unsigned int lun_id = cmnd->device->lun;
3259 struct lpfc_scsi_event_header scsi_event; 3300 struct lpfc_scsi_event_header scsi_event;
3260 int status; 3301 int status;
3261 3302
3262 lpfc_block_error_handler(cmnd); 3303 if (!rdata) {
3304 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
3305 "0798 Device Reset rport failure: rdata x%p\n", rdata);
3306 return FAILED;
3307 }
3308 pnode = rdata->pnode;
3309 fc_block_scsi_eh(cmnd);
3263 3310
3264 status = lpfc_chk_tgt_mapped(vport, cmnd); 3311 status = lpfc_chk_tgt_mapped(vport, cmnd);
3265 if (status == FAILED) { 3312 if (status == FAILED) {
@@ -3312,13 +3359,19 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
3312 struct Scsi_Host *shost = cmnd->device->host; 3359 struct Scsi_Host *shost = cmnd->device->host;
3313 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 3360 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3314 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 3361 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
3315 struct lpfc_nodelist *pnode = rdata->pnode; 3362 struct lpfc_nodelist *pnode;
3316 unsigned tgt_id = cmnd->device->id; 3363 unsigned tgt_id = cmnd->device->id;
3317 unsigned int lun_id = cmnd->device->lun; 3364 unsigned int lun_id = cmnd->device->lun;
3318 struct lpfc_scsi_event_header scsi_event; 3365 struct lpfc_scsi_event_header scsi_event;
3319 int status; 3366 int status;
3320 3367
3321 lpfc_block_error_handler(cmnd); 3368 if (!rdata) {
3369 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
3370 "0799 Target Reset rport failure: rdata x%p\n", rdata);
3371 return FAILED;
3372 }
3373 pnode = rdata->pnode;
3374 fc_block_scsi_eh(cmnd);
3322 3375
3323 status = lpfc_chk_tgt_mapped(vport, cmnd); 3376 status = lpfc_chk_tgt_mapped(vport, cmnd);
3324 if (status == FAILED) { 3377 if (status == FAILED) {
@@ -3384,7 +3437,7 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
3384 fc_host_post_vendor_event(shost, fc_get_event_number(), 3437 fc_host_post_vendor_event(shost, fc_get_event_number(),
3385 sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID); 3438 sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID);
3386 3439
3387 lpfc_block_error_handler(cmnd); 3440 fc_block_scsi_eh(cmnd);
3388 3441
3389 /* 3442 /*
3390 * Since the driver manages a single bus device, reset all 3443 * Since the driver manages a single bus device, reset all
@@ -3498,6 +3551,8 @@ lpfc_slave_alloc(struct scsi_device *sdev)
3498 "Allocated %d buffers.\n", 3551 "Allocated %d buffers.\n",
3499 num_to_alloc, num_allocated); 3552 num_to_alloc, num_allocated);
3500 } 3553 }
3554 if (num_allocated > 0)
3555 phba->total_scsi_bufs += num_allocated;
3501 return 0; 3556 return 0;
3502} 3557}
3503 3558
@@ -3534,7 +3589,8 @@ lpfc_slave_configure(struct scsi_device *sdev)
3534 rport->dev_loss_tmo = vport->cfg_devloss_tmo; 3589 rport->dev_loss_tmo = vport->cfg_devloss_tmo;
3535 3590
3536 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 3591 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
3537 lpfc_sli_poll_fcp_ring(phba); 3592 lpfc_sli_handle_fast_ring_event(phba,
3593 &phba->sli.ring[LPFC_FCP_RING], HA_R0RE_REQ);
3538 if (phba->cfg_poll & DISABLE_FCP_RING_INT) 3594 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
3539 lpfc_poll_rearm_timer(phba); 3595 lpfc_poll_rearm_timer(phba);
3540 } 3596 }
@@ -3576,6 +3632,7 @@ struct scsi_host_template lpfc_template = {
3576 .shost_attrs = lpfc_hba_attrs, 3632 .shost_attrs = lpfc_hba_attrs,
3577 .max_sectors = 0xFFFF, 3633 .max_sectors = 0xFFFF,
3578 .vendor_id = LPFC_NL_VENDOR_ID, 3634 .vendor_id = LPFC_NL_VENDOR_ID,
3635 .change_queue_depth = lpfc_change_queue_depth,
3579}; 3636};
3580 3637
3581struct scsi_host_template lpfc_vport_template = { 3638struct scsi_host_template lpfc_vport_template = {
@@ -3597,4 +3654,5 @@ struct scsi_host_template lpfc_vport_template = {
3597 .use_clustering = ENABLE_CLUSTERING, 3654 .use_clustering = ENABLE_CLUSTERING,
3598 .shost_attrs = lpfc_vport_attrs, 3655 .shost_attrs = lpfc_vport_attrs,
3599 .max_sectors = 0xFFFF, 3656 .max_sectors = 0xFFFF,
3657 .change_queue_depth = lpfc_change_queue_depth,
3600}; 3658};