Skip to contentSkip to conversation

Add iSCSI iBFT support (v0.4.5)

PATCH In review Konrad Rzeszutek 9 participants 13 messages Jan 25, 2008 – Jan 30, 2008

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

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

Hey Andrew,

Please add this patch along with Greg KH's kobject fixes. This module is dependent on the fixes that Greg KH has in his patches git tree.

This patch (v0.4.5) 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.

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

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 +17 -0
index 9c24b45..8127cad 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>
@@ -148,6 +149,20 @@ static inline void copy_edd(void)
 }
 #endif
 
+#if defined(CONFIG_ISCSI_IBFT_FIND)
+static void __init reserve_ibft_region(void)
+{
+	unsigned int ibft_len;
+
+	ibft_len = find_ibft();
+	if (ibft_len)
+		reserve_bootmem((unsigned int)ibft_phys,
+				PAGE_ALIGN(ibft_len));
+}
+#else
+static void __init reserve_ibft_region(void) { }
+#endif
+
 int __initdata user_defined_memmap = 0;
 
 /*
@@ -496,6 +511,8 @@ void __init setup_bootmem_allocator(void)
 	}
 #endif
 	reserve_crashkernel();
+
+	reserve_ibft_region();
 }
 
 /*
arch/x86/kernel/setup_64.c +18 -0
index 30d94d1..307fb99 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>
@@ -198,6 +199,20 @@ static inline void copy_edd(void)
 }
 #endif
 
+#if defined(CONFIG_ISCSI_IBFT_FIND)
+static void __init reserve_ibft_region(void)
+{
+	unsigned int ibft_len;
+
+	ibft_len = find_ibft();
+	if (ibft_len)
+		reserve_bootmem_generic((unsigned long)ibft_phys,
+					PAGE_ALIGN(ibft_len));
+}
+#else
+static void __init reserve_ibft_region(void) { }
+#endif
+
 #ifdef CONFIG_KEXEC
 static void __init reserve_crashkernel(void)
 {
@@ -403,6 +418,9 @@ void __init setup_arch(char **cmdline_p)
 	}
 #endif
 	reserve_crashkernel();
+
+	reserve_ibft_region();
+
 	paging_init();
 
 #ifdef CONFIG_PCI
drivers/firmware/Kconfig +19 -0
index 05f02a3..e2f7208 100644
@@ -93,4 +93,23 @@ 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"
+	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 +972 -0

972 lines not on this page · raw message

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

77 lines not on this page · raw message

include/linux/iscsi_ibft.h new file +38 -0
new file mode 100644
index 0000000..d36ca16
@@ -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
+
+#if defined(CONFIG_ISCSI_IBFT_FIND)
+
+/*
+ * Physical location of iSCSI Boot Format Table.
+ */
+extern void *ibft_phys;
+
+/*
+ * Routine used to find the iSCSI Boot Format Table. The physical
+ * location is set in the ibft_phys variable. The return value is the
+ * size of IBFT.
+ */
+extern ssize_t find_ibft(void);
+
+#endif
+
+#endif /* ISCSI_IBFT_H */
#1 lore raw

Please always include a diffstat with non-trivial patches.

arch/x86/kernel/setup_32.c

Quoted 3 lines · On Fri, 25 Jan 2008 18:06:29 -0400 Konrad Rzeszutek <[email protected]> wrote:
arch/x86/kernel/setup_32.c +0 -0

lol. You touched x86 code.

<goes off to fix the inevitable rejects>

#2 lore raw
In reply to Konrad Rzeszutek
Quoted 4 lines · On Fri, 25 Jan 2008 18:06:29 -0400 Konrad Rzeszutek <[email protected]> wrote:

Hey Andrew,

Please add this patch along with Greg KH's kobject fixes.

erm, OK. But I don't think I'm the appropriate conduit for iscsi paches.

By what path _does_ iscsi ode get into the tree, anyway? Mike is listed as maintainer...

Oh well, at least I get to read some code.

Quoted 7 lines

This module
is dependent on the fixes that Greg KH has in his patches git tree.

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

Quoted 7 lines

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.

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

When adding new sysfs things (especially things as complex as this) please fully describe the user-visible interface in the changelog so that we can review your interface design.

