iPXE
bofm.h
Go to the documentation of this file.
00001 #ifndef _IPXE_BOFM_H
00002 #define _IPXE_BOFM_H
00003 
00004 /**
00005  * @file
00006  *
00007  * IBM BladeCenter Open Fabric Manager (BOFM)
00008  *
00009  */
00010 
00011 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00012 
00013 #include <stdint.h>
00014 #include <ipxe/list.h>
00015 #include <ipxe/pci.h>
00016 #include <config/sideband.h>
00017 
00018 /** 'IBM ' signature
00019  *
00020  * Present in %edi when the BIOS initialisation entry point is called,
00021  * with the BOFM table pointer in %esi.
00022  *
00023  * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
00024  * Re-Assignment Architecture document.
00025  */
00026 #define IBMs_SIGNATURE ( ( 'I' << 24 ) + ( 'B' << 16 ) + ( 'M' << 8 ) + ' ' )
00027 
00028 /** ' IBM' signature
00029  *
00030  * Returned in %edi from the BIOS initialisation entry point, with the
00031  * return code in %dl.
00032  *
00033  * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
00034  * Re-Assignment Architecture document.
00035  */
00036 #define sIBM_SIGNATURE ( ( ' ' << 24 ) + ( 'I' << 16 ) + ( 'B' << 8 ) + 'M' )
00037 
00038 /** @defgroup bofmrc BOFM return codes
00039  *
00040  * Defined in section 4.1.3 of the POST/BIOS BOFM I/O Address
00041  * Re-Assignment Architecture document.
00042  *
00043  * @{
00044  */
00045 
00046 /** Successful */
00047 #define BOFM_SUCCESS 0x00
00048 
00049 /** Invalid action string */
00050 #define BOFM_ERR_INVALID_ACTION 0x01
00051 
00052 /** Unsupported parameter structure version */
00053 #define BOFM_ERR_UNSUPPORTED 0x02
00054 
00055 /** Device error prohibited MAC/WWN update */
00056 #define BOFM_ERR_DEVICE_ERROR 0x03
00057 
00058 /** PCI reset required (may be combined with another return code) */
00059 #define BOFM_PCI_RESET 0x80
00060 
00061 /** @} */
00062 
00063 /** Skip option ROM initialisation
00064  *
00065  * A BOFM BIOS may call the initialisation entry point multiple times;
00066  * only the last call should result in actual initialisation.
00067  *
00068  * This flag is internal to iPXE.
00069  */
00070 #define BOFM_SKIP_INIT 0x80000000UL
00071 
00072 /** BOFM table header
00073  *
00074  * Defined in section 4.1 of the Open Fabric Manager Parameter
00075  * Specification document.
00076  */
00077 struct bofm_global_header {
00078         /** Signature */
00079         uint32_t magic;
00080         /** Subsignature (action string) */
00081         uint32_t action;
00082         /** Data structure version */
00083         uint8_t version;
00084         /** Data structure level */
00085         uint8_t level;
00086         /** Data structure length */
00087         uint16_t length;
00088         /** Data structure checksum */
00089         uint8_t checksum;
00090         /** Data structure profile */
00091         char profile[32];
00092         /** Data structure global options */
00093         uint32_t options;
00094         /** Data structure sequence stamp */
00095         uint32_t sequence;
00096 } __attribute__ (( packed ));
00097 
00098 /** BOFM table header signature
00099  *
00100  * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
00101  * Re-Assignment Architecture document.
00102  */
00103 #define BOFM_IOAA_MAGIC  ( 'I' + ( 'O' << 8 ) + ( 'A' << 16 ) + ( 'A' << 24 ) )
00104 
00105 /** @defgroup bofmaction BOFM header subsignatures (action strings)
00106  *
00107  * Defined in section 4.1.2 of the POST/BIOS BOFM I/O Address
00108  * Re-Assignment Architecture document.
00109  *
00110  * @{
00111  */
00112 
00113 /** Update MAC/WWN */
00114 #define BOFM_ACTION_UPDT ( 'U' + ( 'P' << 8 ) + ( 'D' << 16 ) + ( 'T' << 24 ) )
00115 
00116 /** Restore MAC/WWN to factory default */
00117 #define BOFM_ACTION_DFLT ( 'D' + ( 'F' << 8 ) + ( 'L' << 16 ) + ( 'T' << 24 ) )
00118 
00119 /** Harvest MAC/WWN */
00120 #define BOFM_ACTION_HVST ( 'H' + ( 'V' << 8 ) + ( 'S' << 16 ) + ( 'T' << 24 ) )
00121 
00122 /** Update MAC/WWN and initialise device */
00123 #define BOFM_ACTION_PARM ( 'P' + ( 'A' << 8 ) + ( 'R' << 16 ) + ( 'M' << 24 ) )
00124 
00125 /** Just initialise the device */
00126 #define BOFM_ACTION_NONE ( 'N' + ( 'O' << 8 ) + ( 'N' << 16 ) + ( 'E' << 24 ) )
00127 
00128 /** @} */
00129 
00130 /** BOFM section header
00131  *
00132  * Defined in section 4.2 of the Open Fabric Manager Parameter
00133  * Specification document.
00134  */
00135 struct bofm_section_header {
00136         /** Signature */
00137         uint32_t magic;
00138         /** Length */
00139         uint16_t length;
00140 } __attribute__ (( packed ));
00141 
00142 /** @defgroup bofmsections BOFM section header signatures
00143  *
00144  * Defined in section 4.2 of the Open Fabric Manager Parameter
00145  * Specification document.
00146  *
00147  * @{
00148  */
00149 
00150 /** EN start marker */
00151 #define BOFM_EN_MAGIC    ( ' ' + ( ' ' << 8 ) + ( 'E' << 16 ) + ( 'N' << 24 ) )
00152 
00153 /** End marker */
00154 #define BOFM_DONE_MAGIC  ( 'D' + ( 'O' << 8 ) + ( 'N' << 16 ) + ( 'E' << 24 ) )
00155 
00156 /** @} */
00157 
00158 /** BOFM Ethernet parameter entry
00159  *
00160  * Defined in section 5.1 of the Open Fabric Manager Parameter
00161  * Specification document.
00162  */
00163 struct bofm_en {
00164         /** Options */
00165         uint16_t options;
00166         /** PCI bus:dev.fn
00167          *
00168          * Valid only if @c options indicates @c BOFM_EN_MAP_PFA
00169          */
00170         uint16_t busdevfn;
00171         /** Slot or mezzanine number
00172          *
00173          * Valid only if @c options indicates @c BOFM_EN_MAP_SLOT_PORT
00174          */
00175         uint8_t slot;
00176         /** Port number
00177          *
00178          * Valid only if @c options indicates @c BOFM_EN_MAP_SLOT_PORT
00179          */
00180         uint8_t port;
00181         /** Multi-port index */
00182         uint8_t mport;
00183         /** VLAN tag for MAC address A */
00184         uint16_t vlan_a;
00185         /** MAC address A
00186          *
00187          * MAC address A is the sole MAC address, or the lower
00188          * (inclusive) bound of a range of MAC addresses.
00189          */
00190         uint8_t mac_a[6];
00191         /** VLAN tag for MAC address B */
00192         uint16_t vlan_b;
00193         /** MAC address B
00194          *
00195          * MAC address B is unset, or the upper (inclusive) bound of a
00196          * range of MAC addresses
00197          */
00198         uint8_t mac_b[6];
00199 } __attribute__ (( packed ));
00200 
00201 /** @defgroup bofmenopts BOFM Ethernet parameter entry options
00202  *
00203  * Defined in section 5.1 of the Open Fabric Manager Parameter
00204  * Specification document.
00205  *
00206  * @{
00207  */
00208 
00209 /** Port mapping mask */
00210 #define BOFM_EN_MAP_MASK        0x0001
00211 
00212 /** Port mapping is by PCI bus:dev.fn */
00213 #define BOFM_EN_MAP_PFA                 0x0000
00214 
00215 /** Port mapping is by slot/port */
00216 #define BOFM_EN_MAP_SLOT_PORT           0x0001
00217 
00218 /** MAC address B is present */
00219 #define BOFM_EN_EN_B            0x0002
00220 
00221 /** VLAN tag for MAC address B is present */
00222 #define BOFM_EN_VLAN_B          0x0004
00223 
00224 /** MAC address A is present */
00225 #define BOFM_EN_EN_A            0x0008
00226 
00227 /** VLAN tag for MAC address A is present */
00228 #define BOFM_EN_VLAN_A          0x0010
00229 
00230 /** Entry consumption indicator mask */
00231 #define BOFM_EN_CSM_MASK        0x00c0
00232 
00233 /** Entry has not been used */
00234 #define BOFM_EN_CSM_UNUSED              0x0000
00235 
00236 /** Entry has been used successfully */
00237 #define BOFM_EN_CSM_SUCCESS             0x0040
00238 
00239 /** Entry has been used but failed */
00240 #define BOFM_EN_CSM_FAILED              0x0080
00241 
00242 /** Consumed entry change mask */
00243 #define BOFM_EN_CHG_MASK        0x0100
00244 
00245 /** Consumed entry is same as previous active entry */
00246 #define BOFM_EN_CHG_UNCHANGED           0x0000
00247 
00248 /** Consumed entry is different than previous active entry */
00249 #define BOFM_EN_CHG_CHANGED             0x0100
00250 
00251 /** Ignore values - it's harvest time */
00252 #define BOFM_EN_USAGE_HARVEST   0x1000
00253 
00254 /** Use entry values for assignment */
00255 #define BOFM_EN_USAGE_ENTRY     0x0800
00256 
00257 /** Use factory default values */
00258 #define BOFM_EN_USAGE_DEFAULT   0x0400
00259 
00260 /** Harvest complete */
00261 #define BOFM_EN_HVST            0x2000
00262 
00263 /** Harvest request mask */
00264 #define BOFM_EN_RQ_HVST_MASK    0xc000
00265 
00266 /** Do not harvest */
00267 #define BOFM_EN_RQ_HVST_NONE            0x0000
00268 
00269 /** Harvest factory default values */
00270 #define BOFM_EN_RQ_HVST_DEFAULT         0x4000
00271 
00272 /** Harvest active values */
00273 #define BOFM_EN_RQ_HVST_ACTIVE          0xc000
00274 
00275 /** @} */
00276 
00277 /** BOFM magic value debug message format */
00278 #define BOFM_MAGIC_FMT "'%c%c%c%c'"
00279 
00280 /** BOFM magic value debug message arguments */
00281 #define BOFM_MAGIC_ARGS( magic )                                        \
00282         ( ( (magic) >> 0 ) & 0xff ), ( ( (magic) >> 8 ) & 0xff ),       \
00283         ( ( (magic) >> 16 ) & 0xff ), ( ( (magic) >> 24 ) & 0xff )
00284 
00285 /** A BOFM device */
00286 struct bofm_device {
00287         /** Underlying PCI device */
00288         struct pci_device *pci;
00289         /** BOFM device operations */
00290         struct bofm_operations *op;
00291         /** List of BOFM devices */
00292         struct list_head list;
00293 };
00294 
00295 /** BOFM device operations */
00296 struct bofm_operations {
00297         /** Harvest Ethernet MAC
00298          *
00299          * @v bofm              BOFM device
00300          * @v mport             Multi-port index
00301          * @v mac               MAC to fill in
00302          * @ret rc              Return status code
00303          */
00304         int ( * harvest ) ( struct bofm_device *bofm, unsigned int mport,
00305                             uint8_t *mac );
00306         /** Update Ethernet MAC
00307          *
00308          * @v bofm              BOFM device
00309          * @v mport             Multi-port index
00310          * @v mac               New MAC
00311          * @ret rc              Return status code
00312          */
00313         int ( * update ) ( struct bofm_device *bofm, unsigned int mport,
00314                            const uint8_t *mac );
00315 };
00316 
00317 /** BOFM driver table */
00318 #define BOFM_DRIVERS __table ( struct pci_driver, "bofm_drivers" )
00319 
00320 /** Declare a BOFM driver
00321  *
00322  * In the common case of non-BOFM-enabled builds, allow any BOFM code
00323  * to be garbage-collected at link time to save space.
00324  */
00325 #ifdef CONFIG_BOFM
00326 #define __bofm_driver __table_entry ( BOFM_DRIVERS, 01 )
00327 #else
00328 #define __bofm_driver
00329 #endif
00330 
00331 /**
00332  * Initialise BOFM device
00333  *
00334  * @v bofm              BOFM device
00335  * @v pci               PCI device
00336  * @v op                BOFM device operations
00337  */
00338 static inline __attribute__ (( always_inline )) void
00339 bofm_init ( struct bofm_device *bofm, struct pci_device *pci,
00340             struct bofm_operations *op ) {
00341         bofm->pci = pci;
00342         bofm->op = op;
00343 }
00344 
00345 extern int bofm_register ( struct bofm_device *bofm );
00346 extern void bofm_unregister ( struct bofm_device *bofm );
00347 extern int bofm_find_driver ( struct pci_device *pci );
00348 extern int bofm ( userptr_t bofmtab, struct pci_device *pci );
00349 extern void bofm_test ( struct pci_device *pci );
00350 
00351 #endif /* _IPXE_BOFM_H */