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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. #ifndef _IPXE_IBFT_H
  2. #define _IPXE_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_LICENCE ( BSD2 );
  30. /** @file
  31. *
  32. * iSCSI boot firmware table
  33. *
  34. * The information in this file is derived from the document "iSCSI
  35. * Boot Firmware Table (iBFT)" as published by IBM at
  36. *
  37. * ftp://ftp.software.ibm.com/systems/support/system_x_pdf/ibm_iscsi_boot_firmware_table_v1.02.pdf
  38. *
  39. */
  40. #include <stdint.h>
  41. #include <ipxe/acpi.h>
  42. #include <ipxe/in.h>
  43. /** iSCSI Boot Firmware Table signature */
  44. #define IBFT_SIG "iBFT"
  45. /** An offset from the start of the iBFT */
  46. typedef uint16_t ibft_off_t;
  47. /** Length of a string within the iBFT (excluding terminating NUL) */
  48. typedef uint16_t ibft_size_t;
  49. /** A string within the iBFT */
  50. struct ibft_string {
  51. /** Length of string */
  52. ibft_size_t length;
  53. /** Offset to string */
  54. ibft_off_t offset;
  55. } __attribute__ (( packed ));
  56. /** An IP address within the iBFT */
  57. struct ibft_ipaddr {
  58. /** Reserved; must be zero */
  59. uint16_t zeroes[5];
  60. /** Must be 0xffff if IPv4 address is present, otherwise zero */
  61. uint16_t ones;
  62. /** The IPv4 address, or zero if not present */
  63. struct in_addr in;
  64. } __attribute__ (( packed ));
  65. /**
  66. * iBFT structure header
  67. *
  68. * This structure is common to several sections within the iBFT.
  69. */
  70. struct ibft_header {
  71. /** Structure ID
  72. *
  73. * This is an IBFT_STRUCTURE_ID_XXX constant
  74. */
  75. uint8_t structure_id;
  76. /** Version (always 1) */
  77. uint8_t version;
  78. /** Length, including this header */
  79. uint16_t length;
  80. /** Index
  81. *
  82. * This is the number of the NIC or Target, when applicable.
  83. */
  84. uint8_t index;
  85. /** Flags */
  86. uint8_t flags;
  87. } __attribute__ (( packed ));
  88. /**
  89. * iBFT Control structure
  90. *
  91. */
  92. struct ibft_control {
  93. /** Common header */
  94. struct ibft_header header;
  95. /** Extensions */
  96. uint16_t extensions;
  97. /** Offset to Initiator structure */
  98. ibft_off_t initiator;
  99. /** Offset to NIC structure for NIC 0 */
  100. ibft_off_t nic_0;
  101. /** Offset to Target structure for target 0 */
  102. ibft_off_t target_0;
  103. /** Offset to NIC structure for NIC 1 */
  104. ibft_off_t nic_1;
  105. /** Offset to Target structure for target 1 */
  106. ibft_off_t target_1;
  107. } __attribute__ (( packed ));
  108. /** Structure ID for Control section */
  109. #define IBFT_STRUCTURE_ID_CONTROL 0x01
  110. /** Attempt login only to specified target
  111. *
  112. * If this flag is not set, all targets will be logged in to.
  113. */
  114. #define IBFT_FL_CONTROL_SINGLE_LOGIN_ONLY 0x01
  115. /**
  116. * iBFT Initiator structure
  117. *
  118. */
  119. struct ibft_initiator {
  120. /** Common header */
  121. struct ibft_header header;
  122. /** iSNS server */
  123. struct ibft_ipaddr isns_server;
  124. /** SLP server */
  125. struct ibft_ipaddr slp_server;
  126. /** Primary and secondary Radius servers */
  127. struct ibft_ipaddr radius[2];
  128. /** Initiator name */
  129. struct ibft_string initiator_name;
  130. } __attribute__ (( packed ));
  131. /** Structure ID for Initiator section */
  132. #define IBFT_STRUCTURE_ID_INITIATOR 0x02
  133. /** Initiator block valid */
  134. #define IBFT_FL_INITIATOR_BLOCK_VALID 0x01
  135. /** Initiator firmware boot selected */
  136. #define IBFT_FL_INITIATOR_FIRMWARE_BOOT_SELECTED 0x02
  137. /**
  138. * iBFT NIC structure
  139. *
  140. */
  141. struct ibft_nic {
  142. /** Common header */
  143. struct ibft_header header;
  144. /** IP address */
  145. struct ibft_ipaddr ip_address;
  146. /** Subnet mask
  147. *
  148. * This is the length of the subnet mask in bits (e.g. /24).
  149. */
  150. uint8_t subnet_mask_prefix;
  151. /** Origin */
  152. uint8_t origin;
  153. /** Default gateway */
  154. struct ibft_ipaddr gateway;
  155. /** Primary and secondary DNS servers */
  156. struct ibft_ipaddr dns[2];
  157. /** DHCP server */
  158. struct ibft_ipaddr dhcp;
  159. /** VLAN tag */
  160. uint16_t vlan;
  161. /** MAC address */
  162. uint8_t mac_address[6];
  163. /** PCI bus:dev:fn */
  164. uint16_t pci_bus_dev_func;
  165. /** Hostname */
  166. struct ibft_string hostname;
  167. } __attribute__ (( packed ));
  168. /** Structure ID for NIC section */
  169. #define IBFT_STRUCTURE_ID_NIC 0x03
  170. /** NIC block valid */
  171. #define IBFT_FL_NIC_BLOCK_VALID 0x01
  172. /** NIC firmware boot selected */
  173. #define IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED 0x02
  174. /** NIC global / link local */
  175. #define IBFT_FL_NIC_GLOBAL 0x04
  176. /**
  177. * iBFT Target structure
  178. *
  179. */
  180. struct ibft_target {
  181. /** Common header */
  182. struct ibft_header header;
  183. /** IP address */
  184. struct ibft_ipaddr ip_address;
  185. /** TCP port */
  186. uint16_t socket;
  187. /** Boot LUN */
  188. uint64_t boot_lun;
  189. /** CHAP type
  190. *
  191. * This is an IBFT_CHAP_XXX constant.
  192. */
  193. uint8_t chap_type;
  194. /** NIC association */
  195. uint8_t nic_association;
  196. /** Target name */
  197. struct ibft_string target_name;
  198. /** CHAP name */
  199. struct ibft_string chap_name;
  200. /** CHAP secret */
  201. struct ibft_string chap_secret;
  202. /** Reverse CHAP name */
  203. struct ibft_string reverse_chap_name;
  204. /** Reverse CHAP secret */
  205. struct ibft_string reverse_chap_secret;
  206. } __attribute__ (( packed ));
  207. /** Structure ID for Target section */
  208. #define IBFT_STRUCTURE_ID_TARGET 0x04
  209. /** Target block valid */
  210. #define IBFT_FL_TARGET_BLOCK_VALID 0x01
  211. /** Target firmware boot selected */
  212. #define IBFT_FL_TARGET_FIRMWARE_BOOT_SELECTED 0x02
  213. /** Target use Radius CHAP */
  214. #define IBFT_FL_TARGET_USE_CHAP 0x04
  215. /** Target use Radius rCHAP */
  216. #define IBFT_FL_TARGET_USE_RCHAP 0x08
  217. /* Values for chap_type */
  218. #define IBFT_CHAP_NONE 0 /**< No CHAP authentication */
  219. #define IBFT_CHAP_ONE_WAY 1 /**< One-way CHAP */
  220. #define IBFT_CHAP_MUTUAL 2 /**< Mutual CHAP */
  221. /**
  222. * iSCSI Boot Firmware Table (iBFT)
  223. */
  224. struct ibft_table {
  225. /** ACPI header */
  226. struct acpi_description_header acpi;
  227. /** Reserved */
  228. uint8_t reserved[12];
  229. /** Control structure */
  230. struct ibft_control control;
  231. } __attribute__ (( packed ));
  232. /**
  233. * iSCSI string block descriptor
  234. *
  235. * This is an internal structure that we use to keep track of the
  236. * allocation of string data.
  237. */
  238. struct ibft_string_block {
  239. /** The iBFT containing these strings */
  240. struct ibft_table *table;
  241. /** Offset of first free byte within iBFT */
  242. unsigned int offset;
  243. };
  244. /** Amount of space reserved for strings in a iPXE iBFT */
  245. #define IBFT_STRINGS_SIZE 384
  246. /**
  247. * An iBFT created by iPXE
  248. *
  249. */
  250. struct ipxe_ibft {
  251. /** The fixed section */
  252. struct ibft_table table;
  253. /** The Initiator section */
  254. struct ibft_initiator initiator __attribute__ (( aligned ( 16 ) ));
  255. /** The NIC section */
  256. struct ibft_nic nic __attribute__ (( aligned ( 16 ) ));
  257. /** The Target section */
  258. struct ibft_target target __attribute__ (( aligned ( 16 ) ));
  259. /** Strings block */
  260. char strings[IBFT_STRINGS_SIZE];
  261. } __attribute__ (( packed, aligned ( 16 ) ));
  262. struct net_device;
  263. struct iscsi_session;
  264. extern int ibft_fill_data ( struct net_device *netdev,
  265. struct iscsi_session *iscsi );
  266. #endif /* _IPXE_IBFT_H */