Commit cc1146a8 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Ben Walker
Browse files

iscsi: move iSCSI-specific SenseLength into PDU



This removes the 2 bytes of SenseLength from the beginning of the SCSI
sense_data buffer, so now the offsets within sense.data match up to the
expected values from the SCSI spec.

Change-Id: I9188560096a9ec5a8fcf83bec95201521b127494
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent fcb00f37
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -914,6 +914,7 @@ void process_task_completion(spdk_event_t event)
		    (task->scsi.status != SPDK_SCSI_STATUS_GOOD)) {
			memcpy(primary->scsi.sense_data, task->scsi.sense_data,
			       task->scsi.sense_data_len);
			primary->scsi.sense_data_len = task->scsi.sense_data_len;
			primary->scsi.status = task->scsi.status;
		}

+8 −2
Original line number Diff line number Diff line
@@ -3131,7 +3131,10 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
	/* response PDU */
	rsp_pdu = spdk_get_pdu();
	rsph = (struct iscsi_bhs_scsi_resp *)&rsp_pdu->bhs;
	rsp_pdu->data = task->scsi.sense_data;
	assert(task->scsi.sense_data_len <= sizeof(rsp_pdu->sense.data));
	memcpy(rsp_pdu->sense.data, task->scsi.sense_data, task->scsi.sense_data_len);
	to_be16(&rsp_pdu->sense.length, task->scsi.sense_data_len);
	rsp_pdu->data = (uint8_t *)&rsp_pdu->sense;
	rsp_pdu->data_from_mempool = true;

	/*
@@ -3157,7 +3160,10 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
		rsph->flags |= ISCSI_SCSI_UNDERFLOW;

	rsph->status = task->scsi.status;
	DSET24(rsph->data_segment_len, task->scsi.sense_data_len);
	if (task->scsi.sense_data_len) {
		/* SenseLength (2 bytes) + SenseData  */
		DSET24(rsph->data_segment_len, 2 + task->scsi.sense_data_len);
	}
	to_be32(&rsph->itt, task_tag);

	to_be32(&rsph->stat_sn, conn->StatSN);
+5 −0
Original line number Diff line number Diff line
@@ -183,6 +183,11 @@ struct spdk_iscsi_pdu {
	 * we need to not zero this out when doing memory clear.
	 */
	uint8_t ahs_data[ISCSI_AHS_LEN];

	struct {
		uint16_t length; /* iSCSI SenseLength (big-endian) */
		uint8_t data[32];
	} sense;
};

enum iscsi_connection_state {
+1 −1
Original line number Diff line number Diff line
@@ -515,7 +515,7 @@ struct spdk_iscsi_pdu *spdk_get_pdu(void)
		rte_panic("no memory\n");
	}

	/* we do not want to zero out the last 60 bytes reserved for AHS */
	/* we do not want to zero out the last part of the structure reserved for AHS and sense data */
	memset(pdu, 0, offsetof(struct spdk_iscsi_pdu, ahs_data));
	pdu->ref = 1;

+2 −3
Original line number Diff line number Diff line
@@ -1841,9 +1841,8 @@ spdk_bdev_scsi_process_primary(struct spdk_bdev *bdev,

		spdk_scsi_task_build_sense_data(task, sk, asc, ascq);

		/* omit SenseLength */
		data_len = task->sense_data_len - 2;
		memcpy(data, &task->sense_data[2], data_len);
		data_len = task->sense_data_len;
		memcpy(data, task->sense_data, data_len);
		task->data_transferred = (uint64_t)data_len;
		task->status = SPDK_SCSI_STATUS_GOOD;
		break;
Loading