您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ibft.h 7.0KB

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