Skip to contentSkip to conversation

Add iSCSI iBFT support (v0.4.7)

PATCH In review Konrad Rzeszutek 4 participants 8 messages Feb 8, 2008 – Feb 12, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add iSCSI iBFT support (v0.4.7)

This patch (v0.4.7) adds /sysfs/firmware/ibft/[initiator|targetX|ethernetX] directories along with text properties which export the the iSCSI Boot Firmware Table (iBFT) structure.

What is iSCSI Boot Firmware Table? It is a mechanism for the iSCSI tools to extract from the machine NICs the iSCSI connection information so that they can automagically mount the iSCSI share/target. Currently the iSCSI information is hard-coded in the initrd. The /sysfs entries are read-only one-name-and-value fields.

The usual set of data exposed is:

# for a in `find /sys/firmware/ibft/ -type f -print`; do  echo -n "$a: ";  cat $a; done
/sys/firmware/ibft/target0/target-name: iqn.2007.com.intel-sbx44:storage-10gb
/sys/firmware/ibft/target0/nic-assoc: 0
/sys/firmware/ibft/target0/chap-type: 0
/sys/firmware/ibft/target0/lun: 00000000
/sys/firmware/ibft/target0/port: 3260
/sys/firmware/ibft/target0/ip-addr: 192.168.79.116
/sys/firmware/ibft/target0/flags: 3
/sys/firmware/ibft/target0/index: 0
/sys/firmware/ibft/ethernet0/mac: 00:11:25:9d:8b:01
/sys/firmware/ibft/ethernet0/vlan: 0
/sys/firmware/ibft/ethernet0/gateway: 192.168.79.254
/sys/firmware/ibft/ethernet0/origin: 0
/sys/firmware/ibft/ethernet0/subnet-mask: 255.255.252.0
/sys/firmware/ibft/ethernet0/ip-addr: 192.168.77.41
/sys/firmware/ibft/ethernet0/flags: 7
/sys/firmware/ibft/ethernet0/index: 0
/sys/firmware/ibft/initiator/initiator-name: iqn.2007-07.com:konrad.initiator
/sys/firmware/ibft/initiator/flags: 3
/sys/firmware/ibft/initiator/index: 0

For full details of the IBFT structure please take a look at:
ftp://ftp.software.ibm.com/systems/support/system_x_pdf/ibm_iscsi_boot_firmware_table_v1.02.pdf

Cc Mike Christie <[email protected]>
Cc Peter Jones <[email protected]>
Cc James Bottomley <[email protected]>
Cc Greg KH <[email protected]>
 Documentation/ABI/testing/sysfs-ibft |   23 
 arch/x86/kernel/setup_32.c           |    3 
 arch/x86/kernel/setup_64.c           |    4 
 drivers/firmware/Kconfig             |   20 
 drivers/firmware/Makefile            |    2 
 drivers/firmware/iscsi_ibft.c        |  985 +++++++++++++++++++++++++++++++++++
 drivers/firmware/iscsi_ibft_find.c   |   83 ++
 include/linux/iscsi_ibft.h           |   38 +
 8 files changed, 1158 insertions(+)
Documentation/ABI/testing/sysfs-ibft new file +23 -0
new file mode 100644
index 0000000..062c009
@@ -0,0 +1,23 @@
+What:		/sys/firmware/ibft/initiator
+Date:		November 2007
+Contact:	Konrad Rzeszutek <[email protected]>
+Description:	The /sys/firmware/ibft/initiator directory will contain
+		files that expose the iSCSI Boot Firmware Table initiator data.
+		Usually this contains the Initiator name.
+
+What:		/sys/firmware/ibft/targetX
+Date:		November 2007
+Contact:	Konrad Rzeszutek <[email protected]>
+Description:	The /sys/firmware/ibft/targetX directory will contain
+		files that expose the iSCSI Boot Firmware Table target data.
+		Usually this contains the target's IP address, boot LUN,
+		target name, and what NIC it is associated with. It can also
+		contain the CHAP name (and password), the reverse CHAP
+		name (and password)
+
+What:		/sys/firmware/ibft/ethernetX
+Date:		November 2007
+Contact:	Konrad Rzeszutek <[email protected]>
+Description:	The /sys/firmware/ibft/ethernetX directory will contain
+		files that expose the iSCSI Boot Firmware Table NIC data.
+		This can this can the IP address, MAC, and gateway of the NIC.
arch/x86/kernel/setup_32.c +3 -0
index 62adc5f..83a05cf 100644
@@ -39,6 +39,7 @@
 #include <linux/efi.h>
 #include <linux/init.h>
 #include <linux/edd.h>
