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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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/scsi.h>
  43. #include <ipxe/in.h>
  44. /** iSCSI Boot Firmware Table signature */
  45. #define IBFT_SIG ACPI_SIGNATURE ( 'i', 'B', 'F', 'T' )
  46. /** Alignment of structures within iBFT */
  47. #define IBFT_ALIGN 16
  48. /** An offset from the start of the iBFT */
  49. typedef uint16_t ibft_off_t;
  50. /** Length of a string within the iBFT (excluding terminating NUL) */
  51. typedef uint16_t ibft_size_t;
  52. /** A string within the iBFT */
  53. struct ibft_string {
  54. /** Length of string */
  55. ibft_size_t len;
  56. /** Offset to string */
  57. ibft_off_t offset;
  58. } __attribute__ (( packed ));
  59. /** An IP address within the iBFT */
  60. struct ibft_ipaddr {
  61. /** Reserved; must be zero */
  62. uint16_t zeroes[5];
  63. /** Must be 0xffff if IPv4 address is present, otherwise zero */
  64. uint16_t ones;
  65. /** The IPv4 address, or zero if not present */
  66. struct in_addr in;
  67. } __attribute__ (( packed ));
  68. /**
  69. * iBFT structure header
  70. *
  71. * This structure is common to several sections within the iBFT.
  72. */
  73. struct ibft_header {
  74. /** Structure ID
  75. *
  76. * This is an IBFT_STRUCTURE_ID_XXX constant
  77. */
  78. uint8_t structure_id;
  79. /** Version (always 1) */
  80. uint8_t version;
  81. /** Length, including this header */
  82. uint16_t length;
  83. /** Index
  84. *
  85. * This is the number of the NIC or Target, when applicable.
  86. */
  87. uint8_t index;
  88. /** Flags */
  89. uint8_t flags;
  90. } __attribute__ (( packed ));
  91. /**
  92. * iBFT NIC and Target offset pair
  93. *
  94. * There is no implicit relation between the NIC and the Target, but
  95. * using this structure simplifies the table construction code while
  96. * matching the expected table layout.
  97. */
  98. struct ibft_offset_pair {
  99. /** Offset to NIC structure */
  100. ibft_off_t nic;
  101. /** Offset to Target structure */
  102. ibft_off_t target;
  103. } __attribute__ (( packed ));
  104. /**
  105. * iBFT Control structure
  106. *
  107. */
  108. struct ibft_control {
  109. /** Common header */
  110. struct ibft_header header;
  111. /** Extensions */
  112. uint16_t extensions;
  113. /** Offset to Initiator structure */
  114. ibft_off_t initiator;
  115. /** Offsets to NIC and Target structures */
  116. struct ibft_offset_pair pair[2];
  117. } __attribute__ (( packed ));
  118. /** Structure ID for Control section */
  119. #define IBFT_STRUCTURE_ID_CONTROL 0x01
  120. /** Attempt login only to specified target
  121. *
  122. * If this flag is not set, all targets will be logged in to.
  123. */
  124. #define IBFT_FL_CONTROL_SINGLE_LOGIN_ONLY 0x01
  125. /**
  126. * iBFT Initiator structure
  127. *
  128. */
  129. struct ibft_initiator {
  130. /** Common header */
  131. struct ibft_header header;
  132. /** iSNS server */
  133. struct ibft_ipaddr isns_server;
  134. /** SLP server */
  135. struct ibft_ipaddr slp_server;
  136. /** Primary and secondary Radius servers */
  137. struct ibft_ipaddr radius[2];
  138. /** Initiator name */
  139. struct ibft_string initiator_name;
  140. } __attribute__ (( packed ));
  141. /** Structure ID for Initiator section */
  142. #define IBFT_STRUCTURE_ID_INITIATOR 0x02
  143. /** Initiator block valid */
  144. #define IBFT_FL_INITIATOR_BLOCK_VALID 0x01
  145. /** Initiator firmware boot selected */
  146. #define IBFT_FL_INITIATOR_FIRMWARE_BOOT_SELECTED 0x02
  147. /**
  148. * iBFT NIC structure
  149. *
  150. */
  151. struct ibft_nic {
  152. /** Common header */
  153. struct ibft_header header;
  154. /** IP address */
  155. struct ibft_ipaddr ip_address;
  156. /** Subnet mask
  157. *
  158. * This is the length of the subnet mask in bits (e.g. /24).
  159. */
  160. uint8_t subnet_mask_prefix;
  161. /** Origin */
  162. uint8_t origin;
  163. /** Default gateway */
  164. struct ibft_ipaddr gateway;
  165. /** Primary and secondary DNS servers */
  166. struct ibft_ipaddr dns[2];
  167. /** DHCP server */
  168. struct ibft_ipaddr dhcp;
  169. /** VLAN tag */
  170. uint16_t vlan;
  171. /** MAC address */
  172. uint8_t mac_address[6];
  173. /** PCI bus:dev:fn */
  174. uint16_t pci_bus_dev_func;
  175. /** Hostname */
  176. struct ibft_string hostname;
  177. } __attribute__ (( packed ));
  178. /** Structure ID for NIC section */
  179. #define IBFT_STRUCTURE_ID_NIC 0x03
  180. /** NIC block valid */
  181. #define IBFT_FL_NIC_BLOCK_VALID 0x01
  182. /** NIC firmware boot selected */
  183. #define IBFT_FL_NIC_FIRMWARE_BOOT_SELECTED 0x02
  184. /** NIC global / link local */
  185. #define IBFT_FL_NIC_GLOBAL 0x04
  186. /** NIC IP address origin */
  187. #define IBFT_NIC_ORIGIN_OTHER 0x00
  188. #define IBFT_NIC_ORIGIN_MANUAL 0x01
  189. #define IBFT_NIC_ORIGIN_WELLKNOWN 0x02
  190. #define IBFT_NIC_ORIGIN_DHCP 0x03
  191. #define IBFT_NIC_ORIGIN_RA 0x04
  192. #define IBFT_NIC_ORIGIN_UNCHANGED 0x0f
  193. /**
  194. * iBFT Target structure
  195. *
  196. */
  197. struct ibft_target {
  198. /** Common header */
  199. struct ibft_header header;
  200. /** IP address */
  201. struct ibft_ipaddr ip_address;
  202. /** TCP port */
  203. uint16_t socket;
  204. /** Boot LUN */
  205. struct scsi_lun boot_lun;
  206. /** CHAP type
  207. *
  208. * This is an IBFT_CHAP_XXX constant.
  209. */
  210. uint8_t chap_type;
  211. /** NIC association */
  212. uint8_t nic_association;
  213. /** Target name */
  214. struct ibft_string target_name;
  215. /** CHAP name */
  216. struct ibft_string chap_name;
  217. /** CHAP secret */
  218. struct ibft_string chap_secret;
  219. /** Reverse CHAP name */
  220. struct ibft_string reverse_chap_name;
  221. /** Reverse CHAP secret */
  222. struct ibft_string reverse_chap_secret;
  223. } __attribute__ (( packed ));
  224. /** Structure ID for Target section */
  225. #define IBFT_STRUCTURE_ID_TARGET 0x04
  226. /** Target block valid */
  227. #define IBFT_FL_TARGET_BLOCK_VALID 0x01
  228. /** Target firmware boot selected */
  229. #define IBFT_FL_TARGET_FIRMWARE_BOOT_SELECTED 0x02
  230. /** Target use Radius CHAP */
  231. #define IBFT_FL_TARGET_USE_CHAP 0x04
  232. /** Target use Radius rCHAP */
  233. #define IBFT_FL_TARGET_USE_RCHAP 0x08
  234. /* Values for chap_type */
  235. #define IBFT_CHAP_NONE 0 /**< No CHAP authentication */
  236. #define IBFT_CHAP_ONE_WAY 1 /**< One-way CHAP */
  237. #define IBFT_CHAP_MUTUAL 2 /**< Mutual CHAP */
  238. /**
  239. * iSCSI Boot Firmware Table (iBFT)
  240. */
  241. struct ibft_table {
  242. /** ACPI header */
  243. struct acpi_header acpi;
  244. /** Reserved */
  245. uint8_t reserved[12];
  246. /** Control structure */
  247. struct ibft_control control;
  248. } __attribute__ (( packed ));
  249. extern struct acpi_model ibft_model __acpi_model;
  250. #endif /* _IPXE_IBFT_H */