Does this code follow the one-value-per-sysfs-file convention?

arch/x86/kernel/setup_32.c static inline void copy_edd(void) · line 164

Quoted 13 lines
arch/x86/kernel/setup_32.c +13 -0
+#if defined(CONFIG_ISCSI_IBFT_FIND)
+static void __init reserve_ibft_region(void)
+{
+	unsigned int ibft_len;
+
+	ibft_len = find_ibft();
+	if (ibft_len)
+		reserve_bootmem((unsigned int)ibft_phys,
+				PAGE_ALIGN(ibft_len));
+}
+#else
+static void __init reserve_ibft_region(void) { }
+#endif

Usually we'd make the CONFIG_ISCSI_IBFT_FIND=n version of this function static inline in a header. As it stands this code will add a pointless empty function to the vmlinux image.

Quoted 1 line

int __initdata user_defined_memmap = 0;

checkpatch should have told you that this "= 0" shouldn't be there. But it doesn't.

drivers/firmware/iscsi_ibft.c line 265

Quoted 9 lines
drivers/firmware/iscsi_ibft.c new file +9 -0
+	struct kobject *kobj;
+	int type; /* The enum of the type. This can be any value off:
+		ibft_eth_properties_enum, ibft_tgt_properties_enum,
+		or ibft_initiator_properties_enum. */
+	struct list_head node;
+};
+
+static LIST_HEAD(ibft_attr_list);
+static LIST_HEAD(ibft_kobject_list);

A brief search for the locking which protects these lists was unsuccessful. What's up?

Quoted 6 lines
drivers/firmware/iscsi_ibft.c new file +6 -0
+/*
+ * Helper functions to parse data properly.
+ */
+static ssize_t sprintf_ipaddr(char *buf, u8 *ip)
+{
+	if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0 &&

drivers/firmware/iscsi_ibft.c line 285

Quoted 10 lines
drivers/firmware/iscsi_ibft.c new file +10 -0
+	    ip[4] == 0 && ip[5] == 0 && ip[6] == 0 && ip[7] == 0 &&
+	    ip[8] == 0 && ip[9] == 0 && ip[10] == 0xff && ip[11] == 0xff) {
+		/*
+		 * IPV4
+		 */
+		return sprintf(buf, "%d.%d.%d.%d\n", ip[12],
+			       ip[13], ip[14], ip[15]);
+	} else
+		return 0;
+}

I'm seeing an awful lot of sprintf()s in here which look like they should be snprintf(). By what means is this code bulletproof against overflows?

Quoted 12 lines
drivers/firmware/iscsi_ibft.c new file +12 -0
+static ssize_t sprintf_string(char *str, int len, char *buf)
+{
+	return sprintf(str, "%.*s\n", len, buf);
+}
+
+/*
+ * Helper function to verify the IBFT header.
+ */
+static int ibft_verify_hdr(char *t, struct ibft_hdr *hdr, int id, int length)
+{
+#define IBFT_VERIFY_HDR_FIELD(val, name) \
+	if (hdr->val != val) { \

drivers/firmware/iscsi_ibft.c line 308

Quoted 10 lines
drivers/firmware/iscsi_ibft.c new file +10 -0
+		printk(KERN_ERR \
+		       "iBFT error: In structure %s field %s expected %d but" \
+		       " found %d!\n", \
+		       t, name, val, hdr->val); \
+		return -ENODEV; \
+	}
+	IBFT_VERIFY_HDR_FIELD(id, "id");
+	IBFT_VERIFY_HDR_FIELD(length, "length");
+	return 0;
+}

I'm not sure that two usages really justifies IBFT_VERIFY_HDR_FIELD's existence. If you're really attched to it then I'd suggest that it be undefed immediately after having been read, for readability reasons.

drivers/firmware/iscsi_ibft.c

Quoted 11 lines
drivers/firmware/iscsi_ibft.c new file +7 -0
+static void ibft_release(struct kobject *kobj)
+{
+	struct ibft_kobject *ibft =
+		container_of(kobj, struct ibft_kobject, kobj);
+	kfree(ibft);
+}
 
...
 
