|
@@ -438,13 +438,13 @@ int iser_reg_rdma_mem_fmr(struct iscsi_iser_task *iser_task,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static inline void
|
|
|
+static void
|
|
|
iser_set_dif_domain(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs,
|
|
|
struct ib_sig_domain *domain)
|
|
|
{
|
|
|
domain->sig_type = IB_SIG_TYPE_T10_DIF;
|
|
|
- domain->sig.dif.pi_interval = sc->device->sector_size;
|
|
|
- domain->sig.dif.ref_tag = scsi_get_lba(sc) & 0xffffffff;
|
|
|
+ domain->sig.dif.pi_interval = scsi_prot_interval(sc);
|
|
|
+ domain->sig.dif.ref_tag = scsi_prot_ref_tag(sc);
|
|
|
/*
|
|
|
* At the moment we hard code those, but in the future
|
|
|
* we will take them from sc.
|
|
@@ -452,8 +452,7 @@ iser_set_dif_domain(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs,
|
|
|
domain->sig.dif.apptag_check_mask = 0xffff;
|
|
|
domain->sig.dif.app_escape = true;
|
|
|
domain->sig.dif.ref_escape = true;
|
|
|
- if (scsi_get_prot_type(sc) == SCSI_PROT_DIF_TYPE1 ||
|
|
|
- scsi_get_prot_type(sc) == SCSI_PROT_DIF_TYPE2)
|
|
|
+ if (sc->prot_flags & SCSI_PROT_REF_INCREMENT)
|
|
|
domain->sig.dif.ref_remap = true;
|
|
|
};
|
|
|
|
|
@@ -471,26 +470,16 @@ iser_set_sig_attrs(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs)
|
|
|
case SCSI_PROT_WRITE_STRIP:
|
|
|
sig_attrs->wire.sig_type = IB_SIG_TYPE_NONE;
|
|
|
iser_set_dif_domain(sc, sig_attrs, &sig_attrs->mem);
|
|
|
- /*
|
|
|
- * At the moment we use this modparam to tell what is
|
|
|
- * the memory bg_type, in the future we will take it
|
|
|
- * from sc.
|
|
|
- */
|
|
|
- sig_attrs->mem.sig.dif.bg_type = iser_pi_guard ? IB_T10DIF_CSUM :
|
|
|
- IB_T10DIF_CRC;
|
|
|
+ sig_attrs->mem.sig.dif.bg_type = sc->prot_flags & SCSI_PROT_IP_CHECKSUM ?
|
|
|
+ IB_T10DIF_CSUM : IB_T10DIF_CRC;
|
|
|
break;
|
|
|
case SCSI_PROT_READ_PASS:
|
|
|
case SCSI_PROT_WRITE_PASS:
|
|
|
iser_set_dif_domain(sc, sig_attrs, &sig_attrs->wire);
|
|
|
sig_attrs->wire.sig.dif.bg_type = IB_T10DIF_CRC;
|
|
|
iser_set_dif_domain(sc, sig_attrs, &sig_attrs->mem);
|
|
|
- /*
|
|
|
- * At the moment we use this modparam to tell what is
|
|
|
- * the memory bg_type, in the future we will take it
|
|
|
- * from sc.
|
|
|
- */
|
|
|
- sig_attrs->mem.sig.dif.bg_type = iser_pi_guard ? IB_T10DIF_CSUM :
|
|
|
- IB_T10DIF_CRC;
|
|
|
+ sig_attrs->mem.sig.dif.bg_type = sc->prot_flags & SCSI_PROT_IP_CHECKSUM ?
|
|
|
+ IB_T10DIF_CSUM : IB_T10DIF_CRC;
|
|
|
break;
|
|
|
default:
|
|
|
iser_err("Unsupported PI operation %d\n",
|
|
@@ -501,26 +490,14 @@ iser_set_sig_attrs(struct scsi_cmnd *sc, struct ib_sig_attrs *sig_attrs)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int
|
|
|
+static inline void
|
|
|
iser_set_prot_checks(struct scsi_cmnd *sc, u8 *mask)
|
|
|
{
|
|
|
- switch (scsi_get_prot_type(sc)) {
|
|
|
- case SCSI_PROT_DIF_TYPE0:
|
|
|
- break;
|
|
|
- case SCSI_PROT_DIF_TYPE1:
|
|
|
- case SCSI_PROT_DIF_TYPE2:
|
|
|
- *mask = ISER_CHECK_GUARD | ISER_CHECK_REFTAG;
|
|
|
- break;
|
|
|
- case SCSI_PROT_DIF_TYPE3:
|
|
|
- *mask = ISER_CHECK_GUARD;
|
|
|
- break;
|
|
|
- default:
|
|
|
- iser_err("Unsupported protection type %d\n",
|
|
|
- scsi_get_prot_type(sc));
|
|
|
- return -EINVAL;
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
+ *mask = 0;
|
|
|
+ if (sc->prot_flags & SCSI_PROT_REF_CHECK)
|
|
|
+ *mask |= ISER_CHECK_REFTAG;
|
|
|
+ if (sc->prot_flags & SCSI_PROT_GUARD_CHECK)
|
|
|
+ *mask |= ISER_CHECK_GUARD;
|
|
|
}
|
|
|
|
|
|
static void
|
|
@@ -554,9 +531,7 @@ iser_reg_sig_mr(struct iscsi_iser_task *iser_task,
|
|
|
if (ret)
|
|
|
goto err;
|
|
|
|
|
|
- ret = iser_set_prot_checks(iser_task->sc, &sig_attrs.check_mask);
|
|
|
- if (ret)
|
|
|
- goto err;
|
|
|
+ iser_set_prot_checks(iser_task->sc, &sig_attrs.check_mask);
|
|
|
|
|
|
if (!(desc->reg_indicators & ISER_SIG_KEY_VALID)) {
|
|
|
iser_inv_rkey(&inv_wr, pi_ctx->sig_mr);
|
|
@@ -590,12 +565,7 @@ iser_reg_sig_mr(struct iscsi_iser_task *iser_task,
|
|
|
|
|
|
sig_sge->lkey = pi_ctx->sig_mr->lkey;
|
|
|
sig_sge->addr = 0;
|
|
|
- sig_sge->length = data_sge->length + prot_sge->length;
|
|
|
- if (scsi_get_prot_op(iser_task->sc) == SCSI_PROT_WRITE_INSERT ||
|
|
|
- scsi_get_prot_op(iser_task->sc) == SCSI_PROT_READ_STRIP) {
|
|
|
- sig_sge->length += (data_sge->length /
|
|
|
- iser_task->sc->device->sector_size) * 8;
|
|
|
- }
|
|
|
+ sig_sge->length = scsi_transfer_length(iser_task->sc);
|
|
|
|
|
|
iser_dbg("sig_sge: addr: 0x%llx length: %u lkey: 0x%x\n",
|
|
|
sig_sge->addr, sig_sge->length,
|