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.

bofm.h 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. #ifndef _IPXE_BOFM_H
  2. #define _IPXE_BOFM_H
  3. /**
  4. * @file
  5. *
  6. * IBM BladeCenter Open Fabric Manager (BOFM)
  7. *
  8. */
  9. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  10. #include <stdint.h>
  11. #include <ipxe/list.h>
  12. #include <ipxe/pci.h>
  13. #include <config/sideband.h>
  14. /** 'IBM ' signature
  15. *
  16. * Present in %edi when the BIOS initialisation entry point is called,
  17. * with the BOFM table pointer in %esi.
  18. *
  19. * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
  20. * Re-Assignment Architecture document.
  21. */
  22. #define IBMs_SIGNATURE ( ( 'I' << 24 ) + ( 'B' << 16 ) + ( 'M' << 8 ) + ' ' )
  23. /** ' IBM' signature
  24. *
  25. * Returned in %edi from the BIOS initialisation entry point, with the
  26. * return code in %dl.
  27. *
  28. * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
  29. * Re-Assignment Architecture document.
  30. */
  31. #define sIBM_SIGNATURE ( ( ' ' << 24 ) + ( 'I' << 16 ) + ( 'B' << 8 ) + 'M' )
  32. /** @defgroup bofmrc BOFM return codes
  33. *
  34. * Defined in section 4.1.3 of the POST/BIOS BOFM I/O Address
  35. * Re-Assignment Architecture document.
  36. *
  37. * @{
  38. */
  39. /** Successful */
  40. #define BOFM_SUCCESS 0x00
  41. /** Invalid action string */
  42. #define BOFM_ERR_INVALID_ACTION 0x01
  43. /** Unsupported parameter structure version */
  44. #define BOFM_ERR_UNSUPPORTED 0x02
  45. /** Device error prohibited MAC/WWN update */
  46. #define BOFM_ERR_DEVICE_ERROR 0x03
  47. /** PCI reset required (may be combined with another return code) */
  48. #define BOFM_PCI_RESET 0x80
  49. /** @} */
  50. /** Skip option ROM initialisation
  51. *
  52. * A BOFM BIOS may call the initialisation entry point multiple times;
  53. * only the last call should result in actual initialisation.
  54. *
  55. * This flag is internal to iPXE.
  56. */
  57. #define BOFM_SKIP_INIT 0x80000000UL
  58. /** BOFM table header
  59. *
  60. * Defined in section 4.1 of the Open Fabric Manager Parameter
  61. * Specification document.
  62. */
  63. struct bofm_global_header {
  64. /** Signature */
  65. uint32_t magic;
  66. /** Subsignature (action string) */
  67. uint32_t action;
  68. /** Data structure version */
  69. uint8_t version;
  70. /** Data structure level */
  71. uint8_t level;
  72. /** Data structure length */
  73. uint16_t length;
  74. /** Data structure checksum */
  75. uint8_t checksum;
  76. /** Data structure profile */
  77. char profile[32];
  78. /** Data structure global options */
  79. uint32_t options;
  80. /** Data structure sequence stamp */
  81. uint32_t sequence;
  82. } __attribute__ (( packed ));
  83. /** BOFM table header signature
  84. *
  85. * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
  86. * Re-Assignment Architecture document.
  87. */
  88. #define BOFM_IOAA_MAGIC ( 'I' + ( 'O' << 8 ) + ( 'A' << 16 ) + ( 'A' << 24 ) )
  89. /** @defgroup bofmaction BOFM header subsignatures (action strings)
  90. *
  91. * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
  92. * Re-Assignment Architecture document.
  93. *
  94. * @{
  95. */
  96. /** Update MAC/WWN */
  97. #define BOFM_ACTION_UPDT ( 'U' + ( 'P' << 8 ) + ( 'D' << 16 ) + ( 'T' << 24 ) )
  98. /** Restore MAC/WWN to factory default */
  99. #define BOFM_ACTION_DFLT ( 'D' + ( 'F' << 8 ) + ( 'L' << 16 ) + ( 'T' << 24 ) )
  100. /** Harvest MAC/WWN */
  101. #define BOFM_ACTION_HVST ( 'H' + ( 'V' << 8 ) + ( 'S' << 16 ) + ( 'T' << 24 ) )
  102. /** Update MAC/WWN and initialise device */
  103. #define BOFM_ACTION_PARM ( 'P' + ( 'A' << 8 ) + ( 'R' << 16 ) + ( 'M' << 24 ) )
  104. /** Just initialise the device */
  105. #define BOFM_ACTION_NONE ( 'N' + ( 'O' << 8 ) + ( 'N' << 16 ) + ( 'E' << 24 ) )
  106. /** @} */
  107. /** BOFM section header
  108. *
  109. * Defined in section 4.2 of the Open Fabric Manager Parameter
  110. * Specification document.
  111. */
  112. struct bofm_section_header {
  113. /** Signature */
  114. uint32_t magic;
  115. /** Length */
  116. uint16_t length;
  117. } __attribute__ (( packed ));
  118. /** @defgroup bofmsections BOFM section header signatures
  119. *
  120. * Defined in section 4.2 of the Open Fabric Manager Parameter
  121. * Specification document.
  122. *
  123. * @{
  124. */
  125. /** EN start marker */
  126. #define BOFM_EN_MAGIC ( ' ' + ( ' ' << 8 ) + ( 'E' << 16 ) + ( 'N' << 24 ) )
  127. /** End marker */
  128. #define BOFM_DONE_MAGIC ( 'D' + ( 'O' << 8 ) + ( 'N' << 16 ) + ( 'E' << 24 ) )
  129. /** @} */
  130. /** BOFM Ethernet parameter entry
  131. *
  132. * Defined in section 5.1 of the Open Fabric Manager Parameter
  133. * Specification document.
  134. */
  135. struct bofm_en {
  136. /** Options */
  137. uint16_t options;
  138. /** PCI bus:dev.fn
  139. *
  140. * Valid only if @c options indicates @c BOFM_EN_MAP_PFA
  141. */
  142. uint16_t busdevfn;
  143. /** Slot or mezzanine number
  144. *
  145. * Valid only if @c options indicates @c BOFM_EN_MAP_SLOT_PORT
  146. */
  147. uint8_t slot;
  148. /** Port number
  149. *
  150. * Valid only if @c options indicates @c BOFM_EN_MAP_SLOT_PORT
  151. */
  152. uint8_t port;
  153. /** Multi-port index */
  154. uint8_t mport;
  155. /** VLAN tag for MAC address A */
  156. uint16_t vlan_a;
  157. /** MAC address A
  158. *
  159. * MAC address A is the sole MAC address, or the lower
  160. * (inclusive) bound of a range of MAC addresses.
  161. */
  162. uint8_t mac_a[6];
  163. /** VLAN tag for MAC address B */
  164. uint16_t vlan_b;
  165. /** MAC address B
  166. *
  167. * MAC address B is unset, or the upper (inclusive) bound of a
  168. * range of MAC addresses
  169. */
  170. uint8_t mac_b[6];
  171. } __attribute__ (( packed ));
  172. /** @defgroup bofmenopts BOFM Ethernet parameter entry options
  173. *
  174. * Defined in section 5.1 of the Open Fabric Manager Parameter
  175. * Specification document.
  176. *
  177. * @{
  178. */
  179. /** Port mapping mask */
  180. #define BOFM_EN_MAP_MASK 0x0001
  181. /** Port mapping is by PCI bus:dev.fn */
  182. #define BOFM_EN_MAP_PFA 0x0000
  183. /** Port mapping is by slot/port */
  184. #define BOFM_EN_MAP_SLOT_PORT 0x0001
  185. /** MAC address B is present */
  186. #define BOFM_EN_EN_B 0x0002
  187. /** VLAN tag for MAC address B is present */
  188. #define BOFM_EN_VLAN_B 0x0004
  189. /** MAC address A is present */
  190. #define BOFM_EN_EN_A 0x0008
  191. /** VLAN tag for MAC address A is present */
  192. #define BOFM_EN_VLAN_A 0x0010
  193. /** Entry consumption indicator mask */
  194. #define BOFM_EN_CSM_MASK 0x00c0
  195. /** Entry has not been used */
  196. #define BOFM_EN_CSM_UNUSED 0x0000
  197. /** Entry has been used successfully */
  198. #define BOFM_EN_CSM_SUCCESS 0x0040
  199. /** Entry has been used but failed */
  200. #define BOFM_EN_CSM_FAILED 0x0080
  201. /** Consumed entry change mask */
  202. #define BOFM_EN_CHG_MASK 0x0100
  203. /** Consumed entry is same as previous active entry */
  204. #define BOFM_EN_CHG_UNCHANGED 0x0000
  205. /** Consumed entry is different than previous active entry */
  206. #define BOFM_EN_CHG_CHANGED 0x0100
  207. /** Ignore values - it's harvest time */
  208. #define BOFM_EN_USAGE_HARVEST 0x1000
  209. /** Use entry values for assignment */
  210. #define BOFM_EN_USAGE_ENTRY 0x0800
  211. /** Use factory default values */
  212. #define BOFM_EN_USAGE_DEFAULT 0x0400
  213. /** Harvest complete */
  214. #define BOFM_EN_HVST 0x2000
  215. /** Harvest request mask */
  216. #define BOFM_EN_RQ_HVST_MASK 0xc000
  217. /** Do not harvest */
  218. #define BOFM_EN_RQ_HVST_NONE 0x0000
  219. /** Harvest factory default values */
  220. #define BOFM_EN_RQ_HVST_DEFAULT 0x4000
  221. /** Harvest active values */
  222. #define BOFM_EN_RQ_HVST_ACTIVE 0xc000
  223. /** @} */
  224. /** BOFM magic value debug message format */
  225. #define BOFM_MAGIC_FMT "'%c%c%c%c'"
  226. /** BOFM magic value debug message arguments */
  227. #define BOFM_MAGIC_ARGS( magic ) \
  228. ( ( (magic) >> 0 ) & 0xff ), ( ( (magic) >> 8 ) & 0xff ), \
  229. ( ( (magic) >> 16 ) & 0xff ), ( ( (magic) >> 24 ) & 0xff )
  230. /** A BOFM device */
  231. struct bofm_device {
  232. /** Underlying PCI device */
  233. struct pci_device *pci;
  234. /** BOFM device operations */
  235. struct bofm_operations *op;
  236. /** List of BOFM devices */
  237. struct list_head list;
  238. };
  239. /** BOFM device operations */
  240. struct bofm_operations {
  241. /** Harvest Ethernet MAC
  242. *
  243. * @v bofm BOFM device
  244. * @v mport Multi-port index
  245. * @v mac MAC to fill in
  246. * @ret rc Return status code
  247. */
  248. int ( * harvest ) ( struct bofm_device *bofm, unsigned int mport,
  249. uint8_t *mac );
  250. /** Update Ethernet MAC
  251. *
  252. * @v bofm BOFM device
  253. * @v mport Multi-port index
  254. * @v mac New MAC
  255. * @ret rc Return status code
  256. */
  257. int ( * update ) ( struct bofm_device *bofm, unsigned int mport,
  258. const uint8_t *mac );
  259. };
  260. /** BOFM driver table */
  261. #define BOFM_DRIVERS __table ( struct pci_driver, "bofm_drivers" )
  262. /** Declare a BOFM driver
  263. *
  264. * In the common case of non-BOFM-enabled builds, allow any BOFM code
  265. * to be garbage-collected at link time to save space.
  266. */
  267. #ifdef CONFIG_BOFM
  268. #define __bofm_driver __table_entry ( BOFM_DRIVERS, 01 )
  269. #else
  270. #define __bofm_driver
  271. #endif
  272. /**
  273. * Initialise BOFM device
  274. *
  275. * @v bofm BOFM device
  276. * @v pci PCI device
  277. * @v op BOFM device operations
  278. */
  279. static inline __attribute__ (( always_inline )) void
  280. bofm_init ( struct bofm_device *bofm, struct pci_device *pci,
  281. struct bofm_operations *op ) {
  282. bofm->pci = pci;
  283. bofm->op = op;
  284. }
  285. extern int bofm_register ( struct bofm_device *bofm );
  286. extern void bofm_unregister ( struct bofm_device *bofm );
  287. extern int bofm_find_driver ( struct pci_device *pci );
  288. extern int bofm ( userptr_t bofmtab, struct pci_device *pci );
  289. extern void bofm_test ( struct pci_device *pci );
  290. #endif /* _IPXE_BOFM_H */