Navigation Menu

Skip to content

Commit

Permalink
[hermon] Use PCI VPD for non-volatile option storage
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Oct 25, 2012
1 parent 2c011d7 commit c4ee23e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/drivers/infiniband/hermon.c
Expand Up @@ -42,6 +42,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/fcoe.h>
#include <ipxe/vlan.h>
#include <ipxe/bofm.h>
#include <ipxe/nvsvpd.h>
#include <ipxe/nvo.h>
#include "hermon.h"

/**
Expand Down Expand Up @@ -3383,7 +3385,7 @@ static int hermon_register_netdev ( struct hermon *hermon,
&query_port ) ) != 0 ) {
DBGC ( hermon, "Hermon %p port %d could not query port: %s\n",
hermon, ibdev->port, strerror ( rc ) );
return rc;
goto err_query_port;
}
mac.dwords[0] = htonl ( MLX_GET ( &query_port, mac_47_32 ) );
mac.dwords[1] = htonl ( MLX_GET ( &query_port, mac_31_0 ) );
Expand All @@ -3394,10 +3396,26 @@ static int hermon_register_netdev ( struct hermon *hermon,
if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
DBGC ( hermon, "Hermon %p port %d could not register network "
"device: %s\n", hermon, ibdev->port, strerror ( rc ) );
return rc;
goto err_register_netdev;
}

/* Register non-volatile options */
if ( ( rc = register_nvo ( &port->nvo,
netdev_settings ( netdev ) ) ) != 0 ) {
DBGC ( hermon, "Hermon %p port %d could not register non-"
"volatile options: %s\n",
hermon, ibdev->port, strerror ( rc ) );
goto err_register_nvo;
}

return 0;

unregister_nvo ( &port->nvo );
err_register_nvo:
unregister_netdev ( netdev );
err_register_netdev:
err_query_port:
return rc;
}

/**
Expand Down Expand Up @@ -3429,6 +3447,7 @@ static void hermon_unregister_netdev ( struct hermon *hermon __unused,
struct hermon_port *port ) {
struct net_device *netdev = port->netdev;

unregister_nvo ( &port->nvo );
unregister_netdev ( netdev );
}

Expand Down Expand Up @@ -3822,6 +3841,15 @@ static int hermon_probe ( struct pci_device *pci ) {
goto err_set_port_type;
}

/* Initialise non-volatile storage */
nvs_vpd_init ( &hermon->nvsvpd, pci );
for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
port = &hermon->port[i];
nvs_vpd_nvo_init ( &hermon->nvsvpd,
HERMON_VPD_FIELD ( port->ibdev->port ),
&port->nvo, NULL );
}

/* Register devices */
for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
port = &hermon->port[i];
Expand Down
10 changes: 10 additions & 0 deletions src/drivers/infiniband/hermon.h
Expand Up @@ -13,6 +13,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/uaccess.h>
#include <ipxe/ib_packet.h>
#include <ipxe/bofm.h>
#include <ipxe/nvsvpd.h>
#include <ipxe/nvo.h>
#include "mlx_bitops.h"
#include "MT25408_PRM.h"

Expand Down Expand Up @@ -135,6 +137,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define HERMON_MOD_STAT_CFG_SET 0x01
#define HERMON_MOD_STAT_CFG_QUERY 0x03

#define HERMON_VPD_FIELD( port ) \
PCI_VPD_FIELD ( PCI_VPD_TAG_RW, 'V', ( '5' + (port) - 1 ) )

/*
* Datatypes that seem to be missing from the autogenerated documentation
*
Expand Down Expand Up @@ -825,6 +830,8 @@ struct hermon_port {
struct ib_queue_pair *eth_qp;
/** Port type */
struct hermon_port_type *type;
/** Non-volatile option storage */
struct nvo_block nvo;
};

/** A Hermon device */
Expand Down Expand Up @@ -891,6 +898,9 @@ struct hermon {
/** QPN base */
unsigned long qpn_base;

/** Non-volatile storage in PCI VPD */
struct nvs_vpd_device nvsvpd;

/** Ports */
struct hermon_port port[HERMON_MAX_PORTS];

Expand Down

0 comments on commit c4ee23e

Please sign in to comment.