#include <linux/blkdev.h>
#include <linux/capability.h>
#include <linux/ctype.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/iscsi_ibft.h>
#include <linux/limits.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/acpi.h>
#include <linux/iscsi_boot_sysfs.h>
#define IBFT_ISCSI_VERSION …
#define IBFT_ISCSI_DATE …
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_VERSION(…);
static struct acpi_table_ibft *ibft_addr;
struct ibft_hdr { … } __attribute__((packed));
struct ibft_control { … } __attribute__((packed));
struct ibft_initiator { … } __attribute__((packed));
struct ibft_nic { … } __attribute__((packed));
struct ibft_tgt { … } __attribute__((packed));
enum ibft_id { … };
struct ibft_kobject { … };
static struct iscsi_boot_kset *boot_kset;
static const char nulls[16];
static const char mapped_nulls[16] = …;
static int address_not_null(u8 *ip)
{ … }
static ssize_t sprintf_ipaddr(char *buf, u8 *ip)
{ … }
static ssize_t sprintf_string(char *str, int len, char *buf)
{ … }
static int ibft_verify_hdr(char *t, struct ibft_hdr *hdr, int id, int length)
{ … }
static ssize_t ibft_attr_show_initiator(void *data, int type, char *buf)
{ … }
static ssize_t ibft_attr_show_nic(void *data, int type, char *buf)
{
struct ibft_kobject *entry = data;
struct ibft_nic *nic = entry->nic;
void *ibft_loc = entry->header;
char *str = buf;
__be32 val;
if (!nic)
return 0;
switch (type) {
case ISCSI_BOOT_ETH_INDEX:
str += sprintf(str, "%d\n", nic->hdr.index);
break;
case ISCSI_BOOT_ETH_FLAGS:
str += sprintf(str, "%d\n", nic->hdr.flags);
break;
case ISCSI_BOOT_ETH_IP_ADDR:
str += sprintf_ipaddr(str, nic->ip_addr);
break;
case ISCSI_BOOT_ETH_SUBNET_MASK:
val = cpu_to_be32(~((1 << (32-nic->subnet_mask_prefix))-1));
str += sprintf(str, "%pI4", &val);
break;
case ISCSI_BOOT_ETH_PREFIX_LEN:
str += sprintf(str, "%d\n", nic->subnet_mask_prefix);
break;
case ISCSI_BOOT_ETH_ORIGIN:
str += sprintf(str, "%d\n", nic->origin);
break;
case ISCSI_BOOT_ETH_GATEWAY:
str += sprintf_ipaddr(str, nic->gateway);
break;
case ISCSI_BOOT_ETH_PRIMARY_DNS:
str += sprintf_ipaddr(str, nic->primary_dns);
break;
case ISCSI_BOOT_ETH_SECONDARY_DNS:
str += sprintf_ipaddr(str, nic->secondary_dns);
break;
case ISCSI_BOOT_ETH_DHCP:
str += sprintf_ipaddr(str, nic->dhcp);
break;
case ISCSI_BOOT_ETH_VLAN:
str += sprintf(str, "%d\n", nic->vlan);
break;
case ISCSI_BOOT_ETH_MAC:
str += sprintf(str, "%pM\n", nic->mac);
break;
case ISCSI_BOOT_ETH_HOSTNAME:
str += sprintf_string(str, nic->hostname_len,
(char *)ibft_loc + nic->hostname_off);
break;
default:
break;
}
return str - buf;
};
static ssize_t ibft_attr_show_target(void *data, int type, char *buf)
{ … }
static ssize_t ibft_attr_show_acpitbl(void *data, int type, char *buf)
{ … }
static int __init ibft_check_device(void)
{ … }
static umode_t ibft_check_nic_for(void *data, int type)
{ … }
static umode_t __init ibft_check_tgt_for(void *data, int type)
{ … }
static umode_t __init ibft_check_initiator_for(void *data, int type)
{ … }
static umode_t __init ibft_check_acpitbl_for(void *data, int type)
{ … }
static void ibft_kobj_release(void *data)
{ … }
static int __init ibft_create_kobject(struct acpi_table_ibft *header,
struct ibft_hdr *hdr)
{ … }
static int __init ibft_register_kobjects(struct acpi_table_ibft *header)
{ … }
static void ibft_unregister(void)
{ … }
static void ibft_cleanup(void)
{ … }
static void __exit ibft_exit(void)
{ … }
#ifdef CONFIG_ACPI
static const struct { … } ibft_signs[] = …;
static void __init acpi_find_ibft_region(void)
{ … }
#else
static void __init acpi_find_ibft_region(void)
{
}
#endif
#ifdef CONFIG_ISCSI_IBFT_FIND
static int __init acpi_find_isa_region(void)
{ … }
#else
static int __init acpi_find_isa_region(void)
{
return -ENODEV;
}
#endif
static int __init ibft_init(void)
{ … }
module_init(…) …;
module_exit(ibft_exit);