7 * IBM BladeCenter Open Fabric Manager (BOFM)
11 FILE_LICENCE ( GPL2_OR_LATER );
14 #include <ipxe/list.h>
16 #include <config/sideband.h>
20 * Present in %edi when the BIOS initialisation entry point is called,
21 * with the BOFM table pointer in %esi.
23 * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
24 * Re-Assignment Architecture document.
26 #define IBMs_SIGNATURE ( ( 'I' << 24 ) + ( 'B' << 16 ) + ( 'M' << 8 ) + ' ' )
30 * Returned in %edi from the BIOS initialisation entry point, with the
33 * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
34 * Re-Assignment Architecture document.
36 #define sIBM_SIGNATURE ( ( ' ' << 24 ) + ( 'I' << 16 ) + ( 'B' << 8 ) + 'M' )
38 /** @defgroup bofmrc BOFM return codes
40 * Defined in section 4.1.3 of the POST/BIOS BOFM I/O Address
41 * Re-Assignment Architecture document.
47 #define BOFM_SUCCESS 0x00
49 /** Invalid action string */
50 #define BOFM_ERR_INVALID_ACTION 0x01
52 /** Unsupported parameter structure version */
53 #define BOFM_ERR_UNSUPPORTED 0x02
55 /** Device error prohibited MAC/WWN update */
56 #define BOFM_ERR_DEVICE_ERROR 0x03
58 /** PCI reset required (may be combined with another return code) */
59 #define BOFM_PCI_RESET 0x80
63 /** Skip option ROM initialisation
65 * A BOFM BIOS may call the initialisation entry point multiple times;
66 * only the last call should result in actual initialisation.
68 * This flag is internal to iPXE.
70 #define BOFM_SKIP_INIT 0x80000000UL
74 * Defined in section 4.1 of the Open Fabric Manager Parameter
75 * Specification document.
77 struct bofm_global_header {
80 /** Subsignature (action string) */
82 /** Data structure version */
84 /** Data structure level */
86 /** Data structure length */
88 /** Data structure checksum */
90 /** Data structure profile */
92 /** Data structure global options */
94 /** Data structure sequence stamp */
96 } __attribute__ (( packed ));
98 /** BOFM table header signature
100 * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
101 * Re-Assignment Architecture document.
103 #define BOFM_IOAA_MAGIC ( 'I' + ( 'O' << 8 ) + ( 'A' << 16 ) + ( 'A' << 24 ) )
105 /** @defgroup bofmaction BOFM header subsignatures (action strings)
107 * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
108 * Re-Assignment Architecture document.
113 /** Update MAC/WWN */
114 #define BOFM_ACTION_UPDT ( 'U' + ( 'P' << 8 ) + ( 'D' << 16 ) + ( 'T' << 24 ) )
116 /** Restore MAC/WWN to factory default */
117 #define BOFM_ACTION_DFLT ( 'D' + ( 'F' << 8 ) + ( 'L' << 16 ) + ( 'T' << 24 ) )
119 /** Harvest MAC/WWN */
120 #define BOFM_ACTION_HVST ( 'H' + ( 'V' << 8 ) + ( 'S' << 16 ) + ( 'T' << 24 ) )
122 /** Update MAC/WWN and initialise device */
123 #define BOFM_ACTION_PARM ( 'P' + ( 'A' << 8 ) + ( 'R' << 16 ) + ( 'M' << 24 ) )
125 /** Just initialise the device */
126 #define BOFM_ACTION_NONE ( 'N' + ( 'O' << 8 ) + ( 'N' << 16 ) + ( 'E' << 24 ) )
130 /** BOFM section header
132 * Defined in section 4.2 of the Open Fabric Manager Parameter
133 * Specification document.
135 struct bofm_section_header {
140 } __attribute__ (( packed ));
142 /** @defgroup bofmsections BOFM section header signatures
144 * Defined in section 4.2 of the Open Fabric Manager Parameter
145 * Specification document.
150 /** EN start marker */
151 #define BOFM_EN_MAGIC ( ' ' + ( ' ' << 8 ) + ( 'E' << 16 ) + ( 'N' << 24 ) )
154 #define BOFM_DONE_MAGIC ( 'D' + ( 'O' << 8 ) + ( 'N' << 16 ) + ( 'E' << 24 ) )
158 /** BOFM Ethernet parameter entry
160 * Defined in section 5.1 of the Open Fabric Manager Parameter
161 * Specification document.
168 * Valid only if @c options indicates @c BOFM_EN_MAP_PFA
171 /** Slot or mezzanine number
173 * Valid only if @c options indicates @c BOFM_EN_MAP_SLOT_PORT
178 * Valid only if @c options indicates @c BOFM_EN_MAP_SLOT_PORT
181 /** Multi-port index */
183 /** VLAN tag for MAC address A */
187 * MAC address A is the sole MAC address, or the lower
188 * (inclusive) bound of a range of MAC addresses.
191 /** VLAN tag for MAC address B */
195 * MAC address B is unset, or the upper (inclusive) bound of a
196 * range of MAC addresses
199 } __attribute__ (( packed ));
201 /** @defgroup bofmenopts BOFM Ethernet parameter entry options
203 * Defined in section 5.1 of the Open Fabric Manager Parameter
204 * Specification document.
209 /** Port mapping mask */
210 #define BOFM_EN_MAP_MASK 0x0001
212 /** Port mapping is by PCI bus:dev.fn */
213 #define BOFM_EN_MAP_PFA 0x0000
215 /** Port mapping is by slot/port */
216 #define BOFM_EN_MAP_SLOT_PORT 0x0001
218 /** MAC address B is present */
219 #define BOFM_EN_EN_B 0x0002
221 /** VLAN tag for MAC address B is present */
222 #define BOFM_EN_VLAN_B 0x0004
224 /** MAC address A is present */
225 #define BOFM_EN_EN_A 0x0008
227 /** VLAN tag for MAC address A is present */
228 #define BOFM_EN_VLAN_A 0x0010
230 /** Entry consumption indicator mask */
231 #define BOFM_EN_CSM_MASK 0x00c0
233 /** Entry has not been used */
234 #define BOFM_EN_CSM_UNUSED 0x0000
236 /** Entry has been used successfully */
237 #define BOFM_EN_CSM_SUCCESS 0x0040
239 /** Entry has been used but failed */
240 #define BOFM_EN_CSM_FAILED 0x0080
242 /** Consumed entry change mask */
243 #define BOFM_EN_CHG_MASK 0x0100
245 /** Consumed entry is same as previous active entry */
246 #define BOFM_EN_CHG_UNCHANGED 0x0000
248 /** Consumed entry is different than previous active entry */
249 #define BOFM_EN_CHG_CHANGED 0x0100
251 /** Ignore values - it's harvest time */
252 #define BOFM_EN_USAGE_HARVEST 0x1000
254 /** Use entry values for assignment */
255 #define BOFM_EN_USAGE_ENTRY 0x0800
257 /** Use factory default values */
258 #define BOFM_EN_USAGE_DEFAULT 0x0400
260 /** Harvest complete */
261 #define BOFM_EN_HVST 0x2000
263 /** Harvest request mask */
264 #define BOFM_EN_RQ_HVST_MASK 0xc000
266 /** Do not harvest */
267 #define BOFM_EN_RQ_HVST_NONE 0x0000
269 /** Harvest factory default values */
270 #define BOFM_EN_RQ_HVST_DEFAULT 0x4000
272 /** Harvest active values */
273 #define BOFM_EN_RQ_HVST_ACTIVE 0xc000
277 /** BOFM magic value debug message format */
278 #define BOFM_MAGIC_FMT "'%c%c%c%c'"
280 /** BOFM magic value debug message arguments */
281 #define BOFM_MAGIC_ARGS( magic ) \
282 ( ( (magic) >> 0 ) & 0xff ), ( ( (magic) >> 8 ) & 0xff ), \
283 ( ( (magic) >> 16 ) & 0xff ), ( ( (magic) >> 24 ) & 0xff )
287 /** Underlying PCI device */
288 struct pci_device *pci;
289 /** BOFM device operations */
290 struct bofm_operations *op;
291 /** List of BOFM devices */
292 struct list_head list;
295 /** BOFM device operations */
296 struct bofm_operations {
297 /** Harvest Ethernet MAC
299 * @v bofm BOFM device
300 * @v mport Multi-port index
301 * @v mac MAC to fill in
302 * @ret rc Return status code
304 int ( * harvest ) ( struct bofm_device *bofm, unsigned int mport,
306 /** Update Ethernet MAC
308 * @v bofm BOFM device
309 * @v mport Multi-port index
311 * @ret rc Return status code
313 int ( * update ) ( struct bofm_device *bofm, unsigned int mport,
314 const uint8_t *mac );
317 /** BOFM driver table */
318 #define BOFM_DRIVERS __table ( struct pci_driver, "bofm_drivers" )
320 /** Declare a BOFM driver
322 * In the common case of non-BOFM-enabled builds, allow any BOFM code
323 * to be garbage-collected at link time to save space.
326 #define __bofm_driver __table_entry ( BOFM_DRIVERS, 01 )
328 #define __bofm_driver
332 * Initialise BOFM device
334 * @v bofm BOFM device
336 * @v op BOFM device operations
338 static inline __attribute__ (( always_inline )) void
339 bofm_init ( struct bofm_device *bofm, struct pci_device *pci,
340 struct bofm_operations *op ) {
345 extern int bofm_register ( struct bofm_device *bofm );
346 extern void bofm_unregister ( struct bofm_device *bofm );
347 extern int bofm_find_driver ( struct pci_device *pci );
348 extern int bofm ( userptr_t bofmtab, struct pci_device *pci );
349 extern void bofm_test ( struct pci_device *pci );
351 #endif /* _IPXE_BOFM_H */