2
0
mirror of https://github.com/xcat2/xNBA.git synced 2026-03-25 15:53:29 +00:00
Files
xNBA/src/include/ipxe/aoe.h
Michael Brown 220495f8bf [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-14 20:37:15 +01:00

132 lines
3.1 KiB
C

#ifndef _IPXE_AOE_H
#define _IPXE_AOE_H
/** @file
*
* AoE protocol
*
*/
FILE_LICENCE ( GPL2_OR_LATER );
#include <stdint.h>
#include <ipxe/list.h>
#include <ipxe/if_ether.h>
#include <ipxe/retry.h>
#include <ipxe/ata.h>
#include <ipxe/acpi.h>
/** An AoE config command */
struct aoecfg {
/** AoE queue depth */
uint16_t bufcnt;
/** ATA target firmware version */
uint16_t fwver;
/** ATA target sector count */
uint8_t scnt;
/** AoE config string subcommand */
uint8_t aoeccmd;
/** AoE config string length */
uint16_t cfglen;
/** AoE config string */
uint8_t data[0];
} __attribute__ (( packed ));
/** An AoE ATA command */
struct aoeata {
/** AoE command flags */
uint8_t aflags;
/** ATA error/feature register */
uint8_t err_feat;
/** ATA sector count register */
uint8_t count;
/** ATA command/status register */
uint8_t cmd_stat;
/** Logical block address, in little-endian order */
union {
uint64_t u64;
uint8_t bytes[6];
} lba;
/** Data payload */
uint8_t data[0];
} __attribute__ (( packed ));
#define AOE_FL_EXTENDED 0x40 /**< LBA48 extended addressing */
#define AOE_FL_DEV_HEAD 0x10 /**< Device/head flag */
#define AOE_FL_ASYNC 0x02 /**< Asynchronous write */
#define AOE_FL_WRITE 0x01 /**< Write command */
/** An AoE command */
union aoecmd {
/** Config command */
struct aoecfg cfg;
/** ATA command */
struct aoeata ata;
};
/** An AoE header */
struct aoehdr {
/** Protocol version number and flags */
uint8_t ver_flags;
/** Error code */
uint8_t error;
/** Major device number, in network byte order */
uint16_t major;
/** Minor device number */
uint8_t minor;
/** Command number */
uint8_t command;
/** Tag, in network byte order */
uint32_t tag;
/** Payload */
union aoecmd payload[0];
} __attribute__ (( packed ));
#define AOE_VERSION 0x10 /**< Version 1 */
#define AOE_VERSION_MASK 0xf0 /**< Version part of ver_flags field */
#define AOE_FL_RESPONSE 0x08 /**< Message is a response */
#define AOE_FL_ERROR 0x04 /**< Command generated an error */
#define AOE_MAJOR_BROADCAST 0xffff
#define AOE_MINOR_BROADCAST 0xff
#define AOE_CMD_ATA 0x00 /**< Issue ATA command */
#define AOE_CMD_CONFIG 0x01 /**< Query Config Information */
#define AOE_ERR_BAD_COMMAND 1 /**< Unrecognised command code */
#define AOE_ERR_BAD_PARAMETER 2 /**< Bad argument parameter */
#define AOE_ERR_UNAVAILABLE 3 /**< Device unavailable */
#define AOE_ERR_CONFIG_EXISTS 4 /**< Config string present */
#define AOE_ERR_BAD_VERSION 5 /**< Unsupported version */
#define AOE_STATUS_ERR_MASK 0x0f /**< Error portion of status code */
#define AOE_STATUS_PENDING 0x80 /**< Command pending */
/** AoE tag magic marker */
#define AOE_TAG_MAGIC 0x18ae0000
/** Maximum number of sectors per packet */
#define AOE_MAX_COUNT 2
/** AoE boot firmware table signature */
#define ABFT_SIG ACPI_SIGNATURE ( 'a', 'B', 'F', 'T' )
/**
* AoE Boot Firmware Table (aBFT)
*/
struct abft_table {
/** ACPI header */
struct acpi_description_header acpi;
/** AoE shelf */
uint16_t shelf;
/** AoE slot */
uint8_t slot;
/** Reserved */
uint8_t reserved_a;
/** MAC address */
uint8_t mac[ETH_ALEN];
} __attribute__ (( packed ));
#endif /* _IPXE_AOE_H */