diff --git a/lib/iscsi/conn.c b/lib/iscsi/conn.c index 1cf533449..da1149e3e 100644 --- a/lib/iscsi/conn.c +++ b/lib/iscsi/conn.c @@ -1227,6 +1227,45 @@ iscsi_get_pdu_length(struct spdk_iscsi_pdu *pdu, int header_digest, 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 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; } } else if (tsc - conn->last_nopin > conn->nopininterval) { - spdk_iscsi_send_nopin(conn); + iscsi_conn_send_nopin(conn); } } diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index 578ae4d60..43b6150fd 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -3822,49 +3822,6 @@ iscsi_pdu_hdr_op_task(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) 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 iscsi_pdu_hdr_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu) { diff --git a/lib/iscsi/iscsi.h b/lib/iscsi/iscsi.h index d3a55836f..cd23dc60b 100644 --- a/lib/iscsi/iscsi.h +++ b/lib/iscsi/iscsi.h @@ -413,7 +413,6 @@ int spdk_iscsi_auth_group_delete_secret(struct spdk_iscsi_auth_group *group, const char *user); 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, struct spdk_iscsi_task *task); int spdk_iscsi_build_iovs(struct spdk_iscsi_conn *conn, struct iovec *iovs, int iovcnt,