+#include <linux/iscsi_ibft.h>
 #include <linux/nodemask.h>
 #include <linux/kexec.h>
 #include <linux/crash_dump.h>
@@ -649,6 +650,8 @@ void __init setup_bootmem_allocator(void)
 #endif
 	numa_kva_reserve();
 	reserve_crashkernel();
+
+	reserve_ibft_region();
 }
 
 /*
arch/x86/kernel/setup_64.c +4 -0
index c8939df..9c72fe1 100644
@@ -34,6 +34,7 @@
 #include <linux/acpi.h>
 #include <linux/kallsyms.h>
 #include <linux/edd.h>
+#include <linux/iscsi_ibft.h>
 #include <linux/mmzone.h>
 #include <linux/kexec.h>
 #include <linux/cpufreq.h>
@@ -419,6 +420,9 @@ void __init setup_arch(char **cmdline_p)
 	}
 #endif
 	reserve_crashkernel();
+
+	reserve_ibft_region();
+
 	paging_init();
 	map_vsyscall();
 
drivers/firmware/Kconfig +20 -0
index 05f02a3..81a3e59 100644
@@ -93,4 +93,24 @@ config DMIID
 	  information from userspace through /sys/class/dmi/id/ or if you want
 	  DMI-based module auto-loading.
 
+config ISCSI_IBFT_FIND
+	bool "iSCSI Boot Firmware Table Attributes"
+	depends on X86 || IA64
+	default n
+	help
+	  This option enables the kernel to find the region of memory
+	  in which the ISCSI Boot Firmware Table (iBFT) resides. This
+	  is necessary for iSCSI Boot Firmware Table Attributes module to work
+	  properly.
+
+config ISCSI_IBFT
+	tristate "iSCSI Boot Firmware Table Attributes module"
+	depends on ISCSI_IBFT_FIND
+	default	n
+	help
+	  This option enables support for detection and exposing of iSCSI
+	  Boot Firmware Table (iBFT) via sysfs to userspace. If you wish to
+	  detect iSCSI boot parameters dynamically during system boot, say Y.
+	  Otherwise, say N.
+
 endmenu
drivers/firmware/Makefile +2 -0
index 8d4ebc8..4c91471 100644
@@ -8,3 +8,5 @@ obj-$(CONFIG_EFI_PCDP)		+= pcdp.o
 obj-$(CONFIG_DELL_RBU)          += dell_rbu.o
 obj-$(CONFIG_DCDBAS)		+= dcdbas.o
 obj-$(CONFIG_DMIID)		+= dmi-id.o
+obj-$(CONFIG_ISCSI_IBFT_FIND)	+= iscsi_ibft_find.o
+obj-$(CONFIG_ISCSI_IBFT)	+= iscsi_ibft.o
drivers/firmware/iscsi_ibft.c new file +985 -0

985 lines not on this page · raw message

drivers/firmware/iscsi_ibft_find.c new file +83 -0

83 lines not on this page · raw message

include/linux/iscsi_ibft.h new file +38 -0
new file mode 100644
index 0000000..d58857d
@@ -0,0 +1,38 @@
+/*
+ *  Copyright 2007 Red Hat, Inc.
+ *  by Peter Jones <[email protected]>
+ *  Copyright 2007 IBM, Inc.
+ *  by Konrad Rzeszutek <[email protected]>
+ *
+ * This code exposes the iSCSI Boot Format Table to userland via sysfs.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License v2.0 as published by
+ * the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef ISCSI_IBFT_H
+#define ISCSI_IBFT_H
+
+/*
+ * Physical location of iSCSI Boot Format Table.
+ * If the value is NULL there is no iBFT on the machine.
+ */
+extern unsigned long ibft_addr;
+
+/*
+ * Routine used to find and reserve the iSCSI Boot Format Table. The
+ * mapped address is set in the ibft_addr variable.
+ */
+#ifdef CONFIG_ISCSI_IBFT_FIND
+extern void __init reserve_ibft_region(void);
+#else
+static inline void reserve_ibft_region(void) { }
+#endif
+
+#endif /* ISCSI_IBFT_H */
#1 lore raw

REPOST: [PATCH] Add iSCSI iBFT support (v0.4.7)

Whoops. I've attached an incorrect patch in the previous e-mail (http://lkml.org/lkml/2008/2/8/350) that didn't take in to account the 'reserve_bootmem' parameters changes.

Here is fresher copy which has been tested on 2.6.24-git19 on a machine with iBFT and without.

