From 9a99425f0736a416442525ac7b15903173888b86 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Thu, 25 Feb 2016 09:56:04 -0800 Subject: iscsi_ibft: Add prefix-len attr and display netmask The iBFT table only specifies a prefix length, not a netmask. And the netmask is pretty much pointless for IPv6. So introduce a new attribute 'prefix-len'. Some older user-space code might rely on the netmask attribute being present, so we should always display it. Changes from v1: - Combined two patches into one Changes from v2: - Cleaned up/corrected wording for patch description Signed-off-by: Hannes Reinecke Signed-off-by: Lee Duncan Reviewed-by: Mike Christie Signed-off-by: Konrad Rzeszutek Wilk --- drivers/scsi/iscsi_boot_sysfs.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/scsi/iscsi_boot_sysfs.c') diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c index 680bf6f0ce76..8f0ea97cf31f 100644 --- a/drivers/scsi/iscsi_boot_sysfs.c +++ b/drivers/scsi/iscsi_boot_sysfs.c @@ -166,6 +166,7 @@ static struct attribute_group iscsi_boot_target_attr_group = { iscsi_boot_rd_attr(eth_index, index, ISCSI_BOOT_ETH_INDEX); iscsi_boot_rd_attr(eth_flags, flags, ISCSI_BOOT_ETH_FLAGS); iscsi_boot_rd_attr(eth_ip, ip-addr, ISCSI_BOOT_ETH_IP_ADDR); +iscsi_boot_rd_attr(eth_prefix, prefix-len, ISCSI_BOOT_ETH_PREFIX_LEN); iscsi_boot_rd_attr(eth_subnet, subnet-mask, ISCSI_BOOT_ETH_SUBNET_MASK); iscsi_boot_rd_attr(eth_origin, origin, ISCSI_BOOT_ETH_ORIGIN); iscsi_boot_rd_attr(eth_gateway, gateway, ISCSI_BOOT_ETH_GATEWAY); @@ -181,6 +182,7 @@ static struct attribute *ethernet_attrs[] = { &iscsi_boot_attr_eth_index.attr, &iscsi_boot_attr_eth_flags.attr, &iscsi_boot_attr_eth_ip.attr, + &iscsi_boot_attr_eth_prefix.attr, &iscsi_boot_attr_eth_subnet.attr, &iscsi_boot_attr_eth_origin.attr, &iscsi_boot_attr_eth_gateway.attr, @@ -208,6 +210,9 @@ static umode_t iscsi_boot_eth_attr_is_visible(struct kobject *kobj, else if (attr == &iscsi_boot_attr_eth_ip.attr) return boot_kobj->is_visible(boot_kobj->data, ISCSI_BOOT_ETH_IP_ADDR); + else if (attr == &iscsi_boot_attr_eth_prefix.attr) + return boot_kobj->is_visible(boot_kobj->data, + ISCSI_BOOT_ETH_PREFIX_LEN); else if (attr == &iscsi_boot_attr_eth_subnet.attr) return boot_kobj->is_visible(boot_kobj->data, ISCSI_BOOT_ETH_SUBNET_MASK); -- cgit v1.2.3 From b3c8eb50383178f3a4dcf1dc867001156da6473d Mon Sep 17 00:00:00 2001 From: David Bond Date: Wed, 23 Mar 2016 21:49:26 -0400 Subject: ibft: Expose iBFT acpi header via sysfs Some ethernet adapter vendors are supplying products which support optional (payed license) features. On some adapters this includes a hardware iscsi initiator. The same adapters in a normal (no extra licenses) mode of operation can be used as a software iscsi initiator. In addition, software iscsi boot initiators are becoming a standard part of many vendors uefi implementations. This is creating difficulties during early boot/install determining the proper configuration method for these adapters when they are used as a boot device. The attached patch creates sysfs entries to expose information from the acpi header of the ibft table. This information allows for a method to easily determining if an ibft table was created by a ethernet card's firmware or the system uefi/bios. In the case of a hardware initiator this information in combination with the pci vendor and device id can be used to ascertain any vendor specific behaviors that need to be accommodated. Reviewed-by: Lee Duncan Signed-off-by: David Bond Signed-off-by: Konrad Rzeszutek Wilk --- drivers/scsi/iscsi_boot_sysfs.c | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'drivers/scsi/iscsi_boot_sysfs.c') diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c index 8f0ea97cf31f..d453667612f8 100644 --- a/drivers/scsi/iscsi_boot_sysfs.c +++ b/drivers/scsi/iscsi_boot_sysfs.c @@ -306,6 +306,42 @@ static struct attribute_group iscsi_boot_initiator_attr_group = { .is_visible = iscsi_boot_ini_attr_is_visible, }; +/* iBFT ACPI Table attributes */ +iscsi_boot_rd_attr(acpitbl_signature, signature, ISCSI_BOOT_ACPITBL_SIGNATURE); +iscsi_boot_rd_attr(acpitbl_oem_id, oem_id, ISCSI_BOOT_ACPITBL_OEM_ID); +iscsi_boot_rd_attr(acpitbl_oem_table_id, oem_table_id, + ISCSI_BOOT_ACPITBL_OEM_TABLE_ID); + +static struct attribute *acpitbl_attrs[] = { + &iscsi_boot_attr_acpitbl_signature.attr, + &iscsi_boot_attr_acpitbl_oem_id.attr, + &iscsi_boot_attr_acpitbl_oem_table_id.attr, + NULL +}; + +static umode_t iscsi_boot_acpitbl_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int i) +{ + struct iscsi_boot_kobj *boot_kobj = + container_of(kobj, struct iscsi_boot_kobj, kobj); + + if (attr == &iscsi_boot_attr_acpitbl_signature.attr) + return boot_kobj->is_visible(boot_kobj->data, + ISCSI_BOOT_ACPITBL_SIGNATURE); + if (attr == &iscsi_boot_attr_acpitbl_oem_id.attr) + return boot_kobj->is_visible(boot_kobj->data, + ISCSI_BOOT_ACPITBL_OEM_ID); + if (attr == &iscsi_boot_attr_acpitbl_oem_table_id.attr) + return boot_kobj->is_visible(boot_kobj->data, + ISCSI_BOOT_ACPITBL_OEM_TABLE_ID); + return 0; +} + +static struct attribute_group iscsi_boot_acpitbl_attr_group = { + .attrs = acpitbl_attrs, + .is_visible = iscsi_boot_acpitbl_attr_is_visible, +}; + static struct iscsi_boot_kobj * iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset, struct attribute_group *attr_group, @@ -435,6 +471,32 @@ iscsi_boot_create_ethernet(struct iscsi_boot_kset *boot_kset, int index, } EXPORT_SYMBOL_GPL(iscsi_boot_create_ethernet); +/** + * iscsi_boot_create_acpitbl() - create boot acpi table sysfs dir + * @boot_kset: boot kset + * @index: not used + * @data: driver specific data + * @show: attr show function + * @is_visible: attr visibility function + * @release: release function + * + * Note: The boot sysfs lib will free the data passed in for the caller + * when all refs to the acpitbl kobject have been released. + */ +struct iscsi_boot_kobj * +iscsi_boot_create_acpitbl(struct iscsi_boot_kset *boot_kset, int index, + void *data, + ssize_t (*show)(void *data, int type, char *buf), + umode_t (*is_visible)(void *data, int type), + void (*release)(void *data)) +{ + return iscsi_boot_create_kobj(boot_kset, + &iscsi_boot_acpitbl_attr_group, + "acpi_header", index, data, show, + is_visible, release); +} +EXPORT_SYMBOL_GPL(iscsi_boot_create_acpitbl); + /** * iscsi_boot_create_kset() - creates root sysfs tree * @set_name: name of root dir -- cgit v1.2.3