From 661fc79c0f77585b14a8cf9d38ec7611b49c75f3 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Sun, 1 Dec 2019 17:54:51 -0500 Subject: [PATCH] lib/iscsi: Move up iscsi_op_login_initialize_port in a file This patch series orders login related functions top down in iscsi.c. Signed-off-by: Shuhei Matsumoto Change-Id: I82fe06e3488a1c623c5fc875cf797790ee4ea48f Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476412 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- lib/iscsi/iscsi.c | 73 ++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c index f988c3ffe..a5940d18e 100644 --- a/lib/iscsi/iscsi.c +++ b/lib/iscsi/iscsi.c @@ -1323,6 +1323,43 @@ iscsi_op_login_store_incoming_params(struct spdk_iscsi_conn *conn, return 0; } +/* + * This function is used to initialize the port info + * return + * 0: success + * otherwise: error + */ +static int +iscsi_op_login_initialize_port(struct spdk_iscsi_conn *conn, + struct spdk_iscsi_pdu *rsp_pdu, + char *initiator_port_name, + uint32_t name_length, + struct iscsi_param *params) +{ + const char *val; + struct iscsi_bhs_login_rsp *rsph; + rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs; + + /* Initiator Name and Port */ + val = spdk_iscsi_param_get_val(params, "InitiatorName"); + if (val == NULL) { + SPDK_ERRLOG("InitiatorName is empty\n"); + /* Missing parameter */ + rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; + rsph->status_detail = ISCSI_LOGIN_MISSING_PARMS; + return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; + } + snprintf(conn->initiator_name, sizeof(conn->initiator_name), "%s", val); + snprintf(initiator_port_name, name_length, + "%s,i,0x%12.12" PRIx64, val, iscsi_get_isid(rsph->isid)); + spdk_strlwr(conn->initiator_name); + spdk_strlwr(initiator_port_name); + SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Initiator name: %s\n", conn->initiator_name); + SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Initiator port: %s\n", initiator_port_name); + + return 0; +} + /* * This function is used to del the original param and update it with new * value @@ -1654,42 +1691,6 @@ iscsi_op_login_session_type(struct spdk_iscsi_conn *conn, return 0; } -/* - * This function is used to initialize the port info - * return - * 0: success - * otherwise: error - */ -static int -iscsi_op_login_initialize_port(struct spdk_iscsi_conn *conn, - struct spdk_iscsi_pdu *rsp_pdu, - char *initiator_port_name, - uint32_t name_length, - struct iscsi_param *params) -{ - const char *val; - struct iscsi_bhs_login_rsp *rsph; - rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs; - - /* Initiator Name and Port */ - val = spdk_iscsi_param_get_val(params, "InitiatorName"); - if (val == NULL) { - SPDK_ERRLOG("InitiatorName is empty\n"); - /* Missing parameter */ - rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR; - rsph->status_detail = ISCSI_LOGIN_MISSING_PARMS; - return SPDK_ISCSI_LOGIN_ERROR_RESPONSE; - } - snprintf(conn->initiator_name, sizeof(conn->initiator_name), "%s", val); - snprintf(initiator_port_name, name_length, - "%s,i,0x%12.12" PRIx64, val, iscsi_get_isid(rsph->isid)); - spdk_strlwr(conn->initiator_name); - spdk_strlwr(initiator_port_name); - SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Initiator name: %s\n", conn->initiator_name); - SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Initiator port: %s\n", initiator_port_name); - - return 0; -} /* * This function is used to set the info in the connection data structure