Blob Blame Raw
From 68ef07c23f7c0d1ea6b502c28be1152e77ff1bde Mon Sep 17 00:00:00 2001
From: Eddie Wai <eddie.wai@broadcom.com>
Date: Fri, 12 Apr 2013 10:41:15 -0700
Subject: ISCSISTART: Saved ibft boot info to the session sysfs

Three new session sysfs parameters are introduced:
boot_root   - holds the ibft boot root folder name
boot_nic    - holds the ibft boot ethernetN name
boot_target - holds the ibft boot targetN name

This patch copies over the /sys/firmware/<boot_root>/ethernetN/targetN info
from the boot context to the node_rec.

Signed-off-by: Eddie Wai <eddie.wai@broadcom.com>
---
 include/fw_context.h               |  3 +++
 include/iscsi_if.h                 |  4 ++++
 include/iscsi_proto.h              |  1 +
 usr/config.h                       |  3 +++
 usr/idbm.c                         |  6 ++++++
 usr/initiator_common.c             | 14 +++++++++++++-
 utils/fwparam_ibft/fwparam_sysfs.c |  8 ++++++++
 7 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/include/fw_context.h b/include/fw_context.h
index 1640859..6563d68 100644
--- a/include/fw_context.h
+++ b/include/fw_context.h
@@ -30,6 +30,9 @@
 
 struct boot_context {
 	struct list_head list;
+	char boot_root[BOOT_NAME_MAXLEN];
+	char boot_nic[BOOT_NAME_MAXLEN];
+	char boot_target[BOOT_NAME_MAXLEN];
 
 	/* target settings */
 	int target_port;
diff --git a/include/iscsi_if.h b/include/iscsi_if.h
index 20f2bc2..b47dde7 100644
--- a/include/iscsi_if.h
+++ b/include/iscsi_if.h
@@ -495,6 +495,10 @@ enum iscsi_param {
 
 	ISCSI_PARAM_TGT_RESET_TMO,
 	ISCSI_PARAM_TARGET_ALIAS,
+
+	ISCSI_PARAM_BOOT_ROOT,
+	ISCSI_PARAM_BOOT_NIC,
+	ISCSI_PARAM_BOOT_TARGET,
 	/* must always be last */
 	ISCSI_PARAM_MAX,
 };
diff --git a/include/iscsi_proto.h b/include/iscsi_proto.h
index 1c69feb..56f757b 100644
--- a/include/iscsi_proto.h
+++ b/include/iscsi_proto.h
@@ -619,6 +619,7 @@ struct iscsi_reject {
 #define KEY_MAXLEN		64
 #define VALUE_MAXLEN		255
 #define TARGET_NAME_MAXLEN	VALUE_MAXLEN
+#define BOOT_NAME_MAXLEN	256
 
 #define ISCSI_DEF_MAX_RECV_SEG_LEN		8192
 #define ISCSI_MIN_MAX_RECV_SEG_LEN		512
diff --git a/usr/config.h b/usr/config.h
index 998caff..d457bdd 100644
--- a/usr/config.h
+++ b/usr/config.h
@@ -201,6 +201,9 @@ typedef struct session_rec {
 	 * allowed to be initiated on this record
 	 */
 	unsigned char                           multiple;
+	char					boot_root[BOOT_NAME_MAXLEN];
+	char					boot_nic[BOOT_NAME_MAXLEN];
+	char					boot_target[BOOT_NAME_MAXLEN];
 } session_rec_t;
 
 #define ISCSI_TRANSPORT_NAME_MAXLEN 16
diff --git a/usr/idbm.c b/usr/idbm.c
index bc06058..1e4f8c8 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -2748,6 +2748,12 @@ struct node_rec *idbm_create_rec_from_boot_context(struct boot_context *context)
 				strlen((char *)context->chap_password);
 	rec->session.auth.password_in_length =
 				strlen((char *)context->chap_password_in);
+	strlcpy(rec->session.boot_root, context->boot_root,
+		sizeof(context->boot_root));
+	strlcpy(rec->session.boot_nic, context->boot_nic,
+		sizeof(context->boot_nic));
+	strlcpy(rec->session.boot_target, context->boot_target,
+		sizeof(context->boot_target));
 
 	iface_setup_from_boot_context(&rec->iface, context);
 
diff --git a/usr/initiator_common.c b/usr/initiator_common.c
index eb72795..544d637 100644
--- a/usr/initiator_common.c
+++ b/usr/initiator_common.c
@@ -324,7 +324,7 @@ int iscsi_host_set_params(struct iscsi_session *session)
 	return 0;
 }
 
-#define MAX_SESSION_PARAMS 32
+#define MAX_SESSION_PARAMS 35
 
 int iscsi_session_set_params(struct iscsi_conn *conn)
 {
@@ -496,6 +496,18 @@ int iscsi_session_set_params(struct iscsi_conn *conn)
 			.param = ISCSI_PARAM_INITIATOR_NAME,
 			.value = session->initiator_name,
 			.type = ISCSI_STRING,
+		}, {
+			.param = ISCSI_PARAM_BOOT_ROOT,
+			.value = session->nrec.session.boot_root,
+			.type = ISCSI_STRING,
+		}, {
+			.param = ISCSI_PARAM_BOOT_NIC,
+			.value = session->nrec.session.boot_nic,
+			.type = ISCSI_STRING,
+		}, {
+			.param = ISCSI_PARAM_BOOT_TARGET,
+			.value = session->nrec.session.boot_target,
+			.type = ISCSI_STRING,
 		},
 	};
 
diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c
index 3997363..2f37b59 100644
--- a/utils/fwparam_ibft/fwparam_sysfs.c
+++ b/utils/fwparam_ibft/fwparam_sysfs.c
@@ -200,6 +200,9 @@ static int fill_nic_context(char *subsys, char *id,
 		strlcpy(context->scsi_host_name, subsys,
 			sizeof(context->scsi_host_name));
 
+	memset(&context->boot_nic, 0, sizeof(context->boot_nic));
+	snprintf(context->boot_nic, sizeof(context->boot_nic), "%s", id);
+
 	sysfs_get_str(id, subsys, "ip-addr", context->ipaddr,
 		      sizeof(context->ipaddr));
 	sysfs_get_str(id, subsys, "vlan", context->vlan,
@@ -224,6 +227,8 @@ static void fill_initiator_context(char *subsys, struct boot_context *context)
 		      sizeof(context->initiatorname));
 	sysfs_get_str("initiator", subsys, "isid", context->isid,
 		      sizeof(context->isid));
+
+	strlcpy(context->boot_root, subsys, sizeof(context->boot_root));
 }
 static int fill_tgt_context(char *subsys, char *id,
 			    struct boot_context *context)
@@ -240,6 +245,9 @@ static int fill_tgt_context(char *subsys, char *id,
 	if (rc)
 		return rc;
 
+	memset(&context->boot_target, 0, sizeof(context->boot_target));
+	snprintf(context->boot_target, sizeof(context->boot_target), "%s", id);
+
 	/*
 	 * We can live without the rest of they do not exist. If we
 	 * failed to get them we will figure it out when we login.
-- 
1.8.1.4