summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2010-07-10 00:26:13 -0500
committerMike Christie <michaelc@cs.wisc.edu>2010-07-10 00:26:13 -0500
commitfe5cca505d6509dd67cefe85a96e0a4db6cedb4d (patch)
tree30548c66cf734cad8e9583cb053d998e63719948
parentef4cfcdc7b66a6783aa68af97f02a055908657f0 (diff)
downloadopen-iscsi-fe5cca505d6509dd67cefe85a96e0a4db6cedb4d.tar.gz
iscsi boot: add support for iscsi boot sysfs module
This patch modifies the ibft sysfs code to support the iscsi boot sysfs module which is used by be2iscsi to export be2iscsi boot info.
-rw-r--r--include/fw_context.h2
-rw-r--r--usr/iface.c89
-rw-r--r--usr/iface.h2
-rw-r--r--utils/fwparam_ibft/Makefile2
-rw-r--r--utils/fwparam_ibft/fw_entry.c6
-rw-r--r--utils/fwparam_ibft/fwparam.h4
6 files changed, 64 insertions, 41 deletions
diff --git a/include/fw_context.h b/include/fw_context.h
index abdff42..770b41a 100644
--- a/include/fw_context.h
+++ b/include/fw_context.h
@@ -54,6 +54,8 @@ struct boot_context {
char mask[18];
char lun[17];
char vlan[15];
+
+ char scsi_host_name[64];
};
extern int fw_get_entry(struct boot_context *context);
diff --git a/usr/iface.c b/usr/iface.c
index 27b59d0..80615ca 100644
--- a/usr/iface.c
+++ b/usr/iface.c
@@ -778,31 +778,62 @@ void iface_link_ifaces(struct list_head *ifaces)
iface_for_each_iface(ifaces, 1, &nr_found, iface_link);
}
-void iface_setup_from_boot_context(struct iface_rec *iface,
+/**
+ * iface_setup_from_boot_context - setup iface from boot context info
+ * @iface: iface t setup
+ * @context: boot context info
+ *
+ * Returns 1 if setup for offload.
+ */
+int iface_setup_from_boot_context(struct iface_rec *iface,
struct boot_context *context)
{
if (strlen(context->initiatorname))
strlcpy(iface->iname, context->initiatorname,
sizeof(iface->iname));
- if (strlen(context->iface)) {
- if (!net_get_transport_name_from_netdev(context->iface,
- iface->transport_name)) {
- /* set up for access through offload card */
- memset(iface->name, 0, sizeof(iface->name));
- snprintf(iface->name, sizeof(iface->name),
- "%s.%s", iface->transport_name,
- context->mac);
-
- strlcpy(iface->netdev, context->iface,
- sizeof(iface->netdev));
- strlcpy(iface->hwaddress, context->mac,
- sizeof(iface->hwaddress));
- strlcpy(iface->ipaddress, context->ipaddr,
- sizeof(iface->ipaddress));
+ if (strlen(context->scsi_host_name)) {
+ struct iscsi_transport *t;
+ uint32_t hostno;
+
+ if (sscanf(context->scsi_host_name, "iscsi_boot%u", &hostno) != 1) {
+ log_error("Could not parse %s's host no.",
+ context->scsi_host_name);
+ return 0;
}
- }
+ t = iscsi_sysfs_get_transport_by_hba(hostno);
+ if (!t) {
+ log_error("Could not get transport for %s. "
+ "Make sure the iSCSI driver is loaded.",
+ context->scsi_host_name);
+ return 0;
+ }
+
+ log_debug(3, "boot context has %s transport %s",
+ context->scsi_host_name, t->name);
+ strcpy(iface->transport_name, t->name);
+ } else if (strlen(context->iface) &&
+ (!net_get_transport_name_from_netdev(context->iface,
+ iface->transport_name))) {
+ log_debug(3, "boot context has netdev %s",
+ context->iface);
+ strlcpy(iface->netdev, context->iface,
+ sizeof(iface->netdev));
+ } else
+ return 0;
+ /*
+ * set up for access through a offload card.
+ */
+ memset(iface->name, 0, sizeof(iface->name));
+ snprintf(iface->name, sizeof(iface->name), "%s.%s",
+ iface->transport_name, context->mac);
+
+ strlcpy(iface->hwaddress, context->mac,
+ sizeof(iface->hwaddress));
+ strlcpy(iface->ipaddress, context->ipaddr,
+ sizeof(iface->ipaddress));
log_debug(1, "iface " iface_fmt "\n", iface_str(iface));
+ return 1;
}
/**
@@ -817,32 +848,24 @@ void iface_setup_from_boot_context(struct iface_rec *iface,
int iface_create_ifaces_from_boot_contexts(struct list_head *ifaces,
struct list_head *targets)
{
- char transport_name[ISCSI_TRANSPORT_NAME_MAXLEN];
- char iface_name[ISCSI_MAX_IFACE_LEN];
struct boot_context *context;
struct iface_rec *iface, *tmp_iface;
int rc = 0;
list_for_each_entry(context, targets, list) {
- memset(transport_name, 0, ISCSI_TRANSPORT_NAME_MAXLEN);
-
- if (net_get_transport_name_from_netdev(context->iface,
- transport_name))
- continue;
-
- /* offload + ibft support */
- memset(iface_name, 0, ISCSI_MAX_IFACE_LEN);
- snprintf(iface_name, ISCSI_MAX_IFACE_LEN,
- "%s.%s", transport_name, context->mac);
-
rc = 0;
- iface = iface_alloc(iface_name, &rc);
+ /* use dummy name. If valid it will get overwritten below */
+ iface = iface_alloc(DEFAULT_IFACENAME, &rc);
if (!iface) {
log_error("Could not setup iface %s for boot\n",
- iface_name);
+ context->iface);
goto fail;
}
- iface_setup_from_boot_context(iface, context);
+ if (!iface_setup_from_boot_context(iface, context)) {
+ /* no offload so forget it */
+ free(iface);
+ continue;
+ }
rc = iface_conf_write(iface);
if (rc) {
diff --git a/usr/iface.h b/usr/iface.h
index f948686..9f6d47e 100644
--- a/usr/iface.h
+++ b/usr/iface.h
@@ -50,7 +50,7 @@ extern int iface_conf_write(struct iface_rec *iface);
extern int iface_conf_delete(struct iface_rec *iface);
extern int iface_is_valid(struct iface_rec *iface);
extern void iface_link_ifaces(struct list_head *ifaces);
-extern void iface_setup_from_boot_context(struct iface_rec *iface,
+extern int iface_setup_from_boot_context(struct iface_rec *iface,
struct boot_context *context);
extern int iface_create_ifaces_from_boot_contexts(struct list_head *ifaces,
struct list_head *targets);
diff --git a/utils/fwparam_ibft/Makefile b/utils/fwparam_ibft/Makefile
index b9e7988..ca07b76 100644
--- a/utils/fwparam_ibft/Makefile
+++ b/utils/fwparam_ibft/Makefile
@@ -22,7 +22,7 @@
#
SYSDEPS_OBJS = $(wildcard ../sysdeps/*.o)
-OBJS := fw_entry.o fwparam_ibft_sysfs.o $(SYSDEPS_OBJS) ../../usr/iscsi_net_util.o
+OBJS := fw_entry.o fwparam_sysfs.o $(SYSDEPS_OBJS) ../../usr/iscsi_net_util.o
OBJS += prom_lex.o prom_parse.tab.o fwparam_ppc.o
CLEANFILES = $(OBJS) *.output *~
diff --git a/utils/fwparam_ibft/fw_entry.c b/utils/fwparam_ibft/fw_entry.c
index ae5d34a..bbdb6d2 100644
--- a/utils/fwparam_ibft/fw_entry.c
+++ b/utils/fwparam_ibft/fw_entry.c
@@ -102,8 +102,7 @@ int fw_get_entry(struct boot_context *context)
ret = fwparam_ppc_boot_info(context);
if (ret)
- ret = fwparam_ibft_sysfs_boot_info(context);
-
+ ret = fwparam_sysfs_boot_info(context);
return ret;
}
@@ -124,8 +123,7 @@ int fw_get_targets(struct list_head *list)
ret = fwparam_ppc_get_targets(list);
if (ret)
- ret = fwparam_ibft_sysfs_get_targets(list);
-
+ ret = fwparam_sysfs_get_targets(list);
return ret;
}
diff --git a/utils/fwparam_ibft/fwparam.h b/utils/fwparam_ibft/fwparam.h
index a79213b..32e4961 100644
--- a/utils/fwparam_ibft/fwparam.h
+++ b/utils/fwparam_ibft/fwparam.h
@@ -24,8 +24,8 @@
struct boot_context;
-int fwparam_ibft_sysfs_boot_info(struct boot_context *context);
-int fwparam_ibft_sysfs_get_targets(struct list_head *list);
+int fwparam_sysfs_boot_info(struct boot_context *context);
+int fwparam_sysfs_get_targets(struct list_head *list);
int fwparam_ppc_boot_info(struct boot_context *context);
int fwparam_ppc_get_targets(struct list_head *list);