71 #include <linux/capability.h>
72 #include <linux/ctype.h>
73 #include <linux/device.h>
78 #include <linux/module.h>
79 #include <linux/pci.h>
80 #include <linux/slab.h>
81 #include <linux/stat.h>
82 #include <linux/string.h>
83 #include <linux/types.h>
87 #define IBFT_ISCSI_VERSION "0.5.0"
88 #define IBFT_ISCSI_DATE "2010-Feb-25"
189 static const char nulls[16];
198 if (ip[0] == 0 && ip[1] == 0 && ip[2] == 0 && ip[3] == 0 &&
199 ip[4] == 0 && ip[5] == 0 && ip[6] == 0 && ip[7] == 0 &&
200 ip[8] == 0 && ip[9] == 0 && ip[10] == 0xff && ip[11] == 0xff) {
204 str +=
sprintf(buf,
"%pI4", ip + 12);
209 str +=
sprintf(str,
"%pI6", ip);
217 return sprintf(str,
"%.*s\n", len, buf);
227 "field header.id to have %d but " \
228 "found %d instead!\n", t,
id, hdr->
id);
231 if (hdr->
length != length) {
233 "field header.length to have %d but " \
234 "found %d instead!\n", t, length, hdr->
length);
248 void *ibft_loc = entry->
header;
256 str +=
sprintf(str,
"%d\n", initiator->
hdr.index);
259 str +=
sprintf(str,
"%d\n", initiator->
hdr.flags);
262 str += sprintf_ipaddr(str, initiator->
isns_server);
265 str += sprintf_ipaddr(str, initiator->
slp_server);
285 static ssize_t ibft_attr_show_nic(
void *data,
int type,
char *buf)
289 void *ibft_loc = entry->
header;
304 str += sprintf_ipaddr(str, nic->
ip_addr);
308 str +=
sprintf(str,
"%pI4", &val);
314 str += sprintf_ipaddr(str, nic->
gateway);
323 str += sprintf_ipaddr(str, nic->
dhcp);
342 static ssize_t ibft_attr_show_target(
void *data,
int type,
char *buf)
346 void *ibft_loc = entry->
header;
361 str += sprintf_ipaddr(str, tgt->
ip_addr);
367 for (i = 0; i < 8; i++)
406 static int __init ibft_check_device(
void)
417 "while this is %d.\n",
436 static umode_t ibft_check_nic_for(
void *data,
int type)
491 static umode_t __init ibft_check_tgt_for(
void *data,
int type)
527 static umode_t __init ibft_check_initiator_for(
void *data,
int type)
569 static void ibft_kobj_release(
void *data)
586 ibft_kobj = kzalloc(
sizeof(*ibft_kobj),
GFP_KERNEL);
590 ibft_kobj->
header = header;
602 ibft_attr_show_initiator,
603 ibft_check_initiator_for,
611 rc = ibft_verify_hdr(
"ethernet", hdr,
id_nic,
612 sizeof(*ibft_kobj->
nic));
627 rc = ibft_verify_hdr(
"target", hdr,
id_target,
628 sizeof(*ibft_kobj->
tgt));
634 ibft_attr_show_target,
650 "Report this bug to %.6s!\n", hdr->
id,
673 &pci_dev->
dev.kobj,
"device");
697 control = (
void *)header +
sizeof(*header);
698 end = (
void *)control + control->
hdr.length;
699 eot_offset = (
void *)header + header->
header.length - (
void *)control;
704 rc |= ((control->
hdr.index) ? -
ENODEV : 0);
710 offset = *(
u16 *)ptr;
712 offset < eot_offset) {
713 rc = ibft_create_kobject(header,
714 (
void *)header + offset);
723 static void ibft_unregister(
void)
730 ibft_kobj = boot_kobj->
data;
736 static void ibft_cleanup(
void)
744 static void __exit ibft_exit(
void)
750 static const struct {
761 static void __init acpi_find_ibft_region(
void)
775 static void __init acpi_find_ibft_region(
void)
783 static int __init ibft_init(
void)
793 acpi_find_ibft_region();
798 rc = ibft_check_device();