+	for (pos = (u8 *)hdr; pos < (u8 *)hdr + len; pos ++)

checkpatch should have caught the " ++" but didn't. I think it used to. It seems to be going backwards?

Quoted 12 lines
drivers/firmware/iscsi_ibft.c new file +12 -0
+		csum += *pos;
+
+	if (csum) {
+		printk(KERN_ERR "iBFT has incorrect checksum (0x%x)!\n", csum);
+		return 1;
+	}
+
+	ibft_device = kmalloc(len, GFP_KERNEL);
+	if (!ibft_device)
+		return -ENOMEM;
+
+	memcpy(ibft_device, hdr, len);

drivers/firmware/iscsi_ibft.c line 618

Quoted 10 lines
drivers/firmware/iscsi_ibft.c new file +7 -0
+
+	return 0;
+}
+
 
...
 
+
+	/* kobject fief. We will let the reference counter do the job
+	 of deleting its name if we fail here. */

what's a fief?

Quoted 35 lines
drivers/firmware/iscsi_ibft_find.c new file +35 -0
+/*
+ * Physical location of iSCSI Boot Format Table.
+ */
+void *ibft_phys;
+EXPORT_SYMBOL(ibft_phys);
+
+#define IBFT_SIGN "iBFT"
+#define IBFT_SIGN_LEN 4
+#define IBFT_START 0x80000 /* 512kB */
+#define IBFT_END 0x100000 /* 1MB */
+#define VGA_MEM 0xA0000 /* VGA buffer */
+#define VGA_SIZE 0x20000 /* 128kB */
+
+
+/*
+ * Routine used to find the iSCSI Boot Format Table. the physical
+ * location is set in the ibft_phys variable. The return value is
+ * the size of IBFT.
+ */
+ssize_t find_ibft(void)
+{
+	unsigned long pos;
+
+	for (pos = IBFT_START; pos < IBFT_END; pos += 16) {
+		void *virt;
+		/* The table can't be inside the VGA BIOS reserved space,
+		 * so skip that area */
+		if (pos == VGA_MEM)
+			pos += VGA_SIZE;
+		virt = phys_to_virt(pos);
+		if (memcmp(virt, IBFT_SIGN, IBFT_SIGN_LEN) == 0) {
+			unsigned long *addr =
+			    (unsigned long *)phys_to_virt(pos + 4);
+			unsigned int len = *addr;
+			/* if the length of the table extends past 1M,

drivers/firmware/iscsi_ibft_find.c line 77

Quoted 10 lines
drivers/firmware/iscsi_ibft_find.c new file +10 -0
+			 * the table cannot be valid. */
+			if (pos + len <= (IBFT_END-1)) {
+				ibft_phys = (void *)pos;
+				return len;
+			}
+		}
+	}
+	return 0;
+}
+EXPORT_SYMBOL(find_ibft);

Is this x86-specific? Are suitable Kconfig dependencies in place?

Quoted 16 lines
+ *  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.
+ */

include/linux/iscsi_ibft.h line 22

Quoted 5 lines
include/linux/iscsi_ibft.h new file +5 -0
+
+#ifndef ISCSI_IBFT_H
+#define ISCSI_IBFT_H
+
+#if defined(CONFIG_ISCSI_IBFT_FIND)

We'd more usually use #ifdef here. Whatever.

include/linux/iscsi_ibft.h line 36

Quoted 13 lines
include/linux/iscsi_ibft.h new file +13 -0
+/*
+ * Physical location of iSCSI Boot Format Table.
+ */
+extern void *ibft_phys;
+
+/*
+ * Routine used to find the iSCSI Boot Format Table. The physical
+ * location is set in the ibft_phys variable. The return value is the
+ * size of IBFT.
+ */
+extern ssize_t find_ibft(void);
+
+#endif

Often we don't bother putting declarations like this inside the ifdef.
Upside: cleaner code. Downside: error-detection happens at link-time rather tha compile-time.

#3 lore raw
Quoted 4 lines · Andrew Morton
Quoted 1 line

int __initdata user_defined_memmap = 0;

checkpatch should have told you that this "= 0" shouldn't be there. But it doesn't.

checkpatch checks for static initializers, not non-static ones. Should that be changed?

