lib/iscsi: Change spdk_iscsi_send_nopin() to private and rename it

spdk_iscsi_send_nopin() is called only in a single place of conn.c.
So change it to private in conn.c.  Additionally, iscsi_conn_send_nopin()
may be a little more meaningful and rename to it.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I1fe70e0468e1dd43468492b8b3d359c094130ed7
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/477190
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-12-08 21:48:11 -05:00 committed by Tomasz Zawadzki
parent 4c577b1fce
commit 492789cee1
3 changed files with 40 additions and 45 deletions

View File

@ -1227,6 +1227,45 @@ iscsi_get_pdu_length(struct spdk_iscsi_pdu *pdu, int header_digest,
return total; return total;
} }
static void
iscsi_conn_send_nopin(struct spdk_iscsi_conn *conn)
{
struct spdk_iscsi_pdu *rsp_pdu;
struct iscsi_bhs_nop_in *rsp;
/* Only send nopin if we have logged in and are in a normal session. */
if (conn->sess == NULL ||
!conn->full_feature ||
!spdk_iscsi_param_eq_val(conn->sess->params, "SessionType", "Normal")) {
return;
}
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "send NOPIN isid=%"PRIx64", tsih=%u, cid=%u\n",
conn->sess->isid, conn->sess->tsih, conn->cid);
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "StatSN=%u, ExpCmdSN=%u, MaxCmdSN=%u\n",
conn->StatSN, conn->sess->ExpCmdSN,
conn->sess->MaxCmdSN);
rsp_pdu = spdk_get_pdu();
rsp = (struct iscsi_bhs_nop_in *) &rsp_pdu->bhs;
rsp_pdu->data = NULL;
/*
* spdk_get_pdu() memset's the PDU for us, so only fill out the needed
* fields.
*/
rsp->opcode = ISCSI_OP_NOPIN;
rsp->flags = 0x80;
/*
* Technically the to_be32() is not needed here, since
* to_be32(0xFFFFFFFU) returns 0xFFFFFFFFU.
*/
to_be32(&rsp->itt, 0xFFFFFFFFU);
to_be32(&rsp->ttt, conn->id);
to_be32(&rsp->stat_sn, conn->StatSN);
to_be32(&rsp->exp_cmd_sn, conn->sess->ExpCmdSN);
to_be32(&rsp->max_cmd_sn, conn->sess->MaxCmdSN);
spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
conn->last_nopin = spdk_get_ticks();
conn->nop_outstanding = true;
}
void void
spdk_iscsi_conn_handle_nop(struct spdk_iscsi_conn *conn) spdk_iscsi_conn_handle_nop(struct spdk_iscsi_conn *conn)
{ {
@ -1253,7 +1292,7 @@ spdk_iscsi_conn_handle_nop(struct spdk_iscsi_conn *conn)
conn->state = ISCSI_CONN_STATE_EXITING; conn->state = ISCSI_CONN_STATE_EXITING;
} }
} else if (tsc - conn->last_nopin > conn->nopininterval) { } else if (tsc - conn->last_nopin > conn->nopininterval) {
spdk_iscsi_send_nopin(conn); iscsi_conn_send_nopin(conn);
} }
} }

View File

@ -3822,49 +3822,6 @@ iscsi_pdu_hdr_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
return 0; return 0;
} }
void spdk_iscsi_send_nopin(struct spdk_iscsi_conn *conn)
{
struct spdk_iscsi_pdu *rsp_pdu;
struct iscsi_bhs_nop_in *rsp;
/* Only send nopin if we have logged in and are in a normal session. */
if (conn->sess == NULL ||
!conn->full_feature ||
!spdk_iscsi_param_eq_val(conn->sess->params, "SessionType", "Normal")) {
return;
}
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "send NOPIN isid=%"PRIx64", tsih=%u, cid=%u\n",
conn->sess->isid, conn->sess->tsih, conn->cid);
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "StatSN=%u, ExpCmdSN=%u, MaxCmdSN=%u\n",
conn->StatSN, conn->sess->ExpCmdSN,
conn->sess->MaxCmdSN);
rsp_pdu = spdk_get_pdu();
rsp = (struct iscsi_bhs_nop_in *) &rsp_pdu->bhs;
rsp_pdu->data = NULL;
/*
* spdk_get_pdu() memset's the PDU for us, so only fill out the needed
* fields.
*/
rsp->opcode = ISCSI_OP_NOPIN;
rsp->flags = 0x80;
/*
* Technically the to_be32() is not needed here, since
* to_be32(0xFFFFFFFU) returns 0xFFFFFFFFU.
*/
to_be32(&rsp->itt, 0xFFFFFFFFU);
to_be32(&rsp->ttt, conn->id);
to_be32(&rsp->stat_sn, conn->StatSN);
to_be32(&rsp->exp_cmd_sn, conn->sess->ExpCmdSN);
to_be32(&rsp->max_cmd_sn, conn->sess->MaxCmdSN);
spdk_iscsi_conn_write_pdu(conn, rsp_pdu);
conn->last_nopin = spdk_get_ticks();
conn->nop_outstanding = true;
}
static int static int
iscsi_pdu_hdr_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) iscsi_pdu_hdr_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
{ {

View File

@ -413,7 +413,6 @@ int spdk_iscsi_auth_group_delete_secret(struct spdk_iscsi_auth_group *group,
const char *user); const char *user);
void spdk_iscsi_auth_groups_info_json(struct spdk_json_write_ctx *w); void spdk_iscsi_auth_groups_info_json(struct spdk_json_write_ctx *w);
void spdk_iscsi_send_nopin(struct spdk_iscsi_conn *conn);
void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn, void spdk_iscsi_task_response(struct spdk_iscsi_conn *conn,
struct spdk_iscsi_task *task); struct spdk_iscsi_task *task);
int spdk_iscsi_build_iovs(struct spdk_iscsi_conn *conn, struct iovec *iovs, int iovcnt, int spdk_iscsi_build_iovs(struct spdk_iscsi_conn *conn, struct iovec *iovs, int iovcnt,