Blame 0031-PATCH-v5-1-3-ISCSISTART-Saved-ibft-boot-info-to-the-.patch

2c4537b
From 5992173f13550d75659fec1d7e1f6e87895d560a Mon Sep 17 00:00:00 2001
2c4537b
From: Mike Christie <michaelc@cs.wisc.edu>
2c4537b
Date: Wed, 11 Sep 2013 23:59:31 -0700
2c4537b
Subject: [PATCH] [PATCH v5 1/3] ISCSISTART: Saved ibft boot info to the
2c4537b
 session
2c4537b
2c4537b
Patch and description from Eddie Wai:
c2d5d21
c2d5d21
Three new session sysfs parameters are introduced:
c2d5d21
boot_root   - holds the ibft boot root folder name
c2d5d21
boot_nic    - holds the ibft boot ethernetN name
c2d5d21
boot_target - holds the ibft boot targetN name
c2d5d21
2c4537b
This patch copies over the /sys/firmware/<boot_root>/ethernetN/targetN
2c4537b
info
c2d5d21
from the boot context to the node_rec.
c2d5d21
c2d5d21
Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
c2d5d21
---
c2d5d21
 include/fw_context.h               |  3 +++
c2d5d21
 include/iscsi_proto.h              |  1 +
c2d5d21
 usr/config.h                       |  3 +++
c2d5d21
 usr/idbm.c                         |  6 ++++++
c2d5d21
 usr/initiator_common.c             | 14 +++++++++++++-
c2d5d21
 utils/fwparam_ibft/fwparam_sysfs.c |  8 ++++++++
2c4537b
 6 files changed, 34 insertions(+), 1 deletion(-)
c2d5d21
c2d5d21
diff --git a/include/fw_context.h b/include/fw_context.h
c2d5d21
index 1640859..6563d68 100644
c2d5d21
--- a/include/fw_context.h
c2d5d21
+++ b/include/fw_context.h
c2d5d21
@@ -30,6 +30,9 @@
c2d5d21
 
c2d5d21
 struct boot_context {
c2d5d21
 	struct list_head list;
c2d5d21
+	char boot_root[BOOT_NAME_MAXLEN];
c2d5d21
+	char boot_nic[BOOT_NAME_MAXLEN];
c2d5d21
+	char boot_target[BOOT_NAME_MAXLEN];
c2d5d21
 
c2d5d21
 	/* target settings */
c2d5d21
 	int target_port;
c2d5d21
diff --git a/include/iscsi_proto.h b/include/iscsi_proto.h
c2d5d21
index 1c69feb..56f757b 100644
c2d5d21
--- a/include/iscsi_proto.h
c2d5d21
+++ b/include/iscsi_proto.h
c2d5d21
@@ -619,6 +619,7 @@ struct iscsi_reject {
c2d5d21
 #define KEY_MAXLEN		64
c2d5d21
 #define VALUE_MAXLEN		255
c2d5d21
 #define TARGET_NAME_MAXLEN	VALUE_MAXLEN
c2d5d21
+#define BOOT_NAME_MAXLEN	256
c2d5d21
 
c2d5d21
 #define ISCSI_DEF_MAX_RECV_SEG_LEN		8192
c2d5d21
 #define ISCSI_MIN_MAX_RECV_SEG_LEN		512
c2d5d21
diff --git a/usr/config.h b/usr/config.h
c2d5d21
index 998caff..d457bdd 100644
c2d5d21
--- a/usr/config.h
c2d5d21
+++ b/usr/config.h
c2d5d21
@@ -201,6 +201,9 @@ typedef struct session_rec {
c2d5d21
 	 * allowed to be initiated on this record
c2d5d21
 	 */
c2d5d21
 	unsigned char                           multiple;
c2d5d21
+	char					boot_root[BOOT_NAME_MAXLEN];
c2d5d21
+	char					boot_nic[BOOT_NAME_MAXLEN];
c2d5d21
+	char					boot_target[BOOT_NAME_MAXLEN];
c2d5d21
 } session_rec_t;
c2d5d21
 
c2d5d21
 #define ISCSI_TRANSPORT_NAME_MAXLEN 16
c2d5d21
diff --git a/usr/idbm.c b/usr/idbm.c
c2d5d21
index bc06058..1e4f8c8 100644
c2d5d21
--- a/usr/idbm.c
c2d5d21
+++ b/usr/idbm.c
c2d5d21
@@ -2748,6 +2748,12 @@ struct node_rec *idbm_create_rec_from_boot_context(struct boot_context *context)
c2d5d21
 				strlen((char *)context->chap_password);
c2d5d21
 	rec->session.auth.password_in_length =
c2d5d21
 				strlen((char *)context->chap_password_in);
c2d5d21
+	strlcpy(rec->session.boot_root, context->boot_root,
c2d5d21
+		sizeof(context->boot_root));
c2d5d21
+	strlcpy(rec->session.boot_nic, context->boot_nic,
c2d5d21
+		sizeof(context->boot_nic));
c2d5d21
+	strlcpy(rec->session.boot_target, context->boot_target,
c2d5d21
+		sizeof(context->boot_target));
c2d5d21
 
c2d5d21
 	iface_setup_from_boot_context(&rec->iface, context);
c2d5d21
 
c2d5d21
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
2c4537b
index 0fb7edc..e2e87a1 100644
c2d5d21
--- a/usr/initiator_common.c
c2d5d21
+++ b/usr/initiator_common.c
2c4537b
@@ -345,7 +345,7 @@ void iscsi_session_init_params(struct iscsi_session *session)
2c4537b
 	}
c2d5d21
 }
