You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ibft.h 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. #ifndef _GPXE_IBFT_H
  2. #define _GPXE_IBFT_H
  3. /*
  4. * Copyright Fen Systems Ltd. 2007. Portions of this code are derived
  5. * from IBM Corporation Sample Programs. Copyright IBM Corporation
  6. * 2004, 2007. All rights reserved.
  7. *
  8. * Permission is hereby granted, free of charge, to any person
  9. * obtaining a copy of this software and associated documentation
  10. * files (the "Software"), to deal in the Software without
  11. * restriction, including without limitation the rights to use, copy,
  12. * modify, merge, publish, distribute, sublicense, and/or sell copies
  13. * of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be
  17. * included in all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  23. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  24. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  25. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  26. * SOFTWARE.
  27. *
  28. */
  29. /** @file
  30. *
  31. * iSCSI boot firmware table
  32. *
  33. * The information in this file is derived from the document "iSCSI
  34. * Boot Firmware Table (iBFT)" as published by IBM at
  35. *
  36. * ftp://ftp.software.ibm.com/systems/support/system_x_pdf/ibm_iscsi_boot_firmware_table_v1.02.pdf
  37. *
  38. */
  39. #include <stdint.h>
  40. #include <gpxe/acpi.h>
  41. #include <gpxe/in.h>
  42. /** iSCSI Boot Firmware Table signature */
  43. #define IBFT_SIG "iBFT"
  44. /** An offset from the start of the iBFT */
  45. typedef uint16_t ibft_off_t;
  46. /** Length of a string within the iBFT (excluding terminating NUL) */
  47. typedef uint16_t ibft_size_t;
  48. /** A string within the iBFT */
  49. struct ibft_string {
  50. /** Length of string */
  51. ibft_size_t length;
  52. /** Offset to string */
  53. ibft_off_t offset;
  54. } __attribute__ (( packed ));
  55. /** An IP address within the iBFT */
  56. struct ibft_ipaddr {
  57. /** Reserved; must be zero */
  58. uint16_t zeroes[5];
  59. /** Must be 0xffff if IPv4 address is present, otherwise zero */
  60. uint16_t ones;
  61. /** The IPv4 address, or zero if not present */
  62. struct in_addr in;
  63. } __attribute__ (( packed ));
  64. /**
  65. * iBFT structure header
  66. *
  67. * This structure is common to several sections within the iBFT.
  68. */
  69. struct ibft_header {
  70. /** Structure ID
  71. *
  72. * This is an IBFT_STRUCTURE_ID_XXX constant
  73. */
  74. uint8_t structure_id;
  75. /** Version (always 1) */
  76. uint8_t version;
  77. /** Length, including this header */
  78. uint16_t length;
  79. /** Index
  80. *
  81. * This is the number of the NIC or Target, when applicable.
  82. */
  83. uint8_t index;
  84. /** Flags */
  85. uint8_t flags;
  86. } __attribute__ (( packed ));
  87. /**
  88. * iBFT Control structure
  89. *
  90. */
  91. struct ibft_control {
  92. /** Common header */
  93. struct ibft_header header;
  94. /** Extensions */
  95. uint16_t extensions;
  96. /** Offset to Initiator structure */
  97. ibft_off_t initiator;
  98. /** Offset to NIC structure for NIC 0 */
  99. ibft_off_t nic_0;
  100. /** Offset to Target structure for target 0 */
  101. ibft_off_t target_0;
  102. /** Offset to NIC structure for NIC 1 */
  103. ibft_off_t nic_1;
  104. /** Offset to Target structure for target 1 */
  105. ibft_off_t target_1;
  106. } __attribute__ (( packed ));
  107. /** Structure ID for Control section */
  108. #define IBFT_STRUCTURE_ID_CONTROL 0x01
  109. /** Attempt login only to specified target
  110. *
  111. * If this flag is not set, all targets will be logged in to.
  112. */
  113. #define IBFT_FL_CONTROL_SINGLE_LOGIN_ONLY 0x01
  114. /**
  115. * iBFT Initiator structure
  116. *
  117. */
  118. struct ibft_initiator {
  119. /** Common header */
  120. struct ibft_header header;
  121. /** iSNS server */
  122. struct ibft_ipaddr isns_server;
  123. /** SLP server */
  124. struct ibft_ipaddr slp_server;
  125. /** Primary and secondary Radius servers */
  126. struct ibft_ipaddr radius[2];
  127. /** Initiator name */
  128. struct ibft_string initiator_name;
  129. } __attribute__ (( packed ));
  130. /** Structure ID for Initiator section */
  131. #define IBFT_STRUCTURE_ID_INITIATOR 0x02
  132. /** Initiator block valid */
  133. #define IBFT_FL_INITIATOR_BLOCK_VALID 0x01
  134. /** Initiator firmware boot selected */
  135. #define IBFT_FL_INITIATOR_FIRMWARE_BOOT_SELECTED 0x02
  136. /**
  137. * iBFT NIC structure
  138. *
  139. */
  140. struct ibft_nic {
  141. /** Common header */
  142. struct ibft_header header;
  143. /** IP address */
  144. struct ibft_ipaddr ip_address;
  145. /** Subnet mask
  146. *
  147. * This is the length of the subnet mask in bits (e.g. /24).
  148. */
  149. uint8_t subnet_mask_prefix;
  150. /** Origin */
  151. uint8_t origin;
  152. /** Default gateway */
  153. struct ibft_ipaddr gateway;
  154. /** Primary and secondary DNS servers */
  155. struct ibft_ipaddr dns[2];
  156. /** DHCP server */
  157. struct ibft_ipaddr dhcp;
  158. /** VLAN tag */
  159. uint16_t vlan;
  160. /** MAC address */
  161. uint8_t mac_address[6];
  162. /** PCI bus:dev:fn */
  163. uint16_t pci_bus_dev_func;
  164. /** Hostname */
  165. struct ibft_string hostname;
  166. } __attribute__ (( packed ));
  167. /** Structure ID for NIC section */
  168. #define IBFT_STRUCTURE_ID_NIC 0x03
  169. /** NIC block valid */
  170. #define IBFT_FL_NIC_BLOCK_VALID 0x01
  171. /** NIC firmware boot selected */
  172. #define IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED 0x02
  173. /** NIC global / link local */
  174. #define IBFT_FL_NIC_GLOBAL 0x04
  175. /**
  176. * iBFT Target structure
  177. *
  178. */
  179. struct ibft_target {
  180. /** Common header */
  181. struct ibft_header header;
  182. /** IP address */
  183. struct ibft_ipaddr ip_address;
  184. /** TCP port */
  185. uint16_t socket;
  186. /** Boot LUN */
  187. uint64_t boot_lun;
  188. /** CHAP type
  189. *
  190. * This is an IBFT_CHAP_XXX constant.
  191. */
  192. uint8_t chap_type;
  193. /** NIC association */
  194. uint8_t nic_association;
  195. /** Target name */
  196. struct ibft_string target_name;
  197. /** CHAP name */
  198. struct ibft_string chap_name;
  199. /** CHAP secret */
  200. struct ibft_string chap_secret;
  201. /** Reverse CHAP name */
  202. struct ibft_string reverse_chap_name;
  203. /** Reverse CHAP secret */
  204. struct ibft_string reverse_chap_secret;
  205. } __attribute__ (( packed ));
  206. /** Structure ID for Target section */
  207. #define IBFT_STRUCTURE_ID_TARGET 0x04
  208. /** Target block valid */
  209. #define IBFT_FL_TARGET_BLOCK_VALID 0x01
  210. /** Target firmware boot selected */
  211. #define IBFT_FL_TARGET_FIRMWARE_BOOT_SELECTED 0x02
  212. /** Target use Radius CHAP */
  213. #define IBFT_FL_TARGET_USE_CHAP 0x04
  214. /** Target use Radius rCHAP */
  215. #define IBFT_FL_TARGET_USE_RCHAP 0x08
  216. /* Values for chap_type */
  217. #define IBFT_CHAP_NONE 0 /**< No CHAP authentication */
  218. #define IBFT_CHAP_ONE_WAY 1 /**< One-way CHAP */
  219. #define IBFT_CHAP_MUTUAL 2 /**< Mutual CHAP */
  220. /**
  221. * iSCSI Boot Firmware Table (iBFT)
  222. */
  223. struct ibft_table {
  224. /** ACPI header */
  225. struct acpi_description_header acpi;
  226. /** Reserved */
  227. uint8_t reserved[12];
  228. /** Control structure */
  229. struct ibft_control control;
  230. } __attribute__ (( packed ));
  231. /**
  232. * iSCSI string block descriptor
  233. *
  234. * This is an internal structure that we use to keep track of the
  235. * allocation of string data.
  236. */
  237. struct ibft_string_block {
  238. /** The iBFT containing these strings */
  239. struct ibft_table *table;
  240. /** Offset of first free byte within iBFT */
  241. unsigned int offset;
  242. };
  243. /** Amount of space reserved for strings in a gPXE iBFT */
  244. #define IBFT_STRINGS_SIZE 384
  245. /**
  246. * An iBFT created by gPXE
  247. *
  248. */
  249. struct gpxe_ibft {
  250. /** The fixed section */
  251. struct ibft_table table;
  252. /** The Initiator section */
  253. struct ibft_initiator initiator __attribute__ (( aligned ( 16 ) ));
  254. /** The NIC section */
  255. struct ibft_nic nic __attribute__ (( aligned ( 16 ) ));
  256. /** The Target section */
  257. struct ibft_target target __attribute__ (( aligned ( 16 ) ));
  258. /** Strings block */
  259. char strings[IBFT_STRINGS_SIZE];
  260. } __attribute__ (( packed, aligned ( 16 ) ));
  261. struct net_device;
  262. struct iscsi_session;
  263. extern int ibft_fill_data ( struct net_device *netdev,
  264. struct iscsi_session *iscsi );
  265. #endif /* _GPXE_IBFT_H */