This patch (v0.4.7) adds /sysfs/firmware/ibft/[initiator|targetX|ethernetX] directories along with text properties which export the the iSCSI Boot Firmware Table (iBFT) structure.

What is iSCSI Boot Firmware Table? It is a mechanism for the iSCSI tools to extract from the machine NICs the iSCSI connection information so that they can automagically mount the iSCSI share/target. Currently the iSCSI information is hard-coded in the initrd. The /sysfs entries are read-only one-name-and-value fields.

The usual set of data exposed is:

# for a in `find /sys/firmware/ibft/ -type f -print`; do  echo -n "$a: ";  cat $a; done
/sys/firmware/ibft/target0/target-name: iqn.2007.com.intel-sbx44:storage-10gb
/sys/firmware/ibft/target0/nic-assoc: 0
/sys/firmware/ibft/target0/chap-type: 0
/sys/firmware/ibft/target0/lun: 00000000
/sys/firmware/ibft/target0/port: 3260
/sys/firmware/ibft/target0/ip-addr: 192.168.79.116
/sys/firmware/ibft/target0/flags: 3
/sys/firmware/ibft/target0/index: 0
/sys/firmware/ibft/ethernet0/mac: 00:11:25:9d:8b:01
/sys/firmware/ibft/ethernet0/vlan: 0
/sys/firmware/ibft/ethernet0/gateway: 192.168.79.254
/sys/firmware/ibft/ethernet0/origin: 0
/sys/firmware/ibft/ethernet0/subnet-mask: 255.255.252.0
/sys/firmware/ibft/ethernet0/ip-addr: 192.168.77.41
/sys/firmware/ibft/ethernet0/flags: 7
/sys/firmware/ibft/ethernet0/index: 0
/sys/firmware/ibft/initiator/initiator-name: iqn.2007-07.com:konrad.initiator
/sys/firmware/ibft/initiator/flags: 3
/sys/firmware/ibft/initiator/index: 0

For full details of the IBFT structure please take a look at:
ftp://ftp.software.ibm.com/systems/support/system_x_pdf/ibm_iscsi_boot_firmware_table_v1.02.pdf

Cc Mike Christie <[email protected]>
Cc Peter Jones <[email protected]>
Cc James Bottomley <[email protected]>
Cc Greg KH <[email protected]>
 Documentation/ABI/testing/sysfs-ibft |   23 
 arch/x86/kernel/setup_32.c           |    3 
 arch/x86/kernel/setup_64.c           |    4 
 drivers/firmware/Kconfig             |   20 
 drivers/firmware/Makefile            |    2 
 drivers/firmware/iscsi_ibft.c        |  985 +++++++++++++++++++++++++++++++++++
 drivers/firmware/iscsi_ibft_find.c   |   82 ++
 include/linux/iscsi_ibft.h           |   38 +
 8 files changed, 1157 insertions(+)
Documentation/ABI/testing/sysfs-ibft new file +23 -0
new file mode 100644
index 0000000..062c009
@@ -0,0 +1,23 @@
+What:		/sys/firmware/ibft/initiator
+Date:		November 2007
+Contact:	Konrad Rzeszutek <[email protected]>
+Description:	The /sys/firmware/ibft/initiator directory will contain
+		files that expose the iSCSI Boot Firmware Table initiator data.
+		Usually this contains the Initiator name.
+
+What:		/sys/firmware/ibft/targetX
+Date:		November 2007
+Contact:	Konrad Rzeszutek <[email protected]>
+Description:	The /sys/firmware/ibft/targetX directory will contain
+		files that expose the iSCSI Boot Firmware Table target data.
+		Usually this contains the target's IP address, boot LUN,
+		target name, and what NIC it is associated with. It can also
+		contain the CHAP name (and password), the reverse CHAP
+		name (and password)
+
+What:		/sys/firmware/ibft/ethernetX
+Date:		November 2007
+Contact:	Konrad Rzeszutek <[email protected]>
+Description:	The /sys/firmware/ibft/ethernetX directory will contain
+		files that expose the iSCSI Boot Firmware Table NIC data.
+		This can this can the IP address, MAC, and gateway of the NIC.
arch/x86/kernel/setup_32.c +3 -0
index d1d8c34..9bd9482 100644
@@ -39,6 +39,7 @@
 #include <linux/efi.h>
 #include <linux/init.h>
 #include <linux/edd.h>
+#include <linux/iscsi_ibft.h>
 #include <linux/nodemask.h>
 #include <linux/kexec.h>
 #include <linux/crash_dump.h>
@@ -651,6 +652,8 @@ void __init setup_bootmem_allocator(void)
 #endif
 	numa_kva_reserve();
 	reserve_crashkernel();
