aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_scsi.c
diff options
context:
space:
mode:
authorJames Smart <james.smart@emulex.com>2010-04-06 14:49:53 -0400
committerJames Bottomley <James.Bottomley@suse.de>2010-04-11 14:45:09 -0400
commit6c8eea54ec62c1a3fdb21de583639c49dcdc8811 (patch)
tree81d7a9b54705ccd28be792b73c72604573ccfa87 /drivers/scsi/lpfc/lpfc_scsi.c
parent15672319e3da68bb3f710e724185f4524722a6fa (diff)
[SCSI] lpfc 8.3.12: T10-PI/DIF changes
Update driver for change in T10-PI interface on adapter - Remove Profiles. - Add new SLI Opcodes. - Add new PDE structures used for BlockGuard. Signed-off-by: Alex Iannicelli <alex.iannicelli@emulex.com> Signed-off-by: James Smart <james.smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_scsi.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c149
1 files changed, 100 insertions, 49 deletions
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index dccdb822328c..f4a3b2e79eea 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -1141,37 +1141,47 @@ lpfc_scsi_prep_dma_buf_s3(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1141} 1141}
1142 1142
1143/* 1143/*
1144 * Given a scsi cmnd, determine the BlockGuard profile to be used 1144 * Given a scsi cmnd, determine the BlockGuard opcodes to be used with it
1145 * with the cmd 1145 * @sc: The SCSI command to examine
1146 * @txopt: (out) BlockGuard operation for transmitted data
1147 * @rxopt: (out) BlockGuard operation for received data
1148 *
1149 * Returns: zero on success; non-zero if tx and/or rx op cannot be determined
1150 *
1146 */ 1151 */
1147static int 1152static int
1148lpfc_sc_to_sli_prof(struct lpfc_hba *phba, struct scsi_cmnd *sc) 1153lpfc_sc_to_bg_opcodes(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1154 uint8_t *txop, uint8_t *rxop)
1149{ 1155{
1150 uint8_t guard_type = scsi_host_get_guard(sc->device->host); 1156 uint8_t guard_type = scsi_host_get_guard(sc->device->host);
1151 uint8_t ret_prof = LPFC_PROF_INVALID; 1157 uint8_t ret = 0;
1152 1158
1153 if (guard_type == SHOST_DIX_GUARD_IP) { 1159 if (guard_type == SHOST_DIX_GUARD_IP) {
1154 switch (scsi_get_prot_op(sc)) { 1160 switch (scsi_get_prot_op(sc)) {
1155 case SCSI_PROT_READ_INSERT: 1161 case SCSI_PROT_READ_INSERT:
1156 case SCSI_PROT_WRITE_STRIP: 1162 case SCSI_PROT_WRITE_STRIP:
1157 ret_prof = LPFC_PROF_AST2; 1163 *txop = BG_OP_IN_CSUM_OUT_NODIF;
1164 *rxop = BG_OP_IN_NODIF_OUT_CSUM;
1158 break; 1165 break;
1159 1166
1160 case SCSI_PROT_READ_STRIP: 1167 case SCSI_PROT_READ_STRIP:
1161 case SCSI_PROT_WRITE_INSERT: 1168 case SCSI_PROT_WRITE_INSERT:
1162 ret_prof = LPFC_PROF_A1; 1169 *txop = BG_OP_IN_NODIF_OUT_CRC;
1170 *rxop = BG_OP_IN_CRC_OUT_NODIF;
1163 break; 1171 break;
1164 1172
1165 case SCSI_PROT_READ_PASS: 1173 case SCSI_PROT_READ_PASS:
1166 case SCSI_PROT_WRITE_PASS: 1174 case SCSI_PROT_WRITE_PASS:
1167 ret_prof = LPFC_PROF_AST1; 1175 *txop = BG_OP_IN_CSUM_OUT_CRC;
1176 *rxop = BG_OP_IN_CRC_OUT_CSUM;
1168 break; 1177 break;
1169 1178
1170 case SCSI_PROT_NORMAL: 1179 case SCSI_PROT_NORMAL:
1171 default: 1180 default:
1172 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 1181 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1173 "9063 BLKGRD:Bad op/guard:%d/%d combination\n", 1182 "9063 BLKGRD: Bad op/guard:%d/%d combination\n",
1174 scsi_get_prot_op(sc), guard_type); 1183 scsi_get_prot_op(sc), guard_type);
1184 ret = 1;
1175 break; 1185 break;
1176 1186
1177 } 1187 }
@@ -1179,12 +1189,14 @@ lpfc_sc_to_sli_prof(struct lpfc_hba *phba, struct scsi_cmnd *sc)
1179 switch (scsi_get_prot_op(sc)) { 1189 switch (scsi_get_prot_op(sc)) {
1180 case SCSI_PROT_READ_STRIP: 1190 case SCSI_PROT_READ_STRIP:
1181 case SCSI_PROT_WRITE_INSERT: 1191 case SCSI_PROT_WRITE_INSERT:
1182 ret_prof = LPFC_PROF_A1; 1192 *txop = BG_OP_IN_NODIF_OUT_CRC;
1193 *rxop = BG_OP_IN_CRC_OUT_NODIF;
1183 break; 1194 break;
1184 1195
1185 case SCSI_PROT_READ_PASS: 1196 case SCSI_PROT_READ_PASS:
1186 case SCSI_PROT_WRITE_PASS: 1197 case SCSI_PROT_WRITE_PASS:
1187 ret_prof = LPFC_PROF_C1; 1198 *txop = BG_OP_IN_CRC_OUT_CRC;
1199 *rxop = BG_OP_IN_CRC_OUT_CRC;
1188 break; 1200 break;
1189 1201
1190 case SCSI_PROT_READ_INSERT: 1202 case SCSI_PROT_READ_INSERT:
@@ -1194,6 +1206,7 @@ lpfc_sc_to_sli_prof(struct lpfc_hba *phba, struct scsi_cmnd *sc)
1194 lpfc_printf_log(phba, KERN_ERR, LOG_BG, 1206 lpfc_printf_log(phba, KERN_ERR, LOG_BG,
1195 "9075 BLKGRD: Bad op/guard:%d/%d combination\n", 1207 "9075 BLKGRD: Bad op/guard:%d/%d combination\n",
1196 scsi_get_prot_op(sc), guard_type); 1208 scsi_get_prot_op(sc), guard_type);
1209 ret = 1;
1197 break; 1210 break;
1198 } 1211 }
1199 } else { 1212 } else {
@@ -1201,7 +1214,7 @@ lpfc_sc_to_sli_prof(struct lpfc_hba *phba, struct scsi_cmnd *sc)
1201 BUG(); 1214 BUG();
1202 } 1215 }
1203 1216
1204 return ret_prof; 1217 return ret;
1205} 1218}
1206 1219
1207struct scsi_dif_tuple { 1220struct scsi_dif_tuple {
@@ -1266,7 +1279,9 @@ lpfc_get_cmd_dif_parms(struct scsi_cmnd *sc, uint16_t *apptagmask,
1266 * The buffer list consists of just one protection group described 1279 * The buffer list consists of just one protection group described
1267 * below: 1280 * below:
1268 * +-------------------------+ 1281 * +-------------------------+
1269 * start of prot group --> | PDE_1 | 1282 * start of prot group --> | PDE_5 |
1283 * +-------------------------+
1284 * | PDE_6 |
1270 * +-------------------------+ 1285 * +-------------------------+
1271 * | Data BDE | 1286 * | Data BDE |
1272 * +-------------------------+ 1287 * +-------------------------+
@@ -1284,30 +1299,49 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1284 struct ulp_bde64 *bpl, int datasegcnt) 1299 struct ulp_bde64 *bpl, int datasegcnt)
1285{ 1300{
1286 struct scatterlist *sgde = NULL; /* s/g data entry */ 1301 struct scatterlist *sgde = NULL; /* s/g data entry */
1287 struct lpfc_pde *pde1 = NULL; 1302 struct lpfc_pde5 *pde5 = NULL;
1303 struct lpfc_pde6 *pde6 = NULL;
1288 dma_addr_t physaddr; 1304 dma_addr_t physaddr;
1289 int i = 0, num_bde = 0; 1305 int i = 0, num_bde = 0, status;
1290 int datadir = sc->sc_data_direction; 1306 int datadir = sc->sc_data_direction;
1291 int prof = LPFC_PROF_INVALID;
1292 unsigned blksize; 1307 unsigned blksize;
1293 uint32_t reftag; 1308 uint32_t reftag;
1294 uint16_t apptagmask, apptagval; 1309 uint16_t apptagmask, apptagval;
1310 uint8_t txop, rxop;
1295 1311
1296 pde1 = (struct lpfc_pde *) bpl; 1312 status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop);
1297 prof = lpfc_sc_to_sli_prof(phba, sc); 1313 if (status)
1298
1299 if (prof == LPFC_PROF_INVALID)
1300 goto out; 1314 goto out;
1301 1315
1302 /* extract some info from the scsi command for PDE1*/ 1316 /* extract some info from the scsi command for pde*/
1303 blksize = lpfc_cmd_blksize(sc); 1317 blksize = lpfc_cmd_blksize(sc);
1304 lpfc_get_cmd_dif_parms(sc, &apptagmask, &apptagval, &reftag); 1318 lpfc_get_cmd_dif_parms(sc, &apptagmask, &apptagval, &reftag);
1305 1319
1306 /* setup PDE1 with what we have */ 1320 /* setup PDE5 with what we have */
1307 lpfc_pde_set_bg_parms(pde1, LPFC_PDE1_DESCRIPTOR, prof, blksize, 1321 pde5 = (struct lpfc_pde5 *) bpl;
1308 BG_EC_STOP_ERR); 1322 memset(pde5, 0, sizeof(struct lpfc_pde5));
1309 lpfc_pde_set_dif_parms(pde1, apptagmask, apptagval, reftag); 1323 bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR);
1324 pde5->reftag = reftag;
1310 1325
1326 /* advance bpl and increment bde count */
1327 num_bde++;
1328 bpl++;
1329 pde6 = (struct lpfc_pde6 *) bpl;
1330
1331 /* setup PDE6 with the rest of the info */
1332 memset(pde6, 0, sizeof(struct lpfc_pde6));
1333 bf_set(pde6_type, pde6, LPFC_PDE6_DESCRIPTOR);
1334 bf_set(pde6_optx, pde6, txop);
1335 bf_set(pde6_oprx, pde6, rxop);
1336 if (datadir == DMA_FROM_DEVICE) {
1337 bf_set(pde6_ce, pde6, 1);
1338 bf_set(pde6_re, pde6, 1);
1339 bf_set(pde6_ae, pde6, 1);
1340 }
1341 bf_set(pde6_ai, pde6, 1);
1342 bf_set(pde6_apptagval, pde6, apptagval);
1343
1344 /* advance bpl and increment bde count */
1311 num_bde++; 1345 num_bde++;
1312 bpl++; 1346 bpl++;
1313 1347
@@ -1342,15 +1376,17 @@ out:
1342 * The buffer list for this type consists of one or more of the 1376 * The buffer list for this type consists of one or more of the
1343 * protection groups described below: 1377 * protection groups described below:
1344 * +-------------------------+ 1378 * +-------------------------+
1345 * start of first prot group --> | PDE_1 | 1379 * start of first prot group --> | PDE_5 |
1380 * +-------------------------+
1381 * | PDE_6 |
1346 * +-------------------------+ 1382 * +-------------------------+
1347 * | PDE_3 (Prot BDE) | 1383 * | PDE_7 (Prot BDE) |
1348 * +-------------------------+ 1384 * +-------------------------+
1349 * | Data BDE | 1385 * | Data BDE |
1350 * +-------------------------+ 1386 * +-------------------------+
1351 * |more Data BDE's ... (opt)| 1387 * |more Data BDE's ... (opt)|
1352 * +-------------------------+ 1388 * +-------------------------+
1353 * start of new prot group --> | PDE_1 | 1389 * start of new prot group --> | PDE_5 |
1354 * +-------------------------+ 1390 * +-------------------------+
1355 * | ... | 1391 * | ... |
1356 * +-------------------------+ 1392 * +-------------------------+
@@ -1369,19 +1405,21 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1369{ 1405{
1370 struct scatterlist *sgde = NULL; /* s/g data entry */ 1406 struct scatterlist *sgde = NULL; /* s/g data entry */
1371 struct scatterlist *sgpe = NULL; /* s/g prot entry */ 1407 struct scatterlist *sgpe = NULL; /* s/g prot entry */
1372 struct lpfc_pde *pde1 = NULL; 1408 struct lpfc_pde5 *pde5 = NULL;
1409 struct lpfc_pde6 *pde6 = NULL;
1373 struct ulp_bde64 *prot_bde = NULL; 1410 struct ulp_bde64 *prot_bde = NULL;
1374 dma_addr_t dataphysaddr, protphysaddr; 1411 dma_addr_t dataphysaddr, protphysaddr;
1375 unsigned short curr_data = 0, curr_prot = 0; 1412 unsigned short curr_data = 0, curr_prot = 0;
1376 unsigned int split_offset, protgroup_len; 1413 unsigned int split_offset, protgroup_len;
1377 unsigned int protgrp_blks, protgrp_bytes; 1414 unsigned int protgrp_blks, protgrp_bytes;
1378 unsigned int remainder, subtotal; 1415 unsigned int remainder, subtotal;
1379 int prof = LPFC_PROF_INVALID; 1416 int status;
1380 int datadir = sc->sc_data_direction; 1417 int datadir = sc->sc_data_direction;
1381 unsigned char pgdone = 0, alldone = 0; 1418 unsigned char pgdone = 0, alldone = 0;
1382 unsigned blksize; 1419 unsigned blksize;
1383 uint32_t reftag; 1420 uint32_t reftag;
1384 uint16_t apptagmask, apptagval; 1421 uint16_t apptagmask, apptagval;
1422 uint8_t txop, rxop;
1385 int num_bde = 0; 1423 int num_bde = 0;
1386 1424
1387 sgpe = scsi_prot_sglist(sc); 1425 sgpe = scsi_prot_sglist(sc);
@@ -1394,31 +1432,47 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1394 return 0; 1432 return 0;
1395 } 1433 }
1396 1434
1397 prof = lpfc_sc_to_sli_prof(phba, sc); 1435 status = lpfc_sc_to_bg_opcodes(phba, sc, &txop, &rxop);
1398 if (prof == LPFC_PROF_INVALID) 1436 if (status)
1399 goto out; 1437 goto out;
1400 1438
1401 /* extract some info from the scsi command for PDE1*/ 1439 /* extract some info from the scsi command */
1402 blksize = lpfc_cmd_blksize(sc); 1440 blksize = lpfc_cmd_blksize(sc);
1403 lpfc_get_cmd_dif_parms(sc, &apptagmask, &apptagval, &reftag); 1441 lpfc_get_cmd_dif_parms(sc, &apptagmask, &apptagval, &reftag);
1404 1442
1405 split_offset = 0; 1443 split_offset = 0;
1406 do { 1444 do {
1407 /* setup the first PDE_1 */ 1445 /* setup PDE5 with what we have */
1408 pde1 = (struct lpfc_pde *) bpl; 1446 pde5 = (struct lpfc_pde5 *) bpl;
1409 1447 memset(pde5, 0, sizeof(struct lpfc_pde5));
1410 lpfc_pde_set_bg_parms(pde1, LPFC_PDE1_DESCRIPTOR, prof, blksize, 1448 bf_set(pde5_type, pde5, LPFC_PDE5_DESCRIPTOR);
1411 BG_EC_STOP_ERR); 1449 pde5->reftag = reftag;
1412 lpfc_pde_set_dif_parms(pde1, apptagmask, apptagval, reftag);
1413 1450
1451 /* advance bpl and increment bde count */
1452 num_bde++;
1453 bpl++;
1454 pde6 = (struct lpfc_pde6 *) bpl;
1455
1456 /* setup PDE6 with the rest of the info */
1457 memset(pde6, 0, sizeof(struct lpfc_pde6));
1458 bf_set(pde6_type, pde6, LPFC_PDE6_DESCRIPTOR);
1459 bf_set(pde6_optx, pde6, txop);
1460 bf_set(pde6_oprx, pde6, rxop);
1461 bf_set(pde6_ce, pde6, 1);
1462 bf_set(pde6_re, pde6, 1);
1463 bf_set(pde6_ae, pde6, 1);
1464 bf_set(pde6_ai, pde6, 1);
1465 bf_set(pde6_apptagval, pde6, apptagval);
1466
1467 /* advance bpl and increment bde count */
1414 num_bde++; 1468 num_bde++;
1415 bpl++; 1469 bpl++;
1416 1470
1417 /* setup the first BDE that points to protection buffer */ 1471 /* setup the first BDE that points to protection buffer */
1418 prot_bde = (struct ulp_bde64 *) bpl; 1472 prot_bde = (struct ulp_bde64 *) bpl;
1419 protphysaddr = sg_dma_address(sgpe); 1473 protphysaddr = sg_dma_address(sgpe);
1420 prot_bde->addrLow = le32_to_cpu(putPaddrLow(protphysaddr)); 1474 prot_bde->addrHigh = le32_to_cpu(putPaddrLow(protphysaddr));
1421 prot_bde->addrHigh = le32_to_cpu(putPaddrHigh(protphysaddr)); 1475 prot_bde->addrLow = le32_to_cpu(putPaddrHigh(protphysaddr));
1422 protgroup_len = sg_dma_len(sgpe); 1476 protgroup_len = sg_dma_len(sgpe);
1423 1477
1424 1478
@@ -1429,10 +1483,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1429 protgrp_bytes = protgrp_blks * blksize; 1483 protgrp_bytes = protgrp_blks * blksize;
1430 1484
1431 prot_bde->tus.f.bdeSize = protgroup_len; 1485 prot_bde->tus.f.bdeSize = protgroup_len;
1432 if (datadir == DMA_TO_DEVICE) 1486 prot_bde->tus.f.bdeFlags = LPFC_PDE7_DESCRIPTOR;
1433 prot_bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64;
1434 else
1435 prot_bde->tus.f.bdeFlags = BUFF_TYPE_BDE_64I;
1436 prot_bde->tus.w = le32_to_cpu(bpl->tus.w); 1487 prot_bde->tus.w = le32_to_cpu(bpl->tus.w);
1437 1488
1438 curr_prot++; 1489 curr_prot++;
@@ -1484,6 +1535,7 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1484 1535
1485 /* Move to the next s/g segment if possible */ 1536 /* Move to the next s/g segment if possible */
1486 sgde = sg_next(sgde); 1537 sgde = sg_next(sgde);
1538
1487 } 1539 }
1488 1540
1489 /* are we done ? */ 1541 /* are we done ? */
@@ -1506,7 +1558,6 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
1506 1558
1507out: 1559out:
1508 1560
1509
1510 return num_bde; 1561 return num_bde;
1511} 1562}
1512/* 1563/*
@@ -1828,8 +1879,8 @@ out:
1828 * field of @lpfc_cmd for device with SLI-4 interface spec. 1879 * field of @lpfc_cmd for device with SLI-4 interface spec.
1829 * 1880 *
1830 * Return codes: 1881 * Return codes:
1831 * 1 - Error 1882 * 1 - Error
1832 * 0 - Success 1883 * 0 - Success
1833 **/ 1884 **/
1834static int 1885static int
1835lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) 1886lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
@@ -1937,8 +1988,8 @@ lpfc_scsi_prep_dma_buf_s4(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)
1937 * lpfc_hba struct. 1988 * lpfc_hba struct.
1938 * 1989 *
1939 * Return codes: 1990 * Return codes:
1940 * 1 - Error 1991 * 1 - Error
1941 * 0 - Success 1992 * 0 - Success
1942 **/ 1993 **/
1943static inline int 1994static inline int
1944lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd) 1995lpfc_scsi_prep_dma_buf(struct lpfc_hba *phba, struct lpfc_scsi_buf *lpfc_cmd)