iscsi-target: Add base MaxXmitDataSegmentLength code
authorNicholas Bellinger <nab@linux-iscsi.org>
Sun, 30 Sep 2012 04:47:16 +0000 (21:47 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 2 Oct 2012 20:17:30 +0000 (13:17 -0700)
This patch introduces a new per connection MaxXmitDataSegmentLength
parameter value used to represent the outgoing MaxRecvDataSegmentLength
that is actually sent over the wire during iSCSI login response back
to the initiator side.

It also adds a new MaxXmitDataSegmentLength configfs attribute to
represent this value within the existing TPG parameter group under
/sys/kernel/config/target/iscsi/$TARGETNAME/$TPGT/param/

Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: Andy Grover <agrover@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/iscsi/iscsi_target_configfs.c
drivers/target/iscsi/iscsi_target_core.h
drivers/target/iscsi/iscsi_target_parameters.c
drivers/target/iscsi/iscsi_target_parameters.h

index f86833f..f491f96 100644 (file)
@@ -1034,6 +1034,9 @@ TPG_PARAM_ATTR(ImmediateData, S_IRUGO | S_IWUSR);
 DEF_TPG_PARAM(MaxRecvDataSegmentLength);
 TPG_PARAM_ATTR(MaxRecvDataSegmentLength, S_IRUGO | S_IWUSR);
 
+DEF_TPG_PARAM(MaxXmitDataSegmentLength);
+TPG_PARAM_ATTR(MaxXmitDataSegmentLength, S_IRUGO | S_IWUSR);
+
 DEF_TPG_PARAM(MaxBurstLength);
 TPG_PARAM_ATTR(MaxBurstLength, S_IRUGO | S_IWUSR);
 
@@ -1079,6 +1082,7 @@ static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
        &iscsi_tpg_param_InitialR2T.attr,
        &iscsi_tpg_param_ImmediateData.attr,
        &iscsi_tpg_param_MaxRecvDataSegmentLength.attr,
+       &iscsi_tpg_param_MaxXmitDataSegmentLength.attr,
        &iscsi_tpg_param_MaxBurstLength.attr,
        &iscsi_tpg_param_FirstBurstLength.attr,
        &iscsi_tpg_param_DefaultTime2Wait.attr,
index 8a908b2..b26611a 100644 (file)
@@ -239,6 +239,7 @@ struct iscsi_conn_ops {
        u8      HeaderDigest;                   /* [0,1] == [None,CRC32C] */
        u8      DataDigest;                     /* [0,1] == [None,CRC32C] */
        u32     MaxRecvDataSegmentLength;       /* [512..2**24-1] */
+       u32     MaxXmitDataSegmentLength;       /* [512..2**24-1] */
        u8      OFMarker;                       /* [0,1] == [No,Yes] */
        u8      IFMarker;                       /* [0,1] == [No,Yes] */
        u32     OFMarkInt;                      /* [1..65535] */
index 0c4760f..40864ee 100644 (file)
@@ -334,6 +334,13 @@ int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
        if (!param)
                goto out;
 
+       param = iscsi_set_default_param(pl, MAXXMITDATASEGMENTLENGTH,
+                       INITIAL_MAXXMITDATASEGMENTLENGTH,
+                       PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
+                       TYPERANGE_512_TO_16777215, USE_ALL);
+       if (!param)
+               goto out;
+
        param = iscsi_set_default_param(pl, MAXRECVDATASEGMENTLENGTH,
                        INITIAL_MAXRECVDATASEGMENTLENGTH,
                        PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
@@ -467,6 +474,8 @@ int iscsi_set_keys_to_negotiate(
                        SET_PSTATE_NEGOTIATE(param);
                } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
                        SET_PSTATE_NEGOTIATE(param);
+               } else if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
+                       continue;
                } else if (!strcmp(param->name, MAXBURSTLENGTH)) {
                        SET_PSTATE_NEGOTIATE(param);
                } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
@@ -1720,6 +1729,18 @@ void iscsi_set_connection_parameters(
        pr_debug("---------------------------------------------------"
                        "---------------\n");
        list_for_each_entry(param, &param_list->param_list, p_list) {
+               /*
+                * Special case to set MAXXMITDATASEGMENTLENGTH from the
+                * target requested MaxRecvDataSegmentLength, even though
+                * this key is not sent over the wire.
+                */
+               if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
+                       ops->MaxXmitDataSegmentLength =
+                               simple_strtoul(param->value, &tmpptr, 0);
+                       pr_debug("MaxXmitDataSegmentLength:     %s\n",
+                               param->value);
+               }
+
                if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param))
                        continue;
                if (!strcmp(param->name, AUTHMETHOD)) {
index 6a37fd6..77a28b5 100644 (file)
@@ -70,6 +70,7 @@ extern void iscsi_set_session_parameters(struct iscsi_sess_ops *,
 #define INITIALR2T                     "InitialR2T"
 #define IMMEDIATEDATA                  "ImmediateData"
 #define MAXRECVDATASEGMENTLENGTH       "MaxRecvDataSegmentLength"
+#define MAXXMITDATASEGMENTLENGTH       "MaxXmitDataSegmentLength"
 #define MAXBURSTLENGTH                 "MaxBurstLength"
 #define FIRSTBURSTLENGTH               "FirstBurstLength"
 #define DEFAULTTIME2WAIT               "DefaultTime2Wait"
@@ -113,6 +114,10 @@ extern void iscsi_set_session_parameters(struct iscsi_sess_ops *,
 #define INITIAL_INITIALR2T                     YES
 #define INITIAL_IMMEDIATEDATA                  YES
 #define INITIAL_MAXRECVDATASEGMENTLENGTH       "8192"
+/*
+ * Match outgoing MXDSL default to incoming Open-iSCSI default
+ */
+#define INITIAL_MAXXMITDATASEGMENTLENGTH       "262144"
 #define INITIAL_MAXBURSTLENGTH                 "262144"
 #define INITIAL_FIRSTBURSTLENGTH               "65536"
 #define INITIAL_DEFAULTTIME2WAIT               "2"