Quoted 4 lines

drivers/firmware/iscsi_ibft.c line 545

Quoted 2 lines
drivers/firmware/iscsi_ibft.c new file +1 -0
+	for (pos = (u8 *)hdr; pos < (u8 *)hdr + len; pos ++)

checkpatch should have caught the " ++" but didn't. I think it used to. It seems to be going backwards?

Signature · 1 line
~Randy
#4 lore raw
In reply to Andrew Morton
Quoted 4 lines · Andrew Morton
Quoted 1 line

int __initdata user_defined_memmap = 0;

checkpatch should have told you that this "= 0" shouldn't be there. But it doesn't.

Ok, this line would be correctly picked up if it was being added by this author, but this line is in the context only. We do not blame the current author for those.

ERROR: do not initialise externals to 0 or NULL
#1: FILE: Z57.c:1:
+int __initdata user_defined_memmap = 0;

Quoted 4 lines

drivers/firmware/iscsi_ibft.c line 545

Quoted 1 line
drivers/firmware/iscsi_ibft.c new file +1 -0
+	for (pos = (u8 *)hdr; pos < (u8 *)hdr + len; pos ++)

checkpatch should have caught the " ++" but didn't. I think it used to. It seems to be going backwards?

Somehow this variant was not covered. Added to the tests and to the next version:

ERROR: no space before that '++' (ctx:WxB)
#3: FILE: Z57.c:3:
+ for (pos = (u8 *)hdr; pos < (u8 *)hdr + len; pos ++)

-apw

#5 lore raw
In reply to Andrew Morton
Quoted 9 lines · On Sunday 27 January 2008 01:01:23 you wrote:
Quoted 4 lines

On Fri, 25 Jan 2008 18:06:29 -0400 Konrad Rzeszutek <[email protected]>
wrote: Hey Andrew,

Please add this patch along with Greg KH's kobject fixes.

erm, OK. But I don't think I'm the appropriate conduit for iscsi paches.

By what path _does_ iscsi ode get into the tree, anyway? Mike is listed as maintainer...

This is a bit tricky b/c this goes to the drivers/firmware and also depends on the kobject changes in Greg KH tree. But I should have included Mike on the CC which I keep on forgetting <sigh>.

Quoted 4 lines

When adding new sysfs things (especially things as complex as this) please fully describe the user-visible interface in the changelog so that we can review your interface design.

Done. This repost:
http://lkml.org/lkml/2008/1/28/304

has the details.

Quoted 2 lines

Does this code follow the one-value-per-sysfs-file convention?

Yes.

Quoted 10 lines
Quoted 10 lines
arch/x86/kernel/setup_32.c +9 -0
+#if defined(CONFIG_ISCSI_IBFT_FIND)
+static void __init reserve_ibft_region(void)
+{
+	unsigned int ibft_len;
+
+	ibft_len = find_ibft();
+	if (ibft_len)
+		reserve_bootmem((unsigned int)ibft_phys,
+				PAGE_ALIGN(ibft_len));
Quoted 8 lines

arch/x86/kernel/setup_32.c static inline void copy_edd(void) · line 164

Quoted 4 lines
arch/x86/kernel/setup_32.c +4 -0
+}
+#else
+static void __init reserve_ibft_region(void) { }
+#endif

Usually we'd make the CONFIG_ISCSI_IBFT_FIND=n version of this function static inline in a header. As it stands this code will add a pointless empty function to the vmlinux image.

Fixed. The function now is in include/linux/iscsi_ibft.h

Quoted 5 lines
Quoted 2 lines

int __initdata user_defined_memmap = 0;

checkpatch should have told you that this "= 0" shouldn't be there. But it doesn't.

Uhh, I didn't add that.

Quoted 13 lines

drivers/firmware/iscsi_ibft.c line 265

Quoted 10 lines
drivers/firmware/iscsi_ibft.c new file +9 -0
+	struct kobject *kobj;
+	int type; /* The enum of the type. This can be any value off:
+		ibft_eth_properties_enum, ibft_tgt_properties_enum,
+		or ibft_initiator_properties_enum. */
+	struct list_head node;
+};
+
+static LIST_HEAD(ibft_attr_list);
+static LIST_HEAD(ibft_kobject_list);

