summaryrefslogtreecommitdiffstats
path: root/src/drivers/infiniband
diff options
context:
space:
mode:
authorMichael Brown2012-10-15 14:04:31 +0200
committerMichael Brown2012-10-25 17:24:00 +0200
commitc4ee23e7c6421016400eb76d28a3e2d12617c8ea (patch)
tree9a73185b8b54464d02002f1eaba9122c13b86eff /src/drivers/infiniband
parent[readline] Allow readline_history() to return a meaningful status (diff)
downloadipxe-c4ee23e7c6421016400eb76d28a3e2d12617c8ea.tar.gz
ipxe-c4ee23e7c6421016400eb76d28a3e2d12617c8ea.tar.xz
ipxe-c4ee23e7c6421016400eb76d28a3e2d12617c8ea.zip
[hermon] Use PCI VPD for non-volatile option storage
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/infiniband')
-rw-r--r--src/drivers/infiniband/hermon.c32
-rw-r--r--src/drivers/infiniband/hermon.h10
2 files changed, 40 insertions, 2 deletions
diff --git a/src/drivers/infiniband/hermon.c b/src/drivers/infiniband/hermon.c
index 8a4fba94..a9c72870 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 26940f6f..e0b028f2 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];