diff options
author | James Smart <james.smart@emulex.com> | 2012-03-01 22:37:42 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2012-03-27 03:26:33 -0400 |
commit | 9a6b09c071a5f66ed3c359d8631e07b34a9e738f (patch) | |
tree | e295ef167f092f2e3d160f54b12c5583ae6c6728 /drivers/scsi | |
parent | cf9712403f384f9e832f489e7f41ab535c8f1a74 (diff) |
[SCSI] lpfc 8.3.30: Enhancements for 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_debugfs.c | 32 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_scsi.c | 309 | ||||
-rw-r--r-- | drivers/scsi/lpfc/lpfc_scsi.h | 10 |
3 files changed, 203 insertions, 148 deletions
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c index 22e17be04d8a..c4269ee57e9c 100644 --- a/drivers/scsi/lpfc/lpfc_debugfs.c +++ b/drivers/scsi/lpfc/lpfc_debugfs.c | |||
@@ -1010,25 +1010,28 @@ lpfc_debugfs_dif_err_read(struct file *file, char __user *buf, | |||
1010 | { | 1010 | { |
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[16]; | 1013 | char cbuf[32]; |
1014 | int cnt = 0; | 1014 | int cnt = 0; |
1015 | 1015 | ||
1016 | if (dent == phba->debug_writeGuard) | 1016 | if (dent == phba->debug_writeGuard) |
1017 | cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_wgrd_cnt); | 1017 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wgrd_cnt); |
1018 | else if (dent == phba->debug_writeApp) | 1018 | else if (dent == phba->debug_writeApp) |
1019 | cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_wapp_cnt); | 1019 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wapp_cnt); |
1020 | else if (dent == phba->debug_writeRef) | 1020 | else if (dent == phba->debug_writeRef) |
1021 | cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_wref_cnt); | 1021 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_wref_cnt); |
1022 | else if (dent == phba->debug_readGuard) | 1022 | else if (dent == phba->debug_readGuard) |
1023 | cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_rgrd_cnt); | 1023 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rgrd_cnt); |
1024 | else if (dent == phba->debug_readApp) | 1024 | else if (dent == phba->debug_readApp) |
1025 | cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_rapp_cnt); | 1025 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rapp_cnt); |
1026 | else if (dent == phba->debug_readRef) | 1026 | else if (dent == phba->debug_readRef) |
1027 | cnt = snprintf(cbuf, 16, "%u\n", phba->lpfc_injerr_rref_cnt); | 1027 | cnt = snprintf(cbuf, 32, "%u\n", phba->lpfc_injerr_rref_cnt); |
1028 | else if (dent == phba->debug_InjErrLBA) | 1028 | else if (dent == phba->debug_InjErrLBA) { |
1029 | cnt = snprintf(cbuf, 16, "0x%lx\n", | 1029 | if (phba->lpfc_injerr_lba == (unsigned long)(-1)) |
1030 | cnt = snprintf(cbuf, 32, "off\n"); | ||
1031 | else | ||
1032 | cnt = snprintf(cbuf, 32, "0x%lx\n", | ||
1030 | (unsigned long) phba->lpfc_injerr_lba); | 1033 | (unsigned long) phba->lpfc_injerr_lba); |
1031 | else | 1034 | } else |
1032 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 1035 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
1033 | "0547 Unknown debugfs error injection entry\n"); | 1036 | "0547 Unknown debugfs error injection entry\n"); |
1034 | 1037 | ||
@@ -1042,7 +1045,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf, | |||
1042 | struct dentry *dent = file->f_dentry; | 1045 | struct dentry *dent = file->f_dentry; |
1043 | struct lpfc_hba *phba = file->private_data; | 1046 | struct lpfc_hba *phba = file->private_data; |
1044 | char dstbuf[32]; | 1047 | char dstbuf[32]; |
1045 | unsigned long tmp; | 1048 | unsigned long tmp = 0; |
1046 | int size; | 1049 | int size; |
1047 | 1050 | ||
1048 | memset(dstbuf, 0, 32); | 1051 | memset(dstbuf, 0, 32); |
@@ -1050,7 +1053,12 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf, | |||
1050 | if (copy_from_user(dstbuf, buf, size)) | 1053 | if (copy_from_user(dstbuf, buf, size)) |
1051 | return 0; | 1054 | return 0; |
1052 | 1055 | ||
1053 | if (strict_strtoul(dstbuf, 0, &tmp)) | 1056 | if (dent == phba->debug_InjErrLBA) { |
1057 | if ((buf[0] == 'o') && (buf[1] == 'f') && (buf[2] == 'f')) | ||
1058 | tmp = (unsigned long)(-1); | ||
1059 | } | ||
1060 | |||
1061 | if ((tmp == 0) && (kstrtoul(dstbuf, 0, &tmp))) | ||
1054 | return 0; | 1062 | return 0; |
1055 | 1063 | ||
1056 | if (dent == phba->debug_writeGuard) | 1064 | if (dent == phba->debug_writeGuard) |
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index efc055b6bac4..8021c9e1fb9f 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /******************************************************************* | 1 | /******************************************************************r |
2 | * This file is part of the Emulex Linux Device Driver for * | 2 | * This file is part of the Emulex Linux Device Driver for * |
3 | * Fibre Channel Host Bus Adapters. * | 3 | * Fibre Channel Host Bus Adapters. * |
4 | * Copyright (C) 2004-2012 Emulex. All rights reserved. * | 4 | * Copyright (C) 2004-2012 Emulex. All rights reserved. * |
@@ -39,8 +39,8 @@ | |||
39 | #include "lpfc_sli4.h" | 39 | #include "lpfc_sli4.h" |
40 | #include "lpfc_nl.h" | 40 | #include "lpfc_nl.h" |
41 | #include "lpfc_disc.h" | 41 | #include "lpfc_disc.h" |
42 | #include "lpfc_scsi.h" | ||
43 | #include "lpfc.h" | 42 | #include "lpfc.h" |
43 | #include "lpfc_scsi.h" | ||
44 | #include "lpfc_logmsg.h" | 44 | #include "lpfc_logmsg.h" |
45 | #include "lpfc_crtn.h" | 45 | #include "lpfc_crtn.h" |
46 | #include "lpfc_vport.h" | 46 | #include "lpfc_vport.h" |
@@ -51,13 +51,19 @@ | |||
51 | int _dump_buf_done; | 51 | int _dump_buf_done; |
52 | 52 | ||
53 | static char *dif_op_str[] = { | 53 | static char *dif_op_str[] = { |
54 | "SCSI_PROT_NORMAL", | 54 | "PROT_NORMAL", |
55 | "SCSI_PROT_READ_INSERT", | 55 | "PROT_READ_INSERT", |
56 | "SCSI_PROT_WRITE_STRIP", | 56 | "PROT_WRITE_STRIP", |
57 | "SCSI_PROT_READ_STRIP", | 57 | "PROT_READ_STRIP", |
58 | "SCSI_PROT_WRITE_INSERT", | 58 | "PROT_WRITE_INSERT", |
59 | "SCSI_PROT_READ_PASS", | 59 | "PROT_READ_PASS", |
60 | "SCSI_PROT_WRITE_PASS", | 60 | "PROT_WRITE_PASS", |
61 | }; | ||
62 | |||
63 | static char *dif_grd_str[] = { | ||
64 | "NO_GUARD", | ||
65 | "DIF_CRC", | ||
66 | "DIX_IP", | ||
61 | }; | 67 | }; |
62 | 68 | ||
63 | struct scsi_dif_tuple { | 69 | struct scsi_dif_tuple { |
@@ -1281,10 +1287,14 @@ lpfc_cmd_blksize(struct scsi_cmnd *sc) | |||
1281 | 1287 | ||
1282 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | 1288 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
1283 | 1289 | ||
1284 | #define BG_ERR_INIT 1 | 1290 | /* Return if if error injection is detected by Initiator */ |
1285 | #define BG_ERR_TGT 2 | 1291 | #define BG_ERR_INIT 0x1 |
1286 | #define BG_ERR_SWAP 3 | 1292 | /* Return if if error injection is detected by Target */ |
1287 | #define BG_ERR_CHECK 4 | 1293 | #define BG_ERR_TGT 0x2 |
1294 | /* Return if if swapping CSUM<-->CRC is required for error injection */ | ||
1295 | #define BG_ERR_SWAP 0x10 | ||
1296 | /* Return if disabling Guard/Ref/App checking is required for error injection */ | ||
1297 | #define BG_ERR_CHECK 0x20 | ||
1288 | 1298 | ||
1289 | /** | 1299 | /** |
1290 | * lpfc_bg_err_inject - Determine if we should inject an error | 1300 | * lpfc_bg_err_inject - Determine if we should inject an error |
@@ -1294,10 +1304,7 @@ lpfc_cmd_blksize(struct scsi_cmnd *sc) | |||
1294 | * @apptag: (out) BlockGuard application tag for transmitted data | 1304 | * @apptag: (out) BlockGuard application tag for transmitted data |
1295 | * @new_guard (in) Value to replace CRC with if needed | 1305 | * @new_guard (in) Value to replace CRC with if needed |
1296 | * | 1306 | * |
1297 | * Returns (1) if error injection is detected by Initiator | 1307 | * Returns BG_ERR_* bit mask or 0 if request ignored |
1298 | * Returns (2) if error injection is detected by Target | ||
1299 | * Returns (3) if swapping CSUM->CRC is required for error injection | ||
1300 | * Returns (4) disabling Guard/Ref/App checking is required for error injection | ||
1301 | **/ | 1308 | **/ |
1302 | static int | 1309 | static int |
1303 | lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc, | 1310 | lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc, |
@@ -1305,6 +1312,7 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1305 | { | 1312 | { |
1306 | struct scatterlist *sgpe; /* s/g prot entry */ | 1313 | struct scatterlist *sgpe; /* s/g prot entry */ |
1307 | struct scatterlist *sgde; /* s/g data entry */ | 1314 | struct scatterlist *sgde; /* s/g data entry */ |
1315 | struct lpfc_scsi_buf *lpfc_cmd = NULL; | ||
1308 | struct scsi_dif_tuple *src = NULL; | 1316 | struct scsi_dif_tuple *src = NULL; |
1309 | uint32_t op = scsi_get_prot_op(sc); | 1317 | uint32_t op = scsi_get_prot_op(sc); |
1310 | uint32_t blksize; | 1318 | uint32_t blksize; |
@@ -1336,6 +1344,7 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1336 | blockoff = numblks; | 1344 | blockoff = numblks; |
1337 | src = (struct scsi_dif_tuple *)sg_virt(sgpe); | 1345 | src = (struct scsi_dif_tuple *)sg_virt(sgpe); |
1338 | src += blockoff; | 1346 | src += blockoff; |
1347 | lpfc_cmd = (struct lpfc_scsi_buf *)sc->host_scribble; | ||
1339 | } | 1348 | } |
1340 | } | 1349 | } |
1341 | 1350 | ||
@@ -1344,56 +1353,71 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1344 | if (phba->lpfc_injerr_wref_cnt) { | 1353 | if (phba->lpfc_injerr_wref_cnt) { |
1345 | switch (op) { | 1354 | switch (op) { |
1346 | case SCSI_PROT_WRITE_PASS: | 1355 | case SCSI_PROT_WRITE_PASS: |
1347 | if (blockoff && src) { | 1356 | if (src) { |
1348 | /* Insert error in middle of the IO */ | 1357 | /* |
1358 | * For WRITE_PASS, force the error | ||
1359 | * to be sent on the wire. It should | ||
1360 | * be detected by the Target. | ||
1361 | * If blockoff != 0 error will be | ||
1362 | * inserted in middle of the IO. | ||
1363 | */ | ||
1349 | 1364 | ||
1350 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | 1365 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
1351 | "9076 BLKGRD: Injecting reftag error: " | 1366 | "9076 BLKGRD: Injecting reftag error: " |
1352 | "write lba x%lx + x%x oldrefTag x%x\n", | 1367 | "write lba x%lx + x%x oldrefTag x%x\n", |
1353 | (unsigned long)lba, blockoff, | 1368 | (unsigned long)lba, blockoff, |
1354 | src->ref_tag); | 1369 | be32_to_cpu(src->ref_tag)); |
1355 | 1370 | ||
1356 | /* | 1371 | /* |
1357 | * NOTE, this will change ref tag in | 1372 | * Save the old ref_tag so we can |
1358 | * the memory location forever! | 1373 | * restore it on completion. |
1359 | */ | 1374 | */ |
1360 | src->ref_tag = 0xDEADBEEF; | 1375 | if (lpfc_cmd) { |
1376 | lpfc_cmd->prot_data_type = | ||
1377 | LPFC_INJERR_REFTAG; | ||
1378 | lpfc_cmd->prot_data_segment = | ||
1379 | src; | ||
1380 | lpfc_cmd->prot_data = | ||
1381 | src->ref_tag; | ||
1382 | } | ||
1383 | src->ref_tag = cpu_to_be32(0xDEADBEEF); | ||
1361 | phba->lpfc_injerr_wref_cnt--; | 1384 | phba->lpfc_injerr_wref_cnt--; |
1362 | phba->lpfc_injerr_lba = | 1385 | phba->lpfc_injerr_lba = |
1363 | LPFC_INJERR_LBA_OFF; | 1386 | LPFC_INJERR_LBA_OFF; |
1364 | rc = BG_ERR_CHECK; | 1387 | rc = BG_ERR_TGT | BG_ERR_CHECK; |
1388 | |||
1365 | break; | 1389 | break; |
1366 | } | 1390 | } |
1367 | /* Drop thru */ | 1391 | /* Drop thru */ |
1368 | case SCSI_PROT_WRITE_STRIP: | 1392 | case SCSI_PROT_WRITE_INSERT: |
1369 | /* | 1393 | /* |
1370 | * For WRITE_STRIP and WRITE_PASS, | 1394 | * For WRITE_INSERT, force the error |
1371 | * force the error on data | 1395 | * to be sent on the wire. It should be |
1372 | * being copied from SLI-Host to SLI-Port. | 1396 | * detected by the Target. |
1373 | */ | 1397 | */ |
1398 | /* DEADBEEF will be the reftag on the wire */ | ||
1374 | *reftag = 0xDEADBEEF; | 1399 | *reftag = 0xDEADBEEF; |
1375 | phba->lpfc_injerr_wref_cnt--; | 1400 | phba->lpfc_injerr_wref_cnt--; |
1376 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; | 1401 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; |
1377 | rc = BG_ERR_INIT; | 1402 | rc = BG_ERR_TGT | BG_ERR_CHECK; |
1378 | 1403 | ||
1379 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | 1404 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
1380 | "9077 BLKGRD: Injecting reftag error: " | 1405 | "9078 BLKGRD: Injecting reftag error: " |
1381 | "write lba x%lx\n", (unsigned long)lba); | 1406 | "write lba x%lx\n", (unsigned long)lba); |
1382 | break; | 1407 | break; |
1383 | case SCSI_PROT_WRITE_INSERT: | 1408 | case SCSI_PROT_WRITE_STRIP: |
1384 | /* | 1409 | /* |
1385 | * For WRITE_INSERT, force the | 1410 | * For WRITE_STRIP and WRITE_PASS, |
1386 | * error to be sent on the wire. It should be | 1411 | * force the error on data |
1387 | * detected by the Target. | 1412 | * being copied from SLI-Host to SLI-Port. |
1388 | */ | 1413 | */ |
1389 | /* DEADBEEF will be the reftag on the wire */ | ||
1390 | *reftag = 0xDEADBEEF; | 1414 | *reftag = 0xDEADBEEF; |
1391 | phba->lpfc_injerr_wref_cnt--; | 1415 | phba->lpfc_injerr_wref_cnt--; |
1392 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; | 1416 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; |
1393 | rc = BG_ERR_TGT; | 1417 | rc = BG_ERR_INIT; |
1394 | 1418 | ||
1395 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | 1419 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
1396 | "9078 BLKGRD: Injecting reftag error: " | 1420 | "9077 BLKGRD: Injecting reftag error: " |
1397 | "write lba x%lx\n", (unsigned long)lba); | 1421 | "write lba x%lx\n", (unsigned long)lba); |
1398 | break; | 1422 | break; |
1399 | } | 1423 | } |
@@ -1432,55 +1456,71 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1432 | switch (op) { | 1456 | switch (op) { |
1433 | case SCSI_PROT_WRITE_PASS: | 1457 | case SCSI_PROT_WRITE_PASS: |
1434 | if (blockoff && src) { | 1458 | if (blockoff && src) { |
1435 | /* Insert error in middle of the IO */ | 1459 | /* |
1460 | * For WRITE_PASS, force the error | ||
1461 | * to be sent on the wire. It should | ||
1462 | * be detected by the Target. | ||
1463 | * If blockoff != 0 error will be | ||
1464 | * inserted in middle of the IO. | ||
1465 | */ | ||
1466 | |||
1436 | 1467 | ||
1437 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | 1468 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
1438 | "9080 BLKGRD: Injecting apptag error: " | 1469 | "9080 BLKGRD: Injecting apptag error: " |
1439 | "write lba x%lx + x%x oldappTag x%x\n", | 1470 | "write lba x%lx + x%x oldappTag x%x\n", |
1440 | (unsigned long)lba, blockoff, | 1471 | (unsigned long)lba, blockoff, |
1441 | src->app_tag); | 1472 | be16_to_cpu(src->app_tag)); |
1442 | 1473 | ||
1443 | /* | 1474 | /* |
1444 | * NOTE, this will change app tag in | 1475 | * Save the old app_tag so we can |
1445 | * the memory location forever! | 1476 | * restore it on completion. |
1446 | */ | 1477 | */ |
1447 | src->app_tag = 0xDEAD; | 1478 | if (lpfc_cmd) { |
1479 | lpfc_cmd->prot_data_type = | ||
1480 | LPFC_INJERR_APPTAG; | ||
1481 | lpfc_cmd->prot_data_segment = | ||
1482 | src; | ||
1483 | lpfc_cmd->prot_data = | ||
1484 | src->app_tag; | ||
1485 | } | ||
1486 | src->app_tag = cpu_to_be16(0xDEAD); | ||
1448 | phba->lpfc_injerr_wapp_cnt--; | 1487 | phba->lpfc_injerr_wapp_cnt--; |
1449 | phba->lpfc_injerr_lba = | 1488 | phba->lpfc_injerr_lba = |
1450 | LPFC_INJERR_LBA_OFF; | 1489 | LPFC_INJERR_LBA_OFF; |
1451 | rc = BG_ERR_CHECK; | 1490 | rc = BG_ERR_TGT | BG_ERR_CHECK; |
1452 | break; | 1491 | break; |
1453 | } | 1492 | } |
1454 | /* Drop thru */ | 1493 | /* Drop thru */ |
1455 | case SCSI_PROT_WRITE_STRIP: | 1494 | case SCSI_PROT_WRITE_INSERT: |
1456 | /* | 1495 | /* |
1457 | * For WRITE_STRIP and WRITE_PASS, | 1496 | * For WRITE_INSERT, force the |
1458 | * force the error on data | 1497 | * error to be sent on the wire. It should be |
1459 | * being copied from SLI-Host to SLI-Port. | 1498 | * detected by the Target. |
1460 | */ | 1499 | */ |
1500 | /* DEAD will be the apptag on the wire */ | ||
1461 | *apptag = 0xDEAD; | 1501 | *apptag = 0xDEAD; |
1462 | phba->lpfc_injerr_wapp_cnt--; | 1502 | phba->lpfc_injerr_wapp_cnt--; |
1463 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; | 1503 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; |
1464 | rc = BG_ERR_INIT; | 1504 | rc = BG_ERR_TGT; |
1505 | rc = BG_ERR_TGT | BG_ERR_CHECK; | ||
1465 | 1506 | ||
1466 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | 1507 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
1467 | "0812 BLKGRD: Injecting apptag error: " | 1508 | "0813 BLKGRD: Injecting apptag error: " |
1468 | "write lba x%lx\n", (unsigned long)lba); | 1509 | "write lba x%lx\n", (unsigned long)lba); |
1469 | break; | 1510 | break; |
1470 | case SCSI_PROT_WRITE_INSERT: | 1511 | case SCSI_PROT_WRITE_STRIP: |
1471 | /* | 1512 | /* |
1472 | * For WRITE_INSERT, force the | 1513 | * For WRITE_STRIP and WRITE_PASS, |
1473 | * error to be sent on the wire. It should be | 1514 | * force the error on data |
1474 | * detected by the Target. | 1515 | * being copied from SLI-Host to SLI-Port. |
1475 | */ | 1516 | */ |
1476 | /* DEAD will be the apptag on the wire */ | ||
1477 | *apptag = 0xDEAD; | 1517 | *apptag = 0xDEAD; |
1478 | phba->lpfc_injerr_wapp_cnt--; | 1518 | phba->lpfc_injerr_wapp_cnt--; |
1479 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; | 1519 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; |
1480 | rc = BG_ERR_TGT; | 1520 | rc = BG_ERR_INIT; |
1481 | 1521 | ||
1482 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | 1522 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
1483 | "0813 BLKGRD: Injecting apptag error: " | 1523 | "0812 BLKGRD: Injecting apptag error: " |
1484 | "write lba x%lx\n", (unsigned long)lba); | 1524 | "write lba x%lx\n", (unsigned long)lba); |
1485 | break; | 1525 | break; |
1486 | } | 1526 | } |
@@ -1519,57 +1559,39 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1519 | if (phba->lpfc_injerr_wgrd_cnt) { | 1559 | if (phba->lpfc_injerr_wgrd_cnt) { |
1520 | switch (op) { | 1560 | switch (op) { |
1521 | case SCSI_PROT_WRITE_PASS: | 1561 | case SCSI_PROT_WRITE_PASS: |
1522 | if (blockoff && src) { | 1562 | rc = BG_ERR_CHECK; |
1523 | /* Insert error in middle of the IO */ | ||
1524 | |||
1525 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | ||
1526 | "0815 BLKGRD: Injecting guard error: " | ||
1527 | "write lba x%lx + x%x oldgrdTag x%x\n", | ||
1528 | (unsigned long)lba, blockoff, | ||
1529 | src->guard_tag); | ||
1530 | |||
1531 | /* | ||
1532 | * NOTE, this will change guard tag in | ||
1533 | * the memory location forever! | ||
1534 | */ | ||
1535 | src->guard_tag = 0xDEAD; | ||
1536 | phba->lpfc_injerr_wgrd_cnt--; | ||
1537 | phba->lpfc_injerr_lba = | ||
1538 | LPFC_INJERR_LBA_OFF; | ||
1539 | rc = BG_ERR_CHECK; | ||
1540 | break; | ||
1541 | } | ||
1542 | /* Drop thru */ | 1563 | /* Drop thru */ |
1543 | case SCSI_PROT_WRITE_STRIP: | 1564 | |
1565 | case SCSI_PROT_WRITE_INSERT: | ||
1544 | /* | 1566 | /* |
1545 | * For WRITE_STRIP and WRITE_PASS, | 1567 | * For WRITE_INSERT, force the |
1546 | * force the error on data | 1568 | * error to be sent on the wire. It should be |
1547 | * being copied from SLI-Host to SLI-Port. | 1569 | * detected by the Target. |
1548 | */ | 1570 | */ |
1549 | phba->lpfc_injerr_wgrd_cnt--; | 1571 | phba->lpfc_injerr_wgrd_cnt--; |
1550 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; | 1572 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; |
1551 | 1573 | ||
1552 | rc = BG_ERR_SWAP; | 1574 | rc |= BG_ERR_TGT | BG_ERR_SWAP; |
1553 | /* Signals the caller to swap CRC->CSUM */ | 1575 | /* Signals the caller to swap CRC->CSUM */ |
1554 | 1576 | ||
1555 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | 1577 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
1556 | "0816 BLKGRD: Injecting guard error: " | 1578 | "0817 BLKGRD: Injecting guard error: " |
1557 | "write lba x%lx\n", (unsigned long)lba); | 1579 | "write lba x%lx\n", (unsigned long)lba); |
1558 | break; | 1580 | break; |
1559 | case SCSI_PROT_WRITE_INSERT: | 1581 | case SCSI_PROT_WRITE_STRIP: |
1560 | /* | 1582 | /* |
1561 | * For WRITE_INSERT, force the | 1583 | * For WRITE_STRIP and WRITE_PASS, |
1562 | * error to be sent on the wire. It should be | 1584 | * force the error on data |
1563 | * detected by the Target. | 1585 | * being copied from SLI-Host to SLI-Port. |
1564 | */ | 1586 | */ |
1565 | phba->lpfc_injerr_wgrd_cnt--; | 1587 | phba->lpfc_injerr_wgrd_cnt--; |
1566 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; | 1588 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; |
1567 | 1589 | ||
1568 | rc = BG_ERR_SWAP; | 1590 | rc = BG_ERR_INIT | BG_ERR_SWAP; |
1569 | /* Signals the caller to swap CRC->CSUM */ | 1591 | /* Signals the caller to swap CRC->CSUM */ |
1570 | 1592 | ||
1571 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | 1593 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
1572 | "0817 BLKGRD: Injecting guard error: " | 1594 | "0816 BLKGRD: Injecting guard error: " |
1573 | "write lba x%lx\n", (unsigned long)lba); | 1595 | "write lba x%lx\n", (unsigned long)lba); |
1574 | break; | 1596 | break; |
1575 | } | 1597 | } |
@@ -1589,11 +1611,10 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1589 | * error on data being read off the wire. It | 1611 | * error on data being read off the wire. It |
1590 | * should force an IO error to the driver. | 1612 | * should force an IO error to the driver. |
1591 | */ | 1613 | */ |
1592 | *apptag = 0xDEAD; | ||
1593 | phba->lpfc_injerr_rgrd_cnt--; | 1614 | phba->lpfc_injerr_rgrd_cnt--; |
1594 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; | 1615 | phba->lpfc_injerr_lba = LPFC_INJERR_LBA_OFF; |
1595 | 1616 | ||
1596 | rc = BG_ERR_SWAP; | 1617 | rc = BG_ERR_INIT | BG_ERR_SWAP; |
1597 | /* Signals the caller to swap CRC->CSUM */ | 1618 | /* Signals the caller to swap CRC->CSUM */ |
1598 | 1619 | ||
1599 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, | 1620 | lpfc_printf_log(phba, KERN_ERR, LOG_BG, |
@@ -1722,7 +1743,7 @@ lpfc_bg_err_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1722 | 1743 | ||
1723 | case SCSI_PROT_READ_PASS: | 1744 | case SCSI_PROT_READ_PASS: |
1724 | case SCSI_PROT_WRITE_PASS: | 1745 | case SCSI_PROT_WRITE_PASS: |
1725 | *txop = BG_OP_IN_CRC_OUT_CRC; | 1746 | *txop = BG_OP_IN_CRC_OUT_CSUM; |
1726 | *rxop = BG_OP_IN_CRC_OUT_CRC; | 1747 | *rxop = BG_OP_IN_CRC_OUT_CRC; |
1727 | break; | 1748 | break; |
1728 | 1749 | ||
@@ -1741,7 +1762,7 @@ lpfc_bg_err_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1741 | 1762 | ||
1742 | case SCSI_PROT_READ_PASS: | 1763 | case SCSI_PROT_READ_PASS: |
1743 | case SCSI_PROT_WRITE_PASS: | 1764 | case SCSI_PROT_WRITE_PASS: |
1744 | *txop = BG_OP_IN_CSUM_OUT_CRC; | 1765 | *txop = BG_OP_IN_CSUM_OUT_CSUM; |
1745 | *rxop = BG_OP_IN_CRC_OUT_CSUM; | 1766 | *rxop = BG_OP_IN_CRC_OUT_CSUM; |
1746 | break; | 1767 | break; |
1747 | 1768 | ||
@@ -1819,9 +1840,9 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1819 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | 1840 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
1820 | rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); | 1841 | rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); |
1821 | if (rc) { | 1842 | if (rc) { |
1822 | if (rc == BG_ERR_SWAP) | 1843 | if (rc & BG_ERR_SWAP) |
1823 | lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); | 1844 | lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); |
1824 | if (rc == BG_ERR_CHECK) | 1845 | if (rc & BG_ERR_CHECK) |
1825 | checking = 0; | 1846 | checking = 0; |
1826 | } | 1847 | } |
1827 | #endif | 1848 | #endif |
@@ -1966,9 +1987,9 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
1966 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | 1987 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
1967 | rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); | 1988 | rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); |
1968 | if (rc) { | 1989 | if (rc) { |
1969 | if (rc == BG_ERR_SWAP) | 1990 | if (rc & BG_ERR_SWAP) |
1970 | lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); | 1991 | lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); |
1971 | if (rc == BG_ERR_CHECK) | 1992 | if (rc & BG_ERR_CHECK) |
1972 | checking = 0; | 1993 | checking = 0; |
1973 | } | 1994 | } |
1974 | #endif | 1995 | #endif |
@@ -2174,9 +2195,9 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
2174 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | 2195 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
2175 | rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); | 2196 | rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); |
2176 | if (rc) { | 2197 | if (rc) { |
2177 | if (rc == BG_ERR_SWAP) | 2198 | if (rc & BG_ERR_SWAP) |
2178 | lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); | 2199 | lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); |
2179 | if (rc == BG_ERR_CHECK) | 2200 | if (rc & BG_ERR_CHECK) |
2180 | checking = 0; | 2201 | checking = 0; |
2181 | } | 2202 | } |
2182 | #endif | 2203 | #endif |
@@ -2314,9 +2335,9 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, | |||
2314 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | 2335 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS |
2315 | rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); | 2336 | rc = lpfc_bg_err_inject(phba, sc, &reftag, 0, 1); |
2316 | if (rc) { | 2337 | if (rc) { |
2317 | if (rc == BG_ERR_SWAP) | 2338 | if (rc & BG_ERR_SWAP) |
2318 | lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); | 2339 | lpfc_bg_err_opcodes(phba, sc, &txop, &rxop); |
2319 | if (rc == BG_ERR_CHECK) | 2340 | if (rc & BG_ERR_CHECK) |
2320 | checking = 0; | 2341 | checking = 0; |
2321 | } | 2342 | } |
2322 | #endif | 2343 | #endif |
@@ -3460,6 +3481,37 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn, | |||
3460 | /* pick up SLI4 exhange busy status from HBA */ | 3481 | /* pick up SLI4 exhange busy status from HBA */ |
3461 | lpfc_cmd->exch_busy = pIocbOut->iocb_flag & LPFC_EXCHANGE_BUSY; | 3482 | lpfc_cmd->exch_busy = pIocbOut->iocb_flag & LPFC_EXCHANGE_BUSY; |
3462 | 3483 | ||
3484 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | ||
3485 | if (lpfc_cmd->prot_data_type) { | ||
3486 | struct scsi_dif_tuple *src = NULL; | ||
3487 | |||
3488 | src = (struct scsi_dif_tuple *)lpfc_cmd->prot_data_segment; | ||
3489 | /* | ||
3490 | * Used to restore any changes to protection | ||
3491 | * data for error injection. | ||
3492 | */ | ||
3493 | switch (lpfc_cmd->prot_data_type) { | ||
3494 | case LPFC_INJERR_REFTAG: | ||
3495 | src->ref_tag = | ||
3496 | lpfc_cmd->prot_data; | ||
3497 | break; | ||
3498 | case LPFC_INJERR_APPTAG: | ||
3499 | src->app_tag = | ||
3500 | (uint16_t)lpfc_cmd->prot_data; | ||
3501 | break; | ||
3502 | case LPFC_INJERR_GUARD: | ||
3503 | src->guard_tag = | ||
3504 | (uint16_t)lpfc_cmd->prot_data; | ||
3505 | break; | ||
3506 | default: | ||
3507 | break; | ||
3508 | } | ||
3509 | |||
3510 | lpfc_cmd->prot_data = 0; | ||
3511 | lpfc_cmd->prot_data_type = 0; | ||
3512 | lpfc_cmd->prot_data_segment = NULL; | ||
3513 | } | ||
3514 | #endif | ||
3463 | if (pnode && NLP_CHK_NODE_ACT(pnode)) | 3515 | if (pnode && NLP_CHK_NODE_ACT(pnode)) |
3464 | atomic_dec(&pnode->cmd_pending); | 3516 | atomic_dec(&pnode->cmd_pending); |
3465 | 3517 | ||
@@ -4119,63 +4171,48 @@ lpfc_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) | |||
4119 | if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) { | 4171 | if (scsi_get_prot_op(cmnd) != SCSI_PROT_NORMAL) { |
4120 | if (vport->phba->cfg_enable_bg) { | 4172 | if (vport->phba->cfg_enable_bg) { |
4121 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, | 4173 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, |
4122 | "9033 BLKGRD: rcvd protected cmd:%02x op:%02x " | 4174 | "9033 BLKGRD: rcvd protected cmd:%02x op=%s " |
4123 | "str=%s\n", | 4175 | "guard=%s\n", cmnd->cmnd[0], |
4124 | cmnd->cmnd[0], scsi_get_prot_op(cmnd), | 4176 | dif_op_str[scsi_get_prot_op(cmnd)], |
4125 | dif_op_str[scsi_get_prot_op(cmnd)]); | 4177 | dif_grd_str[scsi_host_get_guard(shost)]); |
4126 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, | ||
4127 | "9034 BLKGRD: CDB: %02x %02x %02x %02x %02x " | ||
4128 | "%02x %02x %02x %02x %02x\n", | ||
4129 | cmnd->cmnd[0], cmnd->cmnd[1], cmnd->cmnd[2], | ||
4130 | cmnd->cmnd[3], cmnd->cmnd[4], cmnd->cmnd[5], | ||
4131 | cmnd->cmnd[6], cmnd->cmnd[7], cmnd->cmnd[8], | ||
4132 | cmnd->cmnd[9]); | ||
4133 | if (cmnd->cmnd[0] == READ_10) | 4178 | if (cmnd->cmnd[0] == READ_10) |
4134 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, | 4179 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, |
4135 | "9035 BLKGRD: READ @ sector %llu, " | 4180 | "9035 BLKGRD: READ @ sector %llu, " |
4136 | "count %u\n", | 4181 | "cnt %u, rpt %d\n", |
4137 | (unsigned long long)scsi_get_lba(cmnd), | 4182 | (unsigned long long)scsi_get_lba(cmnd), |
4138 | blk_rq_sectors(cmnd->request)); | 4183 | blk_rq_sectors(cmnd->request), |
4184 | (cmnd->cmnd[1]>>5)); | ||
4139 | else if (cmnd->cmnd[0] == WRITE_10) | 4185 | else if (cmnd->cmnd[0] == WRITE_10) |
4140 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, | 4186 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, |
4141 | "9036 BLKGRD: WRITE @ sector %llu, " | 4187 | "9036 BLKGRD: WRITE @ sector %llu, " |
4142 | "count %u cmd=%p\n", | 4188 | "cnt %u, wpt %d\n", |
4143 | (unsigned long long)scsi_get_lba(cmnd), | 4189 | (unsigned long long)scsi_get_lba(cmnd), |
4144 | blk_rq_sectors(cmnd->request), | 4190 | blk_rq_sectors(cmnd->request), |
4145 | cmnd); | 4191 | (cmnd->cmnd[1]>>5)); |
4146 | } | 4192 | } |
4147 | 4193 | ||
4148 | err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd); | 4194 | err = lpfc_bg_scsi_prep_dma_buf(phba, lpfc_cmd); |
4149 | } else { | 4195 | } else { |
4150 | if (vport->phba->cfg_enable_bg) { | 4196 | if (vport->phba->cfg_enable_bg) { |
4151 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, | 4197 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, |
4152 | "9038 BLKGRD: rcvd unprotected cmd:" | 4198 | "9038 BLKGRD: rcvd unprotected cmd:" |
4153 | "%02x op:%02x str=%s\n", | 4199 | "%02x op=%s guard=%s\n", cmnd->cmnd[0], |
4154 | cmnd->cmnd[0], scsi_get_prot_op(cmnd), | 4200 | dif_op_str[scsi_get_prot_op(cmnd)], |
4155 | dif_op_str[scsi_get_prot_op(cmnd)]); | 4201 | dif_grd_str[scsi_host_get_guard(shost)]); |
4156 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, | ||
4157 | "9039 BLKGRD: CDB: %02x %02x %02x " | ||
4158 | "%02x %02x %02x %02x %02x %02x %02x\n", | ||
4159 | cmnd->cmnd[0], cmnd->cmnd[1], | ||
4160 | cmnd->cmnd[2], cmnd->cmnd[3], | ||
4161 | cmnd->cmnd[4], cmnd->cmnd[5], | ||
4162 | cmnd->cmnd[6], cmnd->cmnd[7], | ||
4163 | cmnd->cmnd[8], cmnd->cmnd[9]); | ||
4164 | if (cmnd->cmnd[0] == READ_10) | 4202 | if (cmnd->cmnd[0] == READ_10) |
4165 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, | 4203 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, |
4166 | "9040 dbg: READ @ sector %llu, " | 4204 | "9040 dbg: READ @ sector %llu, " |
4167 | "count %u\n", | 4205 | "cnt %u, rpt %d\n", |
4168 | (unsigned long long)scsi_get_lba(cmnd), | 4206 | (unsigned long long)scsi_get_lba(cmnd), |
4169 | blk_rq_sectors(cmnd->request)); | 4207 | blk_rq_sectors(cmnd->request), |
4208 | (cmnd->cmnd[1]>>5)); | ||
4170 | else if (cmnd->cmnd[0] == WRITE_10) | 4209 | else if (cmnd->cmnd[0] == WRITE_10) |
4171 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, | 4210 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, |
4172 | "9041 dbg: WRITE @ sector %llu, " | 4211 | "9041 dbg: WRITE @ sector %llu, " |
4173 | "count %u cmd=%p\n", | 4212 | "cnt %u, wpt %d\n", |
4174 | (unsigned long long)scsi_get_lba(cmnd), | 4213 | (unsigned long long)scsi_get_lba(cmnd), |
4175 | blk_rq_sectors(cmnd->request), cmnd); | 4214 | blk_rq_sectors(cmnd->request), |
4176 | else | 4215 | (cmnd->cmnd[1]>>5)); |
4177 | lpfc_printf_vlog(vport, KERN_WARNING, LOG_BG, | ||
4178 | "9042 dbg: parser not implemented\n"); | ||
4179 | } | 4216 | } |
4180 | err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd); | 4217 | err = lpfc_scsi_prep_dma_buf(phba, lpfc_cmd); |
4181 | } | 4218 | } |
diff --git a/drivers/scsi/lpfc/lpfc_scsi.h b/drivers/scsi/lpfc/lpfc_scsi.h index 9075a08cf781..5a5b98e58593 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.h +++ b/drivers/scsi/lpfc/lpfc_scsi.h | |||
@@ -150,6 +150,16 @@ struct lpfc_scsi_buf { | |||
150 | struct lpfc_iocbq cur_iocbq; | 150 | struct lpfc_iocbq cur_iocbq; |
151 | wait_queue_head_t *waitq; | 151 | wait_queue_head_t *waitq; |
152 | unsigned long start_time; | 152 | unsigned long start_time; |
153 | |||
154 | #ifdef CONFIG_SCSI_LPFC_DEBUG_FS | ||
155 | /* Used to restore any changes to protection data for error injection */ | ||
156 | void *prot_data_segment; | ||
157 | uint32_t prot_data; | ||
158 | uint32_t prot_data_type; | ||
159 | #define LPFC_INJERR_REFTAG 1 | ||
160 | #define LPFC_INJERR_APPTAG 2 | ||
161 | #define LPFC_INJERR_GUARD 3 | ||
162 | #endif | ||
153 | }; | 163 | }; |
154 | 164 | ||
155 | #define LPFC_SCSI_DMA_EXT_SIZE 264 | 165 | #define LPFC_SCSI_DMA_EXT_SIZE 264 |