A brief search for the locking which protects these lists was unsuccessful. What's up?

The data structure does not change when the machine has booted up. The iBFT is a read-only structure and there are no known mechanism to write to it via the iBFT structure (or even BIOS up-calls). You have to use custom-vendor applications to flash the BIOS with the new iBFT structure. Hence no need for locking at this stage - when the specs becomes more advance I will add them if they are required.

Quoted 12 lines
Quoted 12 lines
drivers/firmware/iscsi_ibft.c new file +11 -0
+/*
+ * Helper functions to parse data properly.
+ */
+static ssize_t sprintf_ipaddr(char *buf, u8 *ip)
+{
+	if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0 &&
+	    ip[4] == 0 && ip[5] == 0 && ip[6] == 0 && ip[7] == 0 &&
+	    ip[8] == 0 && ip[9] == 0 && ip[10] == 0xff && ip[11] == 0xff) {
+		/*
+		 * IPV4
+		 */
Quoted 8 lines

drivers/firmware/iscsi_ibft.c line 285

Quoted 5 lines
drivers/firmware/iscsi_ibft.c new file +5 -0
+		return sprintf(buf, "%d.%d.%d.%d\n", ip[12],
+			       ip[13], ip[14], ip[15]);
+	} else
+		return 0;
+}

I'm seeing an awful lot of sprintf()s in here which look like they should be snprintf(). By what means is this code bulletproof against overflows?

There is no reading of data from the user-land. All of it is just outputing to the /sysfs entries from reading the data in the iBFT structure which the BIOS created.

Quoted 19 lines
Quoted 19 lines
drivers/firmware/iscsi_ibft.c new file +9 -0
+static ssize_t sprintf_string(char *str, int len, char *buf)
+{
+	return sprintf(str, "%.*s\n", len, buf);
+}
+
+/*
+ * Helper function to verify the IBFT header.
+ */
+static int ibft_verify_hdr(char *t, struct ibft_hdr *hdr, int id, int

length) +{

drivers/firmware/iscsi_ibft.c new file +8 -0
+#define IBFT_VERIFY_HDR_FIELD(val, name) \
+	if (hdr->val != val) { \
+		printk(KERN_ERR \
+		       "iBFT error: In structure %s field %s expected %d but" \
+		       " found %d!\n", \
+		       t, name, val, hdr->val); \
+		return -ENODEV; \
+	}
Quoted 8 lines

drivers/firmware/iscsi_ibft.c line 308

Quoted 4 lines
drivers/firmware/iscsi_ibft.c new file +4 -0
+	IBFT_VERIFY_HDR_FIELD(id, "id");
+	IBFT_VERIFY_HDR_FIELD(length, "length");
+	return 0;
+}

I'm not sure that two usages really justifies IBFT_VERIFY_HDR_FIELD's existence. If you're really attched to it then I'd suggest that it be undefed immediately after having been read, for readability reasons.

Done. Took out the #define.

Quoted 8 lines
Quoted 8 lines
drivers/firmware/iscsi_ibft.c new file +6 -0
+static void ibft_release(struct kobject *kobj)
+{
+	struct ibft_kobject *ibft =
+		container_of(kobj, struct ibft_kobject, kobj);
+	kfree(ibft);
+}
Quoted 6 lines

drivers/firmware/iscsi_ibft.c line 545

Quoted 3 lines

...

drivers/firmware/iscsi_ibft.c new file +1 -0
+	for (pos = (u8 *)hdr; pos < (u8 *)hdr + len; pos ++)

checkpatch should have caught the " ++" but didn't. I think it used to. It seems to be going backwards?

Fixed.

Quoted 7 lines

drivers/firmware/iscsi_ibft.c line 618

Quoted 5 lines

...

drivers/firmware/iscsi_ibft.c new file +3 -0
+
+	/* kobject fief. We will let the reference counter do the job
+	 of deleting its name if we fail here. */

what's a fief?

FIEF, or FEUD. In its origin, a fief was a district of country allotted to one of the chiefs who invaded the Roman empire, as a stipend or reward.

