Revert "iscsi: change the field bhs to pointer type."

This reverts commit 80cf038ced.

Signed-off-by: Seth Howell <seth.howell@intel.com>
Change-Id: I95e2ddfbc9cd07e874a385b345dc401fc8076e88
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468778
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Seth Howell 2019-09-18 21:00:07 -07:00 committed by Changpeng Liu
parent a19e674be0
commit 72d06a99e1
7 changed files with 122 additions and 129 deletions

View File

@ -309,17 +309,17 @@ void
spdk_iscsi_conn_free_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) spdk_iscsi_conn_free_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{ {
if (pdu->task) { if (pdu->task) {
if (pdu->bhs->opcode == ISCSI_OP_SCSI_DATAIN) { if (pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN) {
if (pdu->task->scsi.offset > 0) { if (pdu->task->scsi.offset > 0) {
conn->data_in_cnt--; conn->data_in_cnt--;
if (pdu->bhs->flags & ISCSI_DATAIN_STATUS) { if (pdu->bhs.flags & ISCSI_DATAIN_STATUS) {
/* Free the primary task after the last subtask done */ /* Free the primary task after the last subtask done */
conn->data_in_cnt--; conn->data_in_cnt--;
spdk_iscsi_task_put(spdk_iscsi_task_get_primary(pdu->task)); spdk_iscsi_task_put(spdk_iscsi_task_get_primary(pdu->task));
} }
spdk_iscsi_conn_handle_queued_datain_tasks(conn); spdk_iscsi_conn_handle_queued_datain_tasks(conn);
} }
} else if (pdu->bhs->opcode == ISCSI_OP_SCSI_RSP && } else if (pdu->bhs.opcode == ISCSI_OP_SCSI_RSP &&
pdu->task->scsi.status != SPDK_SCSI_STATUS_GOOD) { pdu->task->scsi.status != SPDK_SCSI_STATUS_GOOD) {
if (pdu->task->scsi.offset > 0) { if (pdu->task->scsi.offset > 0) {
spdk_iscsi_task_put(spdk_iscsi_task_get_primary(pdu->task)); spdk_iscsi_task_put(spdk_iscsi_task_get_primary(pdu->task));
@ -1087,19 +1087,19 @@ iscsi_get_pdu_length(struct spdk_iscsi_pdu *pdu, int header_digest,
int data_len, enable_digest, total; int data_len, enable_digest, total;
enable_digest = 1; enable_digest = 1;
if (pdu->bhs->opcode == ISCSI_OP_LOGIN_RSP) { if (pdu->bhs.opcode == ISCSI_OP_LOGIN_RSP) {
enable_digest = 0; enable_digest = 0;
} }
total = ISCSI_BHS_LEN; total = ISCSI_BHS_LEN;
total += (4 * pdu->bhs->total_ahs_len); total += (4 * pdu->bhs.total_ahs_len);
if (enable_digest && header_digest) { if (enable_digest && header_digest) {
total += ISCSI_DIGEST_LEN; total += ISCSI_DIGEST_LEN;
} }
data_len = DGET24(pdu->bhs->data_segment_len); data_len = DGET24(pdu->bhs.data_segment_len);
if (data_len > 0) { if (data_len > 0) {
total += ISCSI_ALIGN(data_len); total += ISCSI_ALIGN(data_len);
if (enable_digest && data_digest) { if (enable_digest && data_digest) {
@ -1228,7 +1228,7 @@ iscsi_conn_flush_pdus_internal(struct spdk_iscsi_conn *conn)
(conn->sess->ErrorRecoveryLevel >= 1) && (conn->sess->ErrorRecoveryLevel >= 1) &&
spdk_iscsi_is_deferred_free_pdu(pdu)) { spdk_iscsi_is_deferred_free_pdu(pdu)) {
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "stat_sn=%d\n", SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "stat_sn=%d\n",
from_be32(&pdu->bhs->stat_sn)); from_be32(&pdu->bhs.stat_sn));
TAILQ_INSERT_TAIL(&conn->snack_pdu_list, pdu, TAILQ_INSERT_TAIL(&conn->snack_pdu_list, pdu,
tailq); tailq);
} else { } else {
@ -1334,7 +1334,7 @@ spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p
pdu->dif_insert_or_strip = true; pdu->dif_insert_or_strip = true;
} }
if (pdu->bhs->opcode != ISCSI_OP_LOGIN_RSP) { if (pdu->bhs.opcode != ISCSI_OP_LOGIN_RSP) {
/* Header Digest */ /* Header Digest */
if (conn->header_digest) { if (conn->header_digest) {
crc32c = spdk_iscsi_pdu_calc_header_digest(pdu); crc32c = spdk_iscsi_pdu_calc_header_digest(pdu);
@ -1342,7 +1342,7 @@ spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p
} }
/* Data Digest */ /* Data Digest */
if (conn->data_digest && DGET24(pdu->bhs->data_segment_len) != 0) { if (conn->data_digest && DGET24(pdu->bhs.data_segment_len) != 0) {
crc32c = spdk_iscsi_pdu_calc_data_digest(pdu); crc32c = spdk_iscsi_pdu_calc_data_digest(pdu);
MAKE_DIGEST_WORD(pdu->data_digest, crc32c); MAKE_DIGEST_WORD(pdu->data_digest, crc32c);
} }

View File

@ -283,7 +283,7 @@ uint32_t
spdk_iscsi_pdu_calc_header_digest(struct spdk_iscsi_pdu *pdu) spdk_iscsi_pdu_calc_header_digest(struct spdk_iscsi_pdu *pdu)
{ {
uint32_t crc32c; uint32_t crc32c;
uint32_t ahs_len_bytes = pdu->bhs->total_ahs_len * 4; uint32_t ahs_len_bytes = pdu->bhs.total_ahs_len * 4;
crc32c = SPDK_CRC32C_INITIAL; crc32c = SPDK_CRC32C_INITIAL;
crc32c = spdk_crc32c_update(&pdu->bhs, ISCSI_BHS_LEN, crc32c); crc32c = spdk_crc32c_update(&pdu->bhs, ISCSI_BHS_LEN, crc32c);
@ -300,7 +300,7 @@ spdk_iscsi_pdu_calc_header_digest(struct spdk_iscsi_pdu *pdu)
uint32_t uint32_t
spdk_iscsi_pdu_calc_data_digest(struct spdk_iscsi_pdu *pdu) spdk_iscsi_pdu_calc_data_digest(struct spdk_iscsi_pdu *pdu)
{ {
uint32_t data_len = DGET24(pdu->bhs->data_segment_len); uint32_t data_len = DGET24(pdu->bhs.data_segment_len);
uint32_t crc32c; uint32_t crc32c;
uint32_t mod; uint32_t mod;
struct iovec iov; struct iovec iov;
@ -357,8 +357,8 @@ iscsi_check_data_segment_length(struct spdk_iscsi_conn *conn,
* value. * value.
*/ */
max_segment_len = SPDK_ISCSI_FIRST_BURST_LENGTH; max_segment_len = SPDK_ISCSI_FIRST_BURST_LENGTH;
} else if (pdu->bhs->opcode == ISCSI_OP_SCSI_DATAOUT || } else if (pdu->bhs.opcode == ISCSI_OP_SCSI_DATAOUT ||
pdu->bhs->opcode == ISCSI_OP_NOPOUT) { pdu->bhs.opcode == ISCSI_OP_NOPOUT) {
max_segment_len = SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH; max_segment_len = SPDK_ISCSI_MAX_RECV_DATA_SEGMENT_LENGTH;
} else { } else {
max_segment_len = spdk_get_max_immediate_data_size(); max_segment_len = spdk_get_max_immediate_data_size();
@ -430,7 +430,7 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu)
if (pdu->bhs_valid_bytes < ISCSI_BHS_LEN) { if (pdu->bhs_valid_bytes < ISCSI_BHS_LEN) {
rc = spdk_iscsi_conn_read_data(conn, rc = spdk_iscsi_conn_read_data(conn,
ISCSI_BHS_LEN - pdu->bhs_valid_bytes, ISCSI_BHS_LEN - pdu->bhs_valid_bytes,
(uint8_t *)pdu->bhs + pdu->bhs_valid_bytes); (uint8_t *)&pdu->bhs + pdu->bhs_valid_bytes);
if (rc < 0) { if (rc < 0) {
goto error; goto error;
} }
@ -440,10 +440,10 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu)
} }
} }
data_len = ISCSI_ALIGN(DGET24(pdu->bhs->data_segment_len)); data_len = ISCSI_ALIGN(DGET24(pdu->bhs.data_segment_len));
/* AHS */ /* AHS */
ahs_len = pdu->bhs->total_ahs_len * 4; ahs_len = pdu->bhs.total_ahs_len * 4;
assert(ahs_len <= ISCSI_AHS_LEN); assert(ahs_len <= ISCSI_AHS_LEN);
if (pdu->ahs_valid_bytes < ahs_len) { if (pdu->ahs_valid_bytes < ahs_len) {
rc = spdk_iscsi_conn_read_data(conn, rc = spdk_iscsi_conn_read_data(conn,
@ -532,7 +532,7 @@ spdk_iscsi_read_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu **_pdu)
conn->pdu_in_progress = NULL; conn->pdu_in_progress = NULL;
spdk_trace_record(TRACE_ISCSI_READ_PDU, conn->id, pdu->data_valid_bytes, spdk_trace_record(TRACE_ISCSI_READ_PDU, conn->id, pdu->data_valid_bytes,
(uintptr_t)pdu, pdu->bhs->opcode); (uintptr_t)pdu, pdu->bhs.opcode);
/* Data Segment */ /* Data Segment */
if (data_len != 0) { if (data_len != 0) {
@ -676,12 +676,12 @@ spdk_iscsi_build_iovs(struct spdk_iscsi_conn *conn, struct iovec *iovs, int iovc
return 0; return 0;
} }
total_ahs_len = pdu->bhs->total_ahs_len; total_ahs_len = pdu->bhs.total_ahs_len;
data_len = DGET24(pdu->bhs->data_segment_len); data_len = DGET24(pdu->bhs.data_segment_len);
data_len = ISCSI_ALIGN(data_len); data_len = ISCSI_ALIGN(data_len);
enable_digest = 1; enable_digest = 1;
if (pdu->bhs->opcode == ISCSI_OP_LOGIN_RSP) { if (pdu->bhs.opcode == ISCSI_OP_LOGIN_RSP) {
/* this PDU should be sent without digest */ /* this PDU should be sent without digest */
enable_digest = 0; enable_digest = 0;
} }
@ -689,7 +689,7 @@ spdk_iscsi_build_iovs(struct spdk_iscsi_conn *conn, struct iovec *iovs, int iovc
_iscsi_sgl_init(&sgl, iovs, iovcnt, pdu->writev_offset); _iscsi_sgl_init(&sgl, iovs, iovcnt, pdu->writev_offset);
/* BHS */ /* BHS */
if (!_iscsi_sgl_append(&sgl, (uint8_t *)pdu->bhs, ISCSI_BHS_LEN)) { if (!_iscsi_sgl_append(&sgl, (uint8_t *)&pdu->bhs, ISCSI_BHS_LEN)) {
goto end; goto end;
} }
/* AHS */ /* AHS */
@ -1069,7 +1069,7 @@ iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
int data_len; int data_len;
int alloc_len; int alloc_len;
total_ahs_len = pdu->bhs->total_ahs_len; total_ahs_len = pdu->bhs.total_ahs_len;
data_len = 0; data_len = 0;
alloc_len = ISCSI_BHS_LEN + (4 * total_ahs_len); alloc_len = ISCSI_BHS_LEN + (4 * total_ahs_len);
@ -1094,7 +1094,7 @@ iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "StatSN=%u\n", conn->StatSN); SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "StatSN=%u\n", conn->StatSN);
} }
memcpy(data, pdu->bhs, ISCSI_BHS_LEN); memcpy(data, &pdu->bhs, ISCSI_BHS_LEN);
data_len += ISCSI_BHS_LEN; data_len += ISCSI_BHS_LEN;
if (total_ahs_len != 0) { if (total_ahs_len != 0) {
@ -1113,7 +1113,7 @@ iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
return -ENOMEM; return -ENOMEM;
} }
rsph = (struct iscsi_bhs_reject *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_reject *)&rsp_pdu->bhs;
rsp_pdu->data = data; rsp_pdu->data = data;
rsph->opcode = ISCSI_OP_REJECT; rsph->opcode = ISCSI_OP_REJECT;
rsph->flags |= 0x80; /* bit 0 is default to 1 */ rsph->flags |= 0x80; /* bit 0 is default to 1 */
@ -1132,7 +1132,7 @@ iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
to_be32(&rsph->max_cmd_sn, 1); to_be32(&rsph->max_cmd_sn, 1);
} }
SPDK_LOGDUMP(SPDK_LOG_ISCSI, "PDU", (void *)rsp_pdu->bhs, ISCSI_BHS_LEN); SPDK_LOGDUMP(SPDK_LOG_ISCSI, "PDU", (void *)&rsp_pdu->bhs, ISCSI_BHS_LEN);
spdk_iscsi_conn_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
@ -1185,7 +1185,7 @@ iscsi_op_login_response(struct spdk_iscsi_conn *conn,
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
int rc; int rc;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
rsph->version_max = ISCSI_VERSION; rsph->version_max = ISCSI_VERSION;
rsph->version_act = ISCSI_VERSION; rsph->version_act = ISCSI_VERSION;
DSET24(rsph->data_segment_len, rsp_pdu->data_segment_len); DSET24(rsph->data_segment_len, rsp_pdu->data_segment_len);
@ -1379,7 +1379,7 @@ iscsi_op_login_check_session(struct spdk_iscsi_conn *conn,
int rc = 0; int rc = 0;
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
/* check existing session */ /* check existing session */
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "isid=%"PRIx64", tsih=%u, cid=%u\n", SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "isid=%"PRIx64", tsih=%u, cid=%u\n",
iscsi_get_isid(rsph->isid), from_be16(&rsph->tsih), cid); iscsi_get_isid(rsph->isid), from_be16(&rsph->tsih), cid);
@ -1420,7 +1420,7 @@ iscsi_op_login_check_target(struct spdk_iscsi_conn *conn,
bool result; bool result;
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
*target = spdk_iscsi_find_tgt_node(target_name); *target = spdk_iscsi_find_tgt_node(target_name);
if (*target == NULL) { if (*target == NULL) {
SPDK_WARNLOG("target %s not found\n", target_name); SPDK_WARNLOG("target %s not found\n", target_name);
@ -1467,7 +1467,7 @@ iscsi_op_login_session_normal(struct spdk_iscsi_conn *conn,
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
int rc = 0; int rc = 0;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
target_name = spdk_iscsi_param_get_val(params, "TargetName"); target_name = spdk_iscsi_param_get_val(params, "TargetName");
if (target_name == NULL) { if (target_name == NULL) {
@ -1546,7 +1546,7 @@ iscsi_op_login_session_type(struct spdk_iscsi_conn *conn,
const char *session_type_str; const char *session_type_str;
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
session_type_str = spdk_iscsi_param_get_val(params, "SessionType"); session_type_str = spdk_iscsi_param_get_val(params, "SessionType");
if (session_type_str == NULL) { if (session_type_str == NULL) {
if (rsph->tsih != 0) { if (rsph->tsih != 0) {
@ -1591,7 +1591,7 @@ iscsi_op_login_initialize_port(struct spdk_iscsi_conn *conn,
{ {
const char *val; const char *val;
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
/* Initiator Name and Port */ /* Initiator Name and Port */
val = spdk_iscsi_param_get_val(params, "InitiatorName"); val = spdk_iscsi_param_get_val(params, "InitiatorName");
@ -1632,7 +1632,7 @@ iscsi_op_login_set_conn_info(struct spdk_iscsi_conn *conn,
target = conn->target; target = conn->target;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
conn->authenticated = false; conn->authenticated = false;
conn->auth.chap_phase = ISCSI_CHAP_PHASE_WAIT_A; conn->auth.chap_phase = ISCSI_CHAP_PHASE_WAIT_A;
conn->cid = cid; conn->cid = cid;
@ -1776,7 +1776,7 @@ iscsi_op_login_phase_none(struct spdk_iscsi_conn *conn,
char initiator_port_name[MAX_INITIATOR_PORT_NAME]; char initiator_port_name[MAX_INITIATOR_PORT_NAME];
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
int rc = 0; int rc = 0;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
conn->target = NULL; conn->target = NULL;
conn->dev = NULL; conn->dev = NULL;
@ -1857,7 +1857,7 @@ iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
int rc; int rc;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
rsph->opcode = ISCSI_OP_LOGIN_RSP; rsph->opcode = ISCSI_OP_LOGIN_RSP;
rsph->status_class = ISCSI_CLASS_SUCCESS; rsph->status_class = ISCSI_CLASS_SUCCESS;
rsph->status_detail = ISCSI_LOGIN_ACCEPT; rsph->status_detail = ISCSI_LOGIN_ACCEPT;
@ -1878,7 +1878,7 @@ iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
} }
reqh = (struct iscsi_bhs_login_req *)pdu->bhs; reqh = (struct iscsi_bhs_login_req *)&pdu->bhs;
rsph->flags |= (reqh->flags & ISCSI_LOGIN_TRANSIT); rsph->flags |= (reqh->flags & ISCSI_LOGIN_TRANSIT);
rsph->flags |= (reqh->flags & ISCSI_LOGIN_CONTINUE); rsph->flags |= (reqh->flags & ISCSI_LOGIN_CONTINUE);
rsph->flags |= (reqh->flags & ISCSI_LOGIN_CURRENT_STAGE_MASK); rsph->flags |= (reqh->flags & ISCSI_LOGIN_CURRENT_STAGE_MASK);
@ -1897,7 +1897,7 @@ iscsi_op_login_rsp_init(struct spdk_iscsi_conn *conn,
rsph->stat_sn = reqh->exp_stat_sn; rsph->stat_sn = reqh->exp_stat_sn;
} }
SPDK_LOGDUMP(SPDK_LOG_ISCSI, "PDU", (uint8_t *)pdu->bhs, ISCSI_BHS_LEN); SPDK_LOGDUMP(SPDK_LOG_ISCSI, "PDU", (uint8_t *)&pdu->bhs, ISCSI_BHS_LEN);
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, SPDK_DEBUGLOG(SPDK_LOG_ISCSI,
"T=%d, C=%d, CSG=%d, NSG=%d, Min=%d, Max=%d, ITT=%x\n", "T=%d, C=%d, CSG=%d, NSG=%d, Min=%d, Max=%d, ITT=%x\n",
@ -1980,7 +1980,7 @@ iscsi_op_login_rsp_handle_csg_bit(struct spdk_iscsi_conn *conn,
const char *auth_method; const char *auth_method;
int rc; int rc;
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
switch (ISCSI_BHS_LOGIN_GET_CSG(rsph->flags)) { switch (ISCSI_BHS_LOGIN_GET_CSG(rsph->flags)) {
case ISCSI_SECURITY_NEGOTIATION_PHASE: case ISCSI_SECURITY_NEGOTIATION_PHASE:
@ -2073,7 +2073,7 @@ iscsi_op_login_notify_session_info(struct spdk_iscsi_conn *conn,
{ {
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
if (conn->sess->session_type == SESSION_TYPE_NORMAL) { if (conn->sess->session_type == SESSION_TYPE_NORMAL) {
/* normal session */ /* normal session */
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Login from %s (%s) on %s tgt_node%d" SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Login from %s (%s) on %s tgt_node%d"
@ -2122,7 +2122,7 @@ iscsi_op_login_rsp_handle_t_bit(struct spdk_iscsi_conn *conn,
{ {
int rc; int rc;
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
switch (ISCSI_BHS_LOGIN_GET_NSG(rsph->flags)) { switch (ISCSI_BHS_LOGIN_GET_NSG(rsph->flags)) {
case ISCSI_SECURITY_NEGOTIATION_PHASE: case ISCSI_SECURITY_NEGOTIATION_PHASE:
@ -2173,7 +2173,7 @@ iscsi_op_login_rsp_handle(struct spdk_iscsi_conn *conn,
{ {
int rc; int rc;
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
/* negotiate parameters */ /* negotiate parameters */
rc = spdk_iscsi_negotiate_params(conn, params, rsp_pdu->data, alloc_len, rc = spdk_iscsi_negotiate_params(conn, params, rsp_pdu->data, alloc_len,
@ -2289,7 +2289,7 @@ iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
data_len = 0; data_len = 0;
alloc_len = conn->MaxRecvDataSegmentLength; alloc_len = conn->MaxRecvDataSegmentLength;
reqh = (struct iscsi_bhs_text_req *)pdu->bhs; reqh = (struct iscsi_bhs_text_req *)&pdu->bhs;
F_bit = !!(reqh->flags & ISCSI_FLAG_FINAL); F_bit = !!(reqh->flags & ISCSI_FLAG_FINAL);
C_bit = !!(reqh->flags & ISCSI_TEXT_CONTINUE); C_bit = !!(reqh->flags & ISCSI_TEXT_CONTINUE);
@ -2413,7 +2413,7 @@ iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
free(data); free(data);
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
rsph = (struct iscsi_bhs_text_resp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_text_resp *)&rsp_pdu->bhs;
rsp_pdu->data = data; rsp_pdu->data = data;
rsph->opcode = ISCSI_OP_TEXT_RSP; rsph->opcode = ISCSI_OP_TEXT_RSP;
@ -2481,7 +2481,7 @@ iscsi_op_logout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
struct iscsi_bhs_logout_resp *rsph; struct iscsi_bhs_logout_resp *rsph;
uint16_t cid; uint16_t cid;
reqh = (struct iscsi_bhs_logout_req *)pdu->bhs; reqh = (struct iscsi_bhs_logout_req *)&pdu->bhs;
cid = from_be16(&reqh->cid); cid = from_be16(&reqh->cid);
task_tag = from_be32(&reqh->itt); task_tag = from_be32(&reqh->itt);
@ -2531,7 +2531,7 @@ iscsi_op_logout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
if (rsp_pdu == NULL) { if (rsp_pdu == NULL) {
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
rsph = (struct iscsi_bhs_logout_resp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_logout_resp *)&rsp_pdu->bhs;
rsp_pdu->data = NULL; rsp_pdu->data = NULL;
rsph->opcode = ISCSI_OP_LOGOUT_RSP; rsph->opcode = ISCSI_OP_LOGOUT_RSP;
rsph->flags |= 0x80; /* bit 0 must be 1 */ rsph->flags |= 0x80; /* bit 0 must be 1 */
@ -2609,8 +2609,8 @@ get_scsi_task_from_ttt(struct spdk_iscsi_conn *conn, uint32_t transfer_tag)
struct iscsi_bhs_data_in *datain_bhs; struct iscsi_bhs_data_in *datain_bhs;
TAILQ_FOREACH(pdu, &conn->snack_pdu_list, tailq) { TAILQ_FOREACH(pdu, &conn->snack_pdu_list, tailq) {
if (pdu->bhs->opcode == ISCSI_OP_SCSI_DATAIN) { if (pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN) {
datain_bhs = (struct iscsi_bhs_data_in *)pdu->bhs; datain_bhs = (struct iscsi_bhs_data_in *)&pdu->bhs;
if (from_be32(&datain_bhs->ttt) == transfer_tag) { if (from_be32(&datain_bhs->ttt) == transfer_tag) {
return pdu->task; return pdu->task;
} }
@ -2630,7 +2630,7 @@ get_scsi_task_from_itt(struct spdk_iscsi_conn *conn,
struct spdk_iscsi_pdu *pdu; struct spdk_iscsi_pdu *pdu;
TAILQ_FOREACH(pdu, &conn->snack_pdu_list, tailq) { TAILQ_FOREACH(pdu, &conn->snack_pdu_list, tailq) {
if (pdu->bhs->opcode == opcode && if (pdu->bhs.opcode == opcode &&
pdu->task != NULL && pdu->task != NULL &&
pdu->task->tag == task_tag) { pdu->task->tag == task_tag) {
return pdu->task; return pdu->task;
@ -2656,7 +2656,7 @@ iscsi_send_datain(struct spdk_iscsi_conn *conn,
/* DATA PDU */ /* DATA PDU */
rsp_pdu = spdk_get_pdu(); rsp_pdu = spdk_get_pdu();
rsph = (struct iscsi_bhs_data_in *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_data_in *)&rsp_pdu->bhs;
rsp_pdu->data = task->scsi.iovs[0].iov_base + offset; rsp_pdu->data = task->scsi.iovs[0].iov_base + offset;
rsp_pdu->data_buf_len = task->scsi.iovs[0].iov_len - offset; rsp_pdu->data_buf_len = task->scsi.iovs[0].iov_len - offset;
rsp_pdu->data_from_mempool = true; rsp_pdu->data_from_mempool = true;
@ -2852,13 +2852,13 @@ iscsi_compare_pdu_bhs_within_existed_r2t_tasks(struct spdk_iscsi_conn *conn,
struct spdk_iscsi_task *task; struct spdk_iscsi_task *task;
TAILQ_FOREACH(task, &conn->active_r2t_tasks, link) { TAILQ_FOREACH(task, &conn->active_r2t_tasks, link) {
if (!memcmp(pdu->bhs, spdk_iscsi_task_get_bhs(task), ISCSI_BHS_LEN)) { if (!memcmp(&pdu->bhs, spdk_iscsi_task_get_bhs(task), ISCSI_BHS_LEN)) {
return true; return true;
} }
} }
TAILQ_FOREACH(task, &conn->queued_r2t_tasks, link) { TAILQ_FOREACH(task, &conn->queued_r2t_tasks, link) {
if (!memcmp(pdu->bhs, spdk_iscsi_task_get_bhs(task), ISCSI_BHS_LEN)) { if (!memcmp(&pdu->bhs, spdk_iscsi_task_get_bhs(task), ISCSI_BHS_LEN)) {
return true; return true;
} }
} }
@ -2981,7 +2981,7 @@ iscsi_op_scsi(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
reqh = (struct iscsi_bhs_scsi_req *)pdu->bhs; reqh = (struct iscsi_bhs_scsi_req *)&pdu->bhs;
F_bit = reqh->final_bit; F_bit = reqh->final_bit;
R_bit = reqh->read_bit; R_bit = reqh->read_bit;
@ -3138,10 +3138,10 @@ spdk_iscsi_task_mgmt_response(struct spdk_iscsi_conn *conn,
return; return;
} }
reqh = (struct iscsi_bhs_task_req *)task->pdu->bhs; reqh = (struct iscsi_bhs_task_req *)&task->pdu->bhs;
/* response PDU */ /* response PDU */
rsp_pdu = spdk_get_pdu(); rsp_pdu = spdk_get_pdu();
rsph = (struct iscsi_bhs_task_resp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_task_resp *)&rsp_pdu->bhs;
rsph->opcode = ISCSI_OP_TASK_RSP; rsph->opcode = ISCSI_OP_TASK_RSP;
rsph->flags |= 0x80; /* bit 0 default to 1 */ rsph->flags |= 0x80; /* bit 0 default to 1 */
switch (task->scsi.response) { switch (task->scsi.response) {
@ -3237,7 +3237,7 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
/* response PDU */ /* response PDU */
rsp_pdu = spdk_get_pdu(); rsp_pdu = spdk_get_pdu();
assert(rsp_pdu != NULL); assert(rsp_pdu != NULL);
rsph = (struct iscsi_bhs_scsi_resp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_scsi_resp *)&rsp_pdu->bhs;
assert(task->scsi.sense_data_len <= sizeof(rsp_pdu->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); 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); to_be16(&rsp_pdu->sense.length, task->scsi.sense_data_len);
@ -3446,7 +3446,7 @@ iscsi_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
reqh = (struct iscsi_bhs_task_req *)pdu->bhs; reqh = (struct iscsi_bhs_task_req *)&pdu->bhs;
function = reqh->flags & ISCSI_TASK_FUNCTION_MASK; function = reqh->flags & ISCSI_TASK_FUNCTION_MASK;
lun = from_be64(&reqh->lun); lun = from_be64(&reqh->lun);
task_tag = from_be32(&reqh->itt); task_tag = from_be32(&reqh->itt);
@ -3577,7 +3577,7 @@ iscsi_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
reqh = (struct iscsi_bhs_nop_out *)pdu->bhs; reqh = (struct iscsi_bhs_nop_out *)&pdu->bhs;
I_bit = reqh->immediate; I_bit = reqh->immediate;
data_len = DGET24(reqh->data_segment_len); data_len = DGET24(reqh->data_segment_len);
@ -3644,7 +3644,7 @@ iscsi_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
free(data); free(data);
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
rsph = (struct iscsi_bhs_nop_in *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_nop_in *)&rsp_pdu->bhs;
rsp_pdu->data = data; rsp_pdu->data = data;
rsph->opcode = ISCSI_OP_NOPIN; rsph->opcode = ISCSI_OP_NOPIN;
rsph->flags |= 0x80; /* bit 0 default to 1 */ rsph->flags |= 0x80; /* bit 0 default to 1 */
@ -3930,8 +3930,8 @@ iscsi_handle_recovery_datain(struct spdk_iscsi_conn *conn,
for (i = beg_run; i <= last_statsn; i++) { for (i = beg_run; i <= last_statsn; i++) {
TAILQ_FOREACH_SAFE(old_pdu, &conn->snack_pdu_list, tailq, pdu_temp) { TAILQ_FOREACH_SAFE(old_pdu, &conn->snack_pdu_list, tailq, pdu_temp) {
if (old_pdu->bhs->opcode == ISCSI_OP_SCSI_DATAIN) { if (old_pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN) {
datain_header = (struct iscsi_bhs_data_in *)old_pdu->bhs; datain_header = (struct iscsi_bhs_data_in *)&old_pdu->bhs;
if (from_be32(&datain_header->itt) == task_tag && if (from_be32(&datain_header->itt) == task_tag &&
from_be32(&datain_header->data_sn) == i) { from_be32(&datain_header->data_sn) == i) {
TAILQ_REMOVE(&conn->snack_pdu_list, old_pdu, tailq); TAILQ_REMOVE(&conn->snack_pdu_list, old_pdu, tailq);
@ -3956,7 +3956,7 @@ iscsi_handle_status_snack(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p
bool found_pdu; bool found_pdu;
struct spdk_iscsi_pdu *old_pdu; struct spdk_iscsi_pdu *old_pdu;
reqh = (struct iscsi_bhs_snack_req *)pdu->bhs; reqh = (struct iscsi_bhs_snack_req *)&pdu->bhs;
beg_run = from_be32(&reqh->beg_run); beg_run = from_be32(&reqh->beg_run);
run_length = from_be32(&reqh->run_len); run_length = from_be32(&reqh->run_len);
@ -3979,7 +3979,7 @@ iscsi_handle_status_snack(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *p
for (i = beg_run; i < last_statsn; i++) { for (i = beg_run; i < last_statsn; i++) {
found_pdu = false; found_pdu = false;
TAILQ_FOREACH(old_pdu, &conn->snack_pdu_list, tailq) { TAILQ_FOREACH(old_pdu, &conn->snack_pdu_list, tailq) {
if (from_be32(&old_pdu->bhs->stat_sn) == i) { if (from_be32(&old_pdu->bhs.stat_sn) == i) {
found_pdu = true; found_pdu = true;
break; break;
} }
@ -4013,7 +4013,7 @@ iscsi_handle_data_ack(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
struct iscsi_bhs_data_in *datain_header; struct iscsi_bhs_data_in *datain_header;
struct spdk_iscsi_task *primary; struct spdk_iscsi_task *primary;
reqh = (struct iscsi_bhs_snack_req *)pdu->bhs; reqh = (struct iscsi_bhs_snack_req *)&pdu->bhs;
transfer_tag = from_be32(&reqh->ttt); transfer_tag = from_be32(&reqh->ttt);
beg_run = from_be32(&reqh->beg_run); beg_run = from_be32(&reqh->beg_run);
run_length = from_be32(&reqh->run_len); run_length = from_be32(&reqh->run_len);
@ -4042,8 +4042,8 @@ iscsi_handle_data_ack(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
/* To free the pdu */ /* To free the pdu */
TAILQ_FOREACH(old_pdu, &conn->snack_pdu_list, tailq) { TAILQ_FOREACH(old_pdu, &conn->snack_pdu_list, tailq) {
if (old_pdu->bhs->opcode == ISCSI_OP_SCSI_DATAIN) { if (old_pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN) {
datain_header = (struct iscsi_bhs_data_in *)old_pdu->bhs; datain_header = (struct iscsi_bhs_data_in *) &old_pdu->bhs;
old_datasn = from_be32(&datain_header->data_sn); old_datasn = from_be32(&datain_header->data_sn);
if ((from_be32(&datain_header->ttt) == transfer_tag) && if ((from_be32(&datain_header->ttt) == transfer_tag) &&
(old_datasn == beg_run - 1)) { (old_datasn == beg_run - 1)) {
@ -4077,8 +4077,8 @@ iscsi_remove_r2t_pdu_from_snack_list(struct spdk_iscsi_conn *conn,
struct iscsi_bhs_r2t *r2t_header; struct iscsi_bhs_r2t *r2t_header;
TAILQ_FOREACH(pdu, &conn->snack_pdu_list, tailq) { TAILQ_FOREACH(pdu, &conn->snack_pdu_list, tailq) {
if (pdu->bhs->opcode == ISCSI_OP_R2T) { if (pdu->bhs.opcode == ISCSI_OP_R2T) {
r2t_header = (struct iscsi_bhs_r2t *)pdu->bhs; r2t_header = (struct iscsi_bhs_r2t *)&pdu->bhs;
if (pdu->task == task && if (pdu->task == task &&
from_be32(&r2t_header->r2t_sn) == r2t_sn) { from_be32(&r2t_header->r2t_sn) == r2t_sn) {
TAILQ_REMOVE(&conn->snack_pdu_list, pdu, tailq); TAILQ_REMOVE(&conn->snack_pdu_list, pdu, tailq);
@ -4114,10 +4114,10 @@ iscsi_send_r2t_recovery(struct spdk_iscsi_conn *conn,
* true: we send a r2t with new r2tsn * true: we send a r2t with new r2tsn
*/ */
if (!send_new_r2tsn) { if (!send_new_r2tsn) {
to_be32(&pdu->bhs->stat_sn, conn->StatSN); to_be32(&pdu->bhs.stat_sn, conn->StatSN);
spdk_iscsi_conn_write_pdu(conn, pdu); spdk_iscsi_conn_write_pdu(conn, pdu);
} else { } else {
rsph = (struct iscsi_bhs_r2t *)pdu->bhs; rsph = (struct iscsi_bhs_r2t *)&pdu->bhs;
transfer_len = from_be32(&rsph->desired_xfer_len); transfer_len = from_be32(&rsph->desired_xfer_len);
/* still need to increase the acked r2tsn */ /* still need to increase the acked r2tsn */
@ -4159,7 +4159,7 @@ iscsi_op_snack(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
reqh = (struct iscsi_bhs_snack_req *)pdu->bhs; reqh = (struct iscsi_bhs_snack_req *)&pdu->bhs;
if (!conn->sess->ErrorRecoveryLevel) { if (!conn->sess->ErrorRecoveryLevel) {
SPDK_ERRLOG("Got a SNACK request in ErrorRecoveryLevel=0\n"); SPDK_ERRLOG("Got a SNACK request in ErrorRecoveryLevel=0\n");
return iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR); return iscsi_reject(conn, pdu, ISCSI_REASON_PROTOCOL_ERROR);
@ -4170,7 +4170,7 @@ iscsi_op_snack(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
switch (type) { switch (type) {
case 0: case 0:
reqh = (struct iscsi_bhs_snack_req *)pdu->bhs; reqh = (struct iscsi_bhs_snack_req *)&pdu->bhs;
task_tag = from_be32(&reqh->itt); task_tag = from_be32(&reqh->itt);
beg_run = from_be32(&reqh->beg_run); beg_run = from_be32(&reqh->beg_run);
run_length = from_be32(&reqh->run_len); run_length = from_be32(&reqh->run_len);
@ -4221,7 +4221,7 @@ remove_acked_pdu(struct spdk_iscsi_conn *conn, uint32_t ExpStatSN)
conn->exp_statsn = DMIN32(ExpStatSN, conn->StatSN); conn->exp_statsn = DMIN32(ExpStatSN, conn->StatSN);
TAILQ_FOREACH_SAFE(pdu, &conn->snack_pdu_list, tailq, pdu_temp) { TAILQ_FOREACH_SAFE(pdu, &conn->snack_pdu_list, tailq, pdu_temp) {
stat_sn = from_be32(&pdu->bhs->stat_sn); stat_sn = from_be32(&pdu->bhs.stat_sn);
if (SN32_LT(stat_sn, conn->exp_statsn)) { if (SN32_LT(stat_sn, conn->exp_statsn)) {
TAILQ_REMOVE(&conn->snack_pdu_list, pdu, tailq); TAILQ_REMOVE(&conn->snack_pdu_list, pdu, tailq);
spdk_iscsi_conn_free_pdu(conn, pdu); spdk_iscsi_conn_free_pdu(conn, pdu);
@ -4250,7 +4250,7 @@ iscsi_op_data(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
reqh = (struct iscsi_bhs_data_out *)pdu->bhs; reqh = (struct iscsi_bhs_data_out *)&pdu->bhs;
F_bit = !!(reqh->flags & ISCSI_FLAG_FINAL); F_bit = !!(reqh->flags & ISCSI_FLAG_FINAL);
transfer_tag = from_be32(&reqh->ttt); transfer_tag = from_be32(&reqh->ttt);
task_tag = from_be32(&reqh->itt); task_tag = from_be32(&reqh->itt);
@ -4375,7 +4375,7 @@ iscsi_send_r2t(struct spdk_iscsi_conn *conn,
if (rsp_pdu == NULL) { if (rsp_pdu == NULL) {
return SPDK_ISCSI_CONNECTION_FATAL; return SPDK_ISCSI_CONNECTION_FATAL;
} }
rsph = (struct iscsi_bhs_r2t *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_r2t *)&rsp_pdu->bhs;
rsp_pdu->data = NULL; rsp_pdu->data = NULL;
rsph->opcode = ISCSI_OP_R2T; rsph->opcode = ISCSI_OP_R2T;
rsph->flags |= 0x80; /* bit 0 is default to 1 */ rsph->flags |= 0x80; /* bit 0 is default to 1 */
@ -4426,7 +4426,7 @@ void spdk_iscsi_send_nopin(struct spdk_iscsi_conn *conn)
conn->sess->MaxCmdSN); conn->sess->MaxCmdSN);
rsp_pdu = spdk_get_pdu(); rsp_pdu = spdk_get_pdu();
rsp = (struct iscsi_bhs_nop_in *)rsp_pdu->bhs; rsp = (struct iscsi_bhs_nop_in *) &rsp_pdu->bhs;
rsp_pdu->data = NULL; rsp_pdu->data = NULL;
/* /*
@ -4456,19 +4456,19 @@ init_login_reject_response(struct spdk_iscsi_pdu *pdu, struct spdk_iscsi_pdu *rs
struct iscsi_bhs_login_rsp *rsph; struct iscsi_bhs_login_rsp *rsph;
memset(rsp_pdu, 0, sizeof(struct spdk_iscsi_pdu)); memset(rsp_pdu, 0, sizeof(struct spdk_iscsi_pdu));
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu->bhs; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
rsph->version_max = ISCSI_VERSION; rsph->version_max = ISCSI_VERSION;
rsph->version_act = ISCSI_VERSION; rsph->version_act = ISCSI_VERSION;
rsph->opcode = ISCSI_OP_LOGIN_RSP; rsph->opcode = ISCSI_OP_LOGIN_RSP;
rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR;
rsph->status_detail = ISCSI_LOGIN_INVALID_LOGIN_REQUEST; rsph->status_detail = ISCSI_LOGIN_INVALID_LOGIN_REQUEST;
rsph->itt = pdu->bhs->itt; rsph->itt = pdu->bhs.itt;
} }
static void static void
iscsi_pdu_dump(struct spdk_iscsi_pdu *pdu) iscsi_pdu_dump(struct spdk_iscsi_pdu *pdu)
{ {
SPDK_ERRLOGDUMP("PDU", (uint8_t *)pdu->bhs, ISCSI_BHS_LEN); SPDK_ERRLOGDUMP("PDU", (uint8_t *)&pdu->bhs, ISCSI_BHS_LEN);
} }
int int
@ -4486,8 +4486,8 @@ spdk_iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return -1; return -1;
} }
opcode = pdu->bhs->opcode; opcode = pdu->bhs.opcode;
reqh = (struct iscsi_bhs_scsi_req *)pdu->bhs; reqh = (struct iscsi_bhs_scsi_req *)&pdu->bhs;
pdu->cmd_sn = from_be32(&reqh->cmd_sn); pdu->cmd_sn = from_be32(&reqh->cmd_sn);
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "opcode %x\n", opcode); SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "opcode %x\n", opcode);
@ -4657,7 +4657,7 @@ spdk_iscsi_get_dif_ctx(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
return false; return false;
} }
bhs = pdu->bhs; bhs = &pdu->bhs;
switch (bhs->opcode) { switch (bhs->opcode) {
case ISCSI_OP_SCSI: { case ISCSI_OP_SCSI: {
@ -4943,8 +4943,8 @@ bool spdk_iscsi_is_deferred_free_pdu(struct spdk_iscsi_pdu *pdu)
return false; return false;
} }
if (pdu->bhs->opcode == ISCSI_OP_R2T || if (pdu->bhs.opcode == ISCSI_OP_R2T ||
pdu->bhs->opcode == ISCSI_OP_SCSI_DATAIN) { pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN) {
return true; return true;
} }

View File

@ -157,8 +157,7 @@ struct spdk_mobj {
}; };
struct spdk_iscsi_pdu { struct spdk_iscsi_pdu {
struct iscsi_bhs *bhs; struct iscsi_bhs bhs;
struct iscsi_bhs bhs_mem;
struct spdk_mobj *mobj; struct spdk_mobj *mobj;
uint8_t *data_buf; uint8_t *data_buf;
uint8_t *data; uint8_t *data;

View File

@ -326,7 +326,6 @@ struct spdk_iscsi_pdu *spdk_get_pdu(void)
/* we do not want to zero out the last part of the structure reserved for AHS and sense data */ /* 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)); memset(pdu, 0, offsetof(struct spdk_iscsi_pdu, ahs));
pdu->bhs = &pdu->bhs_mem;
pdu->ref = 1; pdu->ref = 1;
return pdu; return pdu;

View File

@ -127,7 +127,7 @@ spdk_iscsi_task_set_pdu(struct spdk_iscsi_task *task, struct spdk_iscsi_pdu *pdu
static inline struct iscsi_bhs * static inline struct iscsi_bhs *
spdk_iscsi_task_get_bhs(struct spdk_iscsi_task *task) spdk_iscsi_task_get_bhs(struct spdk_iscsi_task *task)
{ {
return spdk_iscsi_task_get_pdu(task)->bhs; return &spdk_iscsi_task_get_pdu(task)->bhs;
} }
static inline void static inline void

View File

@ -69,7 +69,6 @@ spdk_get_pdu(void)
} }
memset(pdu, 0, offsetof(struct spdk_iscsi_pdu, ahs)); memset(pdu, 0, offsetof(struct spdk_iscsi_pdu, ahs));
pdu->bhs = &pdu->bhs_mem;
pdu->ref = 1; pdu->ref = 1;
return pdu; return pdu;

View File

@ -125,11 +125,10 @@ static void
op_login_check_target_test(void) op_login_check_target_test(void)
{ {
struct spdk_iscsi_conn conn; struct spdk_iscsi_conn conn;
struct spdk_iscsi_pdu rsp_pdu = {}; struct spdk_iscsi_pdu rsp_pdu;
struct spdk_iscsi_tgt_node *target; struct spdk_iscsi_tgt_node *target;
int rc; int rc;
rsp_pdu.bhs = &rsp_pdu.bhs_mem;
/* expect success */ /* expect success */
snprintf(conn.initiator_name, sizeof(conn.initiator_name), snprintf(conn.initiator_name, sizeof(conn.initiator_name),
"%s", UT_INITIATOR_NAME1); "%s", UT_INITIATOR_NAME1);
@ -168,8 +167,7 @@ op_login_session_normal_test(void)
int rc; int rc;
/* setup related data structures */ /* setup related data structures */
rsp_pdu.bhs = &rsp_pdu.bhs_mem; rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu.bhs;
rsph = (struct iscsi_bhs_login_rsp *)rsp_pdu.bhs;
rsph->tsih = 0; rsph->tsih = 0;
memset(rsph->isid, 0, sizeof(rsph->isid)); memset(rsph->isid, 0, sizeof(rsph->isid));
conn.portal = &portal; conn.portal = &portal;
@ -286,10 +284,10 @@ maxburstlength_test(void)
TAILQ_INIT(&g_write_pdu_list); TAILQ_INIT(&g_write_pdu_list);
req_pdu->bhs->opcode = ISCSI_OP_SCSI; req_pdu->bhs.opcode = ISCSI_OP_SCSI;
req_pdu->data_segment_len = 0; req_pdu->data_segment_len = 0;
req = (struct iscsi_bhs_scsi_req *)req_pdu->bhs; req = (struct iscsi_bhs_scsi_req *)&req_pdu->bhs;
to_be32(&req->cmd_sn, 0); to_be32(&req->cmd_sn, 0);
to_be32(&req->expected_data_xfer_len, 1028); to_be32(&req->expected_data_xfer_len, 1028);
@ -308,16 +306,16 @@ maxburstlength_test(void)
* SCSI request. * SCSI request.
*/ */
TAILQ_REMOVE(&g_write_pdu_list, response_pdu, tailq); TAILQ_REMOVE(&g_write_pdu_list, response_pdu, tailq);
CU_ASSERT(response_pdu->bhs->opcode == ISCSI_OP_R2T); CU_ASSERT(response_pdu->bhs.opcode == ISCSI_OP_R2T);
r2t = (struct iscsi_bhs_r2t *)response_pdu->bhs; r2t = (struct iscsi_bhs_r2t *)&response_pdu->bhs;
CU_ASSERT(from_be32(&r2t->desired_xfer_len) == 1024); CU_ASSERT(from_be32(&r2t->desired_xfer_len) == 1024);
CU_ASSERT(from_be32(&r2t->buffer_offset) == 0); CU_ASSERT(from_be32(&r2t->buffer_offset) == 0);
CU_ASSERT(from_be32(&r2t->itt) == 0x1234); CU_ASSERT(from_be32(&r2t->itt) == 0x1234);
data_out_pdu->bhs->opcode = ISCSI_OP_SCSI_DATAOUT; data_out_pdu->bhs.opcode = ISCSI_OP_SCSI_DATAOUT;
data_out_pdu->bhs->flags = ISCSI_FLAG_FINAL; data_out_pdu->bhs.flags = ISCSI_FLAG_FINAL;
data_out_pdu->data_segment_len = 1028; data_out_pdu->data_segment_len = 1028;
data_out = (struct iscsi_bhs_data_out *)data_out_pdu->bhs; data_out = (struct iscsi_bhs_data_out *)&data_out_pdu->bhs;
data_out->itt = r2t->itt; data_out->itt = r2t->itt;
data_out->ttt = r2t->ttt; data_out->ttt = r2t->ttt;
DSET24(data_out->data_segment_len, 1028); DSET24(data_out->data_segment_len, 1028);
@ -364,7 +362,7 @@ underflow_for_read_transfer_test(void)
pdu = spdk_get_pdu(); pdu = spdk_get_pdu();
SPDK_CU_ASSERT_FATAL(pdu != NULL); SPDK_CU_ASSERT_FATAL(pdu != NULL);
scsi_req = (struct iscsi_bhs_scsi_req *)pdu->bhs; scsi_req = (struct iscsi_bhs_scsi_req *)&pdu->bhs;
scsi_req->read_bit = 1; scsi_req->read_bit = 1;
spdk_iscsi_task_set_pdu(&task, pdu); spdk_iscsi_task_set_pdu(&task, pdu);
@ -390,9 +388,9 @@ underflow_for_read_transfer_test(void)
pdu = TAILQ_FIRST(&g_write_pdu_list); pdu = TAILQ_FIRST(&g_write_pdu_list);
SPDK_CU_ASSERT_FATAL(pdu != NULL); SPDK_CU_ASSERT_FATAL(pdu != NULL);
CU_ASSERT(pdu->bhs->opcode == ISCSI_OP_SCSI_DATAIN); CU_ASSERT(pdu->bhs.opcode == ISCSI_OP_SCSI_DATAIN);
datah = (struct iscsi_bhs_data_in *)pdu->bhs; datah = (struct iscsi_bhs_data_in *)&pdu->bhs;
CU_ASSERT(datah->flags == (ISCSI_DATAIN_UNDERFLOW | ISCSI_FLAG_FINAL | ISCSI_DATAIN_STATUS)); CU_ASSERT(datah->flags == (ISCSI_DATAIN_UNDERFLOW | ISCSI_FLAG_FINAL | ISCSI_DATAIN_STATUS));
CU_ASSERT(datah->res_cnt == residual_count); CU_ASSERT(datah->res_cnt == residual_count);
@ -428,7 +426,7 @@ underflow_for_zero_read_transfer_test(void)
pdu = spdk_get_pdu(); pdu = spdk_get_pdu();
SPDK_CU_ASSERT_FATAL(pdu != NULL); SPDK_CU_ASSERT_FATAL(pdu != NULL);
scsi_req = (struct iscsi_bhs_scsi_req *)pdu->bhs; scsi_req = (struct iscsi_bhs_scsi_req *)&pdu->bhs;
scsi_req->read_bit = 1; scsi_req->read_bit = 1;
spdk_iscsi_task_set_pdu(&task, pdu); spdk_iscsi_task_set_pdu(&task, pdu);
@ -452,9 +450,9 @@ underflow_for_zero_read_transfer_test(void)
pdu = TAILQ_FIRST(&g_write_pdu_list); pdu = TAILQ_FIRST(&g_write_pdu_list);
SPDK_CU_ASSERT_FATAL(pdu != NULL); SPDK_CU_ASSERT_FATAL(pdu != NULL);
CU_ASSERT(pdu->bhs->opcode == ISCSI_OP_SCSI_RSP); CU_ASSERT(pdu->bhs.opcode == ISCSI_OP_SCSI_RSP);
resph = (struct iscsi_bhs_scsi_resp *)pdu->bhs; resph = (struct iscsi_bhs_scsi_resp *)&pdu->bhs;
CU_ASSERT(resph->flags == (ISCSI_SCSI_UNDERFLOW | 0x80)); CU_ASSERT(resph->flags == (ISCSI_SCSI_UNDERFLOW | 0x80));
@ -494,7 +492,7 @@ underflow_for_request_sense_test(void)
pdu1 = spdk_get_pdu(); pdu1 = spdk_get_pdu();
SPDK_CU_ASSERT_FATAL(pdu1 != NULL); SPDK_CU_ASSERT_FATAL(pdu1 != NULL);
scsi_req = (struct iscsi_bhs_scsi_req *)pdu1->bhs; scsi_req = (struct iscsi_bhs_scsi_req *)&pdu1->bhs;
scsi_req->read_bit = 1; scsi_req->read_bit = 1;
spdk_iscsi_task_set_pdu(&task, pdu1); spdk_iscsi_task_set_pdu(&task, pdu1);
@ -526,9 +524,9 @@ underflow_for_request_sense_test(void)
pdu1 = TAILQ_FIRST(&g_write_pdu_list); pdu1 = TAILQ_FIRST(&g_write_pdu_list);
SPDK_CU_ASSERT_FATAL(pdu1 != NULL); SPDK_CU_ASSERT_FATAL(pdu1 != NULL);
CU_ASSERT(pdu1->bhs->opcode == ISCSI_OP_SCSI_DATAIN); CU_ASSERT(pdu1->bhs.opcode == ISCSI_OP_SCSI_DATAIN);
datah = (struct iscsi_bhs_data_in *)pdu1->bhs; datah = (struct iscsi_bhs_data_in *)&pdu1->bhs;
CU_ASSERT(datah->flags == ISCSI_FLAG_FINAL); CU_ASSERT(datah->flags == ISCSI_FLAG_FINAL);
@ -544,9 +542,9 @@ underflow_for_request_sense_test(void)
SPDK_CU_ASSERT_FATAL(pdu1 != pdu2); SPDK_CU_ASSERT_FATAL(pdu1 != pdu2);
SPDK_CU_ASSERT_FATAL(pdu2 != NULL); SPDK_CU_ASSERT_FATAL(pdu2 != NULL);
CU_ASSERT(pdu2->bhs->opcode == ISCSI_OP_SCSI_RSP); CU_ASSERT(pdu2->bhs.opcode == ISCSI_OP_SCSI_RSP);
resph = (struct iscsi_bhs_scsi_resp *)pdu2->bhs; resph = (struct iscsi_bhs_scsi_resp *)&pdu2->bhs;
CU_ASSERT(resph->flags == (ISCSI_SCSI_UNDERFLOW | 0x80)); CU_ASSERT(resph->flags == (ISCSI_SCSI_UNDERFLOW | 0x80));
@ -585,7 +583,7 @@ underflow_for_check_condition_test(void)
pdu = spdk_get_pdu(); pdu = spdk_get_pdu();
SPDK_CU_ASSERT_FATAL(pdu != NULL); SPDK_CU_ASSERT_FATAL(pdu != NULL);
scsi_req = (struct iscsi_bhs_scsi_req *)pdu->bhs; scsi_req = (struct iscsi_bhs_scsi_req *)&pdu->bhs;
scsi_req->read_bit = 1; scsi_req->read_bit = 1;
spdk_iscsi_task_set_pdu(&task, pdu); spdk_iscsi_task_set_pdu(&task, pdu);
@ -612,9 +610,9 @@ underflow_for_check_condition_test(void)
pdu = TAILQ_FIRST(&g_write_pdu_list); pdu = TAILQ_FIRST(&g_write_pdu_list);
SPDK_CU_ASSERT_FATAL(pdu != NULL); SPDK_CU_ASSERT_FATAL(pdu != NULL);
CU_ASSERT(pdu->bhs->opcode == ISCSI_OP_SCSI_RSP); CU_ASSERT(pdu->bhs.opcode == ISCSI_OP_SCSI_RSP);
resph = (struct iscsi_bhs_scsi_resp *)pdu->bhs; resph = (struct iscsi_bhs_scsi_resp *)&pdu->bhs;
CU_ASSERT(resph->flags == 0x80); CU_ASSERT(resph->flags == 0x80);
@ -695,7 +693,7 @@ add_transfer_task_test(void)
tmp = TAILQ_FIRST(&g_write_pdu_list); tmp = TAILQ_FIRST(&g_write_pdu_list);
TAILQ_REMOVE(&g_write_pdu_list, tmp, tailq); TAILQ_REMOVE(&g_write_pdu_list, tmp, tailq);
r2th = (struct iscsi_bhs_r2t *)tmp->bhs; r2th = (struct iscsi_bhs_r2t *)&tmp->bhs;
buffer_offset = from_be32(&r2th->buffer_offset); buffer_offset = from_be32(&r2th->buffer_offset);
CU_ASSERT(buffer_offset == pdu->data_segment_len + sess.MaxBurstLength * count); CU_ASSERT(buffer_offset == pdu->data_segment_len + sess.MaxBurstLength * count);
@ -1317,19 +1315,18 @@ build_iovs_test(void)
conn.header_digest = true; conn.header_digest = true;
conn.data_digest = true; conn.data_digest = true;
pdu.bhs = &pdu.bhs_mem; DSET24(&pdu.bhs.data_segment_len, 512);
DSET24(&pdu.bhs->data_segment_len, 512);
data = calloc(1, 512); data = calloc(1, 512);
SPDK_CU_ASSERT_FATAL(data != NULL); SPDK_CU_ASSERT_FATAL(data != NULL);
pdu.data = data; pdu.data = data;
pdu.bhs->total_ahs_len = 0; pdu.bhs.total_ahs_len = 0;
pdu.bhs->opcode = ISCSI_OP_SCSI; pdu.bhs.opcode = ISCSI_OP_SCSI;
pdu.writev_offset = 0; pdu.writev_offset = 0;
rc = spdk_iscsi_build_iovs(&conn, iovs, 5, &pdu, &mapped_length); rc = spdk_iscsi_build_iovs(&conn, iovs, 5, &pdu, &mapped_length);
CU_ASSERT(rc == 4); CU_ASSERT(rc == 4);
CU_ASSERT(iovs[0].iov_base == (void *)pdu.bhs); CU_ASSERT(iovs[0].iov_base == (void *)&pdu.bhs);
CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN); CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN);
CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest); CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest);
CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN); CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN);
@ -1342,7 +1339,7 @@ build_iovs_test(void)
pdu.writev_offset = ISCSI_BHS_LEN / 2; pdu.writev_offset = ISCSI_BHS_LEN / 2;
rc = spdk_iscsi_build_iovs(&conn, iovs, 5, &pdu, &mapped_length); rc = spdk_iscsi_build_iovs(&conn, iovs, 5, &pdu, &mapped_length);
CU_ASSERT(rc == 4); CU_ASSERT(rc == 4);
CU_ASSERT(iovs[0].iov_base == (void *)((uint8_t *)pdu.bhs + ISCSI_BHS_LEN / 2)); CU_ASSERT(iovs[0].iov_base == (void *)((uint8_t *)&pdu.bhs + ISCSI_BHS_LEN / 2));
CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN / 2); CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN / 2);
CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest); CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest);
CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN); CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN);
@ -1405,13 +1402,13 @@ build_iovs_test(void)
pdu.writev_offset = 0; pdu.writev_offset = 0;
rc = spdk_iscsi_build_iovs(&conn, iovs, 1, &pdu, &mapped_length); rc = spdk_iscsi_build_iovs(&conn, iovs, 1, &pdu, &mapped_length);
CU_ASSERT(rc == 1); CU_ASSERT(rc == 1);
CU_ASSERT(iovs[0].iov_base == (void *)pdu.bhs); CU_ASSERT(iovs[0].iov_base == (void *)&pdu.bhs);
CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN); CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN);
CU_ASSERT(mapped_length == ISCSI_BHS_LEN); CU_ASSERT(mapped_length == ISCSI_BHS_LEN);
rc = spdk_iscsi_build_iovs(&conn, iovs, 2, &pdu, &mapped_length); rc = spdk_iscsi_build_iovs(&conn, iovs, 2, &pdu, &mapped_length);
CU_ASSERT(rc == 2); CU_ASSERT(rc == 2);
CU_ASSERT(iovs[0].iov_base == (void *)pdu.bhs); CU_ASSERT(iovs[0].iov_base == (void *)&pdu.bhs);
CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN); CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN);
CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest); CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest);
CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN); CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN);
@ -1419,7 +1416,7 @@ build_iovs_test(void)
rc = spdk_iscsi_build_iovs(&conn, iovs, 3, &pdu, &mapped_length); rc = spdk_iscsi_build_iovs(&conn, iovs, 3, &pdu, &mapped_length);
CU_ASSERT(rc == 3); CU_ASSERT(rc == 3);
CU_ASSERT(iovs[0].iov_base == (void *)pdu.bhs); CU_ASSERT(iovs[0].iov_base == (void *)&pdu.bhs);
CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN); CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN);
CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest); CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest);
CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN); CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN);
@ -1429,7 +1426,7 @@ build_iovs_test(void)
rc = spdk_iscsi_build_iovs(&conn, iovs, 4, &pdu, &mapped_length); rc = spdk_iscsi_build_iovs(&conn, iovs, 4, &pdu, &mapped_length);
CU_ASSERT(rc == 4); CU_ASSERT(rc == 4);
CU_ASSERT(iovs[0].iov_base == (void *)pdu.bhs); CU_ASSERT(iovs[0].iov_base == (void *)&pdu.bhs);
CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN); CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN);
CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest); CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest);
CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN); CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN);
@ -1455,15 +1452,14 @@ build_iovs_with_md_test(void)
conn.header_digest = true; conn.header_digest = true;
conn.data_digest = true; conn.data_digest = true;
pdu.bhs = &pdu.bhs_mem; DSET24(&pdu.bhs.data_segment_len, 4096 * 2);
DSET24(pdu.bhs->data_segment_len, 4096 * 2);
data = calloc(1, (4096 + 128) * 2); data = calloc(1, (4096 + 128) * 2);
SPDK_CU_ASSERT_FATAL(data != NULL); SPDK_CU_ASSERT_FATAL(data != NULL);
pdu.data = data; pdu.data = data;
pdu.data_buf_len = (4096 + 128) * 2; pdu.data_buf_len = (4096 + 128) * 2;
pdu.bhs->total_ahs_len = 0; pdu.bhs.total_ahs_len = 0;
pdu.bhs->opcode = ISCSI_OP_SCSI; pdu.bhs.opcode = ISCSI_OP_SCSI;
rc = spdk_dif_ctx_init(&pdu.dif_ctx, 4096 + 128, 128, true, false, SPDK_DIF_TYPE1, rc = spdk_dif_ctx_init(&pdu.dif_ctx, 4096 + 128, 128, true, false, SPDK_DIF_TYPE1,
0, 0, 0, 0, 0, 0); 0, 0, 0, 0, 0, 0);
@ -1474,7 +1470,7 @@ build_iovs_with_md_test(void)
pdu.writev_offset = 0; pdu.writev_offset = 0;
rc = spdk_iscsi_build_iovs(&conn, iovs, 6, &pdu, &mapped_length); rc = spdk_iscsi_build_iovs(&conn, iovs, 6, &pdu, &mapped_length);
CU_ASSERT(rc == 5); CU_ASSERT(rc == 5);
CU_ASSERT(iovs[0].iov_base == (void *)pdu.bhs); CU_ASSERT(iovs[0].iov_base == (void *)&pdu.bhs);
CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN); CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN);
CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest); CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest);
CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN); CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN);
@ -1507,7 +1503,7 @@ build_iovs_with_md_test(void)
pdu.writev_offset = 0; pdu.writev_offset = 0;
rc = spdk_iscsi_build_iovs(&conn, iovs, 3, &pdu, &mapped_length); rc = spdk_iscsi_build_iovs(&conn, iovs, 3, &pdu, &mapped_length);
CU_ASSERT(rc == 3); CU_ASSERT(rc == 3);
CU_ASSERT(iovs[0].iov_base == (void *)pdu.bhs); CU_ASSERT(iovs[0].iov_base == (void *)&pdu.bhs);
CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN); CU_ASSERT(iovs[0].iov_len == ISCSI_BHS_LEN);
CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest); CU_ASSERT(iovs[1].iov_base == (void *)pdu.header_digest);
CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN); CU_ASSERT(iovs[1].iov_len == ISCSI_DIGEST_LEN);