Commit 37bdd0e8 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Ben Walker
Browse files

scsi: Add data offset to DIF context separately from start block address



This patch uses the change by the last patch to initialize DIF
context in SCSI layer. Besides this patch changes the name of a
parameter from offset to data_offset to clarify the meaning.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I54bf1168ec5959432aa15dae0360c0640138b033
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457541


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 73204fe2
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -527,13 +527,13 @@ void spdk_scsi_lun_free_io_channel(struct spdk_scsi_lun_desc *desc);
 *
 * \param lun Logical unit.
 * \param cdb SCSI CDB.
 * \param offset Byte offset in the payload.
 * \param data_offset Byte offset in the payload.
 * \param dif_ctx Output parameter which will contain initialized DIF context.
 *
 * \return true on success or false otherwise.
 */
bool spdk_scsi_lun_get_dif_ctx(struct spdk_scsi_lun *lun, uint8_t *cdb, uint32_t offset,
			       struct spdk_dif_ctx *dif_ctx);
bool spdk_scsi_lun_get_dif_ctx(struct spdk_scsi_lun *lun, uint8_t *cdb,
			       uint32_t data_offset, struct spdk_dif_ctx *dif_ctx);

/**
 * Set iSCSI Initiator port TransportID
+5 −5
Original line number Diff line number Diff line
@@ -4620,7 +4620,7 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
		       struct spdk_dif_ctx *dif_ctx)
{
	struct iscsi_bhs *bhs;
	uint32_t offset = 0;
	uint32_t data_offset = 0;
	uint8_t *cdb = NULL;
	uint64_t lun;
	int lun_id = 0;
@@ -4647,7 +4647,7 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
		struct iscsi_bhs_scsi_req *sbhs;

		sbhs = (struct iscsi_bhs_scsi_req *)bhs;
		offset = 0;
		data_offset = 0;
		cdb = sbhs->cdb;
		lun = from_be64(&sbhs->lun);
		lun_id = spdk_scsi_lun_id_fmt_to_int(lun);
@@ -4659,7 +4659,7 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
		int transfer_tag;

		dbhs = (struct iscsi_bhs_data_out *)bhs;
		offset = from_be32(&dbhs->buffer_offset);
		data_offset = from_be32(&dbhs->buffer_offset);
		transfer_tag = from_be32(&dbhs->ttt);
		task = get_transfer_task(conn, transfer_tag);
		if (task == NULL) {
@@ -4674,7 +4674,7 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
		struct spdk_iscsi_task *task;

		dbhs = (struct iscsi_bhs_data_in *)bhs;
		offset = from_be32(&dbhs->buffer_offset);
		data_offset = from_be32(&dbhs->buffer_offset);
		task = pdu->task;
		assert(task != NULL);
		cdb = task->scsi.cdb;
@@ -4690,7 +4690,7 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
		return false;
	}

	return spdk_scsi_lun_get_dif_ctx(lun_dev, cdb, offset, dif_ctx);
	return spdk_scsi_lun_get_dif_ctx(lun_dev, cdb, data_offset, dif_ctx);
}

void spdk_free_sess(struct spdk_iscsi_sess *sess)
+2 −2
Original line number Diff line number Diff line
@@ -511,7 +511,7 @@ spdk_scsi_lun_is_removing(const struct spdk_scsi_lun *lun)

bool
spdk_scsi_lun_get_dif_ctx(struct spdk_scsi_lun *lun, uint8_t *cdb,
			  uint32_t offset, struct spdk_dif_ctx *dif_ctx)
			  uint32_t data_offset, struct spdk_dif_ctx *dif_ctx)
{
	return spdk_scsi_bdev_get_dif_ctx(lun->bdev, cdb, offset, dif_ctx);
	return spdk_scsi_bdev_get_dif_ctx(lun->bdev, cdb, data_offset, dif_ctx);
}
+3 −5
Original line number Diff line number Diff line
@@ -2115,8 +2115,8 @@ spdk_bdev_scsi_reset(struct spdk_scsi_task *task)
}

bool
spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, uint8_t *cdb, uint32_t offset,
			   struct spdk_dif_ctx *dif_ctx)
spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, uint8_t *cdb,
			   uint32_t data_offset, struct spdk_dif_ctx *dif_ctx)
{
	uint32_t ref_tag = 0, dif_check_flags = 0;
	int rc;
@@ -2147,8 +2147,6 @@ spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, uint8_t *cdb, uint32_t offset
		return false;
	}

	ref_tag += offset / spdk_bdev_get_data_block_size(bdev);

	if (spdk_bdev_is_dif_check_enabled(bdev, SPDK_DIF_CHECK_TYPE_REFTAG)) {
		dif_check_flags |= SPDK_DIF_FLAGS_REFTAG_CHECK;
	}
@@ -2164,7 +2162,7 @@ spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, uint8_t *cdb, uint32_t offset
			       spdk_bdev_is_dif_head_of_md(bdev),
			       spdk_bdev_get_dif_type(bdev),
			       dif_check_flags,
			       ref_tag, 0, 0, 0, 0);
			       ref_tag, 0, 0, data_offset, 0);

	return (rc == 0) ? true : false;
}
+1 −1
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ void spdk_scsi_port_destruct(struct spdk_scsi_port *port);
int spdk_bdev_scsi_execute(struct spdk_scsi_task *task);
void spdk_bdev_scsi_reset(struct spdk_scsi_task *task);

bool spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, uint8_t *cdb, uint32_t offset,
bool spdk_scsi_bdev_get_dif_ctx(struct spdk_bdev *bdev, uint8_t *cdb, uint32_t data_offset,
				struct spdk_dif_ctx *dif_ctx);

int spdk_scsi_pr_out(struct spdk_scsi_task *task, uint8_t *cdb, uint8_t *data, uint16_t data_len);
Loading