aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h167
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c149
2 files changed, 177 insertions, 139 deletions
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index 6ba1f307ccce..0cf9a2bd3469 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -1500,7 +1500,6 @@ typedef struct { /* FireFly BIU registers */
1500#define MBXERR_BAD_RCV_LENGTH 14 1500#define MBXERR_BAD_RCV_LENGTH 14
1501#define MBXERR_DMA_ERROR 15 1501#define MBXERR_DMA_ERROR 15
1502#define MBXERR_ERROR 16 1502#define MBXERR_ERROR 16
1503#define MBXERR_UNKNOWN_CMD 18
1504#define MBXERR_LINK_DOWN 0x33 1503#define MBXERR_LINK_DOWN 0x33
1505#define MBX_NOT_FINISHED 255 1504#define MBX_NOT_FINISHED 255
1506 1505
@@ -1566,95 +1565,83 @@ enum lpfc_protgrp_type {
1566}; 1565};
1567 1566
1568/* PDE Descriptors */ 1567/* PDE Descriptors */
1569#define LPFC_PDE1_DESCRIPTOR 0x81 1568#define LPFC_PDE5_DESCRIPTOR 0x85
1570#define LPFC_PDE2_DESCRIPTOR 0x82 1569#define LPFC_PDE6_DESCRIPTOR 0x86
1571#define LPFC_PDE3_DESCRIPTOR 0x83 1570#define LPFC_PDE7_DESCRIPTOR 0x87
1572 1571
1573/* BlockGuard Profiles */ 1572/* BlockGuard Opcodes */
1574enum lpfc_bg_prof_codes { 1573#define BG_OP_IN_NODIF_OUT_CRC 0x0
1575 LPFC_PROF_INVALID, 1574#define BG_OP_IN_CRC_OUT_NODIF 0x1
1576 LPFC_PROF_A1 = 128, /* Full Protection */ 1575#define BG_OP_IN_NODIF_OUT_CSUM 0x2
1577 LPFC_PROF_A2, /* Disabled Protection Checks:A2~A4 */ 1576#define BG_OP_IN_CSUM_OUT_NODIF 0x3
1578 LPFC_PROF_A3, 1577#define BG_OP_IN_CRC_OUT_CRC 0x4
1579 LPFC_PROF_A4, 1578#define BG_OP_IN_CSUM_OUT_CSUM 0x5
1580 LPFC_PROF_B1, /* Embedded DIFs: B1~B3 */ 1579#define BG_OP_IN_CRC_OUT_CSUM 0x6
1581 LPFC_PROF_B2, 1580#define BG_OP_IN_CSUM_OUT_CRC 0x7
1582 LPFC_PROF_B3, 1581
1583 LPFC_PROF_C1, /* Separate DIFs: C1~C3 */ 1582struct lpfc_pde5 {
1584 LPFC_PROF_C2, 1583 uint32_t word0;
1585 LPFC_PROF_C3, 1584#define pde5_type_SHIFT 24
1586 LPFC_PROF_D1, /* Full Protection */ 1585#define pde5_type_MASK 0x000000ff
1587 LPFC_PROF_D2, /* Partial Protection & Check Disabling */ 1586#define pde5_type_WORD word0
1588 LPFC_PROF_D3, 1587#define pde5_rsvd0_SHIFT 0
1589 LPFC_PROF_E1, /* E1~E4:out - check-only, in - update apptag */ 1588#define pde5_rsvd0_MASK 0x00ffffff
1590 LPFC_PROF_E2, 1589#define pde5_rsvd0_WORD word0
1591 LPFC_PROF_E3, 1590 uint32_t reftag; /* Reference Tag Value */
1592 LPFC_PROF_E4, 1591 uint32_t reftagtr; /* Reference Tag Translation Value */
1593 LPFC_PROF_F1, /* Full Translation - F1 Prot Descriptor */
1594 /* F1 Translation BDE */
1595 LPFC_PROF_ANT1, /* TCP checksum, DIF inline with data buffers */
1596 LPFC_PROF_AST1, /* TCP checksum, DIF split from data buffer */
1597 LPFC_PROF_ANT2,
1598 LPFC_PROF_AST2
1599}; 1592};
1600 1593
1601/* BlockGuard error-control defines */ 1594struct lpfc_pde6 {
1602#define BG_EC_STOP_ERR 0x00 1595 uint32_t word0;
1603#define BG_EC_CONT_ERR 0x01 1596#define pde6_type_SHIFT 24
1604#define BG_EC_IGN_UNINIT_STOP_ERR 0x10 1597#define pde6_type_MASK 0x000000ff
1605#define BG_EC_IGN_UNINIT_CONT_ERR 0x11 1598#define pde6_type_WORD word0
1606 1599#define pde6_rsvd0_SHIFT 0
1607/* PDE (Protection Descriptor Entry) word 0 bit masks and shifts */ 1600#define pde6_rsvd0_MASK 0x00ffffff
1608#define PDE_DESC_TYPE_MASK 0xff000000 1601#define pde6_rsvd0_WORD word0
1609#define PDE_DESC_TYPE_SHIFT 24 1602 uint32_t word1;
1610#define PDE_BG_PROFILE_MASK 0x00ff0000 1603#define pde6_rsvd1_SHIFT 26
1611#define PDE_BG_PROFILE_SHIFT 16 1604#define pde6_rsvd1_MASK 0x0000003f
1612#define PDE_BLOCK_LEN_MASK 0x0000fffc 1605#define pde6_rsvd1_WORD word1
1613#define PDE_BLOCK_LEN_SHIFT 2 1606#define pde6_na_SHIFT 25
1614#define PDE_ERR_CTRL_MASK 0x00000003 1607#define pde6_na_MASK 0x00000001
1615#define PDE_ERR_CTRL_SHIFT 0 1608#define pde6_na_WORD word1
1616/* PDE word 1 bit masks and shifts */ 1609#define pde6_rsvd2_SHIFT 16
1617#define PDE_APPTAG_MASK_MASK 0xffff0000 1610#define pde6_rsvd2_MASK 0x000001FF
1618#define PDE_APPTAG_MASK_SHIFT 16 1611#define pde6_rsvd2_WORD word1
1619#define PDE_APPTAG_VAL_MASK 0x0000ffff 1612#define pde6_apptagtr_SHIFT 0
1620#define PDE_APPTAG_VAL_SHIFT 0 1613#define pde6_apptagtr_MASK 0x0000ffff
1621struct lpfc_pde { 1614#define pde6_apptagtr_WORD word1
1622 uint32_t parms; /* bitfields of descriptor, prof, len, and ec */ 1615 uint32_t word2;
1623 uint32_t apptag; /* bitfields of app tag maskand app tag value */ 1616#define pde6_optx_SHIFT 28
1624 uint32_t reftag; /* reference tag occupying all 32 bits */ 1617#define pde6_optx_MASK 0x0000000f
1618#define pde6_optx_WORD word2
1619#define pde6_oprx_SHIFT 24
1620#define pde6_oprx_MASK 0x0000000f
1621#define pde6_oprx_WORD word2
1622#define pde6_nr_SHIFT 23
1623#define pde6_nr_MASK 0x00000001
1624#define pde6_nr_WORD word2
1625#define pde6_ce_SHIFT 22
1626#define pde6_ce_MASK 0x00000001
1627#define pde6_ce_WORD word2
1628#define pde6_re_SHIFT 21
1629#define pde6_re_MASK 0x00000001
1630#define pde6_re_WORD word2
1631#define pde6_ae_SHIFT 20
1632#define pde6_ae_MASK 0x00000001
1633#define pde6_ae_WORD word2
1634#define pde6_ai_SHIFT 19
1635#define pde6_ai_MASK 0x00000001
1636#define pde6_ai_WORD word2
1637#define pde6_bs_SHIFT 16
1638#define pde6_bs_MASK 0x00000007
1639#define pde6_bs_WORD word2
1640#define pde6_apptagval_SHIFT 0
1641#define pde6_apptagval_MASK 0x0000ffff
1642#define pde6_apptagval_WORD word2
1625}; 1643};
1626 1644
1627/* inline function to set fields in parms of PDE */
1628static inline void
1629lpfc_pde_set_bg_parms(struct lpfc_pde *p, u8 desc, u8 prof, u16 len, u8 ec)
1630{
1631 uint32_t *wp = &p->parms;
1632
1633 /* spec indicates that adapter appends two 0's to length field */
1634 len = len >> 2;
1635
1636 *wp &= 0;
1637 *wp |= ((desc << PDE_DESC_TYPE_SHIFT) & PDE_DESC_TYPE_MASK);
1638 *wp |= ((prof << PDE_BG_PROFILE_SHIFT) & PDE_BG_PROFILE_MASK);
1639 *wp |= ((len << PDE_BLOCK_LEN_SHIFT) & PDE_BLOCK_LEN_MASK);
1640 *wp |= ((ec << PDE_ERR_CTRL_SHIFT) & PDE_ERR_CTRL_MASK);
1641 *wp = le32_to_cpu(*wp);
1642}
1643
1644/* inline function to set apptag and reftag fields of PDE */
1645static inline void
1646lpfc_pde_set_dif_parms(struct lpfc_pde *p, u16 apptagmask, u16 apptagval,
1647 u32 reftag)
1648{
1649 uint32_t *wp = &p->apptag;
1650 *wp &= 0;
1651 *wp |= ((apptagmask << PDE_APPTAG_MASK_SHIFT) & PDE_APPTAG_MASK_MASK);
1652 *wp |= ((apptagval << PDE_APPTAG_VAL_SHIFT) & PDE_APPTAG_VAL_MASK);
1653 *wp = le32_to_cpu(*wp);
1654 wp = &p->reftag;
1655 *wp = le32_to_cpu(reftag);
1656}
1657
1658 1645
1659/* Structure for MB Command LOAD_SM and DOWN_LOAD */ 1646/* Structure for MB Command LOAD_SM and DOWN_LOAD */
1660 1647
@@ -2488,8 +2475,8 @@ typedef struct {
2488#define DMP_VPORT_REGION_SIZE 0x200 2475#define DMP_VPORT_REGION_SIZE 0x200
2489#define DMP_MBOX_OFFSET_WORD 0x5 2476#define DMP_MBOX_OFFSET_WORD 0x5
2490 2477
2491#define DMP_REGION_23 0x17 /* fcoe param and port state region */ 2478#define DMP_REGION_23 0x17 /* fcoe param and port state region */
2492#define DMP_RGN23_SIZE 0x400 2479#define DMP_RGN23_SIZE 0x400
2493 2480
2494#define WAKE_UP_PARMS_REGION_ID 4 2481#define WAKE_UP_PARMS_REGION_ID 4
2495#define WAKE_UP_PARMS_WORD_SIZE 15 2482#define WAKE_UP_PARMS_WORD_SIZE 15
@@ -2504,9 +2491,9 @@ struct vport_rec {
2504#define VPORT_INFO_REV 0x1 2491#define VPORT_INFO_REV 0x1
2505#define MAX_STATIC_VPORT_COUNT 16 2492#define MAX_STATIC_VPORT_COUNT 16
2506struct static_vport_info { 2493struct static_vport_info {
2507 uint32_t signature; 2494 uint32_t signature;
2508 uint32_t rev; 2495 uint32_t rev;
2509 struct vport_rec vport_list[MAX_STATIC_VPORT_COUNT]; 2496 struct vport_rec vport_list[MAX_STATIC_VPORT_COUNT];
2510 uint32_t resvd[66]; 2497 uint32_t resvd[66];
2511}; 2498};
2512 2499
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)