ibft.h

Go to the documentation of this file.
00001 #ifndef _GPXE_IBFT_H
00002 #define _GPXE_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 <gpxe/acpi.h>
00046 #include <gpxe/in.h>
00047 
00048 /** iSCSI Boot Firmware Table signature */
00049 #define IBFT_SIG "iBFT"
00050 
00051 /** An offset from the start of the iBFT */
00052 typedef uint16_t ibft_off_t;
00053 
00054 /** Length of a string within the iBFT (excluding terminating NUL) */
00055 typedef uint16_t ibft_size_t;
00056 
00057 /** A string within the iBFT */
00058 struct ibft_string {
00059         /** Length of string */
00060         ibft_size_t length;
00061         /** Offset to string */
00062         ibft_off_t offset;
00063 } __attribute__ (( packed ));
00064 
00065 /** An IP address within the iBFT */
00066 struct ibft_ipaddr {
00067         /** Reserved; must be zero */
00068         uint16_t zeroes[5];
00069         /** Must be 0xffff if IPv4 address is present, otherwise zero */
00070         uint16_t ones;
00071         /** The IPv4 address, or zero if not present */
00072         struct in_addr in;
00073 } __attribute__ (( packed ));
00074 
00075 /**
00076  * iBFT structure header
00077  *
00078  * This structure is common to several sections within the iBFT.
00079  */
00080 struct ibft_header {
00081         /** Structure ID
00082          *
00083          * This is an IBFT_STRUCTURE_ID_XXX constant
00084          */
00085         uint8_t structure_id;
00086         /** Version (always 1) */
00087         uint8_t version;
00088         /** Length, including this header */
00089         uint16_t length;
00090         /** Index 
00091          *
00092          * This is the number of the NIC or Target, when applicable.
00093          */
00094         uint8_t index;
00095         /** Flags */
00096         uint8_t flags;
00097 } __attribute__ (( packed ));
00098 
00099 /**
00100  * iBFT Control structure
00101  *
00102  */
00103 struct ibft_control {
00104         /** Common header */
00105         struct ibft_header header;
00106         /** Extensions */
00107         uint16_t extensions;
00108         /** Offset to Initiator structure */
00109         ibft_off_t initiator;
00110         /** Offset to NIC structure for NIC 0 */
00111         ibft_off_t nic_0;
00112         /** Offset to Target structure for target 0 */
00113         ibft_off_t target_0;
00114         /** Offset to NIC structure for NIC 1 */
00115         ibft_off_t nic_1;
00116         /** Offset to Target structure for target 1 */
00117         ibft_off_t target_1;
00118 } __attribute__ (( packed ));
00119 
00120 /** Structure ID for Control section */
00121 #define IBFT_STRUCTURE_ID_CONTROL 0x01
00122 
00123 /** Attempt login only to specified target
00124  *
00125  * If this flag is not set, all targets will be logged in to.
00126  */
00127 #define IBFT_FL_CONTROL_SINGLE_LOGIN_ONLY 0x01
00128 
00129 /**
00130  * iBFT Initiator structure
00131  *
00132  */
00133 struct ibft_initiator {
00134         /** Common header */
00135         struct ibft_header header;
00136         /** iSNS server */
00137         struct ibft_ipaddr isns_server;
00138         /** SLP server */
00139         struct ibft_ipaddr slp_server;
00140         /** Primary and secondary Radius servers */
00141         struct ibft_ipaddr radius[2];
00142         /** Initiator name */
00143         struct ibft_string initiator_name;
00144 } __attribute__ (( packed ));
00145 
00146 /** Structure ID for Initiator section */
00147 #define IBFT_STRUCTURE_ID_INITIATOR 0x02
00148 
00149 /** Initiator block valid */
00150 #define IBFT_FL_INITIATOR_BLOCK_VALID 0x01
00151 
00152 /** Initiator firmware boot selected */
00153 #define IBFT_FL_INITIATOR_FIRMWARE_BOOT_SELECTED 0x02
00154 
00155 /**
00156  * iBFT NIC structure
00157  *
00158  */
00159 struct ibft_nic {
00160         /** Common header */
00161         struct ibft_header header;
00162         /** IP address */
00163         struct ibft_ipaddr ip_address;
00164         /** Subnet mask
00165          *
00166          * This is the length of the subnet mask in bits (e.g. /24).
00167          */
00168         uint8_t subnet_mask_prefix;
00169         /** Origin */
00170         uint8_t origin;
00171         /** Default gateway */
00172         struct ibft_ipaddr gateway;
00173         /** Primary and secondary DNS servers */
00174         struct ibft_ipaddr dns[2];
00175         /** DHCP server */
00176         struct ibft_ipaddr dhcp;
00177         /** VLAN tag */
00178         uint16_t vlan;
00179         /** MAC address */
00180         uint8_t mac_address[6];
00181         /** PCI bus:dev:fn */
00182         uint16_t pci_bus_dev_func;
00183         /** Hostname */
00184         struct ibft_string hostname;
00185 } __attribute__ (( packed ));
00186 
00187 /** Structure ID for NIC section */
00188 #define IBFT_STRUCTURE_ID_NIC 0x03
00189 
00190 /** NIC block valid */
00191 #define IBFT_FL_NIC_BLOCK_VALID 0x01
00192 
00193 /** NIC firmware boot selected */
00194 #define IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED 0x02
00195 
00196 /** NIC global / link local */
00197 #define IBFT_FL_NIC_GLOBAL 0x04
00198 
00199 /**
00200  * iBFT Target structure
00201  *
00202  */
00203 struct ibft_target {
00204         /** Common header */
00205         struct ibft_header header;
00206         /** IP address */
00207         struct ibft_ipaddr ip_address;
00208         /** TCP port */
00209         uint16_t socket;
00210         /** Boot LUN */
00211         uint64_t boot_lun;
00212         /** CHAP type
00213          *
00214          * This is an IBFT_CHAP_XXX constant.
00215          */
00216         uint8_t chap_type;
00217         /** NIC association */
00218         uint8_t nic_association;
00219         /** Target name */
00220         struct ibft_string target_name;
00221         /** CHAP name */
00222         struct ibft_string chap_name;
00223         /** CHAP secret */
00224         struct ibft_string chap_secret;
00225         /** Reverse CHAP name */
00226         struct ibft_string reverse_chap_name;
00227         /** Reverse CHAP secret */
00228         struct ibft_string reverse_chap_secret;
00229 } __attribute__ (( packed ));
00230 
00231 /** Structure ID for Target section */
00232 #define IBFT_STRUCTURE_ID_TARGET 0x04
00233 
00234 /** Target block valid */
00235 #define IBFT_FL_TARGET_BLOCK_VALID 0x01
00236 
00237 /** Target firmware boot selected */
00238 #define IBFT_FL_TARGET_FIRMWARE_BOOT_SELECTED 0x02
00239 
00240 /** Target use Radius CHAP */
00241 #define IBFT_FL_TARGET_USE_CHAP 0x04
00242 
00243 /** Target use Radius rCHAP */
00244 #define IBFT_FL_TARGET_USE_RCHAP 0x08
00245 
00246 /* Values for chap_type */
00247 #define IBFT_CHAP_NONE          0       /**< No CHAP authentication */
00248 #define IBFT_CHAP_ONE_WAY       1       /**< One-way CHAP */
00249 #define IBFT_CHAP_MUTUAL        2       /**< Mutual CHAP */
00250 
00251 /**
00252  * iSCSI Boot Firmware Table (iBFT)
00253  */
00254 struct ibft_table {
00255         /** ACPI header */
00256         struct acpi_description_header acpi;
00257         /** Reserved */
00258         uint8_t reserved[12];
00259         /** Control structure */
00260         struct ibft_control control;
00261 } __attribute__ (( packed ));
00262 
00263 /**
00264  * iSCSI string block descriptor
00265  *
00266  * This is an internal structure that we use to keep track of the
00267  * allocation of string data.
00268  */
00269 struct ibft_string_block {
00270         /** The iBFT containing these strings */
00271         struct ibft_table *table;
00272         /** Offset of first free byte within iBFT */
00273         unsigned int offset;
00274 };
00275 
00276 /** Amount of space reserved for strings in a gPXE iBFT */
00277 #define IBFT_STRINGS_SIZE 384
00278 
00279 /**
00280  * An iBFT created by gPXE
00281  *
00282  */
00283 struct gpxe_ibft {
00284         /** The fixed section */
00285         struct ibft_table table;
00286         /** The Initiator section */
00287         struct ibft_initiator initiator __attribute__ (( aligned ( 16 ) ));
00288         /** The NIC section */
00289         struct ibft_nic nic __attribute__ (( aligned ( 16 ) ));
00290         /** The Target section */
00291         struct ibft_target target __attribute__ (( aligned ( 16 ) ));
00292         /** Strings block */
00293         char strings[IBFT_STRINGS_SIZE];
00294 } __attribute__ (( packed, aligned ( 16 ) ));
00295 
00296 struct net_device;
00297 struct iscsi_session;
00298 
00299 extern int ibft_fill_data ( struct net_device *netdev,
00300                             struct iscsi_session *iscsi );
00301 
00302 #endif /* _GPXE_IBFT_H */

Generated on Tue Apr 6 20:00:50 2010 for gPXE by  doxygen 1.5.7.1