aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorJames Smart <james.smart@emulex.com>2012-03-01 22:38:29 -0500
committerJames Bottomley <JBottomley@Parallels.com>2012-03-27 03:26:33 -0400
commit4ac9b22625333f9d86c01df702c83d2dfe732131 (patch)
treec54573b26a422a155e1d8231fd9af672f5484f3d /drivers/scsi
parentd85296cfddb0a4702bc9b05a6f288516b0adb6ba (diff)
[SCSI] lpfc 8.3.30: Added more T10 DIF debugfs error injection
Signed-off-by: Alex Iannicelli <alex.iannicelli@emulex.com> Signed-off-by: James Smart <james.smart@emulex.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/lpfc/lpfc.h4
-rw-r--r--drivers/scsi/lpfc/lpfc_debugfs.c58
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c178
3 files changed, 180 insertions, 60 deletions
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index bb2e9ec0adea..3a1ffdd6d831 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -840,6 +840,8 @@ struct lpfc_hba {
840 struct dentry *debug_dumpData; /* BlockGuard BPL */ 840 struct dentry *debug_dumpData; /* BlockGuard BPL */
841 struct dentry *debug_dumpDif; /* BlockGuard BPL */ 841 struct dentry *debug_dumpDif; /* BlockGuard BPL */
842 struct dentry *debug_InjErrLBA; /* LBA to inject errors at */ 842 struct dentry *debug_InjErrLBA; /* LBA to inject errors at */
843 struct dentry *debug_InjErrNPortID; /* NPortID to inject errors at */
844 struct dentry *debug_InjErrWWPN; /* WWPN to inject errors at */
843 struct dentry *debug_writeGuard; /* inject write guard_tag errors */ 845 struct dentry *debug_writeGuard; /* inject write guard_tag errors */
844 struct dentry *debug_writeApp; /* inject write app_tag errors */ 846 struct dentry *debug_writeApp; /* inject write app_tag errors */
845 struct dentry *debug_writeRef; /* inject write ref_tag errors */ 847 struct dentry *debug_writeRef; /* inject write ref_tag errors */
@@ -854,6 +856,8 @@ struct lpfc_hba {
854 uint32_t lpfc_injerr_rgrd_cnt; 856 uint32_t lpfc_injerr_rgrd_cnt;
855 uint32_t lpfc_injerr_rapp_cnt; 857 uint32_t lpfc_injerr_rapp_cnt;
856 uint32_t lpfc_injerr_rref_cnt; 858 uint32_t lpfc_injerr_rref_cnt;
859 uint32_t lpfc_injerr_nportid;
860 struct lpfc_name lpfc_injerr_wwpn;
857 sector_t lpfc_injerr_lba; 861 sector_t lpfc_injerr_lba;
858#define LPFC_INJERR_LBA_OFF (sector_t)(-1) 862#define LPFC_INJERR_LBA_OFF (sector_t)(-1)
859 863
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 4f16327e19c8..5bdf2eecb178 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -1011,6 +1011,7 @@ lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
1011 struct dentry *dent = file->f_dentry; 1011 struct dentry *dent = file->f_dentry;
1012 struct lpfc_hba *phba = file->private_data; 1012 struct lpfc_hba *phba = file->private_data;
1013 char cbuf[32]; 1013 char cbuf[32];
1014 uint64_t tmp = 0;
1014 int cnt = 0; 1015 int cnt = 0;
1015 1016
1016 if (dent == phba->debug_writeGuard) 1017 if (dent == phba->debug_writeGuard)
@@ -1025,12 +1026,18 @@ lpfc_debugfs_dif_err_read(struct file *file, char __user *buf,
1025 cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt); 1026 cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt);
1026 else if (dent == phba->debug_readRef) 1027 else if (dent == phba->debug_readRef)
1027 cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt); 1028 cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt);
1028 else if (dent == phba->debug_InjErrLBA) { 1029 else if (dent == phba->debug_InjErrNPortID)
1029 if (phba->lpfc_injerr_lba == (unsigned long)(-1)) 1030 cnt = snprintf(cbuf, 32, "0x%06x\n", phba->lpfc_injerr_nportid);
1031 else if (dent == phba->debug_InjErrWWPN) {
1032 memcpy(&tmp, &phba->lpfc_injerr_wwpn, sizeof(struct lpfc_name));
1033 tmp = cpu_to_be64(tmp);
1034 cnt = snprintf(cbuf, 32, "0x%016llx\n", tmp);
1035 } else if (dent == phba->debug_InjErrLBA) {
1036 if (phba->lpfc_injerr_lba == (sector_t)(-1))
1030 cnt = snprintf(cbuf, 32, "off\n"); 1037 cnt = snprintf(cbuf, 32, "off\n");
1031 else 1038 else
1032 cnt = snprintf(cbuf, 32, "0x%lx\n", 1039 cnt = snprintf(cbuf, 32, "0x%llx\n",
1033 (unsigned long) phba->lpfc_injerr_lba); 1040 (uint64_t) phba->lpfc_injerr_lba);
1034 } else 1041 } else
1035 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1042 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1036 "0547 Unknown debugfs error injection entry\n"); 1043 "0547 Unknown debugfs error injection entry\n");
@@ -1045,7 +1052,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
1045 struct dentry *dent = file->f_dentry; 1052 struct dentry *dent = file->f_dentry;
1046 struct lpfc_hba *phba = file->private_data; 1053 struct lpfc_hba *phba = file->private_data;
1047 char dstbuf[32]; 1054 char dstbuf[32];
1048 unsigned long tmp = 0; 1055 uint64_t tmp = 0;
1049 int size; 1056 int size;
1050 1057
1051 memset(dstbuf, 0, 32); 1058 memset(dstbuf, 0, 32);
@@ -1055,10 +1062,10 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
1055 1062
1056 if (dent == phba->debug_InjErrLBA) { 1063 if (dent == phba->debug_InjErrLBA) {
1057 if ((buf[0] == 'o') && (buf[1] == 'f') && (buf[2] == 'f')) 1064 if ((buf[0] == 'o') && (buf[1] == 'f') && (buf[2] == 'f'))
1058 tmp = (unsigned long)(-1); 1065 tmp = (uint64_t)(-1);
1059 } 1066 }
1060 1067
1061 if ((tmp == 0) && (kstrtoul(dstbuf, 0, &tmp))) 1068 if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp)))
1062 return 0; 1069 return 0;
1063 1070
1064 if (dent == phba->debug_writeGuard) 1071 if (dent == phba->debug_writeGuard)
@@ -1075,7 +1082,12 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
1075 phba->lpfc_injerr_rref_cnt = (uint32_t)tmp; 1082 phba->lpfc_injerr_rref_cnt = (uint32_t)tmp;
1076 else if (dent == phba->debug_InjErrLBA) 1083 else if (dent == phba->debug_InjErrLBA)
1077 phba->lpfc_injerr_lba = (sector_t)tmp; 1084 phba->lpfc_injerr_lba = (sector_t)tmp;
1078 else 1085 else if (dent == phba->debug_InjErrNPortID)
1086 phba->lpfc_injerr_nportid = (uint32_t)(tmp & Mask_DID);
1087 else if (dent == phba->debug_InjErrWWPN) {
1088 tmp = cpu_to_be64(tmp);
1089 memcpy(&phba->lpfc_injerr_wwpn, &tmp, sizeof(struct lpfc_name));
1090 } else
1079 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, 1091 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1080 "0548 Unknown debugfs error injection entry\n"); 1092 "0548 Unknown debugfs error injection entry\n");
1081 1093
@@ -3957,6 +3969,28 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
3957 } 3969 }
3958 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 3970 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF;
3959 3971
3972 snprintf(name, sizeof(name), "InjErrNPortID");
3973 phba->debug_InjErrNPortID =
3974 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
3975 phba->hba_debugfs_root,
3976 phba, &lpfc_debugfs_op_dif_err);
3977 if (!phba->debug_InjErrNPortID) {
3978 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3979 "0809 Cannot create debugfs InjErrNPortID\n");
3980 goto debug_failed;
3981 }
3982
3983 snprintf(name, sizeof(name), "InjErrWWPN");
3984 phba->debug_InjErrWWPN =
3985 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
3986 phba->hba_debugfs_root,
3987 phba, &lpfc_debugfs_op_dif_err);
3988 if (!phba->debug_InjErrWWPN) {
3989 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
3990 "0810 Cannot create debugfs InjErrWWPN\n");
3991 goto debug_failed;
3992 }
3993
3960 snprintf(name, sizeof(name), "writeGuardInjErr"); 3994 snprintf(name, sizeof(name), "writeGuardInjErr");
3961 phba->debug_writeGuard = 3995 phba->debug_writeGuard =
3962 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR, 3996 debugfs_create_file(name, S_IFREG|S_IRUGO|S_IWUSR,
@@ -4329,6 +4363,14 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
4329 debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */ 4363 debugfs_remove(phba->debug_InjErrLBA); /* InjErrLBA */
4330 phba->debug_InjErrLBA = NULL; 4364 phba->debug_InjErrLBA = NULL;
4331 } 4365 }
4366 if (phba->debug_InjErrNPortID) { /* InjErrNPortID */
4367 debugfs_remove(phba->debug_InjErrNPortID);
4368 phba->debug_InjErrNPortID = NULL;
4369 }
4370 if (phba->debug_InjErrWWPN) {
4371 debugfs_remove(phba->debug_InjErrWWPN); /* InjErrWWPN */
4372 phba->debug_InjErrWWPN = NULL;
4373 }
4332 if (phba->debug_writeGuard) { 4374 if (phba->debug_writeGuard) {
4333 debugfs_remove(phba->debug_writeGuard); /* writeGuard */ 4375 debugfs_remove(phba->debug_writeGuard); /* writeGuard */
4334 phba->debug_writeGuard = NULL; 4376 phba->debug_writeGuard = NULL;
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index b1b7dd22af09..2e65168d8723 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -1314,6 +1314,8 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1314 struct scatterlist *sgde; /* s/g data entry */ 1314 struct scatterlist *sgde; /* s/g data entry */
1315 struct lpfc_scsi_buf *lpfc_cmd = NULL; 1315 struct lpfc_scsi_buf *lpfc_cmd = NULL;
1316 struct scsi_dif_tuple *src = NULL; 1316 struct scsi_dif_tuple *src = NULL;
1317 struct lpfc_nodelist *ndlp;
1318 struct lpfc_rport_data *rdata;
1317 uint32_t op = scsi_get_prot_op(sc); 1319 uint32_t op = scsi_get_prot_op(sc);
1318 uint32_t blksize; 1320 uint32_t blksize;
1319 uint32_t numblks; 1321 uint32_t numblks;
@@ -1326,8 +1328,9 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1326 1328
1327 sgpe = scsi_prot_sglist(sc); 1329 sgpe = scsi_prot_sglist(sc);
1328 sgde = scsi_sglist(sc); 1330 sgde = scsi_sglist(sc);
1329
1330 lba = scsi_get_lba(sc); 1331 lba = scsi_get_lba(sc);
1332
1333 /* First check if we need to match the LBA */
1331 if (phba->lpfc_injerr_lba != LPFC_INJERR_LBA_OFF) { 1334 if (phba->lpfc_injerr_lba != LPFC_INJERR_LBA_OFF) {
1332 blksize = lpfc_cmd_blksize(sc); 1335 blksize = lpfc_cmd_blksize(sc);
1333 numblks = (scsi_bufflen(sc) + blksize - 1) / blksize; 1336 numblks = (scsi_bufflen(sc) + blksize - 1) / blksize;
@@ -1342,12 +1345,36 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1342 sizeof(struct scsi_dif_tuple); 1345 sizeof(struct scsi_dif_tuple);
1343 if (numblks < blockoff) 1346 if (numblks < blockoff)
1344 blockoff = numblks; 1347 blockoff = numblks;
1345 src = (struct scsi_dif_tuple *)sg_virt(sgpe);
1346 src += blockoff;
1347 lpfc_cmd = (struct lpfc_scsi_buf *)sc->host_scribble;
1348 } 1348 }
1349 } 1349 }
1350 1350
1351 /* Next check if we need to match the remote NPortID or WWPN */
1352 rdata = sc->device->hostdata;
1353 if (rdata && rdata->pnode) {
1354 ndlp = rdata->pnode;
1355
1356 /* Make sure we have the right NPortID if one is specified */
1357 if (phba->lpfc_injerr_nportid &&
1358 (phba->lpfc_injerr_nportid != ndlp->nlp_DID))
1359 return 0;
1360
1361 /*
1362 * Make sure we have the right WWPN if one is specified.
1363 * wwn[0] should be a non-zero NAA in a good WWPN.
1364 */
1365 if (phba->lpfc_injerr_wwpn.u.wwn[0] &&
1366 (memcmp(&ndlp->nlp_portname, &phba->lpfc_injerr_wwpn,
1367 sizeof(struct lpfc_name)) != 0))
1368 return 0;
1369 }
1370
1371 /* Setup a ptr to the protection data if the SCSI host provides it */
1372 if (sgpe) {
1373 src = (struct scsi_dif_tuple *)sg_virt(sgpe);
1374 src += blockoff;
1375 lpfc_cmd = (struct lpfc_scsi_buf *)sc->host_scribble;
1376 }
1377
1351 /* Should we change the Reference Tag */ 1378 /* Should we change the Reference Tag */
1352 if (reftag) { 1379 if (reftag) {
1353 if (phba->lpfc_injerr_wref_cnt) { 1380 if (phba->lpfc_injerr_wref_cnt) {
@@ -1382,8 +1409,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1382 } 1409 }
1383 src->ref_tag = cpu_to_be32(0xDEADBEEF); 1410 src->ref_tag = cpu_to_be32(0xDEADBEEF);
1384 phba->lpfc_injerr_wref_cnt--; 1411 phba->lpfc_injerr_wref_cnt--;
1385 phba->lpfc_injerr_lba = 1412 if (phba->lpfc_injerr_wref_cnt == 0) {
1386 LPFC_INJERR_LBA_OFF; 1413 phba->lpfc_injerr_nportid = 0;
1414 phba->lpfc_injerr_lba =
1415 LPFC_INJERR_LBA_OFF;
1416 memset(&phba->lpfc_injerr_wwpn,
1417 0, sizeof(struct lpfc_name));
1418 }
1387 rc = BG_ERR_TGT | BG_ERR_CHECK; 1419 rc = BG_ERR_TGT | BG_ERR_CHECK;
1388 1420
1389 break; 1421 break;
@@ -1398,7 +1430,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1398 /* DEADBEEF will be the reftag on the wire */ 1430 /* DEADBEEF will be the reftag on the wire */
1399 *reftag = 0xDEADBEEF; 1431 *reftag = 0xDEADBEEF;
1400 phba->lpfc_injerr_wref_cnt--; 1432 phba->lpfc_injerr_wref_cnt--;
1401 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 1433 if (phba->lpfc_injerr_wref_cnt == 0) {
1434 phba->lpfc_injerr_nportid = 0;
1435 phba->lpfc_injerr_lba =
1436 LPFC_INJERR_LBA_OFF;
1437 memset(&phba->lpfc_injerr_wwpn,
1438 0, sizeof(struct lpfc_name));
1439 }
1402 rc = BG_ERR_TGT | BG_ERR_CHECK; 1440 rc = BG_ERR_TGT | BG_ERR_CHECK;
1403 1441
1404 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 1442 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
@@ -1413,7 +1451,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1413 */ 1451 */
1414 *reftag = 0xDEADBEEF; 1452 *reftag = 0xDEADBEEF;
1415 phba->lpfc_injerr_wref_cnt--; 1453 phba->lpfc_injerr_wref_cnt--;
1416 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 1454 if (phba->lpfc_injerr_wref_cnt == 0) {
1455 phba->lpfc_injerr_nportid = 0;
1456 phba->lpfc_injerr_lba =
1457 LPFC_INJERR_LBA_OFF;
1458 memset(&phba->lpfc_injerr_wwpn,
1459 0, sizeof(struct lpfc_name));
1460 }
1417 rc = BG_ERR_INIT; 1461 rc = BG_ERR_INIT;
1418 1462
1419 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 1463 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
@@ -1425,11 +1469,6 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1425 if (phba->lpfc_injerr_rref_cnt) { 1469 if (phba->lpfc_injerr_rref_cnt) {
1426 switch (op) { 1470 switch (op) {
1427 case SCSI_PROT_READ_INSERT: 1471 case SCSI_PROT_READ_INSERT:
1428 /*
1429 * For READ_INSERT, it doesn't make sense
1430 * to change the reftag.
1431 */
1432 break;
1433 case SCSI_PROT_READ_STRIP: 1472 case SCSI_PROT_READ_STRIP:
1434 case SCSI_PROT_READ_PASS: 1473 case SCSI_PROT_READ_PASS:
1435 /* 1474 /*
@@ -1439,7 +1478,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1439 */ 1478 */
1440 *reftag = 0xDEADBEEF; 1479 *reftag = 0xDEADBEEF;
1441 phba->lpfc_injerr_rref_cnt--; 1480 phba->lpfc_injerr_rref_cnt--;
1442 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 1481 if (phba->lpfc_injerr_rref_cnt == 0) {
1482 phba->lpfc_injerr_nportid = 0;
1483 phba->lpfc_injerr_lba =
1484 LPFC_INJERR_LBA_OFF;
1485 memset(&phba->lpfc_injerr_wwpn,
1486 0, sizeof(struct lpfc_name));
1487 }
1443 rc = BG_ERR_INIT; 1488 rc = BG_ERR_INIT;
1444 1489
1445 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 1490 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
@@ -1455,7 +1500,7 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1455 if (phba->lpfc_injerr_wapp_cnt) { 1500 if (phba->lpfc_injerr_wapp_cnt) {
1456 switch (op) { 1501 switch (op) {
1457 case SCSI_PROT_WRITE_PASS: 1502 case SCSI_PROT_WRITE_PASS:
1458 if (blockoff && src) { 1503 if (src) {
1459 /* 1504 /*
1460 * For WRITE_PASS, force the error 1505 * For WRITE_PASS, force the error
1461 * to be sent on the wire. It should 1506 * to be sent on the wire. It should
@@ -1464,7 +1509,6 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1464 * inserted in middle of the IO. 1509 * inserted in middle of the IO.
1465 */ 1510 */
1466 1511
1467
1468 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 1512 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1469 "9080 BLKGRD: Injecting apptag error: " 1513 "9080 BLKGRD: Injecting apptag error: "
1470 "write lba x%lx + x%x oldappTag x%x\n", 1514 "write lba x%lx + x%x oldappTag x%x\n",
@@ -1485,8 +1529,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1485 } 1529 }
1486 src->app_tag = cpu_to_be16(0xDEAD); 1530 src->app_tag = cpu_to_be16(0xDEAD);
1487 phba->lpfc_injerr_wapp_cnt--; 1531 phba->lpfc_injerr_wapp_cnt--;
1488 phba->lpfc_injerr_lba = 1532 if (phba->lpfc_injerr_wapp_cnt == 0) {
1489 LPFC_INJERR_LBA_OFF; 1533 phba->lpfc_injerr_nportid = 0;
1534 phba->lpfc_injerr_lba =
1535 LPFC_INJERR_LBA_OFF;
1536 memset(&phba->lpfc_injerr_wwpn,
1537 0, sizeof(struct lpfc_name));
1538 }
1490 rc = BG_ERR_TGT | BG_ERR_CHECK; 1539 rc = BG_ERR_TGT | BG_ERR_CHECK;
1491 break; 1540 break;
1492 } 1541 }
@@ -1500,8 +1549,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1500 /* DEAD will be the apptag on the wire */ 1549 /* DEAD will be the apptag on the wire */
1501 *apptag = 0xDEAD; 1550 *apptag = 0xDEAD;
1502 phba->lpfc_injerr_wapp_cnt--; 1551 phba->lpfc_injerr_wapp_cnt--;
1503 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 1552 if (phba->lpfc_injerr_wapp_cnt == 0) {
1504 rc = BG_ERR_TGT; 1553 phba->lpfc_injerr_nportid = 0;
1554 phba->lpfc_injerr_lba =
1555 LPFC_INJERR_LBA_OFF;
1556 memset(&phba->lpfc_injerr_wwpn,
1557 0, sizeof(struct lpfc_name));
1558 }
1505 rc = BG_ERR_TGT | BG_ERR_CHECK; 1559 rc = BG_ERR_TGT | BG_ERR_CHECK;
1506 1560
1507 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 1561 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
@@ -1516,7 +1570,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1516 */ 1570 */
1517 *apptag = 0xDEAD; 1571 *apptag = 0xDEAD;
1518 phba->lpfc_injerr_wapp_cnt--; 1572 phba->lpfc_injerr_wapp_cnt--;
1519 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 1573 if (phba->lpfc_injerr_wapp_cnt == 0) {
1574 phba->lpfc_injerr_nportid = 0;
1575 phba->lpfc_injerr_lba =
1576 LPFC_INJERR_LBA_OFF;
1577 memset(&phba->lpfc_injerr_wwpn,
1578 0, sizeof(struct lpfc_name));
1579 }
1520 rc = BG_ERR_INIT; 1580 rc = BG_ERR_INIT;
1521 1581
1522 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 1582 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
@@ -1528,11 +1588,6 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1528 if (phba->lpfc_injerr_rapp_cnt) { 1588 if (phba->lpfc_injerr_rapp_cnt) {
1529 switch (op) { 1589 switch (op) {
1530 case SCSI_PROT_READ_INSERT: 1590 case SCSI_PROT_READ_INSERT:
1531 /*
1532 * For READ_INSERT, it doesn't make sense
1533 * to change the apptag.
1534 */
1535 break;
1536 case SCSI_PROT_READ_STRIP: 1591 case SCSI_PROT_READ_STRIP:
1537 case SCSI_PROT_READ_PASS: 1592 case SCSI_PROT_READ_PASS:
1538 /* 1593 /*
@@ -1542,7 +1597,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1542 */ 1597 */
1543 *apptag = 0xDEAD; 1598 *apptag = 0xDEAD;
1544 phba->lpfc_injerr_rapp_cnt--; 1599 phba->lpfc_injerr_rapp_cnt--;
1545 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 1600 if (phba->lpfc_injerr_rapp_cnt == 0) {
1601 phba->lpfc_injerr_nportid = 0;
1602 phba->lpfc_injerr_lba =
1603 LPFC_INJERR_LBA_OFF;
1604 memset(&phba->lpfc_injerr_wwpn,
1605 0, sizeof(struct lpfc_name));
1606 }
1546 rc = BG_ERR_INIT; 1607 rc = BG_ERR_INIT;
1547 1608
1548 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 1609 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
@@ -1569,7 +1630,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1569 * detected by the Target. 1630 * detected by the Target.
1570 */ 1631 */
1571 phba->lpfc_injerr_wgrd_cnt--; 1632 phba->lpfc_injerr_wgrd_cnt--;
1572 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 1633 if (phba->lpfc_injerr_wgrd_cnt == 0) {
1634 phba->lpfc_injerr_nportid = 0;
1635 phba->lpfc_injerr_lba =
1636 LPFC_INJERR_LBA_OFF;
1637 memset(&phba->lpfc_injerr_wwpn,
1638 0, sizeof(struct lpfc_name));
1639 }
1573 1640
1574 rc |= BG_ERR_TGT | BG_ERR_SWAP; 1641 rc |= BG_ERR_TGT | BG_ERR_SWAP;
1575 /* Signals the caller to swap CRC->CSUM */ 1642 /* Signals the caller to swap CRC->CSUM */
@@ -1585,7 +1652,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1585 * being copied from SLI-Host to SLI-Port. 1652 * being copied from SLI-Host to SLI-Port.
1586 */ 1653 */
1587 phba->lpfc_injerr_wgrd_cnt--; 1654 phba->lpfc_injerr_wgrd_cnt--;
1588 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 1655 if (phba->lpfc_injerr_wgrd_cnt == 0) {
1656 phba->lpfc_injerr_nportid = 0;
1657 phba->lpfc_injerr_lba =
1658 LPFC_INJERR_LBA_OFF;
1659 memset(&phba->lpfc_injerr_wwpn,
1660 0, sizeof(struct lpfc_name));
1661 }
1589 1662
1590 rc = BG_ERR_INIT | BG_ERR_SWAP; 1663 rc = BG_ERR_INIT | BG_ERR_SWAP;
1591 /* Signals the caller to swap CRC->CSUM */ 1664 /* Signals the caller to swap CRC->CSUM */
@@ -1599,11 +1672,6 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1599 if (phba->lpfc_injerr_rgrd_cnt) { 1672 if (phba->lpfc_injerr_rgrd_cnt) {
1600 switch (op) { 1673 switch (op) {
1601 case SCSI_PROT_READ_INSERT: 1674 case SCSI_PROT_READ_INSERT:
1602 /*
1603 * For READ_INSERT, it doesn't make sense
1604 * to change the guard tag.
1605 */
1606 break;
1607 case SCSI_PROT_READ_STRIP: 1675 case SCSI_PROT_READ_STRIP:
1608 case SCSI_PROT_READ_PASS: 1676 case SCSI_PROT_READ_PASS:
1609 /* 1677 /*
@@ -1612,7 +1680,13 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1612 * should force an IO error to the driver. 1680 * should force an IO error to the driver.
1613 */ 1681 */
1614 phba->lpfc_injerr_rgrd_cnt--; 1682 phba->lpfc_injerr_rgrd_cnt--;
1615 phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; 1683 if (phba->lpfc_injerr_rgrd_cnt == 0) {
1684 phba->lpfc_injerr_nportid = 0;
1685 phba->lpfc_injerr_lba =
1686 LPFC_INJERR_LBA_OFF;
1687 memset(&phba->lpfc_injerr_wwpn,
1688 0, sizeof(struct lpfc_name));
1689 }
1616 1690
1617 rc = BG_ERR_INIT | BG_ERR_SWAP; 1691 rc = BG_ERR_INIT | BG_ERR_SWAP;
1618 /* Signals the caller to swap CRC->CSUM */ 1692 /* Signals the caller to swap CRC->CSUM */
@@ -1650,20 +1724,20 @@ lpfc_sc_to_bg_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1650 switch (scsi_get_prot_op(sc)) { 1724 switch (scsi_get_prot_op(sc)) {
1651 case SCSI_PROT_READ_INSERT: 1725 case SCSI_PROT_READ_INSERT:
1652 case SCSI_PROT_WRITE_STRIP: 1726 case SCSI_PROT_WRITE_STRIP:
1653 *txop = BG_OP_IN_CSUM_OUT_NODIF;
1654 *rxop = BG_OP_IN_NODIF_OUT_CSUM; 1727 *rxop = BG_OP_IN_NODIF_OUT_CSUM;
1728 *txop = BG_OP_IN_CSUM_OUT_NODIF;
1655 break; 1729 break;
1656 1730
1657 case SCSI_PROT_READ_STRIP: 1731 case SCSI_PROT_READ_STRIP:
1658 case SCSI_PROT_WRITE_INSERT: 1732 case SCSI_PROT_WRITE_INSERT:
1659 *txop = BG_OP_IN_NODIF_OUT_CRC;
1660 *rxop = BG_OP_IN_CRC_OUT_NODIF; 1733 *rxop = BG_OP_IN_CRC_OUT_NODIF;
1734 *txop = BG_OP_IN_NODIF_OUT_CRC;
1661 break; 1735 break;
1662 1736
1663 case SCSI_PROT_READ_PASS: 1737 case SCSI_PROT_READ_PASS:
1664 case SCSI_PROT_WRITE_PASS: 1738 case SCSI_PROT_WRITE_PASS:
1665 *txop = BG_OP_IN_CSUM_OUT_CRC;
1666 *rxop = BG_OP_IN_CRC_OUT_CSUM; 1739 *rxop = BG_OP_IN_CRC_OUT_CSUM;
1740 *txop = BG_OP_IN_CSUM_OUT_CRC;
1667 break; 1741 break;
1668 1742
1669 case SCSI_PROT_NORMAL: 1743 case SCSI_PROT_NORMAL:
@@ -1679,20 +1753,20 @@ lpfc_sc_to_bg_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1679 switch (scsi_get_prot_op(sc)) { 1753 switch (scsi_get_prot_op(sc)) {
1680 case SCSI_PROT_READ_STRIP: 1754 case SCSI_PROT_READ_STRIP:
1681 case SCSI_PROT_WRITE_INSERT: 1755 case SCSI_PROT_WRITE_INSERT:
1682 *txop = BG_OP_IN_NODIF_OUT_CRC;
1683 *rxop = BG_OP_IN_CRC_OUT_NODIF; 1756 *rxop = BG_OP_IN_CRC_OUT_NODIF;
1757 *txop = BG_OP_IN_NODIF_OUT_CRC;
1684 break; 1758 break;
1685 1759
1686 case SCSI_PROT_READ_PASS: 1760 case SCSI_PROT_READ_PASS:
1687 case SCSI_PROT_WRITE_PASS: 1761 case SCSI_PROT_WRITE_PASS:
1688 *txop = BG_OP_IN_CRC_OUT_CRC;
1689 *rxop = BG_OP_IN_CRC_OUT_CRC; 1762 *rxop = BG_OP_IN_CRC_OUT_CRC;
1763 *txop = BG_OP_IN_CRC_OUT_CRC;
1690 break; 1764 break;
1691 1765
1692 case SCSI_PROT_READ_INSERT: 1766 case SCSI_PROT_READ_INSERT:
1693 case SCSI_PROT_WRITE_STRIP: 1767 case SCSI_PROT_WRITE_STRIP:
1694 *txop = BG_OP_IN_CRC_OUT_NODIF;
1695 *rxop = BG_OP_IN_NODIF_OUT_CRC; 1768 *rxop = BG_OP_IN_NODIF_OUT_CRC;
1769 *txop = BG_OP_IN_CRC_OUT_NODIF;
1696 break; 1770 break;
1697 1771
1698 case SCSI_PROT_NORMAL: 1772 case SCSI_PROT_NORMAL:
@@ -1731,20 +1805,20 @@ lpfc_bg_err_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1731 switch (scsi_get_prot_op(sc)) { 1805 switch (scsi_get_prot_op(sc)) {
1732 case SCSI_PROT_READ_INSERT: 1806 case SCSI_PROT_READ_INSERT:
1733 case SCSI_PROT_WRITE_STRIP: 1807 case SCSI_PROT_WRITE_STRIP:
1734 *txop = BG_OP_IN_CRC_OUT_NODIF;
1735 *rxop = BG_OP_IN_NODIF_OUT_CRC; 1808 *rxop = BG_OP_IN_NODIF_OUT_CRC;
1809 *txop = BG_OP_IN_CRC_OUT_NODIF;
1736 break; 1810 break;
1737 1811
1738 case SCSI_PROT_READ_STRIP: 1812 case SCSI_PROT_READ_STRIP:
1739 case SCSI_PROT_WRITE_INSERT: 1813 case SCSI_PROT_WRITE_INSERT:
1740 *txop = BG_OP_IN_NODIF_OUT_CSUM;
1741 *rxop = BG_OP_IN_CSUM_OUT_NODIF; 1814 *rxop = BG_OP_IN_CSUM_OUT_NODIF;
1815 *txop = BG_OP_IN_NODIF_OUT_CSUM;
1742 break; 1816 break;
1743 1817
1744 case SCSI_PROT_READ_PASS: 1818 case SCSI_PROT_READ_PASS:
1745 case SCSI_PROT_WRITE_PASS: 1819 case SCSI_PROT_WRITE_PASS:
1820 *rxop = BG_OP_IN_CSUM_OUT_CRC;
1746 *txop = BG_OP_IN_CRC_OUT_CSUM; 1821 *txop = BG_OP_IN_CRC_OUT_CSUM;
1747 *rxop = BG_OP_IN_CRC_OUT_CRC;
1748 break; 1822 break;
1749 1823
1750 case SCSI_PROT_NORMAL: 1824 case SCSI_PROT_NORMAL:
@@ -1756,20 +1830,20 @@ lpfc_bg_err_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1756 switch (scsi_get_prot_op(sc)) { 1830 switch (scsi_get_prot_op(sc)) {
1757 case SCSI_PROT_READ_STRIP: 1831 case SCSI_PROT_READ_STRIP:
1758 case SCSI_PROT_WRITE_INSERT: 1832 case SCSI_PROT_WRITE_INSERT:
1759 *txop = BG_OP_IN_NODIF_OUT_CSUM;
1760 *rxop = BG_OP_IN_CSUM_OUT_NODIF; 1833 *rxop = BG_OP_IN_CSUM_OUT_NODIF;
1834 *txop = BG_OP_IN_NODIF_OUT_CSUM;
1761 break; 1835 break;
1762 1836
1763 case SCSI_PROT_READ_PASS: 1837 case SCSI_PROT_READ_PASS:
1764 case SCSI_PROT_WRITE_PASS: 1838 case SCSI_PROT_WRITE_PASS:
1839 *rxop = BG_OP_IN_CSUM_OUT_CSUM;
1765 *txop = BG_OP_IN_CSUM_OUT_CSUM; 1840 *txop = BG_OP_IN_CSUM_OUT_CSUM;
1766 *rxop = BG_OP_IN_CRC_OUT_CSUM;
1767 break; 1841 break;
1768 1842
1769 case SCSI_PROT_READ_INSERT: 1843 case SCSI_PROT_READ_INSERT:
1770 case SCSI_PROT_WRITE_STRIP: 1844 case SCSI_PROT_WRITE_STRIP:
1771 *txop = BG_OP_IN_CSUM_OUT_NODIF;
1772 *rxop = BG_OP_IN_NODIF_OUT_CSUM; 1845 *rxop = BG_OP_IN_NODIF_OUT_CSUM;
1846 *txop = BG_OP_IN_CSUM_OUT_NODIF;
1773 break; 1847 break;
1774 1848
1775 case SCSI_PROT_NORMAL: 1849 case SCSI_PROT_NORMAL:
@@ -1838,7 +1912,7 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1838 reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */ 1912 reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */
1839 1913
1840#ifdef CONFIG_SCSI_LPFC_DEBUG_FS 1914#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1841 rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); 1915 rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
1842 if (rc) { 1916 if (rc) {
1843 if (rc & BG_ERR_SWAP) 1917 if (rc & BG_ERR_SWAP)
1844 lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); 1918 lpfc_bg_err_opcodes(phba, sc, &txop, &rxop);
@@ -1985,7 +2059,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1985 reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */ 2059 reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */
1986 2060
1987#ifdef CONFIG_SCSI_LPFC_DEBUG_FS 2061#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
1988 rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); 2062 rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
1989 if (rc) { 2063 if (rc) {
1990 if (rc & BG_ERR_SWAP) 2064 if (rc & BG_ERR_SWAP)
1991 lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); 2065 lpfc_bg_err_opcodes(phba, sc, &txop, &rxop);
@@ -2193,7 +2267,7 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
2193 reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */ 2267 reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */
2194 2268
2195#ifdef CONFIG_SCSI_LPFC_DEBUG_FS 2269#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
2196 rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); 2270 rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
2197 if (rc) { 2271 if (rc) {
2198 if (rc & BG_ERR_SWAP) 2272 if (rc & BG_ERR_SWAP)
2199 lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); 2273 lpfc_bg_err_opcodes(phba, sc, &txop, &rxop);
@@ -2333,7 +2407,7 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
2333 reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */ 2407 reftag = (uint32_t)scsi_get_lba(sc); /* Truncate LBA */
2334 2408
2335#ifdef CONFIG_SCSI_LPFC_DEBUG_FS 2409#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
2336 rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); 2410 rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
2337 if (rc) { 2411 if (rc) {
2338 if (rc & BG_ERR_SWAP) 2412 if (rc & BG_ERR_SWAP)
2339 lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); 2413 lpfc_bg_err_opcodes(phba, sc, &txop, &rxop);
@@ -2809,7 +2883,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd,
2809 /* No error was reported - problem in FW? */ 2883 /* No error was reported - problem in FW? */
2810 cmd->result = ScsiResult(DID_ERROR, 0); 2884 cmd->result = ScsiResult(DID_ERROR, 0);
2811 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 2885 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
2812 "9057 BLKGRD: no errors reported!\n"); 2886 "9057 BLKGRD: Unknown error reported!\n");
2813 } 2887 }
2814 2888
2815out: 2889out: