From 23250756c2bbab4121c11fe809990373650c4ccf Mon Sep 17 00:00:00 2001 From: Yan Burman Date: Mon, 28 Apr 2014 12:22:13 +0000 Subject: [PATCH] isert: Handle TargetRecvDataSegmentLength in RFC compliant way iSER RFC defines TargetRecvDataSegmentLength to be mandatory. Also, according to the RFC, the target must be prepared to receive at least 512 bytes, so fix that. Signed-off-by: Yan Burman git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@5486 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/isert-scst/TODO | 2 -- iscsi-scst/kernel/isert-scst/iser_pdu.c | 2 +- iscsi-scst/usr/iscsid.c | 9 +++++++++ iscsi-scst/usr/param.c | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/iscsi-scst/kernel/isert-scst/TODO b/iscsi-scst/kernel/isert-scst/TODO index 2bd1eca90..479c6b76b 100644 --- a/iscsi-scst/kernel/isert-scst/TODO +++ b/iscsi-scst/kernel/isert-scst/TODO @@ -1,5 +1,3 @@ -* In login, handle declarative statements correctly: - use text_key_add() to add target declarative keys. * Add suppport for immediate data in iSER * Add suppport for data-out in iSER * Look into allocating wr and sg entries dynamically from kmem_cache instead of embedding them into iser_cmnd diff --git a/iscsi-scst/kernel/isert-scst/iser_pdu.c b/iscsi-scst/kernel/isert-scst/iser_pdu.c index 7d151db26..eeecc2f2e 100644 --- a/iscsi-scst/kernel/isert-scst/iser_pdu.c +++ b/iscsi-scst/kernel/isert-scst/iser_pdu.c @@ -371,7 +371,7 @@ static inline void isert_link_recv_pdu_wrs(struct isert_cmnd *from_pdu, int isert_alloc_conn_resources(struct isert_connection *isert_conn) { struct isert_cmnd *pdu, *prev_pdu = NULL, *first_pdu = NULL; - int t_datasz = ISER_HDRS_SZ; + int t_datasz = 512; /* RFC states that minimum receive data size is 512 */ int i_datasz = ISER_HDRS_SZ + SCST_SENSE_BUFFERSIZE; int i, err = 0; int to_alloc; diff --git a/iscsi-scst/usr/iscsid.c b/iscsi-scst/usr/iscsid.c index 67accbd64..2e104a756 100644 --- a/iscsi-scst/usr/iscsid.c +++ b/iscsi-scst/usr/iscsid.c @@ -642,6 +642,15 @@ static int login_finish(struct connection *conn) { int res = 0; + if (conn->is_iser && + conn->session_params[key_target_recv_data_length].key_state == KEY_STATE_START) { + char buf[32] = "\0"; + params_val_to_str(session_keys, key_target_recv_data_length, + session_keys[key_target_recv_data_length].local_def, + buf, sizeof(buf)); + text_key_add(conn, "TargetRecvDataSegmentLength", buf); + } + switch (conn->session_type) { case SESSION_NORMAL: if (!conn->sess) diff --git a/iscsi-scst/usr/param.c b/iscsi-scst/usr/param.c index c4689ed25..27a3f8ad1 100644 --- a/iscsi-scst/usr/param.c +++ b/iscsi-scst/usr/param.c @@ -383,7 +383,7 @@ struct iscsi_key session_keys[] = { {"OFMarkInt", 2048, 2048, 1, 65535, 0, &marker_ops}, {"IFMarkInt", 2048, 2048, 1, 65535, 0, &marker_ops}, {"RDMAExtensions", 0, 0, 0, 0, 1, &and_ops}, - {"TargetRecvDataSegmentLength", 8192, -1, 512, -1, 0, &minimum_ops}, + {"TargetRecvDataSegmentLength", 8192, 512, 512, -1, 0, &minimum_ops}, {"InitiatorRecvDataSegmentLength", 8192, -1, 512, -1, 0, &minimum_ops}, {"MaxAHSLength", 256, 0, 0, -1, 0, &minimum_ops}, {"TaggedBufferForSolicitedDataOnly", 0, 0, 0, 0, 0, &and_ops},