Quoted 40 lines
Quoted 40 lines
drivers/firmware/iscsi_ibft_find.c new file +39 -0
+/*
+ * Physical location of iSCSI Boot Format Table.
+ */
+void *ibft_phys;
+EXPORT_SYMBOL(ibft_phys);
+
+#define IBFT_SIGN "iBFT"
+#define IBFT_SIGN_LEN 4
+#define IBFT_START 0x80000 /* 512kB */
+#define IBFT_END 0x100000 /* 1MB */
+#define VGA_MEM 0xA0000 /* VGA buffer */
+#define VGA_SIZE 0x20000 /* 128kB */
+
+
+/*
+ * Routine used to find the iSCSI Boot Format Table. the physical
+ * location is set in the ibft_phys variable. The return value is
+ * the size of IBFT.
+ */
+ssize_t find_ibft(void)
+{
+	unsigned long pos;
+
+	for (pos = IBFT_START; pos < IBFT_END; pos += 16) {
+		void *virt;
+		/* The table can't be inside the VGA BIOS reserved space,
+		 * so skip that area */
+		if (pos == VGA_MEM)
+			pos += VGA_SIZE;
+		virt = phys_to_virt(pos);
+		if (memcmp(virt, IBFT_SIGN, IBFT_SIGN_LEN) == 0) {
+			unsigned long *addr =
+			    (unsigned long *)phys_to_virt(pos + 4);
+			unsigned int len = *addr;
+			/* if the length of the table extends past 1M,
+			 * the table cannot be valid. */
+			if (pos + len <= (IBFT_END-1)) {
+				ibft_phys = (void *)pos;
+				return len;
Quoted 8 lines

drivers/firmware/iscsi_ibft_find.c line 77

Quoted 6 lines
drivers/firmware/iscsi_ibft_find.c new file +6 -0
+			}
+		}
+	}
+	return 0;
+}
+EXPORT_SYMBOL(find_ibft);

Is this x86-specific? Are suitable Kconfig dependencies in place?

Originally I had it to be x86-specific but was told that I should make it all platforms since the IBFT is platform independent. Somebody can very well insert a NIC with IBFT on a IA64 machine or PPC.

Quoted 5 lines

include/linux/iscsi_ibft.h line 22

Quoted 3 lines
include/linux/iscsi_ibft.h new file +3 -0
+#define ISCSI_IBFT_H
+
+#if defined(CONFIG_ISCSI_IBFT_FIND)

We'd more usually use #ifdef here. Whatever.

Fixed.

Quoted 10 lines
Quoted 10 lines
include/linux/iscsi_ibft.h new file +9 -0
+/*
+ * Physical location of iSCSI Boot Format Table.
+ */
+extern void *ibft_phys;
+
+/*
+ * Routine used to find the iSCSI Boot Format Table. The physical
+ * location is set in the ibft_phys variable. The return value is the
+ * size of IBFT.
Quoted 8 lines

include/linux/iscsi_ibft.h line 36

Quoted 4 lines

+ */

include/linux/iscsi_ibft.h new file +3 -0
+extern ssize_t find_ibft(void);
+
+#endif

Often we don't bother putting declarations like this inside the ifdef.
Upside: cleaner code. Downside: error-detection happens at link-time rather tha compile-time.

Ok. Fixed it.

#6 lore raw
Quoted 8 lines · Konrad Rzeszutek
Quoted 3 lines
Quoted 1 line

+EXPORT_SYMBOL(find_ibft);

Is this x86-specific? Are suitable Kconfig dependencies in place?

Originally I had it to be x86-specific but was told that I should make it all platforms since the IBFT is platform independent. Somebody can very well insert a NIC with IBFT on a IA64 machine or PPC.

I would beg to differ regarding the powerpc. On powerpc, the bios is invisible and ignored. We have our own "special" way, via the device-tree in procfs.

++doug

#7 lore raw
Quoted 9 lines · Doug Maxey
Quoted 3 lines · Konrad Rzeszutek
Quoted 2 lines
Quoted 1 line

+EXPORT_SYMBOL(find_ibft);

Is this x86-specific? Are suitable Kconfig dependencies in place?

