Przeglądaj źródła

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 lat temu
rodzic
commit
c4ee23e7c6
2 zmienionych plików z 40 dodań i 2 usunięć
  1. 30
    2
      src/drivers/infiniband/hermon.c
  2. 10
    0
      src/drivers/infiniband/hermon.h

+ 30
- 2
src/drivers/infiniband/hermon.c Wyświetl plik

@@ -42,6 +42,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
42 42
 #include <ipxe/fcoe.h>
43 43
 #include <ipxe/vlan.h>
44 44
 #include <ipxe/bofm.h>
45
+#include <ipxe/nvsvpd.h>
46
+#include <ipxe/nvo.h>
45 47
 #include "hermon.h"
46 48
 
47 49
 /**
@@ -3383,7 +3385,7 @@ static int hermon_register_netdev ( struct hermon *hermon,
3383 3385
 					    &query_port ) ) != 0 ) {
3384 3386
 		DBGC ( hermon, "Hermon %p port %d could not query port: %s\n",
3385 3387
 		       hermon, ibdev->port, strerror ( rc ) );
3386
-		return rc;
3388
+		goto err_query_port;
3387 3389
 	}
3388 3390
 	mac.dwords[0] = htonl ( MLX_GET ( &query_port, mac_47_32 ) );
3389 3391
 	mac.dwords[1] = htonl ( MLX_GET ( &query_port, mac_31_0 ) );
@@ -3394,10 +3396,26 @@ static int hermon_register_netdev ( struct hermon *hermon,
3394 3396
 	if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
3395 3397
 		DBGC ( hermon, "Hermon %p port %d could not register network "
3396 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 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,6 +3447,7 @@ static void hermon_unregister_netdev ( struct hermon *hermon __unused,
3429 3447
 				       struct hermon_port *port ) {
3430 3448
 	struct net_device *netdev = port->netdev;
3431 3449
 
3450
+	unregister_nvo ( &port->nvo );
3432 3451
 	unregister_netdev ( netdev );
3433 3452
 }
3434 3453
 
@@ -3822,6 +3841,15 @@ static int hermon_probe ( struct pci_device *pci ) {
3822 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 3853
 	/* Register devices */
3826 3854
 	for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
3827 3855
 		port = &hermon->port[i];

+ 10
- 0
src/drivers/infiniband/hermon.h Wyświetl plik

@@ -13,6 +13,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
13 13
 #include <ipxe/uaccess.h>
14 14
 #include <ipxe/ib_packet.h>
15 15
 #include <ipxe/bofm.h>
16
+#include <ipxe/nvsvpd.h>
17
+#include <ipxe/nvo.h>
16 18
 #include "mlx_bitops.h"
17 19
 #include "MT25408_PRM.h"
18 20
 
@@ -135,6 +137,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
135 137
 #define HERMON_MOD_STAT_CFG_SET		0x01
136 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 144
  * Datatypes that seem to be missing from the autogenerated documentation
140 145
  *
@@ -825,6 +830,8 @@ struct hermon_port {
825 830
 	struct ib_queue_pair *eth_qp;
826 831
 	/** Port type */
827 832
 	struct hermon_port_type *type;
833
+	/** Non-volatile option storage */
834
+	struct nvo_block nvo;
828 835
 };
829 836
 
830 837
 /** A Hermon device */
@@ -891,6 +898,9 @@ struct hermon {
891 898
 	/** QPN base */
892 899
 	unsigned long qpn_base;
893 900
 
901
+	/** Non-volatile storage in PCI VPD */
902
+	struct nvs_vpd_device nvsvpd;
903
+
894 904
 	/** Ports */
895 905
 	struct hermon_port port[HERMON_MAX_PORTS];
896 906
 

Ładowanie…
Anuluj
Zapisz