iPXE
ibft.h
Go to the documentation of this file.
00001 #ifndef _IPXE_IBFT_H
00002 #define _IPXE_IBFT_H
00003 
00004 /*
00005  * Copyright Fen Systems Ltd. 2007.  Portions of this code are derived
00006  * from IBM Corporation Sample Programs.  Copyright IBM Corporation
00007  * 2004, 2007.  All rights reserved.
00008  *
00009  * Permission is hereby granted, free of charge, to any person
00010  * obtaining a copy of this software and associated documentation
00011  * files (the "Software"), to deal in the Software without
00012  * restriction, including without limitation the rights to use, copy,
00013  * modify, merge, publish, distribute, sublicense, and/or sell copies
00014  * of the Software, and to permit persons to whom the Software is
00015  * furnished to do so, subject to the following conditions:
00016  *
00017  * The above copyright notice and this permission notice shall be
00018  * included in all copies or substantial portions of the Software.
00019  *
00020  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00023  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
00024  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00025  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00026  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00027  * SOFTWARE.
00028  *
00029  */
00030 
00031 FILE_LICENCE ( BSD2 );
00032 
00033 /** @file
00034  *
00035  * iSCSI boot firmware table
00036  *
00037  * The information in this file is derived from the document "iSCSI
00038  * Boot Firmware Table (iBFT)" as published by IBM at
00039  *
00040  * ftp://ftp.software.ibm.com/systems/support/system_x_pdf/ibm_iscsi_boot_firmware_table_v1.02.pdf
00041  *
00042  */
00043 
00044 #include <stdint.h>
00045 #include <ipxe/acpi.h>
00046 #include <ipxe/scsi.h>
00047 #include <ipxe/in.h>
00048 
00049 /** iSCSI Boot Firmware Table signature */
00050 #define IBFT_SIG ACPI_SIGNATURE ( 'i', 'B', 'F', 'T' )
00051 
00052 /** Alignment of structures within iBFT */
00053 #define IBFT_ALIGN 16
00054 
00055 /** An offset from the start of the iBFT */
00056 typedef uint16_t ibft_off_t;
00057 
00058 /** Length of a string within the iBFT (excluding terminating NUL) */
00059 typedef uint16_t ibft_size_t;
00060 
00061 /** A string within the iBFT */
00062 struct ibft_string {
00063         /** Length of string */
00064         ibft_size_t len;
00065         /** Offset to string */
00066         ibft_off_t offset;
00067 } __attribute__ (( packed ));
00068 
00069 /** An IP address within the iBFT */
00070 struct ibft_ipaddr {
00071         /** Reserved; must be zero */
00072         uint16_t zeroes[5];
00073         /** Must be 0xffff if IPv4 address is present, otherwise zero */
00074         uint16_t ones;
00075         /** The IPv4 address, or zero if not present */
00076         struct in_addr in;
00077 } __attribute__ (( packed ));
00078 
00079 /**
00080  * iBFT structure header
00081  *
00082  * This structure is common to several sections within the iBFT.
00083  */
00084 struct ibft_header {
00085         /** Structure ID
00086          *
00087          * This is an IBFT_STRUCTURE_ID_XXX constant
00088          */
00089         uint8_t structure_id;
00090         /** Version (always 1) */
00091         uint8_t version;
00092         /** Length, including this header */
00093         uint16_t length;
00094         /** Index 
00095          *
00096          * This is the number of the NIC or Target, when applicable.
00097          */
00098         uint8_t index;
00099         /** Flags */
00100         uint8_t flags;
00101 } __attribute__ (( packed ));
00102 
00103 /**
00104  * iBFT NIC and Target offset pair
00105  *
00106  * There is no implicit relation between the NIC and the Target, but
00107  * using this structure simplifies the table construction code while
00108  * matching the expected table layout.
00109  */
00110 struct ibft_offset_pair {
00111         /** Offset to NIC structure */
00112         ibft_off_t nic;
00113         /** Offset to Target structure */
00114         ibft_off_t target;
00115 } __attribute__ (( packed ));
00116 
00117 /**
00118  * iBFT Control structure
00119  *
00120  */
00121 struct ibft_control {
00122         /** Common header */
00123         struct ibft_header header;
00124         /** Extensions */
00125         uint16_t extensions;
00126         /** Offset to Initiator structure */
00127         ibft_off_t initiator;
00128         /** Offsets to NIC and Target structures */
00129         struct ibft_offset_pair pair[2];
00130 } __attribute__ (( packed ));
00131 
00132 /** Structure ID for Control section */
00133 #define IBFT_STRUCTURE_ID_CONTROL 0x01
00134 
00135 /** Attempt login only to specified target
00136  *
00137  * If this flag is not set, all targets will be logged in to.
00138  */
00139 #define IBFT_FL_CONTROL_SINGLE_LOGIN_ONLY 0x01
00140 
00141 /**
00142  * iBFT Initiator structure
00143  *
00144  */
00145 struct ibft_initiator {
00146         /** Common header */
00147         struct ibft_header header;
00148         /** iSNS server */
00149         struct ibft_ipaddr isns_server;
00150         /** SLP server */
00151         struct ibft_ipaddr slp_server;
00152         /** Primary and secondary Radius servers */
00153         struct ibft_ipaddr radius[2];
00154         /** Initiator name */
00155         struct ibft_string initiator_name;
00156 } __attribute__ (( packed ));
00157 
00158 /** Structure ID for Initiator section */
00159 #define IBFT_STRUCTURE_ID_INITIATOR 0x02
00160 
00161 /** Initiator block valid */
00162 #define IBFT_FL_INITIATOR_BLOCK_VALID 0x01
00163 
00164 /** Initiator firmware boot selected */
00165 #define IBFT_FL_INITIATOR_FIRMWARE_BOOT_SELECTED 0x02
00166 
00167 /**
00168  * iBFT NIC structure
00169  *
00170  */
00171 struct ibft_nic {
00172         /** Common header */
00173         struct ibft_header header;
00174         /** IP address */
00175         struct ibft_ipaddr ip_address;
00176         /** Subnet mask
00177          *
00178          * This is the length of the subnet mask in bits (e.g. /24).
00179          */
00180         uint8_t subnet_mask_prefix;
00181         /** Origin */
00182         uint8_t origin;
00183         /** Default gateway */
00184         struct ibft_ipaddr gateway;
00185         /** Primary and secondary DNS servers */
00186         struct ibft_ipaddr dns[2];
00187         /** DHCP server */
00188         struct ibft_ipaddr dhcp;
00189         /** VLAN tag */
00190         uint16_t vlan;
00191         /** MAC address */
00192         uint8_t mac_address[6];
00193         /** PCI bus:dev:fn */
00194         uint16_t pci_bus_dev_func;
00195         /** Hostname */
00196         struct ibft_string hostname;
00197 } __attribute__ (( packed ));
00198 
00199 /** Structure ID for NIC section */
00200 #define IBFT_STRUCTURE_ID_NIC 0x03
00201 
00202 /** NIC block valid */
00203 #define IBFT_FL_NIC_BLOCK_VALID 0x01
00204 
00205 /** NIC firmware boot selected */
00206 #define IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED 0x02
00207 
00208 /** NIC global / link local */
00209 #define IBFT_FL_NIC_GLOBAL 0x04
00210 
00211 /** NIC IP address origin */
00212 #define IBFT_NIC_ORIGIN_OTHER 0x00
00213 #define IBFT_NIC_ORIGIN_MANUAL 0x01
00214 #define IBFT_NIC_ORIGIN_WELLKNOWN 0x02
00215 #define IBFT_NIC_ORIGIN_DHCP 0x03
00216 #define IBFT_NIC_ORIGIN_RA 0x04
00217 #define IBFT_NIC_ORIGIN_UNCHANGED 0x0f
00218 
00219 /**
00220  * iBFT Target structure
00221  *
00222  */
00223 struct ibft_target {
00224         /** Common header */
00225         struct ibft_header header;
00226         /** IP address */
00227         struct ibft_ipaddr ip_address;
00228         /** TCP port */
00229         uint16_t socket;
00230         /** Boot LUN */
00231         struct scsi_lun boot_lun;
00232         /** CHAP type
00233          *
00234          * This is an IBFT_CHAP_XXX constant.
00235          */
00236         uint8_t chap_type;
00237         /** NIC association */
00238         uint8_t nic_association;
00239         /** Target name */
00240         struct ibft_string target_name;
00241         /** CHAP name */
00242         struct ibft_string chap_name;
00243         /** CHAP secret */
00244         struct ibft_string chap_secret;
00245         /** Reverse CHAP name */
00246         struct ibft_string reverse_chap_name;
00247         /** Reverse CHAP secret */
00248         struct ibft_string reverse_chap_secret;
00249 } __attribute__ (( packed ));
00250 
00251 /** Structure ID for Target section */
00252 #define IBFT_STRUCTURE_ID_TARGET 0x04
00253 
00254 /** Target block valid */
00255 #define IBFT_FL_TARGET_BLOCK_VALID 0x01
00256 
00257 /** Target firmware boot selected */
00258 #define IBFT_FL_TARGET_FIRMWARE_BOOT_SELECTED 0x02
00259 
00260 /** Target use Radius CHAP */
00261 #define IBFT_FL_TARGET_USE_CHAP 0x04
00262 
00263 /** Target use Radius rCHAP */
00264 #define IBFT_FL_TARGET_USE_RCHAP 0x08
00265 
00266 /* Values for chap_type */
00267 #define IBFT_CHAP_NONE          0       /**< No CHAP authentication */
00268 #define IBFT_CHAP_ONE_WAY       1       /**< One-way CHAP */
00269 #define IBFT_CHAP_MUTUAL        2       /**< Mutual CHAP */
00270 
00271 /**
00272  * iSCSI Boot Firmware Table (iBFT)
00273  */
00274 struct ibft_table {
00275         /** ACPI header */
00276         struct acpi_header acpi;
00277         /** Reserved */
00278         uint8_t reserved[12];
00279         /** Control structure */
00280         struct ibft_control control;
00281 } __attribute__ (( packed ));
00282 
00283 extern struct acpi_model ibft_model __acpi_model;
00284 
00285 #endif /* _IPXE_IBFT_H */