2007-08-10 02:44:20 +02:00
|
|
|
/*
|
|
|
|
* Copyright Fen Systems Ltd. 2007. Portions of this code are derived
|
|
|
|
* from IBM Corporation Sample Programs. Copyright IBM Corporation
|
|
|
|
* 2004, 2007. All rights reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-05-01 16:41:06 +02:00
|
|
|
FILE_LICENCE ( BSD2 );
|
|
|
|
|
2007-08-10 02:44:20 +02:00
|
|
|
#include <stdint.h>
|
2017-03-27 17:20:34 +02:00
|
|
|
#include <stdlib.h>
|
2007-08-10 02:44:20 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <byteswap.h>
|
2010-04-19 21:16:01 +02:00
|
|
|
#include <ipxe/pci.h>
|
|
|
|
#include <ipxe/acpi.h>
|
|
|
|
#include <ipxe/in.h>
|
|
|
|
#include <ipxe/netdevice.h>
|
|
|
|
#include <ipxe/ethernet.h>
|
2013-03-01 16:32:16 +01:00
|
|
|
#include <ipxe/vlan.h>
|
2017-03-27 17:20:34 +02:00
|
|
|
#include <ipxe/tcpip.h>
|
2010-04-19 21:16:01 +02:00
|
|
|
#include <ipxe/dhcp.h>
|
|
|
|
#include <ipxe/iscsi.h>
|
|
|
|
#include <ipxe/ibft.h>
|
2007-08-10 02:44:20 +02:00
|
|
|
|
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* iSCSI boot firmware table
|
|
|
|
*
|
|
|
|
* The information in this file is derived from the document "iSCSI
|
|
|
|
* Boot Firmware Table (iBFT)" as published by IBM at
|
|
|
|
*
|
|
|
|
* ftp://ftp.software.ibm.com/systems/support/system_x_pdf/ibm_iscsi_boot_firmware_table_v1.02.pdf
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/**
|
2017-03-27 17:20:34 +02:00
|
|
|
* iSCSI string buffer
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
*
|
|
|
|
* This is an internal structure that we use to keep track of the
|
|
|
|
* allocation of string data.
|
|
|
|
*/
|
|
|
|
struct ibft_strings {
|
2017-03-27 17:20:34 +02:00
|
|
|
/** Strings data */
|
|
|
|
char *data;
|
|
|
|
/** Starting offset of strings */
|
|
|
|
size_t start;
|
|
|
|
/** Total length */
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
size_t len;
|
2007-08-10 02:44:20 +02:00
|
|
|
};
|
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/**
|
|
|
|
* Align structure within iBFT
|
|
|
|
*
|
|
|
|
* @v len Unaligned length (or offset)
|
|
|
|
* @ret len Aligned length (or offset)
|
|
|
|
*/
|
|
|
|
static inline size_t ibft_align ( size_t len ) {
|
|
|
|
|
|
|
|
return ( ( len + IBFT_ALIGN - 1 ) & ~( IBFT_ALIGN - 1 ) );
|
|
|
|
}
|
|
|
|
|
2007-08-10 02:44:20 +02:00
|
|
|
/**
|
|
|
|
* Fill in an IP address field within iBFT
|
|
|
|
*
|
|
|
|
* @v ipaddr IP address field
|
|
|
|
* @v in IPv4 address
|
|
|
|
*/
|
|
|
|
static void ibft_set_ipaddr ( struct ibft_ipaddr *ipaddr, struct in_addr in ) {
|
2011-02-25 00:39:38 +01:00
|
|
|
memset ( ipaddr, 0, sizeof ( *ipaddr ) );
|
2007-08-10 02:44:20 +02:00
|
|
|
if ( in.s_addr ) {
|
|
|
|
ipaddr->in = in;
|
|
|
|
ipaddr->ones = 0xffff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-03-25 21:46:16 +01:00
|
|
|
* Fill in an IP address within iBFT from configuration setting
|
2007-08-10 02:44:20 +02:00
|
|
|
*
|
2014-06-12 17:08:28 +02:00
|
|
|
* @v settings Parent settings block, or NULL
|
2007-08-10 02:44:20 +02:00
|
|
|
* @v ipaddr IP address field
|
2008-03-25 21:46:16 +01:00
|
|
|
* @v setting Configuration setting
|
2010-12-09 16:35:02 +01:00
|
|
|
* @v count Maximum number of IP addresses
|
2007-08-10 02:44:20 +02:00
|
|
|
*/
|
2014-06-12 17:08:28 +02:00
|
|
|
static void ibft_set_ipaddr_setting ( struct settings *settings,
|
|
|
|
struct ibft_ipaddr *ipaddr,
|
2013-12-03 17:48:56 +01:00
|
|
|
const struct setting *setting,
|
2010-12-09 16:35:02 +01:00
|
|
|
unsigned int count ) {
|
|
|
|
struct in_addr in[count];
|
|
|
|
unsigned int i;
|
|
|
|
|
2014-06-12 17:08:28 +02:00
|
|
|
fetch_ipv4_array_setting ( settings, setting, in, count );
|
2010-12-09 16:35:02 +01:00
|
|
|
for ( i = 0 ; i < count ; i++ ) {
|
|
|
|
ibft_set_ipaddr ( &ipaddr[i], in[i] );
|
|
|
|
}
|
2007-08-10 02:44:20 +02:00
|
|
|
}
|
|
|
|
|
2009-02-20 22:41:00 +01:00
|
|
|
/**
|
|
|
|
* Read IP address from iBFT (for debugging)
|
|
|
|
*
|
|
|
|
* @v strings iBFT string block descriptor
|
|
|
|
* @v string String field
|
|
|
|
* @ret ipaddr IP address string
|
|
|
|
*/
|
|
|
|
static const char * ibft_ipaddr ( struct ibft_ipaddr *ipaddr ) {
|
|
|
|
return inet_ntoa ( ipaddr->in );
|
|
|
|
}
|
|
|
|
|
2007-08-10 02:44:20 +02:00
|
|
|
/**
|
2008-03-21 01:49:44 +01:00
|
|
|
* Allocate a string within iBFT
|
2007-08-10 02:44:20 +02:00
|
|
|
*
|
|
|
|
* @v strings iBFT string block descriptor
|
2008-03-21 01:49:44 +01:00
|
|
|
* @v string String field to fill in
|
|
|
|
* @v len Length of string to allocate (excluding NUL)
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
* @ret dest String destination, or NULL
|
2007-08-10 02:44:20 +02:00
|
|
|
*/
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
static char * ibft_alloc_string ( struct ibft_strings *strings,
|
|
|
|
struct ibft_string *string, size_t len ) {
|
2017-03-27 17:20:34 +02:00
|
|
|
size_t new_len;
|
|
|
|
char *new_data;
|
|
|
|
char *dest;
|
2007-08-10 02:44:20 +02:00
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/* Extend string data buffer */
|
|
|
|
new_len = ( strings->len + len + 1 /* NUL */ );
|
|
|
|
new_data = realloc ( strings->data, new_len );
|
|
|
|
if ( ! new_data )
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
return NULL;
|
2017-03-27 17:20:34 +02:00
|
|
|
strings->data = new_data;
|
2007-08-10 02:44:20 +02:00
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/* Fill in string field */
|
|
|
|
string->offset = cpu_to_le16 ( strings->start + strings->len );
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
string->len = cpu_to_le16 ( len );
|
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/* Zero string */
|
|
|
|
dest = ( strings->data + strings->len );
|
|
|
|
memset ( dest, 0, ( len + 1 /* NUL */ ) );
|
|
|
|
|
|
|
|
/* Update allocated length */
|
|
|
|
strings->len = new_len;
|
|
|
|
|
|
|
|
return dest;
|
2007-08-10 02:44:20 +02:00
|
|
|
}
|
|
|
|
|
2008-03-21 01:49:44 +01:00
|
|
|
/**
|
|
|
|
* Fill in a string field within iBFT
|
|
|
|
*
|
|
|
|
* @v strings iBFT string block descriptor
|
|
|
|
* @v string String field
|
2008-08-11 04:12:38 +02:00
|
|
|
* @v data String to fill in, or NULL
|
2008-03-21 01:49:44 +01:00
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
static int ibft_set_string ( struct ibft_strings *strings,
|
2008-03-21 01:49:44 +01:00
|
|
|
struct ibft_string *string, const char *data ) {
|
|
|
|
char *dest;
|
|
|
|
|
2008-08-11 04:12:38 +02:00
|
|
|
if ( ! data )
|
|
|
|
return 0;
|
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
dest = ibft_alloc_string ( strings, string, strlen ( data ) );
|
|
|
|
if ( ! dest )
|
|
|
|
return -ENOBUFS;
|
2008-03-21 01:49:44 +01:00
|
|
|
strcpy ( dest, data );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-10 02:44:20 +02:00
|
|
|
/**
|
2008-03-25 21:46:16 +01:00
|
|
|
* Fill in a string field within iBFT from configuration setting
|
2007-08-10 02:44:20 +02:00
|
|
|
*
|
2014-06-12 17:08:28 +02:00
|
|
|
* @v settings Parent settings block, or NULL
|
2007-08-10 02:44:20 +02:00
|
|
|
* @v strings iBFT string block descriptor
|
|
|
|
* @v string String field
|
2008-03-25 21:46:16 +01:00
|
|
|
* @v setting Configuration setting
|
2007-08-10 02:44:20 +02:00
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
2014-06-12 17:08:28 +02:00
|
|
|
static int ibft_set_string_setting ( struct settings *settings,
|
|
|
|
struct ibft_strings *strings,
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
struct ibft_string *string,
|
2013-12-03 17:48:56 +01:00
|
|
|
const struct setting *setting ) {
|
|
|
|
struct settings *origin;
|
|
|
|
struct setting fetched;
|
2008-03-21 01:49:44 +01:00
|
|
|
int len;
|
|
|
|
char *dest;
|
2007-08-10 02:44:20 +02:00
|
|
|
|
2014-06-12 17:08:28 +02:00
|
|
|
len = fetch_setting ( settings, setting, &origin, &fetched, NULL, 0 );
|
2008-03-21 01:49:44 +01:00
|
|
|
if ( len < 0 ) {
|
2007-08-10 02:44:20 +02:00
|
|
|
string->offset = 0;
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
string->len = 0;
|
2007-08-10 02:44:20 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
dest = ibft_alloc_string ( strings, string, len );
|
|
|
|
if ( ! dest )
|
|
|
|
return -ENOBUFS;
|
2013-12-03 17:48:56 +01:00
|
|
|
fetch_string_setting ( origin, &fetched, dest, ( len + 1 ));
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
|
2008-03-21 01:49:44 +01:00
|
|
|
return 0;
|
2007-08-10 02:44:20 +02:00
|
|
|
}
|
|
|
|
|
2009-02-20 22:41:00 +01:00
|
|
|
/**
|
|
|
|
* Read string from iBFT (for debugging)
|
|
|
|
*
|
|
|
|
* @v strings iBFT string block descriptor
|
|
|
|
* @v string String field
|
|
|
|
* @ret data String content (or "<empty>")
|
|
|
|
*/
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
static const char * ibft_string ( struct ibft_strings *strings,
|
2009-02-20 22:41:00 +01:00
|
|
|
struct ibft_string *string ) {
|
2017-03-27 17:20:34 +02:00
|
|
|
size_t offset = le16_to_cpu ( string->offset );
|
|
|
|
|
|
|
|
return ( offset ? ( strings->data + offset - strings->start ) : NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if network device is required for the iBFT
|
|
|
|
*
|
|
|
|
* @v netdev Network device
|
|
|
|
* @ret is_required Network device is required
|
|
|
|
*/
|
|
|
|
static int ibft_netdev_is_required ( struct net_device *netdev ) {
|
|
|
|
struct iscsi_session *iscsi;
|
|
|
|
struct sockaddr_tcpip *st_target;
|
|
|
|
|
|
|
|
list_for_each_entry ( iscsi, &ibft_model.descs, desc.list ) {
|
|
|
|
st_target = ( struct sockaddr_tcpip * ) &iscsi->target_sockaddr;
|
|
|
|
if ( tcpip_netdev ( st_target ) == netdev )
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-02-20 22:41:00 +01:00
|
|
|
}
|
|
|
|
|
2007-08-10 02:44:20 +02:00
|
|
|
/**
|
|
|
|
* Fill in NIC portion of iBFT
|
|
|
|
*
|
|
|
|
* @v nic NIC portion of iBFT
|
|
|
|
* @v strings iBFT string block descriptor
|
|
|
|
* @v netdev Network device
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
|
|
|
static int ibft_fill_nic ( struct ibft_nic *nic,
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
struct ibft_strings *strings,
|
2007-08-10 02:44:20 +02:00
|
|
|
struct net_device *netdev ) {
|
2009-10-23 23:18:04 +02:00
|
|
|
struct ll_protocol *ll_protocol = netdev->ll_protocol;
|
2008-03-21 01:49:44 +01:00
|
|
|
struct in_addr netmask_addr = { 0 };
|
2007-08-10 02:44:20 +02:00
|
|
|
unsigned int netmask_count = 0;
|
2014-06-12 17:08:28 +02:00
|
|
|
struct settings *parent = netdev_settings ( netdev );
|
2014-06-12 17:05:48 +02:00
|
|
|
struct settings *origin;
|
2007-08-10 02:44:20 +02:00
|
|
|
int rc;
|
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/* Fill in common header */
|
|
|
|
nic->header.structure_id = IBFT_STRUCTURE_ID_NIC;
|
|
|
|
nic->header.version = 1;
|
|
|
|
nic->header.length = cpu_to_le16 ( sizeof ( *nic ) );
|
|
|
|
nic->header.flags = ( IBFT_FL_NIC_BLOCK_VALID |
|
|
|
|
IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED );
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d is %s\n", nic->header.index, netdev->name );
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
|
2014-06-12 17:05:48 +02:00
|
|
|
/* Determine origin of IP address */
|
|
|
|
fetch_setting ( parent, &ip_setting, &origin, NULL, NULL, 0 );
|
|
|
|
nic->origin = ( ( origin == parent ) ?
|
|
|
|
IBFT_NIC_ORIGIN_MANUAL : IBFT_NIC_ORIGIN_DHCP );
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d origin = %d\n", nic->header.index, nic->origin );
|
2014-06-12 17:05:48 +02:00
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/* Extract values from configuration settings */
|
2014-06-12 17:08:28 +02:00
|
|
|
ibft_set_ipaddr_setting ( parent, &nic->ip_address, &ip_setting, 1 );
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d IP = %s\n",
|
|
|
|
nic->header.index, ibft_ipaddr ( &nic->ip_address ) );
|
2014-06-12 17:08:28 +02:00
|
|
|
ibft_set_ipaddr_setting ( parent, &nic->gateway, &gateway_setting, 1 );
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d gateway = %s\n",
|
|
|
|
nic->header.index, ibft_ipaddr ( &nic->gateway ) );
|
2014-06-12 17:08:28 +02:00
|
|
|
ibft_set_ipaddr_setting ( NULL, &nic->dns[0], &dns_setting,
|
2010-12-09 16:35:02 +01:00
|
|
|
( sizeof ( nic->dns ) /
|
|
|
|
sizeof ( nic->dns[0] ) ) );
|
2016-03-29 20:38:18 +02:00
|
|
|
ibft_set_ipaddr_setting ( parent, &nic->dhcp, &dhcp_server_setting, 1 );
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d DNS = %s",
|
|
|
|
nic->header.index, ibft_ipaddr ( &nic->dns[0] ) );
|
2010-12-09 16:35:02 +01:00
|
|
|
DBG ( ", %s\n", ibft_ipaddr ( &nic->dns[1] ) );
|
2014-06-12 17:08:28 +02:00
|
|
|
if ( ( rc = ibft_set_string_setting ( NULL, strings, &nic->hostname,
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
&hostname_setting ) ) != 0 )
|
2007-08-10 02:44:20 +02:00
|
|
|
return rc;
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d hostname = %s\n",
|
|
|
|
nic->header.index, ibft_string ( strings, &nic->hostname ) );
|
2007-08-10 02:44:20 +02:00
|
|
|
|
|
|
|
/* Derive subnet mask prefix from subnet mask */
|
2014-06-12 17:08:28 +02:00
|
|
|
fetch_ipv4_setting ( parent, &netmask_setting, &netmask_addr );
|
2007-08-10 02:44:20 +02:00
|
|
|
while ( netmask_addr.s_addr ) {
|
|
|
|
if ( netmask_addr.s_addr & 0x1 )
|
|
|
|
netmask_count++;
|
|
|
|
netmask_addr.s_addr >>= 1;
|
|
|
|
}
|
|
|
|
nic->subnet_mask_prefix = netmask_count;
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d subnet = /%d\n",
|
|
|
|
nic->header.index, nic->subnet_mask_prefix );
|
2007-08-10 02:44:20 +02:00
|
|
|
|
|
|
|
/* Extract values from net-device configuration */
|
2013-03-01 16:32:16 +01:00
|
|
|
nic->vlan = cpu_to_le16 ( vlan_tag ( netdev ) );
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d VLAN = %02x\n",
|
|
|
|
nic->header.index, le16_to_cpu ( nic->vlan ) );
|
2009-10-23 23:18:04 +02:00
|
|
|
if ( ( rc = ll_protocol->eth_addr ( netdev->ll_addr,
|
|
|
|
nic->mac_address ) ) != 0 ) {
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "Could not determine %s MAC: %s\n",
|
|
|
|
netdev->name, strerror ( rc ) );
|
2009-10-23 23:18:04 +02:00
|
|
|
return rc;
|
|
|
|
}
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d MAC = %s\n",
|
|
|
|
nic->header.index, eth_ntoa ( nic->mac_address ) );
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
nic->pci_bus_dev_func = cpu_to_le16 ( netdev->dev->desc.location );
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT NIC %d PCI = %04x\n",
|
|
|
|
nic->header.index, le16_to_cpu ( nic->pci_bus_dev_func ) );
|
2007-08-10 02:44:20 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in Initiator portion of iBFT
|
|
|
|
*
|
|
|
|
* @v initiator Initiator portion of iBFT
|
|
|
|
* @v strings iBFT string block descriptor
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
|
|
|
static int ibft_fill_initiator ( struct ibft_initiator *initiator,
|
2017-03-27 17:20:34 +02:00
|
|
|
struct ibft_strings *strings ) {
|
2007-08-10 02:44:20 +02:00
|
|
|
int rc;
|
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/* Fill in common header */
|
|
|
|
initiator->header.structure_id = IBFT_STRUCTURE_ID_INITIATOR;
|
|
|
|
initiator->header.version = 1;
|
|
|
|
initiator->header.length = cpu_to_le16 ( sizeof ( *initiator ) );
|
|
|
|
initiator->header.flags = ( IBFT_FL_INITIATOR_BLOCK_VALID |
|
|
|
|
IBFT_FL_INITIATOR_FIRMWARE_BOOT_SELECTED );
|
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/* Fill in initiator name */
|
|
|
|
if ( ( rc = ibft_set_string_setting ( NULL, strings,
|
|
|
|
&initiator->initiator_name,
|
|
|
|
&initiator_iqn_setting ) ) != 0 )
|
2007-08-10 02:44:20 +02:00
|
|
|
return rc;
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT initiator name = %s\n",
|
2009-02-20 22:41:00 +01:00
|
|
|
ibft_string ( strings, &initiator->initiator_name ) );
|
2007-08-10 02:44:20 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/**
|
|
|
|
* Fill in Target NIC association
|
|
|
|
*
|
|
|
|
* @v target Target portion of iBFT
|
|
|
|
* @v iscsi iSCSI session
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
|
|
|
static int ibft_fill_target_nic_association ( struct ibft_target *target,
|
|
|
|
struct iscsi_session *iscsi ) {
|
|
|
|
struct sockaddr_tcpip *st_target =
|
|
|
|
( struct sockaddr_tcpip * ) &iscsi->target_sockaddr;
|
|
|
|
struct net_device *associated;
|
|
|
|
struct net_device *netdev;
|
|
|
|
|
|
|
|
/* Find network device used to reach target */
|
|
|
|
associated = tcpip_netdev ( st_target );
|
|
|
|
if ( ! associated ) {
|
|
|
|
DBG ( "iBFT target %d has no net device\n",
|
|
|
|
target->header.index );
|
|
|
|
return -EHOSTUNREACH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate association */
|
|
|
|
for_each_netdev ( netdev ) {
|
|
|
|
if ( netdev == associated ) {
|
|
|
|
DBG ( "iBFT target %d uses NIC %d (%s)\n",
|
|
|
|
target->header.index, target->nic_association,
|
|
|
|
netdev->name );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ( ! ibft_netdev_is_required ( netdev ) )
|
|
|
|
continue;
|
|
|
|
target->nic_association++;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG ( "iBFT target %d has impossible NIC %s\n",
|
|
|
|
target->header.index, netdev->name );
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2008-08-11 04:12:38 +02:00
|
|
|
/**
|
|
|
|
* Fill in Target CHAP portion of iBFT
|
|
|
|
*
|
|
|
|
* @v target Target portion of iBFT
|
|
|
|
* @v strings iBFT string block descriptor
|
|
|
|
* @v iscsi iSCSI session
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
|
|
|
static int ibft_fill_target_chap ( struct ibft_target *target,
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
struct ibft_strings *strings,
|
2008-08-11 04:12:38 +02:00
|
|
|
struct iscsi_session *iscsi ) {
|
|
|
|
int rc;
|
|
|
|
|
2009-02-20 22:41:00 +01:00
|
|
|
if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_FORWARD_REQUIRED ) )
|
2008-08-11 04:12:38 +02:00
|
|
|
return 0;
|
2009-02-20 22:41:00 +01:00
|
|
|
|
|
|
|
assert ( iscsi->initiator_username );
|
2008-08-11 04:12:38 +02:00
|
|
|
assert ( iscsi->initiator_password );
|
|
|
|
|
|
|
|
target->chap_type = IBFT_CHAP_ONE_WAY;
|
|
|
|
if ( ( rc = ibft_set_string ( strings, &target->chap_name,
|
|
|
|
iscsi->initiator_username ) ) != 0 )
|
|
|
|
return rc;
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT target %d username = %s\n", target->header.index,
|
2009-02-20 22:41:00 +01:00
|
|
|
ibft_string ( strings, &target->chap_name ) );
|
2008-08-11 04:12:38 +02:00
|
|
|
if ( ( rc = ibft_set_string ( strings, &target->chap_secret,
|
|
|
|
iscsi->initiator_password ) ) != 0 )
|
|
|
|
return rc;
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT target %d password = <redacted>\n", target->header.index );
|
2009-02-20 22:41:00 +01:00
|
|
|
|
2008-08-11 04:12:38 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill in Target Reverse CHAP portion of iBFT
|
|
|
|
*
|
|
|
|
* @v target Target portion of iBFT
|
|
|
|
* @v strings iBFT string block descriptor
|
|
|
|
* @v iscsi iSCSI session
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
|
|
|
static int ibft_fill_target_reverse_chap ( struct ibft_target *target,
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
struct ibft_strings *strings,
|
2008-08-11 04:12:38 +02:00
|
|
|
struct iscsi_session *iscsi ) {
|
|
|
|
int rc;
|
|
|
|
|
2009-02-20 22:41:00 +01:00
|
|
|
if ( ! ( iscsi->status & ISCSI_STATUS_AUTH_REVERSE_REQUIRED ) )
|
2008-08-11 04:12:38 +02:00
|
|
|
return 0;
|
2009-02-20 22:41:00 +01:00
|
|
|
|
2008-08-11 04:12:38 +02:00
|
|
|
assert ( iscsi->initiator_username );
|
|
|
|
assert ( iscsi->initiator_password );
|
2009-02-20 22:41:00 +01:00
|
|
|
assert ( iscsi->target_username );
|
|
|
|
assert ( iscsi->target_password );
|
2008-08-11 04:12:38 +02:00
|
|
|
|
|
|
|
target->chap_type = IBFT_CHAP_MUTUAL;
|
|
|
|
if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_name,
|
|
|
|
iscsi->target_username ) ) != 0 )
|
|
|
|
return rc;
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT target %d reverse username = %s\n", target->header.index,
|
2009-02-20 22:41:00 +01:00
|
|
|
ibft_string ( strings, &target->chap_name ) );
|
2008-08-11 04:12:38 +02:00
|
|
|
if ( ( rc = ibft_set_string ( strings, &target->reverse_chap_secret,
|
|
|
|
iscsi->target_password ) ) != 0 )
|
|
|
|
return rc;
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT target %d reverse password = <redacted>\n",
|
|
|
|
target->header.index );
|
2009-02-20 22:41:00 +01:00
|
|
|
|
2008-08-11 04:12:38 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-08-10 02:44:20 +02:00
|
|
|
/**
|
|
|
|
* Fill in Target portion of iBFT
|
|
|
|
*
|
|
|
|
* @v target Target portion of iBFT
|
|
|
|
* @v strings iBFT string block descriptor
|
|
|
|
* @v iscsi iSCSI session
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
|
|
|
static int ibft_fill_target ( struct ibft_target *target,
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
struct ibft_strings *strings,
|
2007-08-10 02:44:20 +02:00
|
|
|
struct iscsi_session *iscsi ) {
|
2017-03-27 17:20:34 +02:00
|
|
|
struct sockaddr_tcpip *st_target =
|
|
|
|
( struct sockaddr_tcpip * ) &iscsi->target_sockaddr;
|
2007-08-10 02:44:20 +02:00
|
|
|
struct sockaddr_in *sin_target =
|
|
|
|
( struct sockaddr_in * ) &iscsi->target_sockaddr;
|
|
|
|
int rc;
|
|
|
|
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
/* Fill in common header */
|
|
|
|
target->header.structure_id = IBFT_STRUCTURE_ID_TARGET;
|
|
|
|
target->header.version = 1;
|
|
|
|
target->header.length = cpu_to_le16 ( sizeof ( *target ) );
|
|
|
|
target->header.flags = ( IBFT_FL_TARGET_BLOCK_VALID |
|
|
|
|
IBFT_FL_TARGET_FIRMWARE_BOOT_SELECTED );
|
|
|
|
|
2007-08-10 02:44:20 +02:00
|
|
|
/* Fill in Target values */
|
|
|
|
ibft_set_ipaddr ( &target->ip_address, sin_target->sin_addr );
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT target %d IP = %s\n",
|
|
|
|
target->header.index, ibft_ipaddr ( &target->ip_address ) );
|
|
|
|
target->socket = cpu_to_le16 ( ntohs ( st_target->st_port ) );
|
|
|
|
DBG ( "iBFT target %d port = %d\n",
|
|
|
|
target->header.index, target->socket );
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
memcpy ( &target->boot_lun, &iscsi->lun, sizeof ( target->boot_lun ) );
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT target %d boot LUN = " SCSI_LUN_FORMAT "\n",
|
|
|
|
target->header.index, SCSI_LUN_DATA ( target->boot_lun ) );
|
2007-08-10 02:44:20 +02:00
|
|
|
if ( ( rc = ibft_set_string ( strings, &target->target_name,
|
2008-03-21 01:49:44 +01:00
|
|
|
iscsi->target_iqn ) ) != 0 )
|
2007-08-10 02:44:20 +02:00
|
|
|
return rc;
|
2017-03-27 17:20:34 +02:00
|
|
|
DBG ( "iBFT target %d name = %s\n", target->header.index,
|
2009-02-20 22:41:00 +01:00
|
|
|
ibft_string ( strings, &target->target_name ) );
|
2017-03-27 17:20:34 +02:00
|
|
|
if ( ( rc = ibft_fill_target_nic_association ( target, iscsi ) ) != 0 )
|
|
|
|
return rc;
|
2008-08-11 04:12:38 +02:00
|
|
|
if ( ( rc = ibft_fill_target_chap ( target, strings, iscsi ) ) != 0 )
|
|
|
|
return rc;
|
|
|
|
if ( ( rc = ibft_fill_target_reverse_chap ( target, strings,
|
|
|
|
iscsi ) ) != 0 )
|
|
|
|
return rc;
|
2007-08-10 02:44:20 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-03-27 17:20:34 +02:00
|
|
|
* Check if iBFT descriptor is complete
|
2007-08-10 02:44:20 +02:00
|
|
|
*
|
2017-03-27 17:20:34 +02:00
|
|
|
* @v desc ACPI descriptor
|
2007-08-10 02:44:20 +02:00
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
2017-03-27 17:20:34 +02:00
|
|
|
static int ibft_complete ( struct acpi_descriptor *desc ) {
|
|
|
|
struct iscsi_session *iscsi =
|
|
|
|
container_of ( desc, struct iscsi_session, desc );
|
|
|
|
|
|
|
|
/* Fail if we do not yet have the target address */
|
|
|
|
if ( ! iscsi->target_sockaddr.sa_family )
|
|
|
|
return -EAGAIN;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Install iBFT
|
|
|
|
*
|
|
|
|
* @v install Installation method
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
|
|
|
static int ibft_install ( int ( * install ) ( struct acpi_header *acpi ) ) {
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
struct net_device *netdev;
|
2017-03-27 17:20:34 +02:00
|
|
|
struct iscsi_session *iscsi;
|
|
|
|
struct ibft_table *table;
|
|
|
|
struct ibft_initiator *initiator;
|
|
|
|
struct ibft_nic *nic;
|
|
|
|
struct ibft_target *target;
|
|
|
|
struct ibft_strings strings;
|
|
|
|
struct acpi_header *acpi;
|
|
|
|
void *data;
|
|
|
|
unsigned int targets = 0;
|
|
|
|
unsigned int pairs = 0;
|
|
|
|
size_t offset = 0;
|
|
|
|
size_t table_len;
|
|
|
|
size_t control_len;
|
|
|
|
size_t initiator_offset;
|
|
|
|
size_t nic_offset;
|
|
|
|
size_t target_offset;
|
|
|
|
size_t strings_offset;
|
|
|
|
size_t len;
|
|
|
|
unsigned int i;
|
2007-08-10 02:44:20 +02:00
|
|
|
int rc;
|
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/* Calculate table sizes and offsets */
|
|
|
|
list_for_each_entry ( iscsi, &ibft_model.descs, desc.list )
|
|
|
|
targets++;
|
|
|
|
pairs = ( sizeof ( table->control.pair ) /
|
|
|
|
sizeof ( table->control.pair[0] ) );
|
|
|
|
if ( pairs < targets )
|
|
|
|
pairs = targets;
|
|
|
|
offset = offsetof ( typeof ( *table ), control.pair );
|
|
|
|
offset += ( pairs * sizeof ( table->control.pair[0] ) );
|
|
|
|
table_len = offset;
|
|
|
|
control_len = ( table_len - offsetof ( typeof ( *table ), control ) );
|
|
|
|
offset = ibft_align ( offset );
|
|
|
|
initiator_offset = offset;
|
|
|
|
offset += ibft_align ( sizeof ( *initiator ) );
|
|
|
|
nic_offset = offset;
|
|
|
|
offset += ( pairs * ibft_align ( sizeof ( *nic ) ) );
|
|
|
|
target_offset = offset;
|
|
|
|
offset += ( pairs * ibft_align ( sizeof ( *target ) ) );
|
|
|
|
strings_offset = offset;
|
|
|
|
strings.data = NULL;
|
|
|
|
strings.start = strings_offset;
|
|
|
|
strings.len = 0;
|
|
|
|
len = offset;
|
|
|
|
|
2017-03-28 19:45:23 +02:00
|
|
|
/* Do nothing if no targets exist */
|
|
|
|
if ( ! targets ) {
|
|
|
|
rc = 0;
|
|
|
|
goto no_targets;
|
|
|
|
}
|
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/* Allocate table */
|
|
|
|
data = zalloc ( len );
|
|
|
|
if ( ! data ) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto err_alloc;
|
[block] Replace gPXE block-device API with an iPXE asynchronous interface
The block device interface used in gPXE predates the invention of even
the old gPXE data-transfer interface, let alone the current iPXE
generic asynchronous interface mechanism. Bring this old code up to
date, with the following benefits:
o Block device commands can be cancelled by the requestor. The INT 13
layer uses this to provide a global timeout on all INT 13 calls,
with the result that an unexpected passive failure mode (such as
an iSCSI target ACKing the request but never sending a response)
will lead to a timeout that gets reported back to the INT 13 user,
rather than simply freezing the system.
o INT 13,00 (reset drive) is now able to reset the underlying block
device. INT 13 users, such as DOS, that use INT 13,00 as a method
for error recovery now have a chance of recovering.
o All block device commands are tagged, with a numerical tag that
will show up in debugging output and in packet captures; this will
allow easier interpretation of bug reports that include both
sources of information.
o The extremely ugly hacks used to generate the boot firmware tables
have been eradicated and replaced with a generic acpi_describe()
method (exploiting the ability of iPXE interfaces to pass through
methods to an underlying interface). The ACPI tables are now
built in a shared data block within .bss16, rather than each
requiring dedicated space in .data16.
o The architecture-independent concept of a SAN device has been
exposed to the iPXE core through the sanboot API, which provides
calls to hook, unhook, boot, and describe SAN devices. This
allows for much more flexible usage patterns (such as hooking an
empty SAN device and then running an OS installer via TFTP).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2010-09-03 17:11:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in Control block */
|
2017-03-27 17:20:34 +02:00
|
|
|
table = data;
|
|
|
|
table->control.header.structure_id = IBFT_STRUCTURE_ID_CONTROL;
|
|
|
|
table->control.header.version = 1;
|
|
|
|
table->control.header.length = cpu_to_le16 ( control_len );
|
|
|
|
|
|
|
|
/* Fill in Initiator block */
|
|
|
|
initiator = ( data + initiator_offset );
|
|
|
|
table->control.initiator = cpu_to_le16 ( initiator_offset );
|
|
|
|
if ( ( rc = ibft_fill_initiator ( initiator, &strings ) ) != 0 )
|
|
|
|
goto err_initiator;
|
|
|
|
|
|
|
|
/* Fill in NIC blocks */
|
|
|
|
i = 0;
|
|
|
|
for_each_netdev ( netdev ) {
|
|
|
|
if ( ! ibft_netdev_is_required ( netdev ) )
|
|
|
|
continue;
|
|
|
|
assert ( i < pairs );
|
|
|
|
table->control.pair[i].nic = nic_offset;
|
|
|
|
nic = ( data + nic_offset );
|
|
|
|
nic->header.index = i;
|
|
|
|
if ( ( rc = ibft_fill_nic ( nic, &strings, netdev ) ) != 0 )
|
|
|
|
goto err_nic;
|
|
|
|
i++;
|
|
|
|
nic_offset += ibft_align ( sizeof ( *nic ) );
|
|
|
|
}
|
2007-08-10 02:44:20 +02:00
|
|
|
|
2017-03-27 17:20:34 +02:00
|
|
|
/* Fill in Target blocks */
|
|
|
|
i = 0;
|
|
|
|
list_for_each_entry ( iscsi, &ibft_model.descs, desc.list ) {
|
|
|
|
assert ( i < pairs );
|
|
|
|
table->control.pair[i].target = target_offset;
|
|
|
|
target = ( data + target_offset );
|
|
|
|
target->header.index = i;
|
|
|
|
if ( ( rc = ibft_fill_target ( target, &strings, iscsi ) ) != 0)
|
|
|
|
goto err_target;
|
|
|
|
i++;
|
|
|
|
target_offset += ibft_align ( sizeof ( *target ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reallocate table to include space for strings */
|
|
|
|
len += strings.len;
|
|
|
|
acpi = realloc ( data, len );
|
|
|
|
if ( ! acpi )
|
|
|
|
goto err_realloc;
|
|
|
|
data = NULL;
|
|
|
|
|
|
|
|
/* Fill in ACPI header */
|
|
|
|
acpi->signature = cpu_to_le32 ( IBFT_SIG );
|
|
|
|
acpi->length = cpu_to_le32 ( len );
|
|
|
|
acpi->revision = 1;
|
|
|
|
|
|
|
|
/* Append strings */
|
|
|
|
memcpy ( ( ( ( void * ) acpi ) + strings_offset ), strings.data,
|
|
|
|
strings.len );
|
|
|
|
|
|
|
|
/* Install ACPI table */
|
|
|
|
if ( ( rc = install ( acpi ) ) != 0 ) {
|
|
|
|
DBG ( "iBFT could not install: %s\n", strerror ( rc ) );
|
|
|
|
goto err_install;
|
|
|
|
}
|
|
|
|
|
|
|
|
err_install:
|
|
|
|
free ( acpi );
|
|
|
|
err_realloc:
|
|
|
|
err_target:
|
|
|
|
err_nic:
|
|
|
|
err_initiator:
|
|
|
|
free ( data );
|
|
|
|
err_alloc:
|
2017-03-28 19:45:23 +02:00
|
|
|
no_targets:
|
2017-03-27 17:20:34 +02:00
|
|
|
free ( strings.data );
|
|
|
|
return rc;
|
2007-08-10 02:44:20 +02:00
|
|
|
}
|
2017-03-27 17:20:34 +02:00
|
|
|
|
|
|
|
/** iBFT model */
|
|
|
|
struct acpi_model ibft_model __acpi_model = {
|
|
|
|
.descs = LIST_HEAD_INIT ( ibft_model.descs ),
|
|
|
|
.complete = ibft_complete,
|
|
|
|
.install = ibft_install,
|
|
|
|
};
|