+
+	reserve_ibft_region();
 }
 
 /*
arch/x86/kernel/setup_64.c +4 -0
index c0d8208..8efab8f 100644
@@ -33,6 +33,7 @@
 #include <linux/acpi.h>
 #include <linux/kallsyms.h>
 #include <linux/edd.h>
+#include <linux/iscsi_ibft.h>
 #include <linux/mmzone.h>
 #include <linux/kexec.h>
 #include <linux/cpufreq.h>
@@ -425,6 +426,9 @@ void __init setup_arch(char **cmdline_p)
 	}
 #endif
 	reserve_crashkernel();
+
+	reserve_ibft_region();
+
 	paging_init();
 	map_vsyscall();
 
drivers/firmware/Kconfig +20 -0
index 05f02a3..40ffd76 100644
@@ -93,4 +93,24 @@ config DMIID
 	  information from userspace through /sys/class/dmi/id/ or if you want
 	  DMI-based module auto-loading.
 
+config ISCSI_IBFT_FIND
+	bool "iSCSI Boot Firmware Table Attributes"
+	depends on X86
+	default n
+	help
+	  This option enables the kernel to find the region of memory
+	  in which the ISCSI Boot Firmware Table (iBFT) resides. This
+	  is necessary for iSCSI Boot Firmware Table Attributes module to work
+	  properly.
+
+config ISCSI_IBFT
+	tristate "iSCSI Boot Firmware Table Attributes module"
+	depends on ISCSI_IBFT_FIND
+	default	n
+	help
+	  This option enables support for detection and exposing of iSCSI
+	  Boot Firmware Table (iBFT) via sysfs to userspace. If you wish to
+	  detect iSCSI boot parameters dynamically during system boot, say Y.
+	  Otherwise, say N.
+
 endmenu
drivers/firmware/Makefile +2 -0
index 8d4ebc8..4c91471 100644
@@ -8,3 +8,5 @@ obj-$(CONFIG_EFI_PCDP)		+= pcdp.o
 obj-$(CONFIG_DELL_RBU)          += dell_rbu.o
 obj-$(CONFIG_DCDBAS)		+= dcdbas.o
 obj-$(CONFIG_DMIID)		+= dmi-id.o
+obj-$(CONFIG_ISCSI_IBFT_FIND)	+= iscsi_ibft_find.o
+obj-$(CONFIG_ISCSI_IBFT)	+= iscsi_ibft.o
drivers/firmware/iscsi_ibft.c new file +985 -0

985 lines not on this page · raw message

drivers/firmware/iscsi_ibft_find.c new file +82 -0

82 lines not on this page · raw message

include/linux/iscsi_ibft.h new file +38 -0
new file mode 100644
index 0000000..d58857d
@@ -0,0 +1,38 @@
+/*
+ *  Copyright 2007 Red Hat, Inc.
+ *  by Peter Jones <[email protected]>
+ *  Copyright 2007 IBM, Inc.
+ *  by Konrad Rzeszutek <[email protected]>
+ *
+ * This code exposes the iSCSI Boot Format Table to userland via sysfs.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License v2.0 as published by
+ * the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef ISCSI_IBFT_H
+#define ISCSI_IBFT_H
+
+/*
+ * Physical location of iSCSI Boot Format Table.
+ * If the value is NULL there is no iBFT on the machine.
+ */
+extern unsigned long ibft_addr;
+
+/*
+ * Routine used to find and reserve the iSCSI Boot Format Table. The
+ * mapped address is set in the ibft_addr variable.
+ */
+#ifdef CONFIG_ISCSI_IBFT_FIND
+extern void __init reserve_ibft_region(void);
+#else
+static inline void reserve_ibft_region(void) { }
+#endif
+
+#endif /* ISCSI_IBFT_H */
#2 lore raw

Re: REPOST: [PATCH] Add iSCSI iBFT support (v0.4.7)

Quoted 2 lines · Konrad Rzeszutek

+/*
+ * Physical location of iSCSI Boot Format Table.

This is now the Virtual address, isn't it? So just drop the Physical.

drivers/firmware/iscsi_ibft_find.c line 39

Quoted 3 lines

+ */

drivers/firmware/iscsi_ibft_find.c new file +2 -0
+unsigned long ibft_addr;
+EXPORT_SYMBOL(ibft_addr);

And since it is the virtual address, there's no point in keeping it unsigned long and doing all the casting. It should be struct ibft_table_hdr *, shouldn't it?

James

#3 lore raw

Re: REPOST: [PATCH] Add iSCSI iBFT support (v0.4.7)

