diff options
author | Michael Brown <mcb30@ipxe.org> | 2012-10-15 13:04:31 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2012-10-25 08:24:00 -0700 |
commit | c4ee23e7c6421016400eb76d28a3e2d12617c8ea (patch) | |
tree | 9a73185b8b54464d02002f1eaba9122c13b86eff /src/drivers | |
parent | 2c011d77ae0147b8cc68bc4f3c577ebf55b83f16 (diff) | |
download | ipxe-c4ee23e7c6421016400eb76d28a3e2d12617c8ea.zip ipxe-c4ee23e7c6421016400eb76d28a3e2d12617c8ea.tar.gz ipxe-c4ee23e7c6421016400eb76d28a3e2d12617c8ea.tar.bz2 |
[hermon] Use PCI VPD for non-volatile option storage
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/infiniband/hermon.c | 32 | ||||
-rw-r--r-- | src/drivers/infiniband/hermon.h | 10 |
2 files changed, 40 insertions, 2 deletions
diff --git a/src/drivers/infiniband/hermon.c b/src/drivers/infiniband/hermon.c index 8a4fba9..a9c7287 100644 --- a/src/drivers/infiniband/hermon.c +++ b/src/drivers/infiniband/hermon.c @@ -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" /** @@ -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 ) ); @@ -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; } /** @@ -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 ); } @@ -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]; diff --git a/src/drivers/infiniband/hermon.h b/src/drivers/infiniband/hermon.h index 26940f6..e0b028f 100644 --- a/src/drivers/infiniband/hermon.h +++ b/src/drivers/infiniband/hermon.h @@ -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" @@ -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 * @@ -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 */ @@ -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]; |