Browse Source

[hermon] Use PCI VPD for non-volatile option storage

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
c4ee23e7c6
2 changed files with 40 additions and 2 deletions
  1. 30
    2
      src/drivers/infiniband/hermon.c
  2. 10
    0
      src/drivers/infiniband/hermon.h

+ 30
- 2
src/drivers/infiniband/hermon.c View File

42
 #include <ipxe/fcoe.h>
42
 #include <ipxe/fcoe.h>
43
 #include <ipxe/vlan.h>
43
 #include <ipxe/vlan.h>
44
 #include <ipxe/bofm.h>
44
 #include <ipxe/bofm.h>
45
+#include <ipxe/nvsvpd.h>
46
+#include <ipxe/nvo.h>
45
 #include "hermon.h"
47
 #include "hermon.h"
46
 
48
 
47
 /**
49
 /**
3383
 					    &query_port ) ) != 0 ) {
3385
 					    &query_port ) ) != 0 ) {
3384
 		DBGC ( hermon, "Hermon %p port %d could not query port: %s\n",
3386
 		DBGC ( hermon, "Hermon %p port %d could not query port: %s\n",
3385
 		       hermon, ibdev->port, strerror ( rc ) );
3387
 		       hermon, ibdev->port, strerror ( rc ) );
3386
-		return rc;
3388
+		goto err_query_port;
3387
 	}
3389
 	}
3388
 	mac.dwords[0] = htonl ( MLX_GET ( &query_port, mac_47_32 ) );
3390
 	mac.dwords[0] = htonl ( MLX_GET ( &query_port, mac_47_32 ) );
3389
 	mac.dwords[1] = htonl ( MLX_GET ( &query_port, mac_31_0 ) );
3391
 	mac.dwords[1] = htonl ( MLX_GET ( &query_port, mac_31_0 ) );
3394
 	if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
3396
 	if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
3395
 		DBGC ( hermon, "Hermon %p port %d could not register network "
3397
 		DBGC ( hermon, "Hermon %p port %d could not register network "
3396
 		       "device: %s\n", hermon, ibdev->port, strerror ( rc ) );
3398
 		       "device: %s\n", hermon, ibdev->port, strerror ( rc ) );
3397
-		return rc;
3399
+		goto err_register_netdev;
3400
+	}
3401
+
3402
+	/* Register non-volatile options */
3403
+	if ( ( rc = register_nvo ( &port->nvo,
3404
+				   netdev_settings ( netdev ) ) ) != 0 ) {
3405
+		DBGC ( hermon, "Hermon %p port %d could not register non-"
3406
+		       "volatile options: %s\n",
3407
+		       hermon, ibdev->port, strerror ( rc ) );
3408
+		goto err_register_nvo;
3398
 	}
3409
 	}
3399
 
3410
 
3400
 	return 0;
3411
 	return 0;
3412
+
3413
+	unregister_nvo ( &port->nvo );
3414
+ err_register_nvo:
3415
+	unregister_netdev ( netdev );
3416
+ err_register_netdev:
3417
+ err_query_port:
3418
+	return rc;
3401
 }
3419
 }
3402
 
3420
 
3403
 /**
3421
 /**
3429
 				       struct hermon_port *port ) {
3447
 				       struct hermon_port *port ) {
3430
 	struct net_device *netdev = port->netdev;
3448
 	struct net_device *netdev = port->netdev;
3431
 
3449
 
3450
+	unregister_nvo ( &port->nvo );
3432
 	unregister_netdev ( netdev );
3451
 	unregister_netdev ( netdev );
3433
 }
3452
 }
3434
 
3453
 
3822
 			goto err_set_port_type;
3841
 			goto err_set_port_type;
3823
 	}
3842
 	}
3824
 
3843
 
3844
+	/* Initialise non-volatile storage */
3845
+	nvs_vpd_init ( &hermon->nvsvpd, pci );
3846
+	for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
3847
+		port = &hermon->port[i];
3848
+		nvs_vpd_nvo_init ( &hermon->nvsvpd,
3849
+				   HERMON_VPD_FIELD ( port->ibdev->port ),
3850
+				   &port->nvo, NULL );
3851
+	}
3852
+
3825
 	/* Register devices */
3853
 	/* Register devices */
3826
 	for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
3854
 	for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
3827
 		port = &hermon->port[i];
3855
 		port = &hermon->port[i];

+ 10
- 0
src/drivers/infiniband/hermon.h View File

13
 #include <ipxe/uaccess.h>
13
 #include <ipxe/uaccess.h>
14
 #include <ipxe/ib_packet.h>
14
 #include <ipxe/ib_packet.h>
15
 #include <ipxe/bofm.h>
15
 #include <ipxe/bofm.h>
16
+#include <ipxe/nvsvpd.h>
17
+#include <ipxe/nvo.h>
16
 #include "mlx_bitops.h"
18
 #include "mlx_bitops.h"
17
 #include "MT25408_PRM.h"
19
 #include "MT25408_PRM.h"
18
 
20
 
135
 #define HERMON_MOD_STAT_CFG_SET		0x01
137
 #define HERMON_MOD_STAT_CFG_SET		0x01
136
 #define HERMON_MOD_STAT_CFG_QUERY	0x03
138
 #define HERMON_MOD_STAT_CFG_QUERY	0x03
137
 
139
 
140
+#define HERMON_VPD_FIELD( port ) \
141
+	PCI_VPD_FIELD ( PCI_VPD_TAG_RW, 'V', ( '5' + (port) - 1 ) )
142
+
138
 /*
143
 /*
139
  * Datatypes that seem to be missing from the autogenerated documentation
144
  * Datatypes that seem to be missing from the autogenerated documentation
140
  *
145
  *
825
 	struct ib_queue_pair *eth_qp;
830
 	struct ib_queue_pair *eth_qp;
826
 	/** Port type */
831
 	/** Port type */
827
 	struct hermon_port_type *type;
832
 	struct hermon_port_type *type;
833
+	/** Non-volatile option storage */
834
+	struct nvo_block nvo;
828
 };
835
 };
829
 
836
 
830
 /** A Hermon device */
837
 /** A Hermon device */
891
 	/** QPN base */
898
 	/** QPN base */
892
 	unsigned long qpn_base;
899
 	unsigned long qpn_base;
893
 
900
 
901
+	/** Non-volatile storage in PCI VPD */
902
+	struct nvs_vpd_device nvsvpd;
903
+
894
 	/** Ports */
904
 	/** Ports */
895
 	struct hermon_port port[HERMON_MAX_PORTS];
905
 	struct hermon_port port[HERMON_MAX_PORTS];
896
 
906
 

Loading…
Cancel
Save