In reply to Konrad Rzeszutek

drivers/firmware/iscsi_ibft.c line 572

Quoted 5 lines · Konrad Rzeszutek
drivers/firmware/iscsi_ibft.c new file +5 -0
+       ibft_device = kmalloc(len, GFP_KERNEL);
+       if (!ibft_device)
+               return -ENOMEM;
+
+       memcpy(ibft_device, hdr, len);

This piece looks a bit odd. you're making ibft_device an exact duplicate of ibft_addr (which is reserved in bootmem and lives as long as the kernel does). I can't seem to find anywhere you actually modify ibft_device, so why not just use the original ibft_addr here instead of making a copy?

James

#4 lore raw

Re: REPOST: [PATCH] Add iSCSI iBFT support (v0.4.7)

In reply to Konrad Rzeszutek

drivers/firmware/iscsi_ibft.c line 653

Quoted 8 lines · Konrad Rzeszutek
drivers/firmware/iscsi_ibft.c new file +8 -0
+       if (hdr->id == id_nic) {
+               pci_dev = pci_get_bus_and_slot((nic->pci_bdf & 0xff00) >> 8,
+                                              (nic->pci_bdf & 0xff));
+               if (pci_dev) {
+                       rc = sysfs_create_link(&ibft_kobj->kobj,
+                                              &pci_dev->dev.kobj, "device");
+                       pci_dev_put(pci_dev);
+               }

pci_get_bus_and_slot fails in the presence of PCI domains, which are getting to be fairly common even in medium sized servers ... what happens in that case?

James

#5 lore raw

Re: REPOST: [PATCH] Add iSCSI iBFT support (v0.4.7)

Quoted 6 lines
Quoted 3 lines
(quoted diff) +2 -0
+       if (hdr->id == id_nic) {
+               pci_dev = pci_get_bus_and_slot((nic->pci_bdf & 0xff00) >>

8, + (nic->pci_bdf & 0xff));

pci_get_bus_and_slot fails in the presence of PCI domains, which are getting to be fairly common even in medium sized servers ... what happens in that case?

The specification did not take that in to account. The Bus/Dev/Func information is only present there - no domain information.

Do you think I should implement a search functionality for this so that is searches through the domains for the bus/dev/func and picks the first found match (which might be the wrong match)? Or wait to get the spec updated so that the iBFT will have this data?

#6 lore raw

Re: REPOST: [PATCH] Add iSCSI iBFT support (v0.4.7)

Quoted 9 lines · Konrad Rzeszutek
Quoted 6 lines
Quoted 3 lines
(quoted diff) +2 -0
+       if (hdr->id == id_nic) {
+               pci_dev = pci_get_bus_and_slot((nic->pci_bdf & 0xff00) >>

8, + (nic->pci_bdf & 0xff));

pci_get_bus_and_slot fails in the presence of PCI domains, which are getting to be fairly common even in medium sized servers ... what happens in that case?

The specification did not take that in to account. The Bus/Dev/Func information is only present there - no domain information.

That's really broken then. Common i386 boxes these days have multiple PCI domains, it's not all that uncommon at all.

And almost all big 64 bit boxes have them.

Quoted 3 lines

Do you think I should implement a search functionality for this so that is searches through the domains for the bus/dev/func and picks the first found match (which might be the wrong match)?

I'm guessing that bad things would happen if you picked the wrong pci device, right?

Quoted 1 line

Or wait to get the spec updated so that the iBFT will have this data?

I think the spec needs to be fixed. Or at least clarified (is it domain 0 only?)

thanks,

greg k-h

#7 lore raw

Re: REPOST: [PATCH] Add iSCSI iBFT support (v0.4.7)

Quoted 7 lines · Greg KH
Quoted 6 lines · Konrad Rzeszutek
Quoted 6 lines
Quoted 3 lines
(quoted diff) +2 -0
+       if (hdr->id == id_nic) {
+               pci_dev = pci_get_bus_and_slot((nic->pci_bdf & 0xff00) >>

8, + (nic->pci_bdf & 0xff));

pci_get_bus_and_slot fails in the presence of PCI domains, which are getting to be fairly common even in medium sized servers ... what happens in that case?

Quoted 6 lines
Quoted 1 line

The specification did not take that in to account. The Bus/Dev/Func information is only present there - no domain information.

That's really broken then. Common i386 boxes these days have multiple PCI domains, it's not all that uncommon at all.

And almost all big 64 bit boxes have them.

Yes, but common x86 boxes can't *boot* from anything but domain 0 (in particular, the domain which the cf8/cfc registers on the boot processor activate.)

-hpa