iPXE
bofm_test.c File Reference

IBM BladeCenter Open Fabric Manager (BOFM) tests. More...

#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <byteswap.h>
#include <ipxe/init.h>
#include <ipxe/pci.h>
#include <ipxe/ethernet.h>
#include <ipxe/bofm.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
void bofm_test (struct pci_device *pci)
 Perform BOFM test.
static int bofm_dummy_harvest (struct bofm_device *bofm, unsigned int mport, uint8_t *mac)
 Harvest dummy Ethernet MAC.
static int bofm_dummy_update (struct bofm_device *bofm __unused, unsigned int mport, const uint8_t *mac)
 Update Ethernet MAC for BOFM.
static int bofm_dummy_probe (struct pci_device *pci)
 Probe dummy BOFM device.
static void bofm_dummy_remove (struct pci_device *pci)
 Remove dummy BOFM device.
static void bofm_test_init (void)
 Perform BOFM test at initialisation time.
struct init_fn bofm_test_init_fn __init_fn (INIT_NORMAL)
 BOFM test initialisation function.

Variables

struct { 
   struct bofm_global_header   header 
   struct bofm_section_header   en_header 
   struct bofm_en   en 
   struct bofm_section_header   done 
bofmtab_harvest
 Harvest test table.
struct { 
   struct bofm_global_header   header 
   struct bofm_section_header   en_header 
   struct bofm_en   en 
   struct bofm_section_header   done 
bofmtab_update
 Update test table.
static struct bofm_operations bofm_dummy_operations
 Dummy BOFM operations.
static struct bofm_device bofm_dummy
 Dummy BOFM device.
static struct pci_device_id bofm_dummy_ids [1]
 Dummy BOFM driver PCI IDs.
struct pci_driver bofm_dummy_driver __bofm_test_driver
 Dummy BOFM driver.

Detailed Description

IBM BladeCenter Open Fabric Manager (BOFM) tests.

Definition in file bofm_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ bofm_test()

void bofm_test ( struct pci_device * pci)

Perform BOFM test.

Parameters
pciPCI device

Definition at line 105 of file bofm_test.c.

105 {
106 int bofmrc;
107
108 printf ( "BOFMTEST using " PCI_FMT "\n", PCI_ARGS ( pci ) );
109
110 /* Perform harvest test */
111 printf ( "BOFMTEST performing harvest\n" );
112 bofmtab_harvest.en.busdevfn = pci->busdevfn;
113 DBG_HDA ( 0, &bofmtab_harvest, sizeof ( bofmtab_harvest ) );
114 bofmrc = bofm ( &bofmtab_harvest, pci );
115 printf ( "BOFMTEST harvest result %08x\n", bofmrc );
116 if ( bofmtab_harvest.en.options & BOFM_EN_HVST ) {
117 printf ( "BOFMTEST harvested MAC address %s\n",
118 eth_ntoa ( &bofmtab_harvest.en.mac_a ) );
119 } else {
120 printf ( "BOFMTEST failed to harvest a MAC address\n" );
121 }
122 DBG_HDA ( 0, &bofmtab_harvest, sizeof ( bofmtab_harvest ) );
123
124 /* Perform update test */
125 printf ( "BOFMTEST performing update\n" );
126 bofmtab_update.en.busdevfn = pci->busdevfn;
127 DBG_HDA ( 0, &bofmtab_update, sizeof ( bofmtab_update ) );
128 bofmrc = bofm ( &bofmtab_update, pci );
129 printf ( "BOFMTEST update result %08x\n", bofmrc );
130 if ( bofmtab_update.en.options & BOFM_EN_CSM_SUCCESS ) {
131 printf ( "BOFMTEST updated MAC address to %s\n",
132 eth_ntoa ( &bofmtab_update.en.mac_a ) );
133 } else {
134 printf ( "BOFMTEST failed to update MAC address\n" );
135 }
136 DBG_HDA ( 0, &bofmtab_update, sizeof ( bofmtab_update ) );
137}
int bofm(void *bofmtab, struct pci_device *pci)
Process BOFM table.
Definition bofm.c:235
static struct @316205131112362033275013007125326304133153167111 bofmtab_update
Update test table.
static struct @105233234272222367367070274036245364006324173364 bofmtab_harvest
Harvest test table.
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition ethernet.c:176
#define BOFM_EN_CSM_SUCCESS
Entry has been used successfully.
Definition bofm.h:237
#define BOFM_EN_HVST
Harvest complete.
Definition bofm.h:261
#define DBG_HDA(...)
Definition compiler.h:499
#define PCI_FMT
PCI device debug message format.
Definition pci.h:312
#define PCI_ARGS(pci)
PCI device debug message arguments.
Definition pci.h:315
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition pci.h:238
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition vsprintf.c:465

References bofm(), BOFM_EN_CSM_SUCCESS, BOFM_EN_HVST, bofmtab_harvest, bofmtab_update, pci_device::busdevfn, DBG_HDA, eth_ntoa(), PCI_ARGS, PCI_FMT, and printf().

Referenced by bofm_test_init().

◆ bofm_dummy_harvest()

int bofm_dummy_harvest ( struct bofm_device * bofm,
unsigned int mport,
uint8_t * mac )
static

Harvest dummy Ethernet MAC.

Parameters
bofmBOFM device
mportMulti-port index
macMAC to fill in
Return values
rcReturn status code

Definition at line 147 of file bofm_test.c.

148 {
149 struct {
152 uint16_t mport;
153 } __attribute__ (( packed )) dummy_mac;
154
155 /* Construct dummy MAC address */
156 dummy_mac.vendor = cpu_to_be16 ( bofm->pci->vendor );
157 dummy_mac.device = cpu_to_be16 ( bofm->pci->device );
158 dummy_mac.mport = cpu_to_be16 ( mport );
159 memcpy ( mac, &dummy_mac, sizeof ( dummy_mac ) );
160 printf ( "BOFMTEST mport %d constructed dummy MAC %s\n",
161 mport, eth_ntoa ( mac ) );
162
163 return 0;
164}
unsigned short uint16_t
Definition stdint.h:11
static unsigned short vendor
Definition davicom.c:128
uint8_t mac[ETH_ALEN]
MAC address.
Definition ena.h:13
#define cpu_to_be16(value)
Definition byteswap.h:110
#define __attribute__(x)
Definition compiler.h:10
void * memcpy(void *dest, const void *src, size_t len) __nonnull
A hardware device.
Definition device.h:77

References __attribute__, bofm(), cpu_to_be16, eth_ntoa(), mac, memcpy(), printf(), and vendor.

◆ bofm_dummy_update()

int bofm_dummy_update ( struct bofm_device *bofm __unused,
unsigned int mport,
const uint8_t * mac )
static

Update Ethernet MAC for BOFM.

Parameters
bofmBOFM device
mportMulti-port index
macMAC to fill in
Return values
rcReturn status code

Definition at line 174 of file bofm_test.c.

175 {
176
177 printf ( "BOFMTEST mport %d asked to update MAC to %s\n",
178 mport, eth_ntoa ( mac ) );
179 return 0;
180}

References __unused, bofm(), eth_ntoa(), mac, and printf().

◆ bofm_dummy_probe()

int bofm_dummy_probe ( struct pci_device * pci)
static

Probe dummy BOFM device.

Parameters
pciPCI device
idPCI ID
Return values
rcReturn status code

Definition at line 198 of file bofm_test.c.

198 {
199 int rc;
200
201 /* Ignore probe for any other devices */
202 if ( pci->busdevfn != bofm_dummy.pci->busdevfn )
203 return 0;
204
205 /* Register BOFM device */
206 if ( ( rc = bofm_register ( &bofm_dummy ) ) != 0 )
207 return rc;
208
209 printf ( "BOFMTEST using dummy BOFM driver\n" );
210 return 0;
211}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
int bofm_register(struct bofm_device *bofm)
Register BOFM device.
Definition bofm.c:48
static struct bofm_device bofm_dummy
Dummy BOFM device.
Definition bofm_test.c:189

References bofm_dummy, bofm_register(), pci_device::busdevfn, bofm_device::pci, printf(), and rc.

◆ bofm_dummy_remove()

void bofm_dummy_remove ( struct pci_device * pci)
static

Remove dummy BOFM device.

Parameters
pciPCI device

Definition at line 218 of file bofm_test.c.

218 {
219
220 /* Ignore removal for any other devices */
221 if ( pci->busdevfn != bofm_dummy.pci->busdevfn )
222 return;
223
224 /* Unregister BOFM device */
226}
void bofm_unregister(struct bofm_device *bofm)
Unregister BOFM device.
Definition bofm.c:61

References bofm_dummy, bofm_unregister(), pci_device::busdevfn, and bofm_device::pci.

◆ bofm_test_init()

void bofm_test_init ( void )
static

Perform BOFM test at initialisation time.

Definition at line 246 of file bofm_test.c.

246 {
247 struct pci_device pci;
248 int busdevfn = -1;
249 int rc;
250
251 /* Uncomment the following line and specify the correct PCI
252 * bus:dev.fn address in order to perform a BOFM test at
253 * initialisation time.
254 */
255 // busdevfn = PCI_BUSDEVFN ( <segment>, <bus>, <dev>, <fn> );
256
257 /* Skip test if no PCI bus:dev.fn is defined */
258 if ( busdevfn < 0 )
259 return;
260
261 /* Initialise PCI device */
262 memset ( &pci, 0, sizeof ( pci ) );
263 pci_init ( &pci, busdevfn );
264 if ( ( rc = pci_read_config ( &pci ) ) != 0 ) {
265 printf ( "BOFMTEST could not create " PCI_FMT " device: %s\n",
266 PCI_ARGS ( &pci ), strerror ( rc ) );
267 return;
268 }
269
270 /* Initialise dummy BOFM device */
272 bofm_dummy_ids[0].vendor = pci.vendor;
273 bofm_dummy_ids[0].device = pci.device;
274
275 /* Perform test */
276 bofm_test ( &pci );
277}
static void bofm_init(struct bofm_device *bofm, struct pci_device *pci, struct bofm_operations *op)
Initialise BOFM device.
Definition bofm.h:342
static struct pci_device_id bofm_dummy_ids[1]
Dummy BOFM driver PCI IDs.
Definition bofm_test.c:229
void bofm_test(struct pci_device *pci)
Perform BOFM test.
Definition bofm_test.c:105
static struct bofm_operations bofm_dummy_operations
Dummy BOFM operations.
Definition bofm_test.c:183
uint16_t busdevfn
PCI bus:dev.fn address.
Definition ena.h:17
void * memset(void *dest, int character, size_t len) __nonnull
int pci_read_config(struct pci_device *pci)
Read PCI device configuration.
Definition pci.c:269
static void pci_init(struct pci_device *pci, unsigned int busdevfn)
Initialise PCI device.
Definition pci.h:341
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
A PCI device.
Definition pci.h:211

References bofm_dummy, bofm_dummy_ids, bofm_dummy_operations, bofm_init(), bofm_test(), busdevfn, pci_device::device, memset(), PCI_ARGS, PCI_FMT, pci_init(), pci_read_config(), printf(), rc, strerror(), and pci_device::vendor.

Referenced by __init_fn().

◆ __init_fn()

struct init_fn bofm_test_init_fn __init_fn ( INIT_NORMAL )

BOFM test initialisation function.

References __init_fn, bofm_test_init(), and INIT_NORMAL.

Variable Documentation

◆ header

struct bofm_global_header header

Definition at line 43 of file bofm_test.c.

◆ en_header

struct bofm_section_header en_header

Definition at line 44 of file bofm_test.c.

◆ en

struct bofm_en en

Definition at line 45 of file bofm_test.c.

Referenced by bofm(), and bofm_en().

◆ done

◆ [struct]

struct { ... } bofmtab_harvest
Initial value:
= {
.header = {
.magic = BOFM_IOAA_MAGIC,
.action = BOFM_ACTION_HVST,
.version = 0x01,
.level = 0x01,
.length = sizeof ( bofmtab_harvest ),
.profile = "Harvest test profile",
},
.en_header = {
.magic = BOFM_EN_MAGIC,
.length = sizeof ( bofmtab_harvest.en ),
},
.en = {
.mport = 1,
},
.done = {
.magic = BOFM_DONE_MAGIC,
},
}
__be16 profile
Definition CIB_PRM.h:2
#define BOFM_IOAA_MAGIC
BOFM table header signature.
Definition bofm.h:103
#define BOFM_ACTION_HVST
Harvest MAC/WWN.
Definition bofm.h:120
#define BOFM_EN_MAP_PFA
Port mapping is by PCI bus:dev.fn.
Definition bofm.h:213
#define BOFM_EN_RQ_HVST_ACTIVE
Harvest active values.
Definition bofm.h:273
#define BOFM_EN_USAGE_HARVEST
Ignore values - it's harvest time.
Definition bofm.h:252
#define BOFM_DONE_MAGIC
End marker.
Definition bofm.h:154
#define BOFM_EN_MAGIC
EN start marker.
Definition bofm.h:151

Harvest test table.

Referenced by bofm_test().

◆ [struct]

struct { ... } bofmtab_update
Initial value:
= {
.header = {
.magic = BOFM_IOAA_MAGIC,
.action = BOFM_ACTION_UPDT,
.version = 0x01,
.level = 0x01,
.length = sizeof ( bofmtab_update ),
.profile = "Update test profile",
},
.en_header = {
.magic = BOFM_EN_MAGIC,
.length = sizeof ( bofmtab_update.en ),
},
.en = {
.options = ( BOFM_EN_MAP_PFA | BOFM_EN_EN_A |
.mport = 1,
.mac_a = { 0x02, 0x00, 0x69, 0x50, 0x58, 0x45 },
},
.done = {
.magic = BOFM_DONE_MAGIC,
},
}
#define BOFM_ACTION_UPDT
Update MAC/WWN.
Definition bofm.h:114
#define BOFM_EN_USAGE_ENTRY
Use entry values for assignment.
Definition bofm.h:255
#define BOFM_EN_EN_A
MAC address A is present.
Definition bofm.h:225

Update test table.

Referenced by bofm_test().

◆ bofm_dummy_operations

struct bofm_operations bofm_dummy_operations
static
Initial value:
= {
.harvest = bofm_dummy_harvest,
.update = bofm_dummy_update,
}
static int bofm_dummy_harvest(struct bofm_device *bofm, unsigned int mport, uint8_t *mac)
Harvest dummy Ethernet MAC.
Definition bofm_test.c:147
static int bofm_dummy_update(struct bofm_device *bofm __unused, unsigned int mport, const uint8_t *mac)
Update Ethernet MAC for BOFM.
Definition bofm_test.c:174

Dummy BOFM operations.

Definition at line 183 of file bofm_test.c.

183 {
184 .harvest = bofm_dummy_harvest,
185 .update = bofm_dummy_update,
186};

Referenced by bofm_test_init().

◆ bofm_dummy

struct bofm_device bofm_dummy
static

Dummy BOFM device.

Definition at line 189 of file bofm_test.c.

Referenced by bofm_dummy_probe(), bofm_dummy_remove(), and bofm_test_init().

◆ bofm_dummy_ids

struct pci_device_id bofm_dummy_ids[1]
static
Initial value:
= {
{ .name = "dummy" },
}

Dummy BOFM driver PCI IDs.

Definition at line 229 of file bofm_test.c.

229 {
230 { .name = "dummy" },
231};

Referenced by bofm_test_init().

◆ __bofm_test_driver

struct pci_driver bofm_dummy_driver __bofm_test_driver
Initial value:
= {
.id_count = ( sizeof ( bofm_dummy_ids ) /
sizeof ( bofm_dummy_ids[0] ) ),
.probe = bofm_dummy_probe,
}
static int bofm_dummy_probe(struct pci_device *pci)
Probe dummy BOFM device.
Definition bofm_test.c:198
static void bofm_dummy_remove(struct pci_device *pci)
Remove dummy BOFM device.
Definition bofm_test.c:218
static struct xen_remove_from_physmap * remove
Definition xenmem.h:40

Dummy BOFM driver.

Definition at line 234 of file bofm_test.c.

234 {
235 .ids = bofm_dummy_ids,
236 .id_count = ( sizeof ( bofm_dummy_ids ) /
237 sizeof ( bofm_dummy_ids[0] ) ),
238 .probe = bofm_dummy_probe,
240};