lib/iscsi: Move up iscsi_op_login_session_type in a file
This patch series orders login related functions top down in iscsi.c. Other than code movement, fix a typo. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: Ib55fe86295f47c1c86bb99d5e3a6862f508bfcfa Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476413 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
661fc79c0f
commit
27d6428076
@ -1360,6 +1360,52 @@ iscsi_op_login_initialize_port(struct spdk_iscsi_conn *conn,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function is used to judge the session type
|
||||||
|
* return
|
||||||
|
* 0: success
|
||||||
|
* Other value: error
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
iscsi_op_login_session_type(struct spdk_iscsi_conn *conn,
|
||||||
|
struct spdk_iscsi_pdu *rsp_pdu,
|
||||||
|
enum session_type *session_type,
|
||||||
|
struct iscsi_param *params)
|
||||||
|
{
|
||||||
|
const char *session_type_str;
|
||||||
|
struct iscsi_bhs_login_rsp *rsph;
|
||||||
|
|
||||||
|
rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
|
||||||
|
session_type_str = spdk_iscsi_param_get_val(params, "SessionType");
|
||||||
|
if (session_type_str == NULL) {
|
||||||
|
if (rsph->tsih != 0) {
|
||||||
|
*session_type = SESSION_TYPE_NORMAL;
|
||||||
|
} else {
|
||||||
|
SPDK_ERRLOG("SessionType 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;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (strcasecmp(session_type_str, "Discovery") == 0) {
|
||||||
|
*session_type = SESSION_TYPE_DISCOVERY;
|
||||||
|
} else if (strcasecmp(session_type_str, "Normal") == 0) {
|
||||||
|
*session_type = SESSION_TYPE_NORMAL;
|
||||||
|
} else {
|
||||||
|
*session_type = SESSION_TYPE_INVALID;
|
||||||
|
SPDK_ERRLOG("SessionType is invalid\n");
|
||||||
|
/* Missing parameter */
|
||||||
|
rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR;
|
||||||
|
rsph->status_detail = ISCSI_LOGIN_MISSING_PARMS;
|
||||||
|
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Session Type: %s\n", session_type_str);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is used to del the original param and update it with new
|
* This function is used to del the original param and update it with new
|
||||||
* value
|
* value
|
||||||
@ -1646,52 +1692,6 @@ iscsi_op_login_session_normal(struct spdk_iscsi_conn *conn,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* This function is used to judge the session type
|
|
||||||
* return
|
|
||||||
* 0: success
|
|
||||||
* otherwise, error
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
iscsi_op_login_session_type(struct spdk_iscsi_conn *conn,
|
|
||||||
struct spdk_iscsi_pdu *rsp_pdu,
|
|
||||||
enum session_type *session_type,
|
|
||||||
struct iscsi_param *params)
|
|
||||||
{
|
|
||||||
const char *session_type_str;
|
|
||||||
struct iscsi_bhs_login_rsp *rsph;
|
|
||||||
|
|
||||||
rsph = (struct iscsi_bhs_login_rsp *)&rsp_pdu->bhs;
|
|
||||||
session_type_str = spdk_iscsi_param_get_val(params, "SessionType");
|
|
||||||
if (session_type_str == NULL) {
|
|
||||||
if (rsph->tsih != 0) {
|
|
||||||
*session_type = SESSION_TYPE_NORMAL;
|
|
||||||
} else {
|
|
||||||
SPDK_ERRLOG("SessionType 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;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (strcasecmp(session_type_str, "Discovery") == 0) {
|
|
||||||
*session_type = SESSION_TYPE_DISCOVERY;
|
|
||||||
} else if (strcasecmp(session_type_str, "Normal") == 0) {
|
|
||||||
*session_type = SESSION_TYPE_NORMAL;
|
|
||||||
} else {
|
|
||||||
*session_type = SESSION_TYPE_INVALID;
|
|
||||||
SPDK_ERRLOG("SessionType is invalid\n");
|
|
||||||
/* Missing parameter */
|
|
||||||
rsph->status_class = ISCSI_CLASS_INITIATOR_ERROR;
|
|
||||||
rsph->status_detail = ISCSI_LOGIN_MISSING_PARMS;
|
|
||||||
return SPDK_ISCSI_LOGIN_ERROR_RESPONSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "Session Type: %s\n", session_type_str);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function is used to set the info in the connection data structure
|
* This function is used to set the info in the connection data structure
|
||||||
* return
|
* return
|
||||||
|
Loading…
Reference in New Issue
Block a user