Originally I had it to be x86-specific but was told that I should make it all platforms since the IBFT is platform independent. Somebody can very well insert a NIC with IBFT on a IA64 machine or PPC.

I would beg to differ regarding the powerpc. On powerpc, the bios is invisible and ignored. We have our own "special" way, via the device-tree in procfs.

iBFT is not platform-independent; it only makes sense on platforms with ACPI (and even then, just barely; ACPI is a poor fit for it and it was probably "integrated" with ACPI for political reasons.)

-hpa

#8 lore raw
Quoted 3 lines

iBFT is not platform-independent; it only makes sense on platforms with ACPI (and even then, just barely; ACPI is a poor fit for it and it was probably "integrated" with ACPI for political reasons.)

The spec just mentions that iBFT table has to be "compatible with an ACPI table format" and nothing else. In reality I've only tested this on x86_64 and i386. We can limit it to be X86 || IA64 but I wouldn't make it dependent on ACPI - as this data does not necessarily have to be exported via ACPI.

maintainer
#9 lore raw
Quoted 5 lines · Konrad Rzeszutek
Quoted 3 lines

iBFT is not platform-independent; it only makes sense on platforms with ACPI (and even then, just barely; ACPI is a poor fit for it and it was probably "integrated" with ACPI for political reasons.)

The spec just mentions that iBFT table has to be "compatible with an ACPI table format" and nothing else.

Well, that's not quite accurate. It also mentions that OEM IDs for vendors come from the ACPI SIG, and they also reserved the "IBFT" signature with the ACPI SIG (it's in ACPI 3.0). It's also pretty clear that the "Locating the iBFT" section in the spec used to be a list with more than one entry and has been edited down to one.

That being said, I don't think there's any reason to expect the table to show up on anything but i386 and x86_64, and maybe ia64.

Signature · 1 line
  Peter
#10 lore raw
Quoted 3 lines

That being said, I don't think there's any reason to expect the table to show up on anything but i386 and x86_64, and maybe ia64.

I've posted a new patch (http://lkml.org/lkml/2008/1/30/531) that includes that dependency in the Kconfig (i386, x86_64, ia64)

#11 lore raw
In reply to Konrad Rzeszutek
Quoted 4 lines · Konrad Rzeszutek
Quoted 3 lines · On Sunday 27 January 2008 01:01:23 you wrote:
Quoted 3 lines

On Fri, 25 Jan 2008 18:06:29 -0400 Konrad Rzeszutek <[email protected]>
wrote: Hey Andrew,

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Please add this patch along with Greg KH's kobject fixes.

erm, OK. But I don't think I'm the appropriate conduit for iscsi paches.

By what path _does_ iscsi ode get into the tree, anyway? Mike is listed as maintainer...

This is a bit tricky b/c this goes to the drivers/firmware and also depends on the kobject changes in Greg KH tree. But I should have included Mike on the CC which I keep on forgetting <sigh>.

It is probably better if it goes through Greg or Andrew. It will not conflict with any iscsi patches. It looks like it is heavier on kobject and sysfs and has some acpi digging magic, and almost no iscsi stuff in there.

#12 lore raw
Quoted 11 lines · Mike Christie
Quoted 10 lines · Konrad Rzeszutek
Quoted 9 lines · On Sunday 27 January 2008 01:01:23 you wrote:
Quoted 4 lines

On Fri, 25 Jan 2008 18:06:29 -0400 Konrad Rzeszutek <[email protected]>
wrote: Hey Andrew,

Please add this patch along with Greg KH's kobject fixes.

erm, OK. But I don't think I'm the appropriate conduit for iscsi paches.

By what path _does_ iscsi ode get into the tree, anyway? Mike is listed as
maintainer...

Quoted 7 lines
Quoted 3 lines

This is a bit tricky b/c this goes to the drivers/firmware and also depends on the kobject changes in Greg KH tree. But I should have included Mike on the CC which I keep on forgetting <sigh>.

It is probably better if it goes through Greg or Andrew. It will not conflict with any iscsi patches. It looks like it is heavier on kobject and sysfs and has some acpi digging magic, and almost no iscsi stuff in there.

It does not need to go through me as all of the kobject changes it depended on are now in Linus's tree.

thanks,

greg k-h