iscsi: put spdk_iscsi_conn_write_pdu() in lib/iscsi/conn.c

This function was originally named spdk_iscsi_write_pdu()
in lib/iscsi/iscsi.c.  Since this is an operation on a
connection, add "conn" to the name and move it to conn.c.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Iaad022907d43788108d5b2660306abcf5e94040d

Reviewed-on: https://review.gerrithub.io/395522
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Jim Harris 2018-01-17 23:34:47 -07:00
parent 936eb59d8d
commit 8c2b8ca7d7
5 changed files with 37 additions and 25 deletions

View File

@ -1319,6 +1319,12 @@ spdk_iscsi_conn_flush_pdus(struct spdk_iscsi_conn *conn)
return rc; return rc;
} }
void
spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{
TAILQ_INSERT_TAIL(&conn->write_pdu_list, pdu, tailq);
}
#define GET_PDU_LOOP_COUNT 16 #define GET_PDU_LOOP_COUNT 16
static int static int

View File

@ -181,6 +181,7 @@ void spdk_iscsi_set_min_conn_idle_interval(int interval_in_us);
int spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int len, int spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int len,
void *buf); void *buf);
void spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu);
void spdk_iscsi_conn_free_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu); void spdk_iscsi_conn_free_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu);

View File

@ -625,12 +625,6 @@ spdk_iscsi_build_iovecs(struct spdk_iscsi_conn *conn, struct iovec *iovec,
return iovec_cnt; return iovec_cnt;
} }
static void
spdk_iscsi_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{
TAILQ_INSERT_TAIL(&conn->write_pdu_list, pdu, tailq);
}
static int static int
spdk_iscsi_append_text(struct spdk_iscsi_conn *conn __attribute__(( spdk_iscsi_append_text(struct spdk_iscsi_conn *conn __attribute__((
__unused__)), const char *key, const char *val, uint8_t *data, int alloc_len, __unused__)), const char *key, const char *val, uint8_t *data, int alloc_len,
@ -1106,7 +1100,7 @@ spdk_iscsi_reject(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu,
SPDK_TRACEDUMP(SPDK_LOG_ISCSI, "PDU", (void *)&rsp_pdu->bhs, ISCSI_BHS_LEN); SPDK_TRACEDUMP(SPDK_LOG_ISCSI, "PDU", (void *)&rsp_pdu->bhs, ISCSI_BHS_LEN);
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
return 0; return 0;
} }
@ -1183,7 +1177,7 @@ spdk_iscsi_op_login_response(struct spdk_iscsi_conn *conn,
rsph->flags &= ~ISCSI_LOGIN_CURRENT_STAGE_MASK; rsph->flags &= ~ISCSI_LOGIN_CURRENT_STAGE_MASK;
rsph->flags &= ~ISCSI_LOGIN_NEXT_STAGE_MASK; rsph->flags &= ~ISCSI_LOGIN_NEXT_STAGE_MASK;
} }
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
/* after send PDU digest on/off */ /* after send PDU digest on/off */
if (conn->full_feature) { if (conn->full_feature) {
@ -2425,7 +2419,7 @@ spdk_iscsi_op_text(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
to_be32(&rsph->exp_cmd_sn, conn->sess->ExpCmdSN); to_be32(&rsph->exp_cmd_sn, conn->sess->ExpCmdSN);
to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN); to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN);
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
/* update internal variables */ /* update internal variables */
rc = spdk_iscsi_copy_param2var(conn); rc = spdk_iscsi_copy_param2var(conn);
@ -2537,7 +2531,7 @@ spdk_iscsi_op_logout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
rsph->time_2_wait = 0; rsph->time_2_wait = 0;
rsph->time_2_retain = 0; rsph->time_2_retain = 0;
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
if (conn->sess == NULL) { if (conn->sess == NULL) {
/* /*
@ -2716,7 +2710,7 @@ spdk_iscsi_send_datain(struct spdk_iscsi_conn *conn,
to_be32(&rsph->res_cnt, residual_len); to_be32(&rsph->res_cnt, residual_len);
} }
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
return DataSN; return DataSN;
} }
@ -3158,7 +3152,7 @@ spdk_iscsi_task_mgmt_response(struct spdk_iscsi_conn *conn,
to_be32(&rsph->exp_cmd_sn, conn->sess->ExpCmdSN); to_be32(&rsph->exp_cmd_sn, conn->sess->ExpCmdSN);
to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN); to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN);
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
} }
@ -3274,7 +3268,7 @@ void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
to_be32(&rsph->bi_read_res_cnt, bidi_residual_len); to_be32(&rsph->bi_read_res_cnt, bidi_residual_len);
to_be32(&rsph->res_cnt, residual_len); to_be32(&rsph->res_cnt, residual_len);
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
} }
static struct spdk_iscsi_task * static struct spdk_iscsi_task *
@ -3527,7 +3521,7 @@ spdk_iscsi_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
to_be32(&rsph->exp_cmd_sn, conn->sess->ExpCmdSN); to_be32(&rsph->exp_cmd_sn, conn->sess->ExpCmdSN);
to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN); to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN);
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
conn->last_nopin = spdk_get_ticks(); conn->last_nopin = spdk_get_ticks();
return SPDK_SUCCESS; return SPDK_SUCCESS;
@ -3780,7 +3774,7 @@ spdk_iscsi_handle_recovery_datain(struct spdk_iscsi_conn *conn,
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);
spdk_iscsi_write_pdu(conn, old_pdu); spdk_iscsi_conn_write_pdu(conn, old_pdu);
break; break;
} }
} }
@ -3839,7 +3833,7 @@ spdk_iscsi_handle_status_snack(struct spdk_iscsi_conn *conn,
beg_run); beg_run);
} else { } else {
TAILQ_REMOVE(&conn->snack_pdu_list, old_pdu, tailq); TAILQ_REMOVE(&conn->snack_pdu_list, old_pdu, tailq);
spdk_iscsi_write_pdu(conn, old_pdu); spdk_iscsi_conn_write_pdu(conn, old_pdu);
} }
} }
@ -3977,7 +3971,7 @@ spdk_iscsi_send_r2t_recovery(struct spdk_iscsi_conn *conn,
*/ */
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_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);
@ -4271,7 +4265,7 @@ spdk_iscsi_send_r2t(struct spdk_iscsi_conn *conn,
rsp_pdu->task = task; rsp_pdu->task = task;
task->scsi.ref++; task->scsi.ref++;
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
return SPDK_SUCCESS; return SPDK_SUCCESS;
} }
@ -4316,7 +4310,7 @@ int spdk_iscsi_send_nopin(struct spdk_iscsi_conn *conn)
to_be32(&rsp->exp_cmd_sn, conn->sess->ExpCmdSN); to_be32(&rsp->exp_cmd_sn, conn->sess->ExpCmdSN);
to_be32(&rsp->max_cmd_sn, conn->sess->MaxCmdSN); to_be32(&rsp->max_cmd_sn, conn->sess->MaxCmdSN);
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
conn->nop_outstanding = true; conn->nop_outstanding = true;
return SPDK_SUCCESS; return SPDK_SUCCESS;
@ -4373,7 +4367,7 @@ spdk_iscsi_execute(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
if (!conn->full_feature && conn->state == ISCSI_CONN_STATE_RUNNING) { if (!conn->full_feature && conn->state == ISCSI_CONN_STATE_RUNNING) {
rsp_pdu = spdk_get_pdu(); rsp_pdu = spdk_get_pdu();
spdk_init_login_reject_response(pdu, rsp_pdu); spdk_init_login_reject_response(pdu, rsp_pdu);
spdk_iscsi_write_pdu(conn, rsp_pdu); spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
SPDK_ERRLOG("Received opcode %d in login phase\n", opcode); SPDK_ERRLOG("Received opcode %d in login phase\n", opcode);
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
} else if (conn->state == ISCSI_CONN_STATE_INVALID) { } else if (conn->state == ISCSI_CONN_STATE_INVALID) {

View File

@ -13,6 +13,8 @@
SPDK_LOG_REGISTER_COMPONENT("iscsi", SPDK_LOG_ISCSI) SPDK_LOG_REGISTER_COMPONENT("iscsi", SPDK_LOG_ISCSI)
TAILQ_HEAD(, spdk_iscsi_pdu) g_write_pdu_list;
struct spdk_iscsi_task * struct spdk_iscsi_task *
spdk_iscsi_task_get(struct spdk_iscsi_conn *conn, spdk_iscsi_task_get(struct spdk_iscsi_conn *conn,
struct spdk_iscsi_task *parent, struct spdk_iscsi_task *parent,
@ -216,6 +218,12 @@ spdk_iscsi_conn_read_data(struct spdk_iscsi_conn *conn, int bytes,
return 0; return 0;
} }
void
spdk_iscsi_conn_write_pdu(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{
TAILQ_INSERT_TAIL(&g_write_pdu_list, pdu, tailq);
}
void void
spdk_iscsi_conn_logout(struct spdk_iscsi_conn *conn) spdk_iscsi_conn_logout(struct spdk_iscsi_conn *conn)
{ {

View File

@ -35,6 +35,7 @@
#include "spdk/endian.h" #include "spdk/endian.h"
#include "spdk/scsi.h" #include "spdk/scsi.h"
#include "spdk_cunit.h"
#include "CUnit/Basic.h" #include "CUnit/Basic.h"
@ -177,6 +178,8 @@ maxburstlength_test(void)
TAILQ_INIT(&conn.write_pdu_list); TAILQ_INIT(&conn.write_pdu_list);
TAILQ_INIT(&conn.active_r2t_tasks); TAILQ_INIT(&conn.active_r2t_tasks);
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;
@ -191,14 +194,14 @@ maxburstlength_test(void)
rc = spdk_iscsi_execute(&conn, req_pdu); rc = spdk_iscsi_execute(&conn, req_pdu);
CU_ASSERT_FATAL(rc == 0); CU_ASSERT_FATAL(rc == 0);
response_pdu = TAILQ_FIRST(&conn.write_pdu_list); response_pdu = TAILQ_FIRST(&g_write_pdu_list);
CU_ASSERT(response_pdu != NULL); SPDK_CU_ASSERT_FATAL(response_pdu != NULL);
/* /*
* Confirm that a correct R2T reply was sent in reponse to the * Confirm that a correct R2T reply was sent in reponse to the
* SCSI request. * SCSI request.
*/ */
TAILQ_REMOVE(&conn.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);
@ -221,9 +224,9 @@ maxburstlength_test(void)
spdk_iscsi_task_put(response_pdu->task); spdk_iscsi_task_put(response_pdu->task);
spdk_put_pdu(response_pdu); spdk_put_pdu(response_pdu);
r2t_pdu = TAILQ_FIRST(&conn.write_pdu_list); r2t_pdu = TAILQ_FIRST(&g_write_pdu_list);
CU_ASSERT(r2t_pdu != NULL); CU_ASSERT(r2t_pdu != NULL);
TAILQ_REMOVE(&conn.write_pdu_list, r2t_pdu, tailq); TAILQ_REMOVE(&g_write_pdu_list, r2t_pdu, tailq);
spdk_put_pdu(r2t_pdu); spdk_put_pdu(r2t_pdu);
spdk_put_pdu(data_out_pdu); spdk_put_pdu(data_out_pdu);