iPXE
Functions | Variables
bofm_test.c File Reference

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

#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <ipxe/uaccess.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. More...
 
static void bofm_test_init (void)
 Perform BOFM test at initialisation time. More...
 
struct init_fn bofm_test_init_fn __init_fn (INIT_NORMAL)
 BOFM test initialisation function. More...
 

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. More...
 
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. More...
 

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 ( virt_to_user ( &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 ( virt_to_user ( &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 }
static struct @421 bofmtab_harvest
Harvest test table.
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
#define DBG_HDA(...)
Definition: compiler.h:499
static struct @422 bofmtab_update
Update test table.
#define PCI_FMT
PCI device debug message format.
Definition: pci.h:287
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
#define BOFM_EN_HVST
Harvest complete.
Definition: bofm.h:261
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:210
int bofm(userptr_t bofmtab, struct pci_device *pci)
Process BOFM table.
Definition: bofm.c:238
#define PCI_ARGS(pci)
PCI device debug message arguments.
Definition: pci.h:290
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
#define BOFM_EN_CSM_SUCCESS
Entry has been used successfully.
Definition: bofm.h:237

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

Referenced by bofm_test_init().

◆ bofm_test_init()

static void bofm_test_init ( void  )
static

Perform BOFM test at initialisation time.

Definition at line 143 of file bofm_test.c.

143  {
144  struct pci_device pci;
145  int busdevfn = -1;
146  int rc;
147 
148  /* Uncomment the following line and specify the correct PCI
149  * bus:dev.fn address in order to perform a BOFM test at
150  * initialisation time.
151  */
152  // busdevfn = PCI_BUSDEVFN ( <bus>, <dev>, <fn> );
153 
154  /* Skip test if no PCI bus:dev.fn is defined */
155  if ( busdevfn < 0 )
156  return;
157 
158  /* Initialise PCI device */
159  memset ( &pci, 0, sizeof ( pci ) );
160  pci_init ( &pci, busdevfn );
161  if ( ( rc = pci_read_config ( &pci ) ) != 0 ) {
162  printf ( "BOFMTEST could not create " PCI_FMT " device: %s\n",
163  PCI_ARGS ( &pci ), strerror ( rc ) );
164  return;
165  }
166 
167  /* Perform test */
168  bofm_test ( &pci );
169 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
void bofm_test(struct pci_device *pci)
Perform BOFM test.
Definition: bofm_test.c:105
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define PCI_FMT
PCI device debug message format.
Definition: pci.h:287
A PCI device.
Definition: pci.h:187
int pci_read_config(struct pci_device *pci)
Read PCI device configuration.
Definition: pci.c:177
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
Definition: pci.h:210
#define PCI_ARGS(pci)
PCI device debug message arguments.
Definition: pci.h:290
static void pci_init(struct pci_device *pci, unsigned int busdevfn)
Initialise PCI device.
Definition: pci.h:313
void * memset(void *dest, int character, size_t len) __nonnull

References bofm_test(), pci_device::busdevfn, memset(), PCI_ARGS, PCI_FMT, pci_init(), pci_read_config(), printf(), rc, and strerror().

◆ __init_fn()

struct init_fn bofm_test_init_fn __init_fn ( INIT_NORMAL  )

BOFM test initialisation function.

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 bofm_section_header done

◆ bofmtab_harvest

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,
},
}
static struct @421 bofmtab_harvest
Harvest test table.
#define BOFM_EN_USAGE_HARVEST
Ignore values - it's harvest time.
Definition: bofm.h:252
#define BOFM_EN_MAGIC
EN start marker.
Definition: bofm.h:151
__be16 profile
Definition: CIB_PRM.h:30
#define BOFM_EN_MAP_PFA
Port mapping is by PCI bus:dev.fn.
Definition: bofm.h:213
#define BOFM_IOAA_MAGIC
BOFM table header signature.
Definition: bofm.h:103
#define BOFM_DONE_MAGIC
End marker.
Definition: bofm.h:154
#define BOFM_EN_RQ_HVST_ACTIVE
Harvest active values.
Definition: bofm.h:273
#define BOFM_ACTION_HVST
Harvest MAC/WWN.
Definition: bofm.h:120

Harvest test table.

Referenced by bofm_test().

◆ bofmtab_update

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_EN_EN_A
MAC address A is present.
Definition: bofm.h:225
#define BOFM_EN_MAGIC
EN start marker.
Definition: bofm.h:151
static struct @422 bofmtab_update
Update test table.
#define BOFM_ACTION_UPDT
Update MAC/WWN.
Definition: bofm.h:114
__be16 profile
Definition: CIB_PRM.h:30
#define BOFM_EN_MAP_PFA
Port mapping is by PCI bus:dev.fn.
Definition: bofm.h:213
#define BOFM_IOAA_MAGIC
BOFM table header signature.
Definition: bofm.h:103
#define BOFM_DONE_MAGIC
End marker.
Definition: bofm.h:154
#define BOFM_EN_USAGE_ENTRY
Use entry values for assignment.
Definition: bofm.h:255

Update test table.

Referenced by bofm_test().