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.c394
1 files changed, 204 insertions, 190 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index c88f59f0ce3..a246410ce9d 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -59,22 +59,26 @@ static char *dif_op_str[] = {
59}; 59};
60static void 60static void
61lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb); 61lpfc_release_scsi_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb);
62static void
63lpfc_release_scsi_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *psb);
62 64
63static void 65static void
64lpfc_debug_save_data(struct scsi_cmnd *cmnd) 66lpfc_debug_save_data(struct lpfc_hba *phba, struct scsi_cmnd *cmnd)
65{ 67{
66 void *src, *dst; 68 void *src, *dst;
67 struct scatterlist *sgde = scsi_sglist(cmnd); 69 struct scatterlist *sgde = scsi_sglist(cmnd);
68 70
69 if (!_dump_buf_data) { 71 if (!_dump_buf_data) {
70 printk(KERN_ERR "BLKGRD ERROR %s _dump_buf_data is NULL\n", 72 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
73 "9050 BLKGRD: ERROR %s _dump_buf_data is NULL\n",
71 __func__); 74 __func__);
72 return; 75 return;
73 } 76 }
74 77
75 78
76 if (!sgde) { 79 if (!sgde) {
77 printk(KERN_ERR "BLKGRD ERROR: data scatterlist is null\n"); 80 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
81 "9051 BLKGRD: ERROR: data scatterlist is null\n");
78 return; 82 return;
79 } 83 }
80 84
@@ -88,19 +92,21 @@ lpfc_debug_save_data(struct scsi_cmnd *cmnd)
88} 92}
89 93
90static void 94static void
91lpfc_debug_save_dif(struct scsi_cmnd *cmnd) 95lpfc_debug_save_dif(struct lpfc_hba *phba, struct scsi_cmnd *cmnd)
92{ 96{
93 void *src, *dst; 97 void *src, *dst;
94 struct scatterlist *sgde = scsi_prot_sglist(cmnd); 98 struct scatterlist *sgde = scsi_prot_sglist(cmnd);
95 99
96 if (!_dump_buf_dif) { 100 if (!_dump_buf_dif) {
97 printk(KERN_ERR "BLKGRD ERROR %s _dump_buf_data is NULL\n", 101 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
102 "9052 BLKGRD: ERROR %s _dump_buf_data is NULL\n",
98 __func__); 103 __func__);
99 return; 104 return;
100 } 105 }
101 106
102 if (!sgde) { 107 if (!sgde) {
103 printk(KERN_ERR "BLKGRD ERROR: prot scatterlist is null\n"); 108 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
109 "9053 BLKGRD: ERROR: prot scatterlist is null\n");
104 return; 110 return;
105 } 111 }
106 112
@@ -242,6 +248,36 @@ lpfc_send_sdev_queuedepth_change_event(struct lpfc_hba *phba,
242} 248}
243 249
244/** 250/**
251 * lpfc_change_queue_depth - Alter scsi device queue depth
252 * @sdev: Pointer the scsi device on which to change the queue depth.
253 * @qdepth: New queue depth to set the sdev to.
254 * @reason: The reason for the queue depth change.
255 *
256 * This function is called by the midlayer and the LLD to alter the queue
257 * depth for a scsi device. This function sets the queue depth to the new
258 * value and sends an event out to log the queue depth change.
259 **/
260int
261lpfc_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
262{
263 struct lpfc_vport *vport = (struct lpfc_vport *) sdev->host->hostdata;
264 struct lpfc_hba *phba = vport->phba;
265 struct lpfc_rport_data *rdata;
266 unsigned long new_queue_depth, old_queue_depth;
267
268 old_queue_depth = sdev->queue_depth;
269 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
270 new_queue_depth = sdev->queue_depth;
271 rdata = sdev->hostdata;
272 if (rdata)
273 lpfc_send_sdev_queuedepth_change_event(phba, vport,
274 rdata->pnode, sdev->lun,
275 old_queue_depth,
276 new_queue_depth);
277 return sdev->queue_depth;
278}
279
280/**
245 * lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread 281 * lpfc_rampdown_queue_depth - Post RAMP_DOWN_QUEUE event to worker thread
246 * @phba: The Hba for which this call is being executed. 282 * @phba: The Hba for which this call is being executed.
247 * 283 *
@@ -305,8 +341,10 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
305 if (vport->cfg_lun_queue_depth <= queue_depth) 341 if (vport->cfg_lun_queue_depth <= queue_depth)
306 return; 342 return;
307 spin_lock_irqsave(&phba->hbalock, flags); 343 spin_lock_irqsave(&phba->hbalock, flags);
308 if (((phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) > jiffies) || 344 if (time_before(jiffies,
309 ((phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL ) > jiffies)) { 345 phba->last_ramp_up_time + QUEUE_RAMP_UP_INTERVAL) ||
346 time_before(jiffies,
347 phba->last_rsrc_error_time + QUEUE_RAMP_UP_INTERVAL)) {
310 spin_unlock_irqrestore(&phba->hbalock, flags); 348 spin_unlock_irqrestore(&phba->hbalock, flags);
311 return; 349 return;
312 } 350 }
@@ -338,10 +376,9 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
338 struct lpfc_vport **vports; 376 struct lpfc_vport **vports;
339 struct Scsi_Host *shost; 377 struct Scsi_Host *shost;
340 struct scsi_device *sdev; 378 struct scsi_device *sdev;
341 unsigned long new_queue_depth, old_queue_depth; 379 unsigned long new_queue_depth;
342 unsigned long num_rsrc_err, num_cmd_success; 380 unsigned long num_rsrc_err, num_cmd_success;
343 int i; 381 int i;
344 struct lpfc_rport_data *rdata;
345 382
346 num_rsrc_err = atomic_read(&phba->num_rsrc_err); 383 num_rsrc_err = atomic_read(&phba->num_rsrc_err);
347 num_cmd_success = atomic_read(&phba->num_cmd_success); 384 num_cmd_success = atomic_read(&phba->num_cmd_success);
@@ -359,22 +396,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
359 else 396 else
360 new_queue_depth = sdev->queue_depth - 397 new_queue_depth = sdev->queue_depth -
361 new_queue_depth; 398 new_queue_depth;
362 old_queue_depth = sdev->queue_depth; 399 lpfc_change_queue_depth(sdev, new_queue_depth,
363 if (sdev->ordered_tags) 400 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 } 401 }
379 } 402 }
380 lpfc_destroy_vport_work_array(phba, vports); 403 lpfc_destroy_vport_work_array(phba, vports);
@@ -398,7 +421,6 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
398 struct Scsi_Host *shost; 421 struct Scsi_Host *shost;
399 struct scsi_device *sdev; 422 struct scsi_device *sdev;
400 int i; 423 int i;
401 struct lpfc_rport_data *rdata;
402 424
403 vports = lpfc_create_vport_work_array(phba); 425 vports = lpfc_create_vport_work_array(phba);
404 if (vports != NULL) 426 if (vports != NULL)
@@ -408,22 +430,9 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
408 if (vports[i]->cfg_lun_queue_depth <= 430 if (vports[i]->cfg_lun_queue_depth <=
409 sdev->queue_depth) 431 sdev->queue_depth)
410 continue; 432 continue;
411 if (sdev->ordered_tags) 433 lpfc_change_queue_depth(sdev,
412 scsi_adjust_queue_depth(sdev, 434 sdev->queue_depth+1,
413 MSG_ORDERED_TAG, 435 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 } 436 }
428 } 437 }
429 lpfc_destroy_vport_work_array(phba, vports); 438 lpfc_destroy_vport_work_array(phba, vports);
@@ -589,7 +598,7 @@ lpfc_new_scsi_buf_s3(struct lpfc_vport *vport, int num_to_alloc)
589 iocb->ulpClass = CLASS3; 598 iocb->ulpClass = CLASS3;
590 psb->status = IOSTAT_SUCCESS; 599 psb->status = IOSTAT_SUCCESS;
591 /* Put it back into the SCSI buffer list */ 600 /* Put it back into the SCSI buffer list */
592 lpfc_release_scsi_buf_s4(phba, psb); 601 lpfc_release_scsi_buf_s3(phba, psb);
593 602
594 } 603 }
595 604
@@ -1024,7 +1033,8 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1024 1033
1025 lpfc_cmd->seg_cnt = nseg; 1034 lpfc_cmd->seg_cnt = nseg;
1026 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { 1035 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
1027 printk(KERN_ERR "%s: Too many sg segments from " 1036 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1037 "9064 BLKGRD: %s: Too many sg segments from "
1028 "dma_map_sg. Config %d, seg_cnt %d\n", 1038 "dma_map_sg. Config %d, seg_cnt %d\n",
1029 __func__, phba->cfg_sg_seg_cnt, 1039 __func__, phba->cfg_sg_seg_cnt,
1030 lpfc_cmd->seg_cnt); 1040 lpfc_cmd->seg_cnt);
@@ -1112,7 +1122,7 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1112 * with the cmd 1122 * with the cmd
1113 */ 1123 */
1114static int 1124static int
1115lpfc_sc_to_sli_prof(struct scsi_cmnd *sc) 1125lpfc_sc_to_sli_prof(struct lpfc_hba *phba, struct scsi_cmnd *sc)
1116{ 1126{
1117 uint8_t guard_type = scsi_host_get_guard(sc->device->host); 1127 uint8_t guard_type = scsi_host_get_guard(sc->device->host);
1118 uint8_t ret_prof = LPFC_PROF_INVALID; 1128 uint8_t ret_prof = LPFC_PROF_INVALID;
@@ -1136,7 +1146,8 @@ lpfc_sc_to_sli_prof(struct scsi_cmnd *sc)
1136 1146
1137 case SCSI_PROT_NORMAL: 1147 case SCSI_PROT_NORMAL:
1138 default: 1148 default:
1139 printk(KERN_ERR "Bad op/guard:%d/%d combination\n", 1149 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1150 "9063 BLKGRD:Bad op/guard:%d/%d combination\n",
1140 scsi_get_prot_op(sc), guard_type); 1151 scsi_get_prot_op(sc), guard_type);
1141 break; 1152 break;
1142 1153
@@ -1157,7 +1168,8 @@ lpfc_sc_to_sli_prof(struct scsi_cmnd *sc)
1157 case SCSI_PROT_WRITE_STRIP: 1168 case SCSI_PROT_WRITE_STRIP:
1158 case SCSI_PROT_NORMAL: 1169 case SCSI_PROT_NORMAL:
1159 default: 1170 default:
1160 printk(KERN_ERR "Bad op/guard:%d/%d combination\n", 1171 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1172 "9075 BLKGRD: Bad op/guard:%d/%d combination\n",
1161 scsi_get_prot_op(sc), guard_type); 1173 scsi_get_prot_op(sc), guard_type);
1162 break; 1174 break;
1163 } 1175 }
@@ -1259,7 +1271,7 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1259 uint16_t apptagmask, apptagval; 1271 uint16_t apptagmask, apptagval;
1260 1272
1261 pde1 = (struct lpfc_pde *) bpl; 1273 pde1 = (struct lpfc_pde *) bpl;
1262 prof = lpfc_sc_to_sli_prof(sc); 1274 prof = lpfc_sc_to_sli_prof(phba, sc);
1263 1275
1264 if (prof == LPFC_PROF_INVALID) 1276 if (prof == LPFC_PROF_INVALID)
1265 goto out; 1277 goto out;
@@ -1359,7 +1371,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1359 return 0; 1371 return 0;
1360 } 1372 }
1361 1373
1362 prof = lpfc_sc_to_sli_prof(sc); 1374 prof = lpfc_sc_to_sli_prof(phba, sc);
1363 if (prof == LPFC_PROF_INVALID) 1375 if (prof == LPFC_PROF_INVALID)
1364 goto out; 1376 goto out;
1365 1377
@@ -1408,7 +1420,8 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1408 subtotal = 0; /* total bytes processed for current prot grp */ 1420 subtotal = 0; /* total bytes processed for current prot grp */
1409 while (!pgdone) { 1421 while (!pgdone) {
1410 if (!sgde) { 1422 if (!sgde) {
1411 printk(KERN_ERR "%s Invalid data segment\n", 1423 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1424 "9065 BLKGRD:%s Invalid data segment\n",
1412 __func__); 1425 __func__);
1413 return 0; 1426 return 0;
1414 } 1427 }
@@ -1462,7 +1475,8 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1462 reftag += protgrp_blks; 1475 reftag += protgrp_blks;
1463 } else { 1476 } else {
1464 /* if we're here, we have a bug */ 1477 /* if we're here, we have a bug */
1465 printk(KERN_ERR "BLKGRD: bug in %s\n", __func__); 1478 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1479 "9054 BLKGRD: bug in %s\n", __func__);
1466 } 1480 }
1467 1481
1468 } while (!alldone); 1482 } while (!alldone);
@@ -1544,8 +1558,10 @@ lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba,
1544 1558
1545 lpfc_cmd->seg_cnt = datasegcnt; 1559 lpfc_cmd->seg_cnt = datasegcnt;
1546 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { 1560 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
1547 printk(KERN_ERR "%s: Too many sg segments from " 1561 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1548 "dma_map_sg. Config %d, seg_cnt %d\n", 1562 "9067 BLKGRD: %s: Too many sg segments"
1563 " from dma_map_sg. Config %d, seg_cnt"
1564 " %d\n",
1549 __func__, phba->cfg_sg_seg_cnt, 1565 __func__, phba->cfg_sg_seg_cnt,
1550 lpfc_cmd->seg_cnt); 1566 lpfc_cmd->seg_cnt);
1551 scsi_dma_unmap(scsi_cmnd); 1567 scsi_dma_unmap(scsi_cmnd);
@@ -1579,8 +1595,9 @@ lpfc_bg_scsi_prep_dma_buf(struct lpfc_hba *phba,
1579 lpfc_cmd->prot_seg_cnt = protsegcnt; 1595 lpfc_cmd->prot_seg_cnt = protsegcnt;
1580 if (lpfc_cmd->prot_seg_cnt 1596 if (lpfc_cmd->prot_seg_cnt
1581 > phba->cfg_prot_sg_seg_cnt) { 1597 > phba->cfg_prot_sg_seg_cnt) {
1582 printk(KERN_ERR "%s: Too many prot sg segments " 1598 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1583 "from dma_map_sg. Config %d," 1599 "9068 BLKGRD: %s: Too many prot sg "
1600 "segments from dma_map_sg. Config %d,"
1584 "prot_seg_cnt %d\n", __func__, 1601 "prot_seg_cnt %d\n", __func__,
1585 phba->cfg_prot_sg_seg_cnt, 1602 phba->cfg_prot_sg_seg_cnt,
1586 lpfc_cmd->prot_seg_cnt); 1603 lpfc_cmd->prot_seg_cnt);
@@ -1671,23 +1688,26 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1671 uint32_t bgstat = bgf->bgstat; 1688 uint32_t bgstat = bgf->bgstat;
1672 uint64_t failing_sector = 0; 1689 uint64_t failing_sector = 0;
1673 1690
1674 printk(KERN_ERR "BG ERROR in cmd 0x%x lba 0x%llx blk cnt 0x%x " 1691 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9069 BLKGRD: BG ERROR in cmd"
1692 " 0x%x lba 0x%llx blk cnt 0x%x "
1675 "bgstat=0x%x bghm=0x%x\n", 1693 "bgstat=0x%x bghm=0x%x\n",
1676 cmd->cmnd[0], (unsigned long long)scsi_get_lba(cmd), 1694 cmd->cmnd[0], (unsigned long long)scsi_get_lba(cmd),
1677 blk_rq_sectors(cmd->request), bgstat, bghm); 1695 blk_rq_sectors(cmd->request), bgstat, bghm);
1678 1696
1679 spin_lock(&_dump_buf_lock); 1697 spin_lock(&_dump_buf_lock);
1680 if (!_dump_buf_done) { 1698 if (!_dump_buf_done) {
1681 printk(KERN_ERR "Saving Data for %u blocks to debugfs\n", 1699 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9070 BLKGRD: Saving"
1700 " Data for %u blocks to debugfs\n",
1682 (cmd->cmnd[7] << 8 | cmd->cmnd[8])); 1701 (cmd->cmnd[7] << 8 | cmd->cmnd[8]));
1683 lpfc_debug_save_data(cmd); 1702 lpfc_debug_save_data(phba, cmd);
1684 1703
1685 /* If we have a prot sgl, save the DIF buffer */ 1704 /* If we have a prot sgl, save the DIF buffer */
1686 if (lpfc_prot_group_type(phba, cmd) == 1705 if (lpfc_prot_group_type(phba, cmd) ==
1687 LPFC_PG_TYPE_DIF_BUF) { 1706 LPFC_PG_TYPE_DIF_BUF) {
1688 printk(KERN_ERR "Saving DIF for %u blocks to debugfs\n", 1707 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9071 BLKGRD: "
1689 (cmd->cmnd[7] << 8 | cmd->cmnd[8])); 1708 "Saving DIF for %u blocks to debugfs\n",
1690 lpfc_debug_save_dif(cmd); 1709 (cmd->cmnd[7] << 8 | cmd->cmnd[8]));
1710 lpfc_debug_save_dif(phba, cmd);
1691 } 1711 }
1692 1712
1693 _dump_buf_done = 1; 1713 _dump_buf_done = 1;
@@ -1696,15 +1716,17 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1696 1716
1697 if (lpfc_bgs_get_invalid_prof(bgstat)) { 1717 if (lpfc_bgs_get_invalid_prof(bgstat)) {
1698 cmd->result = ScsiResult(DID_ERROR, 0); 1718 cmd->result = ScsiResult(DID_ERROR, 0);
1699 printk(KERN_ERR "Invalid BlockGuard profile. bgstat:0x%x\n", 1719 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9072 BLKGRD: Invalid"
1700 bgstat); 1720 " BlockGuard profile. bgstat:0x%x\n",
1721 bgstat);
1701 ret = (-1); 1722 ret = (-1);
1702 goto out; 1723 goto out;
1703 } 1724 }
1704 1725
1705 if (lpfc_bgs_get_uninit_dif_block(bgstat)) { 1726 if (lpfc_bgs_get_uninit_dif_block(bgstat)) {
1706 cmd->result = ScsiResult(DID_ERROR, 0); 1727 cmd->result = ScsiResult(DID_ERROR, 0);
1707 printk(KERN_ERR "Invalid BlockGuard DIF Block. bgstat:0x%x\n", 1728 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9073 BLKGRD: "
1729 "Invalid BlockGuard DIF Block. bgstat:0x%x\n",
1708 bgstat); 1730 bgstat);
1709 ret = (-1); 1731 ret = (-1);
1710 goto out; 1732 goto out;
@@ -1718,7 +1740,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1718 cmd->result = DRIVER_SENSE << 24 1740 cmd->result = DRIVER_SENSE << 24
1719 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION); 1741 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION);
1720 phba->bg_guard_err_cnt++; 1742 phba->bg_guard_err_cnt++;
1721 printk(KERN_ERR "BLKGRD: guard_tag error\n"); 1743 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1744 "9055 BLKGRD: guard_tag error\n");
1722 } 1745 }
1723 1746
1724 if (lpfc_bgs_get_reftag_err(bgstat)) { 1747 if (lpfc_bgs_get_reftag_err(bgstat)) {
@@ -1730,7 +1753,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1730 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION); 1753 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION);
1731 1754
1732 phba->bg_reftag_err_cnt++; 1755 phba->bg_reftag_err_cnt++;
1733 printk(KERN_ERR "BLKGRD: ref_tag error\n"); 1756 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1757 "9056 BLKGRD: ref_tag error\n");
1734 } 1758 }
1735 1759
1736 if (lpfc_bgs_get_apptag_err(bgstat)) { 1760 if (lpfc_bgs_get_apptag_err(bgstat)) {
@@ -1742,7 +1766,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1742 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION); 1766 | ScsiResult(DID_ABORT, SAM_STAT_CHECK_CONDITION);
1743 1767
1744 phba->bg_apptag_err_cnt++; 1768 phba->bg_apptag_err_cnt++;
1745 printk(KERN_ERR "BLKGRD: app_tag error\n"); 1769 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1770 "9061 BLKGRD: app_tag error\n");
1746 } 1771 }
1747 1772
1748 if (lpfc_bgs_get_hi_water_mark_present(bgstat)) { 1773 if (lpfc_bgs_get_hi_water_mark_present(bgstat)) {
@@ -1763,7 +1788,8 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
1763 if (!ret) { 1788 if (!ret) {
1764 /* No error was reported - problem in FW? */ 1789 /* No error was reported - problem in FW? */
1765 cmd->result = ScsiResult(DID_ERROR, 0); 1790 cmd->result = ScsiResult(DID_ERROR, 0);
1766 printk(KERN_ERR "BLKGRD: no errors reported!\n"); 1791 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1792 "9057 BLKGRD: no errors reported!\n");
1767 } 1793 }
1768 1794
1769out: 1795out:
@@ -1822,9 +1848,10 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1822 1848
1823 lpfc_cmd->seg_cnt = nseg; 1849 lpfc_cmd->seg_cnt = nseg;
1824 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) { 1850 if (lpfc_cmd->seg_cnt > phba->cfg_sg_seg_cnt) {
1825 printk(KERN_ERR "%s: Too many sg segments from " 1851 lpfc_printf_log(phba, KERN_ERR, LOG_BG, "9074 BLKGRD:"
1826 "dma_map_sg. Config %d, seg_cnt %d\n", 1852 " %s: Too many sg segments from "
1827 __func__, phba->cfg_sg_seg_cnt, 1853 "dma_map_sg. Config %d, seg_cnt %d\n",
1854 __func__, phba->cfg_sg_seg_cnt,
1828 lpfc_cmd->seg_cnt); 1855 lpfc_cmd->seg_cnt);
1829 scsi_dma_unmap(scsi_cmnd); 1856 scsi_dma_unmap(scsi_cmnd);
1830 return 1; 1857 return 1;
@@ -2050,6 +2077,21 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
2050 goto out; 2077 goto out;
2051 } 2078 }
2052 2079
2080 if (resp_info & RSP_LEN_VALID) {
2081 rsplen = be32_to_cpu(fcprsp->rspRspLen);
2082 if ((rsplen != 0 && rsplen != 4 && rsplen != 8) ||
2083 (fcprsp->rspInfo3 != RSP_NO_FAILURE)) {
2084 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
2085 "2719 Invalid response length: "
2086 "tgt x%x lun x%x cmnd x%x rsplen x%x\n",
2087 cmnd->device->id,
2088 cmnd->device->lun, cmnd->cmnd[0],
2089 rsplen);
2090 host_status = DID_ERROR;
2091 goto out;
2092 }
2093 }
2094
2053 if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) { 2095 if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
2054 uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen); 2096 uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
2055 if (snslen > SCSI_SENSE_BUFFERSIZE) 2097 if (snslen > SCSI_SENSE_BUFFERSIZE)
@@ -2074,15 +2116,6 @@ lpfc_handle_fcp_err(struct lpfc_vport *vport, struct lpfc_scsi_buf *lpfc_cmd,
2074 be32_to_cpu(fcprsp->rspRspLen), 2116 be32_to_cpu(fcprsp->rspRspLen),
2075 fcprsp->rspInfo3); 2117 fcprsp->rspInfo3);
2076 2118
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); 2119 scsi_set_resid(cmnd, 0);
2087 if (resp_info & RESID_UNDER) { 2120 if (resp_info & RESID_UNDER) {
2088 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId)); 2121 scsi_set_resid(cmnd, be32_to_cpu(fcprsp->rspResId));
@@ -2180,7 +2213,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
2180 struct scsi_cmnd *cmd = lpfc_cmd->pCmd; 2213 struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
2181 int result; 2214 int result;
2182 struct scsi_device *tmp_sdev; 2215 struct scsi_device *tmp_sdev;
2183 int depth = 0; 2216 int depth;
2184 unsigned long flags; 2217 unsigned long flags;
2185 struct lpfc_fast_path_event *fast_path_evt; 2218 struct lpfc_fast_path_event *fast_path_evt;
2186 struct Scsi_Host *shost = cmd->device->host; 2219 struct Scsi_Host *shost = cmd->device->host;
@@ -2264,7 +2297,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
2264 lpfc_printf_vlog(vport, KERN_WARNING, 2297 lpfc_printf_vlog(vport, KERN_WARNING,
2265 LOG_BG, 2298 LOG_BG,
2266 "9031 non-zero BGSTAT " 2299 "9031 non-zero BGSTAT "
2267 "on unprotected cmd"); 2300 "on unprotected cmd\n");
2268 } 2301 }
2269 } 2302 }
2270 2303
@@ -2347,67 +2380,29 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
2347 return; 2380 return;
2348 } 2381 }
2349 2382
2350
2351 if (!result) 2383 if (!result)
2352 lpfc_rampup_queue_depth(vport, queue_depth); 2384 lpfc_rampup_queue_depth(vport, queue_depth);
2353 2385
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 /* 2386 /*
2382 * Check for queue full. If the lun is reporting queue full, then 2387 * Check for queue full. If the lun is reporting queue full, then
2383 * back off the lun queue depth to prevent target overloads. 2388 * back off the lun queue depth to prevent target overloads.
2384 */ 2389 */
2385 if (result == SAM_STAT_TASK_SET_FULL && pnode && 2390 if (result == SAM_STAT_TASK_SET_FULL && pnode &&
2386 NLP_CHK_NODE_ACT(pnode)) { 2391 NLP_CHK_NODE_ACT(pnode)) {
2387 pnode->last_q_full_time = jiffies;
2388
2389 shost_for_each_device(tmp_sdev, shost) { 2392 shost_for_each_device(tmp_sdev, shost) {
2390 if (tmp_sdev->id != scsi_id) 2393 if (tmp_sdev->id != scsi_id)
2391 continue; 2394 continue;
2392 depth = scsi_track_queue_full(tmp_sdev, 2395 depth = scsi_track_queue_full(tmp_sdev,
2393 tmp_sdev->queue_depth - 1); 2396 tmp_sdev->queue_depth-1);
2394 } 2397 if (depth <= 0)
2395 /* 2398 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, 2399 lpfc_printf_vlog(vport, KERN_WARNING, LOG_FCP,
2406 "0711 detected queue full - lun queue " 2400 "0711 detected queue full - lun queue "
2407 "depth adjusted to %d.\n", depth); 2401 "depth adjusted to %d.\n", depth);
2408 lpfc_send_sdev_queuedepth_change_event(phba, vport, 2402 lpfc_send_sdev_queuedepth_change_event(phba, vport,
2409 pnode, 0xFFFFFFFF, 2403 pnode,
2410 depth+1, depth); 2404 tmp_sdev->lun,
2405 depth+1, depth);
2411 } 2406 }
2412 } 2407 }
2413 2408
@@ -2745,7 +2740,9 @@ void lpfc_poll_timeout(unsigned long ptr)
2745 struct lpfc_hba *phba = (struct lpfc_hba *) ptr; 2740 struct lpfc_hba *phba = (struct lpfc_hba *) ptr;
2746 2741
2747 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 2742 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
2748 lpfc_sli_poll_fcp_ring (phba); 2743 lpfc_sli_handle_fast_ring_event(phba,
2744 &phba->sli.ring[LPFC_FCP_RING], HA_R0RE_REQ);
2745
2749 if (phba->cfg_poll & DISABLE_FCP_RING_INT) 2746 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
2750 lpfc_poll_rearm_timer(phba); 2747 lpfc_poll_rearm_timer(phba);
2751 } 2748 }
@@ -2771,7 +2768,7 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2771 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 2768 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
2772 struct lpfc_hba *phba = vport->phba; 2769 struct lpfc_hba *phba = vport->phba;
2773 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 2770 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
2774 struct lpfc_nodelist *ndlp = rdata->pnode; 2771 struct lpfc_nodelist *ndlp;
2775 struct lpfc_scsi_buf *lpfc_cmd; 2772 struct lpfc_scsi_buf *lpfc_cmd;
2776 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device)); 2773 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
2777 int err; 2774 int err;
@@ -2781,13 +2778,15 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2781 cmnd->result = err; 2778 cmnd->result = err;
2782 goto out_fail_command; 2779 goto out_fail_command;
2783 } 2780 }
2781 ndlp = rdata->pnode;
2784 2782
2785 if (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED) && 2783 if (!(phba->sli3_options & LPFC_SLI3_BG_ENABLED) &&
2786 scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) { 2784 scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) {
2787 2785
2788 printk(KERN_ERR "BLKGRD ERROR: rcvd protected cmd:%02x op:%02x " 2786 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
2789 "str=%s without registering for BlockGuard - " 2787 "9058 BLKGRD: ERROR: rcvd protected cmd:%02x"
2790 "Rejecting command\n", 2788 " op:%02x str=%s without registering for"
2789 " BlockGuard - Rejecting command\n",
2791 cmnd->cmnd[0], scsi_get_prot_op(cmnd), 2790 cmnd->cmnd[0], scsi_get_prot_op(cmnd),
2792 dif_op_str[scsi_get_prot_op(cmnd)]); 2791 dif_op_str[scsi_get_prot_op(cmnd)]);
2793 goto out_fail_command; 2792 goto out_fail_command;
@@ -2827,61 +2826,66 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2827 cmnd->scsi_done = done; 2826 cmnd->scsi_done = done;
2828 2827
2829 if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) { 2828 if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) {
2830 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2829 if (vport->phba->cfg_enable_bg) {
2830 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2831 "9033 BLKGRD: rcvd protected cmd:%02x op:%02x " 2831 "9033 BLKGRD: rcvd protected cmd:%02x op:%02x "
2832 "str=%s\n", 2832 "str=%s\n",
2833 cmnd->cmnd[0], scsi_get_prot_op(cmnd), 2833 cmnd->cmnd[0], scsi_get_prot_op(cmnd),
2834 dif_op_str[scsi_get_prot_op(cmnd)]); 2834 dif_op_str[scsi_get_prot_op(cmnd)]);
2835 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2835 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2836 "9034 BLKGRD: CDB: %02x %02x %02x %02x %02x " 2836 "9034 BLKGRD: CDB: %02x %02x %02x %02x %02x "
2837 "%02x %02x %02x %02x %02x\n", 2837 "%02x %02x %02x %02x %02x\n",
2838 cmnd->cmnd[0], cmnd->cmnd[1], cmnd->cmnd[2], 2838 cmnd->cmnd[0], cmnd->cmnd[1], cmnd->cmnd[2],
2839 cmnd->cmnd[3], cmnd->cmnd[4], cmnd->cmnd[5], 2839 cmnd->cmnd[3], cmnd->cmnd[4], cmnd->cmnd[5],
2840 cmnd->cmnd[6], cmnd->cmnd[7], cmnd->cmnd[8], 2840 cmnd->cmnd[6], cmnd->cmnd[7], cmnd->cmnd[8],
2841 cmnd->cmnd[9]); 2841 cmnd->cmnd[9]);
2842 if (cmnd->cmnd[0] == READ_10) 2842 if (cmnd->cmnd[0] == READ_10)
2843 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2843 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2844 "9035 BLKGRD: READ @ sector %llu, " 2844 "9035 BLKGRD: READ @ sector %llu, "
2845 "count %u\n", 2845 "count %u\n",
2846 (unsigned long long)scsi_get_lba(cmnd), 2846 (unsigned long long)scsi_get_lba(cmnd),
2847 blk_rq_sectors(cmnd->request)); 2847 blk_rq_sectors(cmnd->request));
2848 else if (cmnd->cmnd[0] == WRITE_10) 2848 else if (cmnd->cmnd[0] == WRITE_10)
2849 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2849 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2850 "9036 BLKGRD: WRITE @ sector %llu, " 2850 "9036 BLKGRD: WRITE @ sector %llu, "
2851 "count %u cmd=%p\n", 2851 "count %u cmd=%p\n",
2852 (unsigned long long)scsi_get_lba(cmnd), 2852 (unsigned long long)scsi_get_lba(cmnd),
2853 blk_rq_sectors(cmnd->request), 2853 blk_rq_sectors(cmnd->request),
2854 cmnd); 2854 cmnd);
2855 }
2855 2856
2856 err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd); 2857 err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd);
2857 } else { 2858 } else {
2858 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2859 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, 2860 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2872 "9040 dbg: READ @ sector %llu, " 2861 "9038 BLKGRD: rcvd unprotected cmd:"
2873 "count %u\n", 2862 "%02x op:%02x str=%s\n",
2874 (unsigned long long)scsi_get_lba(cmnd), 2863 cmnd->cmnd[0], scsi_get_prot_op(cmnd),
2864 dif_op_str[scsi_get_prot_op(cmnd)]);
2865 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2866 "9039 BLKGRD: CDB: %02x %02x %02x "
2867 "%02x %02x %02x %02x %02x %02x %02x\n",
2868 cmnd->cmnd[0], cmnd->cmnd[1],
2869 cmnd->cmnd[2], cmnd->cmnd[3],
2870 cmnd->cmnd[4], cmnd->cmnd[5],
2871 cmnd->cmnd[6], cmnd->cmnd[7],
2872 cmnd->cmnd[8], cmnd->cmnd[9]);
2873 if (cmnd->cmnd[0] == READ_10)
2874 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2875 "9040 dbg: READ @ sector %llu, "
2876 "count %u\n",
2877 (unsigned long long)scsi_get_lba(cmnd),
2875 blk_rq_sectors(cmnd->request)); 2878 blk_rq_sectors(cmnd->request));
2876 else if (cmnd->cmnd[0] == WRITE_10) 2879 else if (cmnd->cmnd[0] == WRITE_10)
2877 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2880 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2878 "9041 dbg: WRITE @ sector %llu, " 2881 "9041 dbg: WRITE @ sector %llu, "
2879 "count %u cmd=%p\n", 2882 "count %u cmd=%p\n",
2880 (unsigned long long)scsi_get_lba(cmnd), 2883 (unsigned long long)scsi_get_lba(cmnd),
2881 blk_rq_sectors(cmnd->request), cmnd); 2884 blk_rq_sectors(cmnd->request), cmnd);
2882 else 2885 else
2883 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, 2886 lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG,
2884 "9042 dbg: parser not implemented\n"); 2887 "9042 dbg: parser not implemented\n");
2888 }
2885 err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd); 2889 err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd);
2886 } 2890 }
2887 2891
@@ -2898,7 +2902,11 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2898 goto out_host_busy_free_buf; 2902 goto out_host_busy_free_buf;
2899 } 2903 }
2900 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 2904 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
2901 lpfc_sli_poll_fcp_ring(phba); 2905 spin_unlock(shost->host_lock);
2906 lpfc_sli_handle_fast_ring_event(phba,
2907 &phba->sli.ring[LPFC_FCP_RING], HA_R0RE_REQ);
2908
2909 spin_lock(shost->host_lock);
2902 if (phba->cfg_poll & DISABLE_FCP_RING_INT) 2910 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
2903 lpfc_poll_rearm_timer(phba); 2911 lpfc_poll_rearm_timer(phba);
2904 } 2912 }
@@ -2917,28 +2925,6 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
2917} 2925}
2918 2926
2919/** 2927/**
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 2928 * lpfc_abort_handler - scsi_host_template eh_abort_handler entry point
2943 * @cmnd: Pointer to scsi_cmnd data structure. 2929 * @cmnd: Pointer to scsi_cmnd data structure.
2944 * 2930 *
@@ -2961,7 +2947,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
2961 int ret = SUCCESS; 2947 int ret = SUCCESS;
2962 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq); 2948 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waitq);
2963 2949
2964 lpfc_block_error_handler(cmnd); 2950 fc_block_scsi_eh(cmnd);
2965 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; 2951 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble;
2966 BUG_ON(!lpfc_cmd); 2952 BUG_ON(!lpfc_cmd);
2967 2953
@@ -3001,6 +2987,10 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
3001 2987
3002 icmd->ulpLe = 1; 2988 icmd->ulpLe = 1;
3003 icmd->ulpClass = cmd->ulpClass; 2989 icmd->ulpClass = cmd->ulpClass;
2990
2991 /* ABTS WQE must go to the same WQ as the WQE to be aborted */
2992 abtsiocb->fcp_wqidx = iocb->fcp_wqidx;
2993
3004 if (lpfc_is_link_up(phba)) 2994 if (lpfc_is_link_up(phba))
3005 icmd->ulpCommand = CMD_ABORT_XRI_CN; 2995 icmd->ulpCommand = CMD_ABORT_XRI_CN;
3006 else 2996 else
@@ -3016,7 +3006,8 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
3016 } 3006 }
3017 3007
3018 if (phba->cfg_poll & DISABLE_FCP_RING_INT) 3008 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
3019 lpfc_sli_poll_fcp_ring (phba); 3009 lpfc_sli_handle_fast_ring_event(phba,
3010 &phba->sli.ring[LPFC_FCP_RING], HA_R0RE_REQ);
3020 3011
3021 lpfc_cmd->waitq = &waitq; 3012 lpfc_cmd->waitq = &waitq;
3022 /* Wait for abort to complete */ 3013 /* Wait for abort to complete */
@@ -3166,9 +3157,15 @@ static int
3166lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd) 3157lpfc_chk_tgt_mapped(struct lpfc_vport *vport, struct scsi_cmnd *cmnd)
3167{ 3158{
3168 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 3159 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
3169 struct lpfc_nodelist *pnode = rdata->pnode; 3160 struct lpfc_nodelist *pnode;
3170 unsigned long later; 3161 unsigned long later;
3171 3162
3163 if (!rdata) {
3164 lpfc_printf_vlog(vport, KERN_INFO, LOG_FCP,
3165 "0797 Tgt Map rport failure: rdata x%p\n", rdata);
3166 return FAILED;
3167 }
3168 pnode = rdata->pnode;
3172 /* 3169 /*
3173 * If target is not in a MAPPED state, delay until 3170 * If target is not in a MAPPED state, delay until
3174 * target is rediscovered or devloss timeout expires. 3171 * target is rediscovered or devloss timeout expires.
@@ -3253,13 +3250,19 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
3253 struct Scsi_Host *shost = cmnd->device->host; 3250 struct Scsi_Host *shost = cmnd->device->host;
3254 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 3251 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3255 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 3252 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
3256 struct lpfc_nodelist *pnode = rdata->pnode; 3253 struct lpfc_nodelist *pnode;
3257 unsigned tgt_id = cmnd->device->id; 3254 unsigned tgt_id = cmnd->device->id;
3258 unsigned int lun_id = cmnd->device->lun; 3255 unsigned int lun_id = cmnd->device->lun;
3259 struct lpfc_scsi_event_header scsi_event; 3256 struct lpfc_scsi_event_header scsi_event;
3260 int status; 3257 int status;
3261 3258
3262 lpfc_block_error_handler(cmnd); 3259 if (!rdata) {
3260 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
3261 "0798 Device Reset rport failure: rdata x%p\n", rdata);
3262 return FAILED;
3263 }
3264 pnode = rdata->pnode;
3265 fc_block_scsi_eh(cmnd);
3263 3266
3264 status = lpfc_chk_tgt_mapped(vport, cmnd); 3267 status = lpfc_chk_tgt_mapped(vport, cmnd);
3265 if (status == FAILED) { 3268 if (status == FAILED) {
@@ -3312,13 +3315,19 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
3312 struct Scsi_Host *shost = cmnd->device->host; 3315 struct Scsi_Host *shost = cmnd->device->host;
3313 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata; 3316 struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
3314 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 3317 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
3315 struct lpfc_nodelist *pnode = rdata->pnode; 3318 struct lpfc_nodelist *pnode;
3316 unsigned tgt_id = cmnd->device->id; 3319 unsigned tgt_id = cmnd->device->id;
3317 unsigned int lun_id = cmnd->device->lun; 3320 unsigned int lun_id = cmnd->device->lun;
3318 struct lpfc_scsi_event_header scsi_event; 3321 struct lpfc_scsi_event_header scsi_event;
3319 int status; 3322 int status;
3320 3323
3321 lpfc_block_error_handler(cmnd); 3324 if (!rdata) {
3325 lpfc_printf_vlog(vport, KERN_ERR, LOG_FCP,
3326 "0799 Target Reset rport failure: rdata x%p\n", rdata);
3327 return FAILED;
3328 }
3329 pnode = rdata->pnode;
3330 fc_block_scsi_eh(cmnd);
3322 3331
3323 status = lpfc_chk_tgt_mapped(vport, cmnd); 3332 status = lpfc_chk_tgt_mapped(vport, cmnd);
3324 if (status == FAILED) { 3333 if (status == FAILED) {
@@ -3384,7 +3393,7 @@ lpfc_bus_reset_handler(struct scsi_cmnd *cmnd)
3384 fc_host_post_vendor_event(shost, fc_get_event_number(), 3393 fc_host_post_vendor_event(shost, fc_get_event_number(),
3385 sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID); 3394 sizeof(scsi_event), (char *)&scsi_event, LPFC_NL_VENDOR_ID);
3386 3395
3387 lpfc_block_error_handler(cmnd); 3396 fc_block_scsi_eh(cmnd);
3388 3397
3389 /* 3398 /*
3390 * Since the driver manages a single bus device, reset all 3399 * Since the driver manages a single bus device, reset all
@@ -3498,6 +3507,8 @@ lpfc_slave_alloc(struct scsi_device *sdev)
3498 "Allocated %d buffers.\n", 3507 "Allocated %d buffers.\n",
3499 num_to_alloc, num_allocated); 3508 num_to_alloc, num_allocated);
3500 } 3509 }
3510 if (num_allocated > 0)
3511 phba->total_scsi_bufs += num_allocated;
3501 return 0; 3512 return 0;
3502} 3513}
3503 3514
@@ -3534,7 +3545,8 @@ lpfc_slave_configure(struct scsi_device *sdev)
3534 rport->dev_loss_tmo = vport->cfg_devloss_tmo; 3545 rport->dev_loss_tmo = vport->cfg_devloss_tmo;
3535 3546
3536 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) { 3547 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
3537 lpfc_sli_poll_fcp_ring(phba); 3548 lpfc_sli_handle_fast_ring_event(phba,
3549 &phba->sli.ring[LPFC_FCP_RING], HA_R0RE_REQ);
3538 if (phba->cfg_poll & DISABLE_FCP_RING_INT) 3550 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
3539 lpfc_poll_rearm_timer(phba); 3551 lpfc_poll_rearm_timer(phba);
3540 } 3552 }
@@ -3576,6 +3588,7 @@ struct scsi_host_template lpfc_template = {
3576 .shost_attrs = lpfc_hba_attrs, 3588 .shost_attrs = lpfc_hba_attrs,
3577 .max_sectors = 0xFFFF, 3589 .max_sectors = 0xFFFF,
3578 .vendor_id = LPFC_NL_VENDOR_ID, 3590 .vendor_id = LPFC_NL_VENDOR_ID,
3591 .change_queue_depth = lpfc_change_queue_depth,
3579}; 3592};
3580 3593
3581struct scsi_host_template lpfc_vport_template = { 3594struct scsi_host_template lpfc_vport_template = {
@@ -3597,4 +3610,5 @@ struct scsi_host_template lpfc_vport_template = {
3597 .use_clustering = ENABLE_CLUSTERING, 3610 .use_clustering = ENABLE_CLUSTERING,
3598 .shost_attrs = lpfc_vport_attrs, 3611 .shost_attrs = lpfc_vport_attrs,
3599 .max_sectors = 0xFFFF, 3612 .max_sectors = 0xFFFF,
3613 .change_queue_depth = lpfc_change_queue_depth,
3600}; 3614};