]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[hermon] Use PCI VPD for non-volatile option storage
authorMichael Brown <mcb30@ipxe.org>
Mon, 15 Oct 2012 12:04:31 +0000 (13:04 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 25 Oct 2012 15:24:00 +0000 (08:24 -0700)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/infiniband/hermon.c
src/drivers/infiniband/hermon.h

index 8a4fba940748c61bd8b787ee849e2756c047e7f5..a9c728706b8a54464c75e1a920da2e8df7f76fc8 100644 (file)
@@ -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];
index 26940f6faa8398816b919049fad5b958e1ed6d22..e0b028f263e86cca2ab040dadccdf8a1e78dd0a8 100644 (file)
@@ -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];