[block] Describe all SAN devices via ACPI tables

Describe all SAN devices via ACPI tables such as the iBFT.  For tables
that can describe only a single device (i.e. the aBFT and sBFT), one
table is installed per device.  For multi-device tables (i.e. the
iBFT), all devices are described in a single table.

An underlying SAN device connection may be closed at the time that we
need to construct an ACPI table.  We therefore introduce the concept
of an "ACPI descriptor" which enables the SAN boot code to maintain an
opaque pointer to the underlying object, and an "ACPI model" which can
build tables from a list of such descriptors.  This separates the
lifecycles of ACPI descriptions from the lifecycles of the block
device interfaces, and allows for construction of the ACPI tables even
if the block device interface has been closed.

For a multipath SAN device, iPXE will wait until sufficient
information is available to describe all devices but will not wait for
all paths to connect successfully.  For example: with a multipath
iSCSI boot iPXE will wait until at least one path has become available
and name resolution has completed on all other paths.  We do this
since the iBFT has to include IP addresses rather than DNS names.  We
will commence booting without waiting for the inactive paths to either
become available or close; this avoids unnecessary boot delays.

Note that the Linux kernel will refuse to accept an iBFT with more
than two NIC or target structures.  We therefore describe only the
NICs that are actually required in order to reach the described
targets.  Any iBFT with at most two targets is therefore guaranteed to
describe at most two NICs.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2017-03-28 19:12:48 +03:00
parent 414b4fc9c5
commit 7cfdd769aa
21 changed files with 930 additions and 491 deletions
-68
View File
@@ -113,13 +113,6 @@ struct srp_device {
/** Login completed successfully */
int logged_in;
/** Initiator port ID (for boot firmware table) */
union srp_port_id initiator;
/** Target port ID (for boot firmware table) */
union srp_port_id target;
/** SCSI LUN (for boot firmware table) */
struct scsi_lun lun;
/** List of active commands */
struct list_head commands;
};
@@ -684,61 +677,6 @@ static size_t srpdev_window ( struct srp_device *srpdev ) {
return ( srpdev->logged_in ? ~( ( size_t ) 0 ) : 0 );
}
/**
* A (transport-independent) sBFT created by iPXE
*/
struct ipxe_sbft {
/** The table header */
struct sbft_table table;
/** The SCSI subtable */
struct sbft_scsi_subtable scsi;
/** The SRP subtable */
struct sbft_srp_subtable srp;
} __attribute__ (( packed, aligned ( 16 ) ));
/**
* Describe SRP device in an ACPI table
*
* @v srpdev SRP device
* @v acpi ACPI table
* @v len Length of ACPI table
* @ret rc Return status code
*/
static int srpdev_describe ( struct srp_device *srpdev,
struct acpi_description_header *acpi,
size_t len ) {
struct ipxe_sbft *sbft =
container_of ( acpi, struct ipxe_sbft, table.acpi );
int rc;
/* Sanity check */
if ( len < sizeof ( *sbft ) )
return -ENOBUFS;
/* Populate table */
sbft->table.acpi.signature = cpu_to_le32 ( SBFT_SIG );
sbft->table.acpi.length = cpu_to_le32 ( sizeof ( *sbft ) );
sbft->table.acpi.revision = 1;
sbft->table.scsi_offset =
cpu_to_le16 ( offsetof ( typeof ( *sbft ), scsi ) );
memcpy ( &sbft->scsi.lun, &srpdev->lun, sizeof ( sbft->scsi.lun ) );
sbft->table.srp_offset =
cpu_to_le16 ( offsetof ( typeof ( *sbft ), srp ) );
memcpy ( &sbft->srp.initiator, &srpdev->initiator,
sizeof ( sbft->srp.initiator ) );
memcpy ( &sbft->srp.target, &srpdev->target,
sizeof ( sbft->srp.target ) );
/* Ask transport layer to describe transport-specific portions */
if ( ( rc = acpi_describe ( &srpdev->socket, acpi, len ) ) != 0 ) {
DBGC ( srpdev, "SRP %p cannot describe transport layer: %s\n",
srpdev, strerror ( rc ) );
return rc;
}
return 0;
}
/** SRP device socket interface operations */
static struct interface_operation srpdev_socket_op[] = {
INTF_OP ( xfer_deliver, struct srp_device *, srpdev_deliver ),
@@ -755,7 +693,6 @@ static struct interface_operation srpdev_scsi_op[] = {
INTF_OP ( scsi_command, struct srp_device *, srpdev_scsi_command ),
INTF_OP ( xfer_window, struct srp_device *, srpdev_window ),
INTF_OP ( intf_close, struct srp_device *, srpdev_close ),
INTF_OP ( acpi_describe, struct srp_device *, srpdev_describe ),
};
/** SRP device SCSI interface descriptor */
@@ -797,11 +734,6 @@ int srp_open ( struct interface *block, struct interface *socket,
ntohl ( target->dwords[0] ), ntohl ( target->dwords[1] ),
ntohl ( target->dwords[2] ), ntohl ( target->dwords[3] ) );
/* Preserve parameters required for boot firmware table */
memcpy ( &srpdev->initiator, initiator, sizeof ( srpdev->initiator ) );
memcpy ( &srpdev->target, target, sizeof ( srpdev->target ) );
memcpy ( &srpdev->lun, lun, sizeof ( srpdev->lun ) );
/* Attach to socket interface and initiate login */
intf_plug_plug ( &srpdev->socket, socket );
tag = srp_new_tag ( srpdev );