c2d5d21
 
c2d5d21
-#define MAX_SESSION_PARAMS 32
c2d5d21
+#define MAX_SESSION_PARAMS 35
c2d5d21
 
c2d5d21
 int iscsi_session_set_params(struct iscsi_conn *conn)
c2d5d21
 {
2c4537b
@@ -516,6 +516,18 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
c2d5d21
 			.param = ISCSI_PARAM_INITIATOR_NAME,
c2d5d21
 			.value = session->initiator_name,
c2d5d21
 			.type = ISCSI_STRING,
c2d5d21
+		}, {
c2d5d21
+			.param = ISCSI_PARAM_BOOT_ROOT,
c2d5d21
+			.value = session->nrec.session.boot_root,
c2d5d21
+			.type = ISCSI_STRING,
c2d5d21
+		}, {
c2d5d21
+			.param = ISCSI_PARAM_BOOT_NIC,
c2d5d21
+			.value = session->nrec.session.boot_nic,
c2d5d21
+			.type = ISCSI_STRING,
c2d5d21
+		}, {
c2d5d21
+			.param = ISCSI_PARAM_BOOT_TARGET,
c2d5d21
+			.value = session->nrec.session.boot_target,
c2d5d21
+			.type = ISCSI_STRING,
c2d5d21
 		},
c2d5d21
 	};
c2d5d21
 
c2d5d21
diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c
c2d5d21
index 3997363..2f37b59 100644
c2d5d21
--- a/utils/fwparam_ibft/fwparam_sysfs.c
c2d5d21
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
c2d5d21
@@ -200,6 +200,9 @@ static int fill_nic_context(char *subsys, char *id,
c2d5d21
 		strlcpy(context->scsi_host_name, subsys,
c2d5d21
 			sizeof(context->scsi_host_name));
c2d5d21
 
c2d5d21
+	memset(&context->boot_nic, 0, sizeof(context->boot_nic));
c2d5d21
+	snprintf(context->boot_nic, sizeof(context->boot_nic), "%s", id);
c2d5d21
+
c2d5d21
 	sysfs_get_str(id, subsys, "ip-addr", context->ipaddr,
c2d5d21
 		      sizeof(context->ipaddr));
c2d5d21
 	sysfs_get_str(id, subsys, "vlan", context->vlan,
c2d5d21
@@ -224,6 +227,8 @@ static void fill_initiator_context(char *subsys, struct boot_context *context)
c2d5d21
 		      sizeof(context->initiatorname));
c2d5d21
 	sysfs_get_str("initiator", subsys, "isid", context->isid,
c2d5d21
 		      sizeof(context->isid));
c2d5d21
+
c2d5d21
+	strlcpy(context->boot_root, subsys, sizeof(context->boot_root));
c2d5d21
 }
c2d5d21
 static int fill_tgt_context(char *subsys, char *id,
c2d5d21
 			    struct boot_context *context)
c2d5d21
@@ -240,6 +245,9 @@ static int fill_tgt_context(char *subsys, char *id,
c2d5d21
 	if (rc)
c2d5d21
 		return rc;
c2d5d21
 
c2d5d21
+	memset(&context->boot_target, 0, sizeof(context->boot_target));
c2d5d21
+	snprintf(context->boot_target, sizeof(context->boot_target), "%s", id);
c2d5d21
+
c2d5d21
 	/*
c2d5d21
 	 * We can live without the rest of they do not exist. If we
c2d5d21
 	 * failed to get them we will figure it out when we login.
c2d5d21
-- 
2c4537b
1.8.3.1
c2d5d21