Bläddra i källkod

[golan] Update Connect-IB, ConnectX-4 and ConnectX-4 Lx (Infiniband) support

Updates:
- Nodnic: Support for arm cq doorbell via the UAR BAR
- Ensure hardware is quiescent when no interface is open - WinPE WA
- Support for clear interrupt via BAR
- Nodnic: Support for send TX doorbells via the UAR BAR
- Added ConnectX-5EX device
- Added ConnectX-5 device

Signed-off-by: Raed Salem <raeds@mellanox.com>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Raed Salem 8 år sedan
förälder
incheckning
26050fd4c8
23 ändrade filer med 901 tillägg och 152 borttagningar
  1. 131
    35
      src/drivers/infiniband/flexboot_nodnic.c
  2. 27
    1
      src/drivers/infiniband/flexboot_nodnic.h
  3. 126
    80
      src/drivers/infiniband/golan.c
  4. 5
    3
      src/drivers/infiniband/golan.h
  5. 31
    1
      src/drivers/infiniband/mlx_nodnic/include/mlx_nodnic_data_structures.h
  6. 13
    0
      src/drivers/infiniband/mlx_nodnic/include/mlx_port.h
  7. 32
    2
      src/drivers/infiniband/mlx_nodnic/src/mlx_device.c
  8. 343
    11
      src/drivers/infiniband/mlx_nodnic/src/mlx_port.c
  9. 5
    0
      src/drivers/infiniband/mlx_utils/include/private/mlx_pci_priv.h
  10. 1
    0
      src/drivers/infiniband/mlx_utils/include/public/mlx_logging.h
  11. 5
    0
      src/drivers/infiniband/mlx_utils/include/public/mlx_pci.h
  12. 5
    0
      src/drivers/infiniband/mlx_utils/mlx_lib/mlx_link_speed/mlx_link_speed.h
  13. 7
    0
      src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.c
  14. 16
    0
      src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.h
  15. 28
    2
      src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig_defaults.c
  16. 6
    0
      src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig_defaults.h
  17. 83
    11
      src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig_prm.h
  18. 1
    1
      src/drivers/infiniband/mlx_utils/src/public/mlx_icmd.c
  19. 16
    0
      src/drivers/infiniband/mlx_utils/src/public/mlx_pci.c
  20. 3
    2
      src/drivers/infiniband/mlx_utils/src/public/mlx_utils.c
  21. 3
    2
      src/drivers/infiniband/mlx_utils_flexboot/include/mlx_logging_priv.h
  22. 1
    1
      src/drivers/infiniband/mlx_utils_flexboot/include/mlx_types_priv.h
  23. 13
    0
      src/drivers/infiniband/mlx_utils_flexboot/src/mlx_pci_priv.c

+ 131
- 35
src/drivers/infiniband/flexboot_nodnic.c Visa fil

@@ -22,7 +22,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
22 22
 #include <stdio.h>
23 23
 #include <unistd.h>
24 24
 #include <errno.h>
25
-#include <byteswap.h>
26 25
 #include <ipxe/pci.h>
27 26
 #include <ipxe/malloc.h>
28 27
 #include <ipxe/umalloc.h>
@@ -31,10 +30,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
31 30
 #include <ipxe/vlan.h>
32 31
 #include <ipxe/io.h>
33 32
 #include "flexboot_nodnic.h"
34
-#include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.h"
35
-#include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig_defaults.h"
36
-#include "mlx_utils/include/public/mlx_pci_gw.h"
37
-#include "mlx_utils/mlx_lib/mlx_vmac/mlx_vmac.h"
38 33
 #include "mlx_utils/include/public/mlx_types.h"
39 34
 #include "mlx_utils/include/public/mlx_utils.h"
40 35
 #include "mlx_utils/include/public/mlx_bail.h"
@@ -43,6 +38,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
43 38
 #include "mlx_utils/include/public/mlx_pci.h"
44 39
 #include "mlx_nodnic/include/mlx_device.h"
45 40
 #include "mlx_nodnic/include/mlx_port.h"
41
+#include <byteswap.h>
42
+#include <usr/ifmgmt.h>
43
+#include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.h"
44
+#include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig_defaults.h"
45
+#include "mlx_utils/include/public/mlx_pci_gw.h"
46
+#include "mlx_utils/mlx_lib/mlx_vmac/mlx_vmac.h"
46 47
 
47 48
 /***************************************************************************
48 49
  *
@@ -52,10 +53,27 @@ FILE_LICENCE ( GPL2_OR_LATER );
52 53
  */
53 54
 static int flexboot_nodnic_arm_cq ( struct flexboot_nodnic_port *port ) {
54 55
 #ifndef DEVICE_CX3
55
-	mlx_uint32 val = ( port->eth_cq->next_idx & 0xffff );
56
-	if ( nodnic_port_set ( & port->port_priv, nodnic_port_option_arm_cq, val ) ) {
57
-		MLX_DEBUG_ERROR( port->port_priv.device, "Failed to arm the CQ\n" );
58
-		return MLX_FAILED;
56
+	mlx_uint32 val32 = 0;
57
+	union arm_cq_uar cq_uar;
58
+
59
+#define ARM_CQ_UAR_CQ_CI_MASK 0xffffff
60
+#define ARM_CQ_UAR_CMDSN_MASK 3
61
+#define ARM_CQ_UAR_CMDSN_OFFSET 28
62
+#define ARM_CQ_UAR_CQ_CI_OFFSET 0x20
63
+	if ( port->port_priv.device->device_cap.support_bar_cq_ctrl ) {
64
+		cq_uar.dword[0] = cpu_to_be32((port->eth_cq->next_idx  & ARM_CQ_UAR_CQ_CI_MASK) |
65
+				((port->cmdsn++ & ARM_CQ_UAR_CMDSN_MASK) << ARM_CQ_UAR_CMDSN_OFFSET));
66
+		cq_uar.dword[1] = cpu_to_be32(port->eth_cq->cqn);
67
+		wmb();
68
+		writeq(cq_uar.qword, port->port_priv.device->uar.virt + ARM_CQ_UAR_CQ_CI_OFFSET);
69
+		port->port_priv.arm_cq_doorbell_record->dword[0] = cq_uar.dword[1];
70
+		port->port_priv.arm_cq_doorbell_record->dword[1] = cq_uar.dword[0];
71
+	} else {
72
+		val32 = ( port->eth_cq->next_idx & 0xffffff );
73
+		if ( nodnic_port_set ( & port->port_priv, nodnic_port_option_arm_cq, val32 ) ) {
74
+			MLX_DEBUG_ERROR( port->port_priv.device, "Failed to arm the CQ\n" );
75
+			return MLX_FAILED;
76
+		}
59 77
 	}
60 78
 #else
61 79
 	mlx_utils *utils = port->port_priv.device->utils;
@@ -77,7 +95,7 @@ static int flexboot_nodnic_arm_cq ( struct flexboot_nodnic_port *port ) {
77 95
 		data = ( ( ( port->eth_cq->next_idx & 0xffff ) << 16 ) | 0x0080 );
78 96
 		/* Write the new index and update FW that new data was submitted */
79 97
 		mlx_pci_mem_write ( utils, MlxPciWidthUint32, 0,
80
-				( mlx_uint64 ) & ( ptr->armcq_cq_ci_dword ), 1, &data );
98
+				( mlx_uintn ) & ( ptr->armcq_cq_ci_dword ), 1, &data );
81 99
 	}
82 100
 #endif
83 101
 	return 0;
@@ -96,6 +114,7 @@ static int flexboot_nodnic_create_cq ( struct ib_device *ibdev ,
96 114
 	struct flexboot_nodnic_port *port = &flexboot_nodnic->port[ibdev->port - 1];
97 115
 	struct flexboot_nodnic_completion_queue *flexboot_nodnic_cq;
98 116
 	mlx_status status = MLX_SUCCESS;
117
+	mlx_uint32 cqn;
99 118
 
100 119
 	flexboot_nodnic_cq = (struct flexboot_nodnic_completion_queue *)
101 120
 			zalloc(sizeof(*flexboot_nodnic_cq));
@@ -114,10 +133,18 @@ static int flexboot_nodnic_create_cq ( struct ib_device *ibdev ,
114 133
 	flexboot_nodnic->callbacks->cqe_set_owner(
115 134
 			flexboot_nodnic_cq->nodnic_completion_queue->cq_virt,
116 135
 			cq->num_cqes);
117
-
136
+	if ( flexboot_nodnic->device_priv.device_cap.support_bar_cq_ctrl ) {
137
+		status = nodnic_port_query(&port->port_priv,
138
+					nodnic_port_option_cq_n_index,
139
+					(mlx_uint32 *)&cqn );
140
+		MLX_FATAL_CHECK_STATUS(status, read_cqn_err,
141
+				"failed to query cqn");
142
+		cq->cqn = cqn;
143
+	}
118 144
 
119 145
 	ib_cq_set_drvdata ( cq, flexboot_nodnic_cq );
120 146
 	return status;
147
+read_cqn_err:
121 148
 create_err:
122 149
 	free(flexboot_nodnic_cq);
123 150
 qp_alloc_err:
@@ -450,6 +477,9 @@ static int flexboot_nodnic_post_send ( struct ib_device *ibdev,
450 477
 
451 478
 	status = port->port_priv.send_doorbell ( &port->port_priv,
452 479
 				&send_ring->nodnic_ring, ( mlx_uint16 ) wq->next_idx );
480
+	if ( flexboot_nodnic->callbacks->tx_uar_send_doorbell_fn ) {
481
+		flexboot_nodnic->callbacks->tx_uar_send_doorbell_fn ( ibdev, wqbb );
482
+	}
453 483
 	if ( status != 0 ) {
454 484
 		DBGC ( flexboot_nodnic, "flexboot_nodnic %p ring send doorbell failed\n", flexboot_nodnic );
455 485
 	}
@@ -1293,12 +1323,14 @@ int flexboot_nodnic_is_supported ( struct pci_device *pci ) {
1293 1323
 	mlx_pci_gw_teardown( &utils );
1294 1324
 
1295 1325
 pci_gw_init_err:
1326
+	mlx_utils_teardown(&utils);
1296 1327
 utils_init_err:
1297 1328
 	DBG ( "%s: NODNIC is %s supported (status = %d)\n",
1298 1329
 			__FUNCTION__, ( is_supported ? "": "not" ), status );
1299 1330
 	return is_supported;
1300 1331
 }
1301 1332
 
1333
+
1302 1334
 void flexboot_nodnic_copy_mac ( uint8_t mac_addr[], uint32_t low_byte,
1303 1335
 		uint16_t high_byte ) {
1304 1336
 	union mac_addr {
@@ -1329,13 +1361,14 @@ static mlx_status flexboot_nodnic_get_factory_mac (
1329 1361
 	status = mlx_vmac_query_virt_mac ( flexboot_nodnic_priv->device_priv.utils,
1330 1362
 			&virt_mac );
1331 1363
 	if ( ! status ) {
1332
-		DBGC ( flexboot_nodnic_priv, "NODNIC %p Failed to set the virtual MAC\n",
1333
-			flexboot_nodnic_priv );
1364
+		DBGC ( flexboot_nodnic_priv, "NODNIC %p Failed to set the virtual MAC\n"
1365
+			,flexboot_nodnic_priv );
1334 1366
 	}
1335 1367
 
1336 1368
 	return status;
1337 1369
 }
1338 1370
 
1371
+
1339 1372
 /**
1340 1373
  * Set port masking
1341 1374
  *
@@ -1361,6 +1394,79 @@ static int flexboot_nodnic_set_port_masking ( struct flexboot_nodnic *flexboot_n
1361 1394
 	return 0;
1362 1395
 }
1363 1396
 
1397
+int init_mlx_utils ( mlx_utils **utils, struct pci_device *pci ) {
1398
+	int rc = 0;
1399
+
1400
+	*utils = ( mlx_utils * ) zalloc ( sizeof ( mlx_utils ) );
1401
+	if ( *utils == NULL ) {
1402
+		DBGC ( utils, "%s: Failed to allocate utils\n", __FUNCTION__ );
1403
+		rc = -1;
1404
+		goto err_utils_alloc;
1405
+	}
1406
+	if ( mlx_utils_init ( *utils, pci ) ) {
1407
+		DBGC ( utils, "%s: mlx_utils_init failed\n", __FUNCTION__ );
1408
+		rc = -1;
1409
+		goto err_utils_init;
1410
+	}
1411
+	if ( mlx_pci_gw_init ( *utils ) ){
1412
+		DBGC ( utils, "%s: mlx_pci_gw_init failed\n", __FUNCTION__ );
1413
+		rc = -1;
1414
+		goto err_cmd_init;
1415
+	}
1416
+
1417
+	return 0;
1418
+
1419
+	mlx_pci_gw_teardown ( *utils );
1420
+err_cmd_init:
1421
+	mlx_utils_teardown ( *utils );
1422
+err_utils_init:
1423
+	free ( *utils );
1424
+err_utils_alloc:
1425
+	*utils = NULL;
1426
+
1427
+	return rc;
1428
+}
1429
+
1430
+void free_mlx_utils ( mlx_utils **utils ) {
1431
+
1432
+	mlx_pci_gw_teardown ( *utils );
1433
+	mlx_utils_teardown ( *utils );
1434
+	free ( *utils );
1435
+	*utils = NULL;
1436
+}
1437
+
1438
+/**
1439
+ * Initialise Nodnic PCI parameters
1440
+ *
1441
+ * @v hermon		Nodnic device
1442
+ */
1443
+static int flexboot_nodnic_alloc_uar ( struct flexboot_nodnic *flexboot_nodnic ) {
1444
+	mlx_status status = MLX_SUCCESS;
1445
+	struct pci_device *pci = flexboot_nodnic->pci;
1446
+	nodnic_uar *uar = &flexboot_nodnic->port[0].port_priv.device->uar;
1447
+
1448
+	if ( ! flexboot_nodnic->device_priv.utils ) {
1449
+		uar->virt = NULL;
1450
+		DBGC ( flexboot_nodnic, "%s: mlx_utils is not initialized \n", __FUNCTION__ );
1451
+		return -EINVAL;
1452
+	}
1453
+
1454
+	if  ( ! flexboot_nodnic->device_priv.device_cap.support_uar_tx_db ) {
1455
+		DBGC ( flexboot_nodnic, "%s: tx db using uar is not supported \n", __FUNCTION__ );
1456
+		return -ENOTSUP;
1457
+	}
1458
+	/* read uar offset then allocate */
1459
+	if  ( ( status = nodnic_port_set_send_uar_offset ( &flexboot_nodnic->port[0].port_priv ) ) ) {
1460
+		DBGC ( flexboot_nodnic, "%s: nodnic_port_set_send_uar_offset failed,"
1461
+				"status = %d\n", __FUNCTION__, status );
1462
+		return -EINVAL;
1463
+	}
1464
+	uar->phys = ( pci_bar_start ( pci, FLEXBOOT_NODNIC_HCA_BAR ) + (mlx_uint32)uar->offset );
1465
+	uar->virt = ( void * )( ioremap ( uar->phys, FLEXBOOT_NODNIC_PAGE_SIZE ) );
1466
+
1467
+	return status;
1468
+}
1469
+
1364 1470
 int flexboot_nodnic_probe ( struct pci_device *pci,
1365 1471
 		struct flexboot_nodnic_callbacks *callbacks,
1366 1472
 		void *drv_priv __unused ) {
@@ -1388,21 +1494,10 @@ int flexboot_nodnic_probe ( struct pci_device *pci,
1388 1494
 	pci_set_drvdata ( pci, flexboot_nodnic_priv );
1389 1495
 
1390 1496
 	device_priv = &flexboot_nodnic_priv->device_priv;
1391
-	device_priv->utils = (mlx_utils *)zalloc( sizeof ( mlx_utils ) );
1392
-	if ( device_priv->utils == NULL ) {
1393
-		DBGC ( flexboot_nodnic_priv, "%s: Failed to allocate utils\n", __FUNCTION__ );
1394
-		status = MLX_OUT_OF_RESOURCES;
1395
-		goto utils_err_alloc;
1396
-	}
1397
-
1398
-	status = mlx_utils_init( device_priv->utils, pci );
1399
-	MLX_FATAL_CHECK_STATUS(status, utils_init_err,
1400
-			"mlx_utils_init failed");
1401
-
1402
-	/* nodnic init*/
1403
-	status = mlx_pci_gw_init( device_priv->utils );
1404
-	MLX_FATAL_CHECK_STATUS(status, cmd_init_err,
1405
-			"mlx_pci_gw_init failed");
1497
+	/* init mlx utils */
1498
+	status = init_mlx_utils ( & device_priv->utils, pci );
1499
+	MLX_FATAL_CHECK_STATUS(status, err_utils_init,
1500
+				"init_mlx_utils failed");
1406 1501
 
1407 1502
 	/* init device */
1408 1503
 	status = nodnic_device_init( device_priv );
@@ -1426,6 +1521,11 @@ int flexboot_nodnic_probe ( struct pci_device *pci,
1426 1521
 	MLX_FATAL_CHECK_STATUS(status, err_thin_init_ports,
1427 1522
 						"flexboot_nodnic_thin_init_ports failed");
1428 1523
 
1524
+	if ( ( status = flexboot_nodnic_alloc_uar ( flexboot_nodnic_priv ) ) ) {
1525
+		DBGC(flexboot_nodnic_priv, "%s: flexboot_nodnic_pci_init failed"
1526
+				" ( status = %d )\n",__FUNCTION__, status );
1527
+	}
1528
+
1429 1529
 	/* device reg */
1430 1530
 	status = flexboot_nodnic_set_ports_type( flexboot_nodnic_priv );
1431 1531
 	MLX_CHECK_STATUS( flexboot_nodnic_priv, status, err_set_ports_types,
@@ -1456,11 +1556,8 @@ err_set_masking:
1456 1556
 get_cap_err:
1457 1557
 	nodnic_device_teardown ( device_priv );
1458 1558
 device_init_err:
1459
-	mlx_pci_gw_teardown ( device_priv->utils );
1460
-cmd_init_err:
1461
-utils_init_err:
1462
-	free ( device_priv->utils );
1463
-utils_err_alloc:
1559
+	free_mlx_utils ( & device_priv->utils );
1560
+err_utils_init:
1464 1561
 	free ( flexboot_nodnic_priv );
1465 1562
 device_err_alloc:
1466 1563
 	return status;
@@ -1473,7 +1570,6 @@ void flexboot_nodnic_remove ( struct pci_device *pci )
1473 1570
 
1474 1571
 	flexboot_nodnic_ports_unregister_dev ( flexboot_nodnic_priv );
1475 1572
 	nodnic_device_teardown( device_priv );
1476
-	mlx_pci_gw_teardown( device_priv->utils );
1477
-	free( device_priv->utils );
1573
+	free_mlx_utils ( & device_priv->utils );
1478 1574
 	free( flexboot_nodnic_priv );
1479 1575
 }

+ 27
- 1
src/drivers/infiniband/flexboot_nodnic.h Visa fil

@@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
27 27
 #include <ipxe/io.h>
28 28
 #include <ipxe/infiniband.h>
29 29
 #include <ipxe/netdevice.h>
30
+#include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.h"
30 31
 
31 32
 /*
32 33
  * If defined, use interrupts in NODNIC driver
@@ -37,6 +38,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
37 38
 #define FLEXBOOT_NODNIC_PORT_BASE		1
38 39
 
39 40
 #define FLEXBOOT_NODNIC_OPCODE_SEND		0xa
41
+#define FLEXBOOT_NODNIC_HCA_BAR	PCI_BASE_ADDRESS_0	//BAR 0
42
+#define FLEXBOOT_NODNIC_PAGE_SHIFT	12
43
+#define	FLEXBOOT_NODNIC_PAGE_SIZE		(1 << FLEXBOOT_NODNIC_PAGE_SHIFT)
44
+#define FLEXBOOT_NODNIC_PAGE_MASK		(FLEXBOOT_NODNIC_PAGE_SIZE - 1)
40 45
 
41 46
 /* Port protocol */
42 47
 enum flexboot_nodnic_protocol {
@@ -60,6 +65,7 @@ struct flexboot_nodnic_port {
60 65
 	struct ib_completion_queue *eth_cq;
61 66
 	/** Ethernet queue pair */
62 67
 	struct ib_queue_pair *eth_qp;
68
+	mlx_uint8 cmdsn;
63 69
 };
64 70
 
65 71
 
@@ -136,6 +142,21 @@ struct cqe_data{
136 142
 	mlx_uint32 byte_cnt;
137 143
 };
138 144
 
145
+union arm_cq_uar {
146
+	struct {
147
+		//big endian
148
+		mlx_uint32 reserved0	:2;
149
+		mlx_uint32 cmdn			:2;
150
+		mlx_uint32 reserved1	:3;
151
+		mlx_uint32 cmd			:1;
152
+		mlx_uint32 cq_ci		:24;
153
+		mlx_uint32 reserved2	:8;
154
+		mlx_uint32 cq_n		:24;
155
+	};
156
+	mlx_uint32 dword[2];
157
+	mlx_uint64 qword;
158
+};
159
+
139 160
 struct flexboot_nodnic_callbacks {
140 161
 	mlx_status ( * fill_completion ) ( void *cqe, struct cqe_data *cqe_data );
141 162
 	mlx_status ( * cqe_set_owner ) ( void *cq, unsigned int num_cqes );
@@ -149,6 +170,10 @@ struct flexboot_nodnic_callbacks {
149 170
 				unsigned long wqe_idx
150 171
 				);
151 172
 	void ( * irq ) ( struct net_device *netdev, int enable );
173
+	mlx_status ( * tx_uar_send_doorbell_fn ) (
174
+					struct ib_device *ibdev,
175
+					struct nodnic_send_wqbb *wqbb
176
+					);
152 177
 };
153 178
 
154 179
 int flexboot_nodnic_probe ( struct pci_device *pci,
@@ -159,5 +184,6 @@ void flexboot_nodnic_eth_irq ( struct net_device *netdev, int enable );
159 184
 int flexboot_nodnic_is_supported ( struct pci_device *pci );
160 185
 void flexboot_nodnic_copy_mac ( uint8_t mac_addr[], uint32_t low_byte,
161 186
 		uint16_t high_byte );
162
-
187
+int init_mlx_utils ( mlx_utils **utils, struct pci_device *pci );
188
+void free_mlx_utils ( mlx_utils **utils );
163 189
 #endif /* SRC_DRIVERS_INFINIBAND_FLEXBOOT_NODNIC_FLEXBOOT_NODNIC_H_ */

+ 126
- 80
src/drivers/infiniband/golan.c Visa fil

@@ -21,31 +21,32 @@ FILE_LICENCE ( GPL2_OR_LATER );
21 21
 
22 22
 #include <errno.h>
23 23
 #include <strings.h>
24
-#include <byteswap.h>
25 24
 #include <ipxe/malloc.h>
26 25
 #include <ipxe/umalloc.h>
27 26
 #include <ipxe/infiniband.h>
28 27
 #include <ipxe/ib_smc.h>
29 28
 #include <ipxe/iobuf.h>
30 29
 #include <ipxe/netdevice.h>
30
+#include "flexboot_nodnic.h"
31 31
 #include <ipxe/ethernet.h>
32 32
 #include <ipxe/if_ether.h>
33
+#include <usr/ifmgmt.h>
33 34
 #include <ipxe/in.h>
35
+#include <byteswap.h>
36
+#include "mlx_utils/include/public/mlx_pci_gw.h"
37
+#include <config/general.h>
34 38
 #include <ipxe/ipoib.h>
35
-#include "flexboot_nodnic.h"
39
+#include "mlx_nodnic/include/mlx_port.h"
36 40
 #include "nodnic_shomron_prm.h"
37 41
 #include "golan.h"
38 42
 #include "mlx_utils/include/public/mlx_bail.h"
39 43
 #include "mlx_utils/mlx_lib/mlx_link_speed/mlx_link_speed.h"
40
-#include "mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.h"
41
-#include "mlx_utils/include/public/mlx_pci_gw.h"
42
-#include "mlx_nodnic/include/mlx_port.h"
43 44
 
45
+#define DEVICE_IS_CIB( device ) ( device == 0x1011 )
44 46
 /******************************************************************************/
45 47
 /************* Very simple memory management for umalloced pages **************/
46 48
 /******* Temporary solution until full memory management is implemented *******/
47 49
 /******************************************************************************/
48
-#define GOLAN_PAGES	20
49 50
 struct golan_page {
50 51
 	struct list_head list;
51 52
 	userptr_t addr;
@@ -61,8 +62,7 @@ static void golan_free_pages ( struct list_head *head ) {
61 62
 }
62 63
 
63 64
 static int golan_init_pages ( struct list_head *head ) {
64
-	struct golan_page *new_entry;
65
-	int rc, i;
65
+	int rc = 0;
66 66
 
67 67
 	if ( !head ) {
68 68
 		rc = -EINVAL;
@@ -70,26 +70,8 @@ static int golan_init_pages ( struct list_head *head ) {
70 70
 	}
71 71
 
72 72
 	INIT_LIST_HEAD ( head );
73
+	return rc;
73 74
 
74
-	for ( i = 0; i < GOLAN_PAGES; i++ ) {
75
-		new_entry = zalloc ( sizeof ( *new_entry ) );
76
-		if ( new_entry == NULL ) {
77
-			rc = -ENOMEM;
78
-			goto err_golan_init_pages_alloc_page;
79
-		}
80
-		new_entry->addr = umalloc ( GOLAN_PAGE_SIZE );
81
-		if ( new_entry->addr == UNULL ) {
82
-			free ( new_entry );
83
-			rc = -ENOMEM;
84
-			goto err_golan_init_pages_alloc_page;
85
-		}
86
-		list_add ( &new_entry->list, head );
87
-	}
88
-
89
-	return 0;
90
-
91
-err_golan_init_pages_alloc_page:
92
-	golan_free_pages ( head );
93 75
 err_golan_init_pages_bad_param:
94 76
 	return rc;
95 77
 }
@@ -98,16 +80,42 @@ static userptr_t golan_get_page ( struct list_head *head ) {
98 80
 	struct golan_page *page;
99 81
 	userptr_t addr;
100 82
 
101
-	if ( list_empty ( head ) )
102
-		return UNULL;
103
-
104
-	page = list_first_entry ( head, struct golan_page, list );
105
-	list_del ( &page->list );
106
-	addr = page->addr;
107
-	free ( page );
83
+	if ( list_empty ( head ) ) {
84
+		addr = umalloc ( GOLAN_PAGE_SIZE );
85
+		if ( addr == UNULL ) {
86
+			goto err_golan_iget_page_alloc_page;
87
+		}
88
+	} else {
89
+		page = list_first_entry ( head, struct golan_page, list );
90
+		list_del ( &page->list );
91
+		addr = page->addr;
92
+		free ( page );
93
+	}
94
+err_golan_iget_page_alloc_page:
108 95
 	return addr;
109 96
 }
110 97
 
98
+static int golan_return_page ( struct list_head *head,
99
+		userptr_t addr ) {
100
+	struct golan_page *new_entry;
101
+	int rc = 0;
102
+
103
+	if ( ! head ) {
104
+		rc = -EINVAL;
105
+		goto err_golan_return_page_bad_param;
106
+	}
107
+	new_entry = zalloc ( sizeof ( *new_entry ) );
108
+	if ( new_entry == NULL ) {
109
+		rc = -ENOMEM;
110
+		goto err_golan_return_page_alloc_page;
111
+	}
112
+	new_entry->addr = addr;
113
+	list_add_tail( &new_entry->list, head );
114
+
115
+err_golan_return_page_alloc_page:
116
+err_golan_return_page_bad_param:
117
+	return rc;
118
+}
111 119
 /******************************************************************************/
112 120
 
113 121
 const char *golan_qp_state_as_string[] = {
@@ -450,8 +458,8 @@ err_query_hca_cap:
450 458
 
451 459
 static inline int golan_take_pages ( struct golan *golan, uint32_t pages, __be16 func_id ) {
452 460
 	uint32_t out_num_entries = 0;
453
-	int size_ibox =  sizeof(struct golan_manage_pages_inbox);
454
-	int size_obox = sizeof(struct golan_manage_pages_outbox);
461
+	int size_ibox = 0;
462
+	int size_obox = 0;
455 463
 	int rc = 0;
456 464
 
457 465
 	DBGC(golan, "%s\n", __FUNCTION__);
@@ -463,8 +471,8 @@ static inline int golan_take_pages ( struct golan *golan, uint32_t pages, __be16
463 471
 		struct golan_manage_pages_inbox *in;
464 472
 		struct golan_manage_pages_outbox_data *out;
465 473
 
466
-		size_ibox += (pas_num * GOLAN_PAS_SIZE);
467
-		size_obox += (pas_num * GOLAN_PAS_SIZE);
474
+		size_ibox = sizeof(struct golan_manage_pages_inbox) + (pas_num * GOLAN_PAS_SIZE);
475
+		size_obox = sizeof(struct golan_manage_pages_outbox) + (pas_num * GOLAN_PAS_SIZE);
468 476
 
469 477
 		cmd = write_cmd(golan, MEM_CMD_IDX, GOLAN_CMD_OP_MANAGE_PAGES, GOLAN_PAGES_TAKE,
470 478
 				MEM_MBOX, MEM_MBOX,
@@ -480,7 +488,7 @@ static inline int golan_take_pages ( struct golan *golan, uint32_t pages, __be16
480 488
 			out = (struct golan_manage_pages_outbox_data *)GET_OUTBOX(golan, MEM_MBOX);
481 489
 			out_num_entries = be32_to_cpu(((struct golan_manage_pages_outbox *)(cmd->out))->num_entries);
482 490
 			for (i = 0; i < out_num_entries; ++i) {
483
-				ufree(BE64_BUS_2_USR(out->pas[i]));
491
+				golan_return_page ( &golan->pages, ( BE64_BUS_2_USR( out->pas[i] ) ) );
484 492
 			}
485 493
 		} else {
486 494
 			if ( rc == -EBUSY ) {
@@ -503,8 +511,8 @@ static inline int golan_take_pages ( struct golan *golan, uint32_t pages, __be16
503 511
 
504 512
 static inline int golan_provide_pages ( struct golan *golan , uint32_t pages, __be16 func_id ) {
505 513
 	struct mbox *mailbox;
506
-	int size_ibox =  sizeof(struct golan_manage_pages_inbox);
507
-	int size_obox = sizeof(struct golan_manage_pages_outbox);
514
+	int size_ibox = 0;
515
+	int size_obox = 0;
508 516
 	int rc = 0;
509 517
 
510 518
 	DBGC(golan, "%s\n", __FUNCTION__);
@@ -517,8 +525,8 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages, __
517 525
 		userptr_t addr = 0;
518 526
 
519 527
 		mailbox = GET_INBOX(golan, MEM_MBOX);
520
-		size_ibox += (pas_num * GOLAN_PAS_SIZE);
521
-		size_obox += (pas_num * GOLAN_PAS_SIZE);
528
+		size_ibox = sizeof(struct golan_manage_pages_inbox) + (pas_num * GOLAN_PAS_SIZE);
529
+		size_obox = sizeof(struct golan_manage_pages_outbox) + (pas_num * GOLAN_PAS_SIZE);
522 530
 
523 531
 		cmd = write_cmd(golan, MEM_CMD_IDX, GOLAN_CMD_OP_MANAGE_PAGES, GOLAN_PAGES_GIVE,
524 532
 				MEM_MBOX, MEM_MBOX,
@@ -531,7 +539,7 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages, __
531 539
 		in->num_entries = cpu_to_be32(pas_num);
532 540
 
533 541
 		for ( i = 0 , j = MANAGE_PAGES_PSA_OFFSET; i < pas_num; ++i ,++j ) {
534
-			if (!(addr = umalloc(GOLAN_PAGE_SIZE))) {
542
+			if ( ! ( addr = golan_get_page ( & golan->pages ) ) ) {
535 543
 				rc = -ENOMEM;
536 544
 				DBGC (golan ,"Couldnt allocated page \n");
537 545
 				goto malloc_dma_failed;
@@ -555,7 +563,7 @@ static inline int golan_provide_pages ( struct golan *golan , uint32_t pages, __
555 563
 						get_cmd( golan , MEM_CMD_IDX )->status_own,
556 564
 						be32_to_cpu(CMD_SYND(golan, MEM_CMD_IDX)), pas_num);
557 565
 			}
558
-			ufree ( addr );
566
+			golan_return_page ( &golan->pages ,addr );
559 567
 			goto err_send_command;
560 568
 		}
561 569
 	}
@@ -834,7 +842,7 @@ static int golan_create_eq(struct golan *golan)
834 842
 	return 0;
835 843
 
836 844
 err_create_eq_cmd:
837
-	ufree(virt_to_user(golan->eq.eqes));
845
+	golan_return_page ( & golan->pages, virt_to_user ( eq->eqes ) );
838 846
 err_create_eq_eqe_alloc:
839 847
 	DBGC (golan ,"%s [%d] out\n", __FUNCTION__, rc);
840 848
 	return rc;
@@ -859,7 +867,7 @@ static void golan_destory_eq(struct golan *golan)
859 867
 	rc = send_command_and_wait(golan, DEF_CMD_IDX, NO_MBOX, NO_MBOX, __FUNCTION__);
860 868
 	GOLAN_PRINT_RC_AND_CMD_STATUS;
861 869
 
862
-	ufree(virt_to_user(golan->eq.eqes));
870
+	golan_return_page ( &golan->pages, virt_to_user ( golan->eq.eqes ) );
863 871
 	golan->eq.eqn = 0;
864 872
 
865 873
 	DBGC( golan, "%s Event queue (0x%x) was destroyed\n", __FUNCTION__, eqn);
@@ -1063,7 +1071,7 @@ static int golan_create_cq(struct ib_device *ibdev,
1063 1071
 	return 0;
1064 1072
 
1065 1073
 err_create_cq_cmd:
1066
-	ufree(virt_to_user(golan_cq->cqes));
1074
+	golan_return_page ( & golan->pages, virt_to_user ( golan_cq->cqes ) );
1067 1075
 err_create_cq_cqe_alloc:
1068 1076
 	free_dma(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE);
1069 1077
 err_create_cq_db_alloc:
@@ -1100,7 +1108,7 @@ static void golan_destroy_cq(struct ib_device *ibdev,
1100 1108
 	cq->cqn = 0;
1101 1109
 
1102 1110
 	ib_cq_set_drvdata(cq, NULL);
1103
-	ufree(virt_to_user(golan_cq->cqes));
1111
+	golan_return_page ( & golan->pages, virt_to_user ( golan_cq->cqes ) );
1104 1112
 	free_dma(golan_cq->doorbell_record, GOLAN_CQ_DB_RECORD_SIZE);
1105 1113
 	free(golan_cq);
1106 1114
 
@@ -1272,7 +1280,7 @@ static int golan_create_qp_aux(struct ib_device *ibdev,
1272 1280
 err_create_qp_cmd:
1273 1281
 	free_dma(golan_qp->doorbell_record, sizeof(struct golan_qp_db));
1274 1282
 err_create_qp_db_alloc:
1275
-	ufree((userptr_t)golan_qp->wqes);
1283
+	golan_return_page ( & golan->pages, ( userptr_t ) golan_qp->wqes );
1276 1284
 err_create_qp_wqe_alloc:
1277 1285
 err_create_qp_sq_size:
1278 1286
 err_create_qp_sq_wqe_size:
@@ -1326,7 +1334,7 @@ static int golan_modify_qp_rst_to_init(struct ib_device *ibdev,
1326 1334
 
1327 1335
 	in->ctx.pri_path.port		= ibdev->port;
1328 1336
 	in->ctx.flags			|= cpu_to_be32(GOLAN_QP_PM_MIGRATED << GOLAN_QP_CTX_PM_STATE_BIT);
1329
-	in->ctx.pri_path.pkey_index	= 0; /* default index */
1337
+	in->ctx.pri_path.pkey_index	= 0;
1330 1338
 	/* QK is 0 */
1331 1339
 	/* QP cntr set 0 */
1332 1340
 	return rc;
@@ -1480,7 +1488,7 @@ static void golan_destroy_qp(struct ib_device *ibdev,
1480 1488
 
1481 1489
 	ib_qp_set_drvdata(qp, NULL);
1482 1490
 	free_dma(golan_qp->doorbell_record, sizeof(struct golan_qp_db));
1483
-	ufree((userptr_t)golan_qp->wqes);
1491
+	golan_return_page ( & golan->pages, ( userptr_t ) golan_qp->wqes );
1484 1492
 	free(golan_qp);
1485 1493
 
1486 1494
 	DBGC( golan ,"%s QP 0x%lx was destroyed\n", __FUNCTION__, qpn);
@@ -1694,8 +1702,8 @@ err_query_vport_gid_cmd:
1694 1702
 static int golan_query_vport_pkey ( struct ib_device *ibdev ) {
1695 1703
 	struct golan *golan = ib_get_drvdata ( ibdev );
1696 1704
 	struct golan_cmd_layout	*cmd;
1697
-	struct golan_query_hca_vport_pkey_inbox *in;
1698 1705
 	//struct golan_query_hca_vport_pkey_data *pkey_table;
1706
+	struct golan_query_hca_vport_pkey_inbox *in;
1699 1707
 	int pkey_table_size_in_entries = (1 << (7 + golan->caps.pkey_table_size));
1700 1708
 	int rc;
1701 1709
 
@@ -2244,26 +2252,24 @@ static inline void golan_bring_down(struct golan *golan)
2244 2252
 }
2245 2253
 
2246 2254
 static int golan_set_link_speed ( struct golan *golan ){
2247
-	mlx_utils utils;
2248 2255
 	mlx_status status;
2249 2256
 	int i = 0;
2257
+	int utils_inited = 0;
2250 2258
 
2251
-	memset ( &utils, 0, sizeof ( utils ) );
2252
-
2253
-	status = mlx_utils_init ( &utils, golan->pci );
2254
-	MLX_CHECK_STATUS ( golan->pci, status, utils_init_err, "mlx_utils_init failed" );
2255
-
2256
-	status = mlx_pci_gw_init ( &utils );
2257
-	MLX_CHECK_STATUS ( golan->pci, status, pci_gw_init_err, "mlx_pci_gw_init failed" );
2259
+	if ( ! golan->utils ) {
2260
+		utils_inited = 1;
2261
+		status = init_mlx_utils ( & golan->utils, golan->pci );
2262
+		MLX_CHECK_STATUS ( golan->pci, status, utils_init_err, "mlx_utils_init failed" );
2263
+	}
2258 2264
 
2259 2265
 	for ( i = 0; i < golan->caps.num_ports; ++i ) {
2260
-		status = mlx_set_link_speed( &utils, i + 1, LINK_SPEED_IB, LINK_SPEED_SDR );
2266
+		status = mlx_set_link_speed ( golan->utils, i + 1, LINK_SPEED_IB, LINK_SPEED_SDR );
2261 2267
 		MLX_CHECK_STATUS ( golan->pci, status, set_link_speed_err, "mlx_set_link_speed failed" );
2262 2268
 	}
2263 2269
 
2264 2270
 set_link_speed_err:
2265
-	mlx_pci_gw_teardown( &utils );
2266
-pci_gw_init_err:
2271
+if ( utils_inited )
2272
+	free_mlx_utils ( & golan->utils );
2267 2273
 utils_init_err:
2268 2274
 	return status;
2269 2275
 }
@@ -2344,7 +2350,16 @@ out:
2344 2350
  *
2345 2351
  * @v ibdev		Infiniband device
2346 2352
  */
2347
-static void golan_ib_close ( struct ib_device *ibdev __unused ) {}
2353
+static void golan_ib_close ( struct ib_device *ibdev ) {
2354
+	struct golan *golan = NULL;
2355
+
2356
+	DBG ( "%s start\n", __FUNCTION__ );
2357
+	if ( ! ibdev )
2358
+		return;
2359
+	golan = ib_get_drvdata ( ibdev );
2360
+	golan_bring_down ( golan );
2361
+	DBG ( "%s end\n", __FUNCTION__ );
2362
+}
2348 2363
 
2349 2364
 /**
2350 2365
  * Initialise Infiniband link
@@ -2353,11 +2368,13 @@ static void golan_ib_close ( struct ib_device *ibdev __unused ) {}
2353 2368
  * @ret rc		Return status code
2354 2369
  */
2355 2370
 static int golan_ib_open ( struct ib_device *ibdev ) {
2371
+	struct golan *golan = NULL;
2356 2372
 	DBG ( "%s start\n", __FUNCTION__ );
2357 2373
 
2358 2374
 	if ( ! ibdev )
2359 2375
 		return -EINVAL;
2360
-
2376
+	golan = ib_get_drvdata ( ibdev );
2377
+	golan_bring_up ( golan );
2361 2378
 	golan_ib_update ( ibdev );
2362 2379
 
2363 2380
 	DBG ( "%s end\n", __FUNCTION__ );
@@ -2417,6 +2434,12 @@ static int golan_probe_normal ( struct pci_device *pci ) {
2417 2434
 		goto err_golan_bringup;
2418 2435
 	}
2419 2436
 
2437
+	if ( ! DEVICE_IS_CIB ( pci->device ) ) {
2438
+		if ( init_mlx_utils ( & golan->utils, pci ) ) {
2439
+			rc = -1;
2440
+			goto err_utils_init;
2441
+		}
2442
+	}
2420 2443
 	/* Allocate Infiniband devices */
2421 2444
 	for (i = 0; i < golan->caps.num_ports; ++i) {
2422 2445
 		ibdev = alloc_ibdev( 0 );
@@ -2435,10 +2458,13 @@ static int golan_probe_normal ( struct pci_device *pci ) {
2435 2458
 	/* Register devices */
2436 2459
 	for ( i = 0; i < golan->caps.num_ports; ++i ) {
2437 2460
 		port = &golan->ports[i];
2438
-		if ((rc = golan_register_ibdev ( port ) ) != 0 )
2461
+		if ((rc = golan_register_ibdev ( port ) ) != 0 ) {
2439 2462
 			goto err_golan_probe_register_ibdev;
2463
+		}
2440 2464
 	}
2441 2465
 
2466
+	golan_bring_down ( golan );
2467
+
2442 2468
 	return 0;
2443 2469
 
2444 2470
 	i = golan->caps.num_ports;
@@ -2450,7 +2476,10 @@ err_golan_probe_register_ibdev:
2450 2476
 err_golan_probe_alloc_ibdev:
2451 2477
 	for ( i-- ; ( signed int ) i >= 0 ; i-- )
2452 2478
 		ibdev_put ( golan->ports[i].ibdev );
2453
-
2479
+	if ( ! DEVICE_IS_CIB ( pci->device ) ) {
2480
+		free_mlx_utils ( & golan->utils );
2481
+	}
2482
+err_utils_init:
2454 2483
 	golan_bring_down ( golan );
2455 2484
 err_golan_bringup:
2456 2485
 err_fw_ver_cmdif:
@@ -2476,13 +2505,13 @@ static void golan_remove_normal ( struct pci_device *pci ) {
2476 2505
 	}
2477 2506
 	for ( i = ( golan->caps.num_ports - 1 ) ; i >= 0 ; i-- ) {
2478 2507
 		netdev_nullify ( golan->ports[i].netdev );
2479
-		netdev_put ( golan->ports[i].netdev );
2480 2508
 	}
2481 2509
 	for ( i = ( golan->caps.num_ports - 1 ) ; i >= 0 ; i-- ) {
2482 2510
 		ibdev_put ( golan->ports[i].ibdev );
2483 2511
 	}
2484
-
2485
-	golan_bring_down(golan);
2512
+	if ( ! DEVICE_IS_CIB ( pci->device ) ) {
2513
+		free_mlx_utils ( & golan->utils );
2514
+	}
2486 2515
 	iounmap( golan->iseg );
2487 2516
 	golan_free_pages( &golan->pages );
2488 2517
 	free(golan);
@@ -2491,6 +2520,26 @@ static void golan_remove_normal ( struct pci_device *pci ) {
2491 2520
 /***************************************************************************
2492 2521
  * NODNIC operations
2493 2522
  **************************************************************************/
2523
+static mlx_status shomron_tx_uar_send_db ( struct ib_device *ibdev,
2524
+		struct nodnic_send_wqbb *wqbb ) {
2525
+	mlx_status status = MLX_SUCCESS;
2526
+	struct flexboot_nodnic *flexboot_nodnic = ib_get_drvdata ( ibdev );
2527
+	struct shomron_nodnic_eth_send_wqe *eth_wqe =
2528
+			( struct shomron_nodnic_eth_send_wqe * )wqbb;
2529
+	struct shomronprm_wqe_segment_ctrl_send *ctrl;
2530
+
2531
+	if ( ! ibdev || ! eth_wqe || ! flexboot_nodnic->device_priv.uar.virt ) {
2532
+		DBG("%s: Invalid parameters\n",__FUNCTION__);
2533
+		status = MLX_FAILED;
2534
+		goto err;
2535
+	}
2536
+	wmb();
2537
+	ctrl = & eth_wqe->ctrl;
2538
+	writeq(*((__be64 *)ctrl), flexboot_nodnic->device_priv.uar.virt + 0x800);
2539
+err:
2540
+	return status;
2541
+}
2542
+
2494 2543
 static mlx_status shomron_fill_eth_send_wqe ( struct ib_device *ibdev,
2495 2544
 			   struct ib_queue_pair *qp, struct ib_address_vector *av __unused,
2496 2545
 			   struct io_buffer *iobuf, struct nodnic_send_wqbb *wqbb,
@@ -2599,12 +2648,13 @@ struct flexboot_nodnic_callbacks shomron_nodnic_callbacks = {
2599 2648
 	.fill_completion = shomron_fill_completion,
2600 2649
 	.cqe_set_owner = shomron_cqe_set_owner,
2601 2650
 	.irq = flexboot_nodnic_eth_irq,
2651
+	.tx_uar_send_doorbell_fn = shomron_tx_uar_send_db,
2602 2652
 };
2603 2653
 
2604 2654
 static int shomron_nodnic_supported = 0;
2605 2655
 
2606 2656
 static int shomron_nodnic_is_supported ( struct pci_device *pci ) {
2607
-	if ( pci->device == 0x1011 )
2657
+	if ( DEVICE_IS_CIB ( pci->device ) )
2608 2658
 		return 0;
2609 2659
 
2610 2660
 	return flexboot_nodnic_is_supported ( pci );
@@ -2624,15 +2674,9 @@ static int golan_probe ( struct pci_device *pci ) {
2624 2674
 
2625 2675
 	shomron_nodnic_supported = shomron_nodnic_is_supported ( pci );
2626 2676
 	if ( shomron_nodnic_supported ) {
2677
+		DBG ( "%s: Using NODNIC driver\n", __FUNCTION__ );
2627 2678
 		rc = flexboot_nodnic_probe ( pci, &shomron_nodnic_callbacks, NULL );
2628
-		if ( rc == 0 ) {
2629
-			DBG ( "%s: Using NODNIC driver\n", __FUNCTION__ );
2630
-			goto probe_done;
2631
-		}
2632
-		shomron_nodnic_supported = 0;
2633
-	}
2634
-
2635
-	if ( ! shomron_nodnic_supported ) {
2679
+	} else {
2636 2680
 		DBG ( "%s: Using normal driver\n", __FUNCTION__ );
2637 2681
 		rc = golan_probe_normal ( pci );
2638 2682
 	}
@@ -2662,6 +2706,8 @@ static struct pci_device_id golan_nics[] = {
2662 2706
 	PCI_ROM ( 0x15b3, 0x1011, "ConnectIB", "ConnectIB HCA driver: DevID 4113", 0 ),
2663 2707
 	PCI_ROM ( 0x15b3, 0x1013, "ConnectX-4", "ConnectX-4 HCA driver, DevID 4115", 0 ),
2664 2708
 	PCI_ROM ( 0x15b3, 0x1015, "ConnectX-4Lx", "ConnectX-4Lx HCA driver, DevID 4117", 0 ),
2709
+	PCI_ROM ( 0x15b3, 0x1017, "ConnectX-5", "ConnectX-5 HCA driver, DevID 4119", 0 ),
2710
+	PCI_ROM ( 0x15b3, 0x1019, "ConnectX-5EX", "ConnectX-5EX HCA driver, DevID 4121", 0 ),
2665 2711
 };
2666 2712
 
2667 2713
 struct pci_driver golan_driver __pci_driver = {

+ 5
- 3
src/drivers/infiniband/golan.h Visa fil

@@ -22,14 +22,15 @@
22 22
 
23 23
 FILE_LICENCE ( GPL2_OR_LATER );
24 24
 
25
+#include <ipxe/pci.h>
26
+#include <ipxe/pcibackup.h>
25 27
 #include <byteswap.h>
26 28
 #include <errno.h>
29
+#include <ipxe/io.h>
27 30
 #include <stdio.h>
28 31
 #include <unistd.h>
29
-#include <ipxe/io.h>
30
-#include <ipxe/pci.h>
31
-#include <ipxe/pcibackup.h>
32 32
 #include "CIB_PRM.h"
33
+#include "mlx_utils/include/public/mlx_utils.h"
33 34
 
34 35
 #define GOLAN_PCI_CONFIG_BAR_SIZE	0x100000//HERMON_PCI_CONFIG_BAR_SIZE //TODO: What is the BAR size?
35 36
 
@@ -319,6 +320,7 @@ struct golan {
319 320
 	uint32_t			pdn;
320 321
 	u32				mkey;
321 322
 	u32				flags;
323
+	mlx_utils		*utils;
322 324
 
323 325
 	struct golan_port		ports[GOLAN_MAX_PORTS];
324 326
 };

+ 31
- 1
src/drivers/infiniband/mlx_nodnic/include/mlx_nodnic_data_structures.h Visa fil

@@ -36,6 +36,8 @@ typedef struct _nodnic_device_capabilites 		nodnic_device_capabilites;
36 36
 typedef struct _nodnic_qp 						nodnic_qp;
37 37
 typedef struct _nodnic_cq 						nodnic_cq;
38 38
 typedef struct _nodnic_eq						nodnic_eq;
39
+typedef struct _nodnic_qp_db					nodnic_qp_db;
40
+typedef struct _nodnic_arm_cq_db				nodnic_arm_cq_db;
39 41
 
40 42
 /* NODNIC Port states
41 43
  * Bit 0 - port open/close
@@ -73,6 +75,12 @@ typedef enum {
73 75
 struct nodnic_send_wqbb {
74 76
 	mlx_uint8 force_align[NODNIC_WQBB_SIZE];
75 77
 };
78
+
79
+struct nodnic_doorbell {
80
+	mlx_physical_address doorbell_physical;
81
+	mlx_void *map;
82
+	nodnic_qp_db *qp_doorbell_record;
83
+};
76 84
 struct nodnic_ring {
77 85
 	mlx_uint32 offset;
78 86
 	/** Work queue entries */
@@ -91,7 +99,8 @@ struct nodnic_ring {
91 99
 	mlx_uint32 num_wqes;
92 100
 	mlx_uint32 qpn;
93 101
 	mlx_uint32 next_idx;
94
-	mlx_uint32	ring_pi;
102
+	struct nodnic_doorbell recv_doorbell;
103
+	struct nodnic_doorbell send_doorbell;
95 104
 };
96 105
 
97 106
 struct nodnic_send_ring{
@@ -117,6 +126,7 @@ struct _nodnic_cq{
117 126
 	mlx_void *map;
118 127
 	/** cq */
119 128
 	mlx_size cq_size;
129
+	struct nodnic_doorbell arm_cq_doorbell;
120 130
 };
121 131
 
122 132
 struct _nodnic_eq{
@@ -136,6 +146,10 @@ struct _nodnic_device_capabilites{
136 146
 #ifdef DEVICE_CX3
137 147
 	mlx_uint8					crspace_doorbells;
138 148
 #endif
149
+	mlx_uint8					support_rx_pi_dma;
150
+	mlx_uint8					support_uar_tx_db;
151
+	mlx_uint8					support_bar_cq_ctrl;
152
+	mlx_uint8					log_uar_page_size;
139 153
 };
140 154
 
141 155
 #ifdef DEVICE_CX3
@@ -151,6 +165,13 @@ struct _nodnic_port_data_flow_gw {
151 165
 } __attribute__ ((packed));
152 166
 #endif
153 167
 
168
+typedef struct _nodnic_uar_priv{
169
+	mlx_uint8 inited;
170
+	mlx_uint64	offset;
171
+	void	*virt;
172
+	unsigned long	phys;
173
+} nodnic_uar;
174
+
154 175
 struct _nodnic_device_priv{
155 176
 	mlx_boolean					is_initiailzied;
156 177
 	mlx_utils					*utils;
@@ -169,6 +190,7 @@ struct _nodnic_device_priv{
169 190
 #ifdef DEVICE_CX3
170 191
 	mlx_void					*crspace_clear_int;
171 192
 #endif
193
+	nodnic_uar uar;
172 194
 };
173 195
 
174 196
 struct _nodnic_port_priv{
@@ -181,6 +203,7 @@ struct _nodnic_port_priv{
181 203
 	mlx_uint8				port_num;
182 204
 	nodnic_eq				eq;
183 205
 	mlx_mac_address			mac_filters[5];
206
+	nodnic_arm_cq_db		*arm_cq_doorbell_record;
184 207
 	mlx_status (*send_doorbell)(
185 208
 			IN nodnic_port_priv		*port_priv,
186 209
 			IN struct nodnic_ring	*ring,
@@ -197,5 +220,12 @@ struct _nodnic_port_priv{
197 220
 #endif
198 221
 };
199 222
 
223
+struct _nodnic_qp_db {
224
+	mlx_uint32	recv_db;
225
+	mlx_uint32	send_db;
226
+} __attribute ( ( packed ) );
200 227
 
228
+struct _nodnic_arm_cq_db {
229
+	mlx_uint32	dword[2];
230
+} __attribute ( ( packed ) );
201 231
 #endif /* STUB_NODNIC_NODNICDATASTRUCTURES_H_ */

+ 13
- 0
src/drivers/infiniband/mlx_nodnic/include/mlx_port.h Visa fil

@@ -47,6 +47,9 @@ typedef enum {
47 47
 #ifdef DEVICE_CX3
48 48
 	nodnic_port_option_crspace_en,
49 49
 #endif
50
+	nodnic_port_option_send_ring0_uar_index,
51
+	nodnic_port_option_send_ring1_uar_index,
52
+	nodnic_port_option_cq_n_index,
50 53
 }nodnic_port_option;
51 54
 
52 55
 struct nodnic_port_data_entry{
@@ -226,4 +229,14 @@ nodnic_port_read_port_management_change_event(
226 229
 						IN nodnic_port_priv		*port_priv,
227 230
 						OUT mlx_boolean			*change_event
228 231
 						);
232
+mlx_status
233
+nodnic_port_set_send_uar_offset(
234
+		IN  nodnic_port_priv	*port_priv
235
+		);
236
+
237
+mlx_status
238
+nodnic_port_update_tx_db_func(
239
+		IN nodnic_device_priv	*device_priv,
240
+		IN nodnic_port_priv		*port_priv
241
+		);
229 242
 #endif /* STUB_NODNIC_PORT_H_ */

+ 32
- 2
src/drivers/infiniband/mlx_nodnic/src/mlx_device.c Visa fil

@@ -169,11 +169,17 @@ nodnic_device_clear_int (
169 169
 	mlx_status 			status = MLX_SUCCESS;
170 170
 	mlx_uint32			disable = 1;
171 171
 #ifndef DEVICE_CX3
172
-	status = nodnic_cmd_write(device_priv, NODNIC_NIC_DISABLE_INT_OFFSET, disable);
172
+#define NODNIC_CLEAR_INT_BAR_OFFSET 0x100C
173
+	if ( device_priv->device_cap.support_bar_cq_ctrl ) {
174
+		status = mlx_pci_mem_write ( device_priv->utils, MlxPciWidthUint32, 0,
175
+			( mlx_uint64 ) ( NODNIC_CLEAR_INT_BAR_OFFSET ), 1, &disable );
176
+	} else {
177
+		status = nodnic_cmd_write(device_priv, NODNIC_NIC_DISABLE_INT_OFFSET, disable);
178
+	}
173 179
 	MLX_CHECK_STATUS(device_priv, status, clear_int_done, "failed writing to disable_bit");
174 180
 #else
175 181
 	mlx_utils *utils = device_priv->utils;
176
-	mlx_uint64 clear_int = (mlx_uint64)(device_priv->crspace_clear_int);
182
+	mlx_uint64 clear_int = (mlx_uintn)(device_priv->crspace_clear_int);
177 183
 	mlx_uint32 swapped = 0;
178 184
 
179 185
 	if (device_priv->device_cap.crspace_doorbells == 0) {
@@ -303,6 +309,30 @@ nodnic_device_get_cap(
303 309
 	status = nodnic_cmd_read(device_priv, device_priv->device_offset + 0x14, (mlx_uint32*)&guid_l);
304 310
 	MLX_FATAL_CHECK_STATUS(status, read_err, "failed to read nodnic guid_l");
305 311
 	device_priv->device_guid = guid_l | (guid_h << 32);
312
+
313
+#define NODNIC_DEVICE_SUPPORT_RX_PI_DMA_OFFSET 31
314
+#define NODNIC_DEVICE_SUPPORT_RX_PI_DMA_MASK 0x1
315
+#define NODNIC_DEVICE_SUPPORT_UAR_TRX_DB_OFFSET 29
316
+#define NODNIC_DEVICE_SUPPORT_UAR_TRX_DB_MASK 0x1
317
+#define NODNIC_DEVICE_SUPPORT_BAR_CQ_CONTROL_OFFSET 27
318
+#define NODNIC_DEVICE_SUPPORT_BAR_CQ_CONTROL_MASK 0x1
319
+	status = nodnic_cmd_read(device_priv, device_priv->device_offset + 0x1c, &buffer);
320
+	MLX_FATAL_CHECK_STATUS(status, read_err, "failed to read nodnic support_rx_pi_dma");
321
+	if ( sizeof ( mlx_uintn ) == sizeof ( mlx_uint32 ) ) {
322
+		device_cap->support_rx_pi_dma = FALSE;
323
+		device_cap->support_uar_tx_db = FALSE;
324
+		device_cap->support_bar_cq_ctrl = FALSE;
325
+	} else {
326
+		device_cap->support_rx_pi_dma = CHECK_BIT(buffer, NODNIC_DEVICE_SUPPORT_RX_PI_DMA_OFFSET);
327
+		device_cap->support_uar_tx_db = CHECK_BIT(buffer, NODNIC_DEVICE_SUPPORT_UAR_TRX_DB_OFFSET);
328
+		device_cap->support_bar_cq_ctrl = CHECK_BIT(buffer, NODNIC_DEVICE_SUPPORT_BAR_CQ_CONTROL_OFFSET);
329
+	}
330
+
331
+#define NODNIC_DEVICE_LOG_UAR_PAGE_SIZE_OFFSET 0
332
+#define NODNIC_DEVICE_LOG_UAR_PAGE_SIZE_MASK 0xFF
333
+	status = nodnic_cmd_read(device_priv, device_priv->device_offset + 0x20, &buffer);
334
+	MLX_FATAL_CHECK_STATUS(status, read_err, "failed to read nodnic log_uar_page_size");
335
+	device_cap->log_uar_page_size = ( buffer >> NODNIC_DEVICE_LOG_UAR_PAGE_SIZE_OFFSET) & NODNIC_DEVICE_LOG_UAR_PAGE_SIZE_MASK;
306 336
 read_err:
307 337
 parm_err:
308 338
 	return status;

+ 343
- 11
src/drivers/infiniband/mlx_nodnic/src/mlx_port.c Visa fil

@@ -55,11 +55,18 @@ struct nodnic_port_data_entry nodnic_port_data_table[] = {
55 55
 		PortDataEntry(nodnic_port_option_cq_addr_high, 0x68, 0, 0xFFFFFFFF),
56 56
 		PortDataEntry(nodnic_port_option_port_management_change_event, 0x0, 30, 0x1),
57 57
 		PortDataEntry(nodnic_port_option_port_promisc_en, 0x4, 29, 0x1),
58
+#ifndef DEVICE_CX3
59
+		PortDataEntry(nodnic_port_option_arm_cq, 0x78, 8, 0xffffff),
60
+#else
58 61
 		PortDataEntry(nodnic_port_option_arm_cq, 0x78, 8, 0xffff),
62
+#endif
59 63
 		PortDataEntry(nodnic_port_option_port_promisc_multicast_en, 0x4, 28, 0x1),
60 64
 #ifdef DEVICE_CX3
61 65
 		PortDataEntry(nodnic_port_option_crspace_en, 0x4, 27, 0x1),
62 66
 #endif
67
+		PortDataEntry(nodnic_port_option_send_ring0_uar_index, 0x108, 0, 0xFFFFFFFF),
68
+		PortDataEntry(nodnic_port_option_send_ring1_uar_index, 0x10c, 0, 0xFFFFFFFF),
69
+		PortDataEntry(nodnic_port_option_cq_n_index, 0x118, 0, 0xFFFFFF),
63 70
 };
64 71
 
65 72
 #define MAX_QP_DATA_ENTRIES 5
@@ -186,6 +193,30 @@ invalid_parm:
186 193
 	return status;
187 194
 }
188 195
 
196
+mlx_status
197
+nodnic_port_set_send_uar_offset(
198
+		IN  nodnic_port_priv	*port_priv
199
+		)
200
+{
201
+	mlx_status status = MLX_SUCCESS;
202
+	mlx_uint32 out = 0;
203
+
204
+	if  ( ! port_priv->device->device_cap.support_uar_tx_db ) {
205
+		MLX_DEBUG_INFO1 ( port_priv, "nodnic_port_set_send_uar_offset: tx db using uar is not supported \n");
206
+		status = MLX_UNSUPPORTED;
207
+		goto uar_not_supported;
208
+   }
209
+
210
+	status = nodnic_port_query(port_priv,
211
+			nodnic_port_option_send_ring0_uar_index, &out);
212
+	MLX_CHECK_STATUS(port_priv->device, status, query_err,
213
+			"nodnic_port_query failed");
214
+	port_priv->device->uar.offset = out << port_priv->device->device_cap.log_uar_page_size;
215
+uar_not_supported:
216
+query_err:
217
+	return status;
218
+}
219
+
189 220
 mlx_status
190 221
 nodnic_port_read_reset_needed(
191 222
 						IN nodnic_port_priv		*port_priv,
@@ -220,6 +251,111 @@ query_err:
220 251
 	return status;
221 252
 }
222 253
 
254
+static
255
+mlx_status
256
+nodnic_port_allocate_dbr_dma (
257
+		IN nodnic_port_priv	*port_priv,
258
+		IN struct nodnic_doorbell	*nodnic_db,
259
+		IN mlx_uint32	dbr_addr_low_ofst,
260
+		IN mlx_uint32	dbr_addr_high_ofst,
261
+		IN void	**dbr_addr,
262
+		IN mlx_size	size,
263
+		IN void	**map
264
+		)
265
+{
266
+	mlx_status status = MLX_SUCCESS;
267
+	mlx_uint64 address = 0;
268
+	nodnic_device_priv *device_priv = NULL;
269
+
270
+	if( port_priv == NULL || nodnic_db == NULL ){
271
+			status = MLX_INVALID_PARAMETER;
272
+			goto invalid_parm;
273
+	}
274
+
275
+	device_priv = port_priv->device;
276
+	status = mlx_memory_alloc_dma(device_priv->utils,
277
+					size,
278
+					NODNIC_MEMORY_ALIGN,
279
+					(void **)dbr_addr
280
+					);
281
+	MLX_FATAL_CHECK_STATUS(status, alloc_db_record_err,
282
+				"doorbell record dma allocation error");
283
+
284
+	status = mlx_memory_map_dma(device_priv->utils,
285
+					(void *)(*dbr_addr),
286
+					size,
287
+					&nodnic_db->doorbell_physical,
288
+					map//nodnic_ring->map
289
+					);
290
+	MLX_FATAL_CHECK_STATUS(status, map_db_record_err,
291
+				"doorbell record map dma error");
292
+
293
+	address = (mlx_uint64)nodnic_db->doorbell_physical;
294
+	status = nodnic_cmd_write(device_priv,
295
+				dbr_addr_low_ofst,
296
+				(mlx_uint32)address);
297
+	MLX_FATAL_CHECK_STATUS(status, set_err,
298
+			"failed to set doorbell addr low");
299
+
300
+	address = address >> 32;
301
+	status = nodnic_cmd_write(device_priv,
302
+				dbr_addr_high_ofst,
303
+				(mlx_uint32)address);
304
+	MLX_FATAL_CHECK_STATUS(status, set_err,
305
+			"failed to set doorbell addr high");
306
+
307
+	return status;
308
+
309
+set_err:
310
+	mlx_memory_ummap_dma(device_priv->utils, *map);
311
+map_db_record_err:
312
+	mlx_memory_free_dma(device_priv->utils, size,
313
+		(void **)dbr_addr);
314
+alloc_db_record_err:
315
+invalid_parm:
316
+	return status;
317
+}
318
+
319
+static
320
+mlx_status
321
+nodnic_port_cq_dbr_dma_init(
322
+		IN nodnic_port_priv	*port_priv,
323
+		OUT nodnic_cq	**cq
324
+		)
325
+{
326
+	mlx_status status = MLX_SUCCESS;
327
+	nodnic_device_priv *device_priv = NULL;
328
+
329
+	if( port_priv == NULL ){
330
+		status = MLX_INVALID_PARAMETER;
331
+		goto invalid_parm;
332
+	}
333
+
334
+	device_priv =  port_priv->device;
335
+	if ( ! device_priv->device_cap.support_bar_cq_ctrl ) {
336
+		status = MLX_UNSUPPORTED;
337
+		goto uar_arm_cq_db_unsupported;
338
+	}
339
+
340
+#define NODNIC_PORT_ARM_CQ_DBR_ADDR_LOW_OFFSET 0x114
341
+#define NODNIC_PORT_ARM_CQ_DBR_ADDR_HIGH_OFFSET 0x110
342
+
343
+	status = nodnic_port_allocate_dbr_dma ( port_priv,&(*cq)->arm_cq_doorbell,
344
+			port_priv->port_offset + NODNIC_PORT_ARM_CQ_DBR_ADDR_LOW_OFFSET,
345
+			port_priv->port_offset + NODNIC_PORT_ARM_CQ_DBR_ADDR_HIGH_OFFSET,
346
+			(void **)&port_priv->arm_cq_doorbell_record ,
347
+			sizeof(nodnic_arm_cq_db),
348
+			(void **)&((*cq)->arm_cq_doorbell.map));
349
+	MLX_FATAL_CHECK_STATUS(status, alloc_dbr_dma_err,
350
+				"failed to allocate doorbell record dma");
351
+	return status;
352
+
353
+alloc_dbr_dma_err:
354
+uar_arm_cq_db_unsupported:
355
+invalid_parm:
356
+	return status;
357
+}
358
+
223 359
 mlx_status
224 360
 nodnic_port_create_cq(
225 361
 					IN nodnic_port_priv	*port_priv,
@@ -257,17 +393,24 @@ nodnic_port_create_cq(
257 393
 	MLX_FATAL_CHECK_STATUS(status, cq_map_err,
258 394
 				"cq map error");
259 395
 
396
+	status = nodnic_port_cq_dbr_dma_init(port_priv,cq);
397
+
260 398
 	/* update cq address */
261 399
 #define NODIC_CQ_ADDR_HIGH 0x68
262 400
 #define NODIC_CQ_ADDR_LOW 0x6c
263 401
 	address = (mlx_uint64)(*cq)->cq_physical;
264
-	nodnic_port_set(port_priv, nodnic_port_option_cq_addr_low,
265
-			(mlx_uint32)(address >> 12));
402
+	status = nodnic_port_set(port_priv, nodnic_port_option_cq_addr_low,
403
+			(mlx_uint32)(address) >> 12);
404
+	MLX_FATAL_CHECK_STATUS(status, dma_set_addr_low_err,
405
+					"cq set addr low error");
266 406
 	address = address >> 32;
267
-	nodnic_port_set(port_priv, nodnic_port_option_cq_addr_high,
407
+	status = nodnic_port_set(port_priv, nodnic_port_option_cq_addr_high,
268 408
 				(mlx_uint32)address);
269
-
409
+	MLX_FATAL_CHECK_STATUS(status, dma_set_addr_high_err,
410
+						"cq set addr high error");
270 411
 	return status;
412
+dma_set_addr_high_err:
413
+dma_set_addr_low_err:
271 414
 	mlx_memory_ummap_dma(device_priv->utils, (*cq)->map);
272 415
 cq_map_err:
273 416
 	mlx_memory_free_dma(device_priv->utils, (*cq)->cq_size,
@@ -294,6 +437,21 @@ nodnic_port_destroy_cq(
294 437
 	}
295 438
 	device_priv =  port_priv->device;
296 439
 
440
+	if ( device_priv->device_cap.support_bar_cq_ctrl ){
441
+			status = mlx_memory_ummap_dma(device_priv->utils,
442
+					cq->arm_cq_doorbell.map);
443
+			if( status != MLX_SUCCESS){
444
+				MLX_DEBUG_ERROR(device_priv, "mlx_memory_ummap_dma failed (Status = %d)\n", status);
445
+			}
446
+
447
+			status = mlx_memory_free_dma(device_priv->utils,
448
+					sizeof(nodnic_arm_cq_db),
449
+					(void **)&(port_priv->arm_cq_doorbell_record));
450
+			if( status != MLX_SUCCESS){
451
+				MLX_DEBUG_ERROR(device_priv, "mlx_memory_free_dma failed (Status = %d)\n", status);
452
+			}
453
+		}
454
+
297 455
 	mlx_memory_ummap_dma(device_priv->utils, cq->map);
298 456
 
299 457
 	mlx_memory_free_dma(device_priv->utils, cq->cq_size,
@@ -303,6 +461,126 @@ nodnic_port_destroy_cq(
303 461
 invalid_parm:
304 462
 	return status;
305 463
 }
464
+
465
+static
466
+mlx_status
467
+nodnic_port_allocate_ring_db_dma (
468
+		IN nodnic_port_priv	*port_priv,
469
+		IN struct nodnic_ring *nodnic_ring,
470
+		IN struct nodnic_doorbell *nodnic_db
471
+		)
472
+{
473
+	mlx_status status = MLX_SUCCESS;
474
+
475
+	if( port_priv == NULL || nodnic_ring == NULL || nodnic_db == NULL ){
476
+			status = MLX_INVALID_PARAMETER;
477
+			goto invalid_parm;
478
+	}
479
+#define NODNIC_RING_DBR_ADDR_LOW_OFFSET 0x1C
480
+#define NODNIC_RING_DBR_ADDR_HIGH_OFFSET 0x18
481
+	status = nodnic_port_allocate_dbr_dma ( port_priv,nodnic_db,
482
+			nodnic_ring->offset + NODNIC_RING_DBR_ADDR_LOW_OFFSET,
483
+			nodnic_ring->offset + NODNIC_RING_DBR_ADDR_HIGH_OFFSET,
484
+			(void **)&nodnic_db->qp_doorbell_record,
485
+			sizeof(nodnic_qp_db),
486
+			(void **)&nodnic_ring->map );
487
+	MLX_FATAL_CHECK_STATUS(status, alloc_dbr_dma_err,
488
+			"failed to allocate doorbell record dma");
489
+
490
+	return status;
491
+alloc_dbr_dma_err:
492
+invalid_parm:
493
+	return status;
494
+}
495
+
496
+static
497
+mlx_status
498
+nodnic_port_rx_pi_dma_alloc(
499
+		IN nodnic_port_priv	*port_priv,
500
+		OUT nodnic_qp	**qp
501
+		)
502
+{
503
+	mlx_status status = MLX_SUCCESS;
504
+	nodnic_device_priv *device_priv = NULL;
505
+
506
+	if( port_priv == NULL || qp == NULL){
507
+		status = MLX_INVALID_PARAMETER;
508
+		goto invalid_parm;
509
+	}
510
+
511
+	device_priv =  port_priv->device;
512
+
513
+	if ( ! device_priv->device_cap.support_rx_pi_dma ) {
514
+		goto rx_pi_dma_unsupported;
515
+	}
516
+
517
+	if ( device_priv->device_cap.support_rx_pi_dma ) {
518
+		status = nodnic_port_allocate_ring_db_dma(port_priv,
519
+				&(*qp)->receive.nodnic_ring,&(*qp)->receive.nodnic_ring.recv_doorbell);
520
+		MLX_FATAL_CHECK_STATUS(status, dma_alloc_err,
521
+				"rx doorbell dma allocation error");
522
+	}
523
+
524
+	return status;
525
+
526
+dma_alloc_err:
527
+rx_pi_dma_unsupported:
528
+invalid_parm:
529
+	return status;
530
+}
531
+
532
+static
533
+mlx_status
534
+nodnic_port_send_db_dma(
535
+		IN nodnic_port_priv	*port_priv,
536
+		IN struct nodnic_ring *ring,
537
+		IN mlx_uint16 index
538
+		)
539
+{
540
+	mlx_uint32 swapped = 0;
541
+	mlx_uint32 index32 = index;
542
+	mlx_memory_cpu_to_be32(port_priv->device->utils, index32, &swapped);
543
+	ring->send_doorbell.qp_doorbell_record->send_db =  swapped;
544
+
545
+	return MLX_SUCCESS;
546
+}
547
+
548
+static
549
+mlx_status
550
+nodnic_port_tx_dbr_dma_init(
551
+		IN nodnic_port_priv	*port_priv,
552
+		OUT nodnic_qp	**qp
553
+		)
554
+{
555
+	mlx_status status = MLX_SUCCESS;
556
+	nodnic_device_priv *device_priv = NULL;
557
+
558
+	if( port_priv == NULL || qp == NULL){
559
+		status = MLX_INVALID_PARAMETER;
560
+		goto invalid_parm;
561
+	}
562
+
563
+	device_priv =  port_priv->device;
564
+
565
+	if ( ! device_priv->device_cap.support_uar_tx_db || ! device_priv->uar.offset ) {
566
+		status = MLX_UNSUPPORTED;
567
+		goto uar_tx_db_unsupported;
568
+	}
569
+	status = nodnic_port_allocate_ring_db_dma(port_priv,
570
+			&(*qp)->send.nodnic_ring,&(*qp)->send.nodnic_ring.send_doorbell);
571
+	MLX_FATAL_CHECK_STATUS(status, dma_alloc_err,
572
+			"tx doorbell dma allocation error");
573
+	port_priv->send_doorbell = nodnic_port_send_db_dma;
574
+
575
+	return status;
576
+
577
+dma_alloc_err:
578
+uar_tx_db_unsupported:
579
+invalid_parm:
580
+
581
+	return status;
582
+}
583
+
306 584
 mlx_status
307 585
 nodnic_port_create_qp(
308 586
 					IN nodnic_port_priv	*port_priv,
@@ -376,6 +654,13 @@ nodnic_port_create_qp(
376 654
 	MLX_FATAL_CHECK_STATUS(status, receive_map_err,
377 655
 				"receive wq map error");
378 656
 
657
+	status = nodnic_port_rx_pi_dma_alloc(port_priv,qp);
658
+	MLX_FATAL_CHECK_STATUS(status, rx_pi_dma_alloc_err,
659
+				"receive db dma error");
660
+
661
+	status = nodnic_port_tx_dbr_dma_init(port_priv,qp);
662
+
663
+
379 664
 	(*qp)->send.nodnic_ring.wq_size = send_wq_size;
380 665
 	(*qp)->send.nodnic_ring.num_wqes = send_wqe_num;
381 666
 	(*qp)->receive.nodnic_ring.wq_size = receive_wq_size;
@@ -420,6 +705,7 @@ nodnic_port_create_qp(
420 705
 write_recv_addr_err:
421 706
 write_send_addr_err:
422 707
 	mlx_memory_ummap_dma(device_priv->utils, (*qp)->receive.nodnic_ring.map);
708
+rx_pi_dma_alloc_err:
423 709
 receive_map_err:
424 710
 	mlx_memory_ummap_dma(device_priv->utils, (*qp)->send.nodnic_ring.map);
425 711
 send_map_err:
@@ -457,6 +743,36 @@ nodnic_port_destroy_qp(
457 743
 		MLX_DEBUG_ERROR(device_priv, "mlx_memory_ummap_dma failed (Status = %d)\n", status);
458 744
 	}
459 745
 
746
+	if ( device_priv->device_cap.support_rx_pi_dma ){
747
+		status = mlx_memory_ummap_dma(device_priv->utils,
748
+					qp->receive.nodnic_ring.recv_doorbell.map);
749
+		if( status != MLX_SUCCESS){
750
+			MLX_DEBUG_ERROR(device_priv, "mlx_memory_ummap_dma failed (Status = %d)\n", status);
751
+		}
752
+
753
+		status = mlx_memory_free_dma(device_priv->utils,
754
+				sizeof(nodnic_qp_db),
755
+				(void **)&(qp->receive.nodnic_ring.recv_doorbell.qp_doorbell_record));
756
+		if( status != MLX_SUCCESS){
757
+			MLX_DEBUG_ERROR(device_priv, "mlx_memory_free_dma failed (Status = %d)\n", status);
758
+		}
759
+	}
760
+
761
+	if ( device_priv->device_cap.support_uar_tx_db || ! device_priv->uar.offset){
762
+		status = mlx_memory_ummap_dma(device_priv->utils,
763
+					qp->send.nodnic_ring.send_doorbell.map);
764
+		if( status != MLX_SUCCESS){
765
+			MLX_DEBUG_ERROR(device_priv, "mlx_memory_ummap_dma failed (Status = %d)\n", status);
766
+		}
767
+
768
+		status = mlx_memory_free_dma(device_priv->utils,
769
+				sizeof(nodnic_qp_db),
770
+				(void **)&(qp->send.nodnic_ring.send_doorbell.qp_doorbell_record));
771
+		if( status != MLX_SUCCESS){
772
+			MLX_DEBUG_ERROR(device_priv, "mlx_memory_free_dma failed (Status = %d)\n", status);
773
+		}
774
+	}
775
+
460 776
 	status = mlx_memory_free_dma(device_priv->utils,
461 777
 			qp->receive.nodnic_ring.wq_size,
462 778
 			(void **)&(qp->receive.wqe_virt));
@@ -520,7 +836,7 @@ nodnic_port_send_db_connectx3(
520 836
 	nodnic_port_data_flow_gw *ptr = port_priv->data_flow_gw;
521 837
 	mlx_uint32 index32 = index;
522 838
 	mlx_pci_mem_write(port_priv->device->utils, MlxPciWidthUint32, 0,
523
-			(mlx_uint64)&(ptr->send_doorbell), 1, &index32);
839
+			(mlx_uintn)&(ptr->send_doorbell), 1, &index32);
524 840
 	return MLX_SUCCESS;
525 841
 }
526 842
 
@@ -535,10 +851,24 @@ nodnic_port_recv_db_connectx3(
535 851
 	nodnic_port_data_flow_gw *ptr = port_priv->data_flow_gw;
536 852
 	mlx_uint32 index32 = index;
537 853
 	mlx_pci_mem_write(port_priv->device->utils, MlxPciWidthUint32, 0,
538
-			(mlx_uint64)&(ptr->recv_doorbell), 1, &index32);
854
+			(mlx_uintn)&(ptr->recv_doorbell), 1, &index32);
539 855
 	return MLX_SUCCESS;
540 856
 }
541 857
 #endif
858
+static
859
+mlx_status
860
+nodnic_port_recv_db_dma(
861
+		IN nodnic_port_priv	*port_priv __attribute__((unused)),
862
+		IN struct nodnic_ring *ring,
863
+		IN mlx_uint16 index
864
+		)
865
+{
866
+	mlx_uint32 swapped = 0;
867
+	mlx_uint32 index32 = index;
868
+	mlx_memory_cpu_to_be32(port_priv->device->utils, index32, &swapped);
869
+	ring->recv_doorbell.qp_doorbell_record->recv_db =  swapped;
870
+	return MLX_SUCCESS;
871
+}
542 872
 
543 873
 mlx_status
544 874
 nodnic_port_update_ring_doorbell(
@@ -678,11 +1008,10 @@ nodnic_port_add_mac_filter(
678 1008
 		goto bad_param;
679 1009
 	}
680 1010
 
681
-	memset(&zero_mac, 0, sizeof(zero_mac));
682
-
683 1011
 	device = port_priv->device;
684 1012
 	utils = device->utils;
685 1013
 
1014
+	mlx_memory_set(utils, &zero_mac, 0, sizeof(zero_mac));
686 1015
 	/* check if mac already exists */
687 1016
 	for( ; index < NODNIC_MAX_MAC_FILTERS ; index ++) {
688 1017
 		mlx_memory_cmp(utils, &port_priv->mac_filters[index], &mac,
@@ -759,11 +1088,10 @@ nodnic_port_remove_mac_filter(
759 1088
 		goto bad_param;
760 1089
 	}
761 1090
 
762
-	memset(&zero_mac, 0, sizeof(zero_mac));
763
-
764 1091
 	device = port_priv->device;
765 1092
 	utils = device->utils;
766 1093
 
1094
+	mlx_memory_set(utils, &zero_mac, 0, sizeof(zero_mac));
767 1095
 	/* serch for mac filter */
768 1096
 	for( ; index < NODNIC_MAX_MAC_FILTERS ; index ++) {
769 1097
 		mlx_memory_cmp(utils, &port_priv->mac_filters[index], &mac,
@@ -832,7 +1160,7 @@ nodnic_port_set_dma_connectx3(
832 1160
 	nodnic_port_data_flow_gw *ptr = port_priv->data_flow_gw;
833 1161
 	mlx_uint32 data = (value ? 0xffffffff : 0x0);
834 1162
 	mlx_pci_mem_write(utils, MlxPciWidthUint32, 0,
835
-			(mlx_uint64)&(ptr->dma_en), 1, &data);
1163
+			(mlx_uintn)&(ptr->dma_en), 1, &data);
836 1164
 	return MLX_SUCCESS;
837 1165
 }
838 1166
 #endif
@@ -1029,6 +1357,10 @@ nodnic_port_thin_init(
1029 1357
 		port_priv->set_dma = nodnic_port_set_dma_connectx3;
1030 1358
 	}
1031 1359
 #endif
1360
+	if ( device_priv->device_cap.support_rx_pi_dma ) {
1361
+		port_priv->recv_doorbell = nodnic_port_recv_db_dma;
1362
+	}
1363
+
1032 1364
 	/* clear reset_needed */
1033 1365
 	nodnic_port_read_reset_needed(port_priv, &reset_needed);
1034 1366
 

+ 5
- 0
src/drivers/infiniband/mlx_utils/include/private/mlx_pci_priv.h Visa fil

@@ -30,6 +30,11 @@ mlx_pci_init_priv(
30 30
 			IN mlx_utils *utils
31 31
 			);
32 32
 
33
+mlx_status
34
+mlx_pci_teardown_priv(
35
+			IN mlx_utils *utils
36
+			);
37
+
33 38
 mlx_status
34 39
 mlx_pci_read_priv(
35 40
 			IN mlx_utils *utils,

+ 1
- 0
src/drivers/infiniband/mlx_utils/include/public/mlx_logging.h Visa fil

@@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
24 24
 
25 25
 #include "../../../mlx_utils_flexboot/include/mlx_logging_priv.h"
26 26
 
27
+#define MLX_PRINT(...)				MLX_PRINT_PRIVATE(__VA_ARGS__)
27 28
 #define MLX_DEBUG_FATAL_ERROR(...)	MLX_DEBUG_FATAL_ERROR_PRIVATE(__VA_ARGS__)
28 29
 #define MLX_DEBUG_ERROR(...)		MLX_DEBUG_ERROR_PRIVATE(__VA_ARGS__)
29 30
 #define MLX_DEBUG_WARN(...)			MLX_DEBUG_WARN_PRIVATE(__VA_ARGS__)

+ 5
- 0
src/drivers/infiniband/mlx_utils/include/public/mlx_pci.h Visa fil

@@ -36,6 +36,11 @@ mlx_pci_init(
36 36
 			IN mlx_utils *utils
37 37
 			);
38 38
 
39
+mlx_status
40
+mlx_pci_teardown(
41
+			IN mlx_utils *utils
42
+			);
43
+
39 44
 mlx_status
40 45
 mlx_pci_read(
41 46
 			IN mlx_utils *utils,

+ 5
- 0
src/drivers/infiniband/mlx_utils/mlx_lib/mlx_link_speed/mlx_link_speed.h Visa fil

@@ -124,6 +124,11 @@ struct mlx_link_speed {
124 124
 	/* -------------- */
125 125
 	mlx_uint32 ib_proto_oper	:16;
126 126
 	mlx_uint32 ib_link_width_oper	:16;
127
+	/* -------------- */
128
+	mlx_uint32 reserved7	:32;
129
+	/* -------------- */
130
+	mlx_uint32 eth_proto_lp_advertise	:32;
131
+	mlx_uint32 reserved[3];
127 132
 };
128 133
 
129 134
 mlx_status

+ 7
- 0
src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.c Visa fil

@@ -42,6 +42,7 @@ struct nvconfig_tlv_mapping nvconfig_tlv_mapping[] = {
42 42
 		TlvMappingEntry(0x2020, 0x2020, NVRAM_TLV_CLASS_PHYSICAL_PORT, FALSE),
43 43
 		TlvMappingEntry(0x2021, 0x221, NVRAM_TLV_CLASS_HOST, FALSE),
44 44
 		TlvMappingEntry(0x2023, 0x223, NVRAM_TLV_CLASS_HOST, FALSE),
45
+		TlvMappingEntry(0x2006, 0x206, NVRAM_TLV_CLASS_HOST, FALSE),
45 46
 		TlvMappingEntry(0x2100, 0x230, NVRAM_TLV_CLASS_HOST, FALSE),
46 47
 		TlvMappingEntry(0x2101, 0x231, NVRAM_TLV_CLASS_HOST, FALSE),
47 48
 		TlvMappingEntry(0x2102, 0x232, NVRAM_TLV_CLASS_HOST, FALSE),
@@ -53,6 +54,7 @@ struct nvconfig_tlv_mapping nvconfig_tlv_mapping[] = {
53 54
 		TlvMappingEntry(0x2108, 0x238, NVRAM_TLV_CLASS_HOST, FALSE),
54 55
 		TlvMappingEntry(0x2109, 0x239, NVRAM_TLV_CLASS_HOST, FALSE),
55 56
 		TlvMappingEntry(0x210A, 0x23A, NVRAM_TLV_CLASS_HOST, FALSE),
57
+		TlvMappingEntry(0x2022, 0x222, NVRAM_TLV_CLASS_HOST, FALSE),
56 58
 		TlvMappingEntry(0x2200, 0x240, NVRAM_TLV_CLASS_HOST, FALSE),
57 59
 		TlvMappingEntry(0x2201, 0x241, NVRAM_TLV_CLASS_HOST, FALSE),
58 60
 		TlvMappingEntry(0x2202, 0x242, NVRAM_TLV_CLASS_HOST, FALSE),
@@ -60,6 +62,11 @@ struct nvconfig_tlv_mapping nvconfig_tlv_mapping[] = {
60 62
 		TlvMappingEntry(0x2204, 0x244, NVRAM_TLV_CLASS_HOST, FALSE),
61 63
 		TlvMappingEntry(0x2205, 0x245, NVRAM_TLV_CLASS_HOST, FALSE),
62 64
 		TlvMappingEntry(0x2207, 0x247, NVRAM_TLV_CLASS_HOST, FALSE),
65
+		TlvMappingEntry(0x2002, 0x202, NVRAM_TLV_CLASS_HOST, FALSE),
66
+		TlvMappingEntry(0x2004, 0x204, NVRAM_TLV_CLASS_HOST, FALSE),
67
+		TlvMappingEntry(0x110, 0x110, NVRAM_TLV_CLASS_HOST, FALSE),
68
+		TlvMappingEntry(0x192, 0x192, NVRAM_TLV_CLASS_GLOBAL, FALSE),
69
+		TlvMappingEntry(0x101, 0x101, NVRAM_TLV_CLASS_GLOBAL, TRUE),
63 70
 		TlvMappingEntry(0, 0, 0, 0),
64 71
 };
65 72
 

+ 16
- 0
src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig.h Visa fil

@@ -107,6 +107,22 @@ struct nvconfig_nvda {
107 107
 	mlx_uint8 data[NVCONFIG_MAX_TLV_SIZE];
108 108
 };
109 109
 
110
+struct nv_conf_cap {
111
+	/** WOL En/Dis **/
112
+	mlx_uint8	wol_en;
113
+	/** VPI En/Dis **/
114
+	mlx_uint8	vpi_en;
115
+};
116
+
117
+struct mlx_nvconfig_virt_net_addr {
118
+		mlx_uint32	reserved1		:29;
119
+		mlx_uint32	erase_on_powerup:1;
120
+		mlx_uint32	reserverd2		:1;
121
+		mlx_uint32 	virtual_mac_en 	:1;
122
+		mlx_uint32	virtual_mac_high;
123
+		mlx_uint32	virtual_mac_low;
124
+};
125
+
110 126
 
111 127
 mlx_status
112 128
 nvconfig_query_capability(

+ 28
- 2
src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig_defaults.c Visa fil

@@ -86,13 +86,13 @@ nvconfig_get_boot_ext_default_conf(
86 86
 			"TLV not found. Using hard-coded defaults ");
87 87
 	port_conf_def->linkup_timeout = nic_boot_ext_conf->linkup_timeout;
88 88
 	port_conf_def->ip_ver = nic_boot_ext_conf->ip_ver;
89
-
89
+	port_conf_def->undi_network_wait_to = nic_boot_ext_conf->undi_network_wait_to;
90 90
 	return MLX_SUCCESS;
91 91
 
92 92
 nvdata_access_err:
93 93
 	port_conf_def->linkup_timeout = DEFAULT_BOOT_LINK_UP_TO;
94 94
 	port_conf_def->ip_ver = DEFAULT_BOOT_IP_VER;
95
-
95
+	port_conf_def->undi_network_wait_to = DEFAULT_BOOT_UNDI_NETWORK_WAIT_TO;
96 96
 	return status;
97 97
 }
98 98
 
@@ -185,8 +185,12 @@ nvconfig_get_iscsi_gen_default_conf(
185 185
 	port_conf_def->iscsi_chap_auth_en = iscsi_gen->chap_auth_en;
186 186
 	port_conf_def->iscsi_lun_busy_retry_count = iscsi_gen->lun_busy_retry_count;
187 187
 	port_conf_def->iscsi_link_up_delay_time = iscsi_gen->link_up_delay_time;
188
+	port_conf_def->iscsi_drive_num = iscsi_gen->drive_num;
189
+
190
+	return MLX_SUCCESS;
188 191
 
189 192
 nvdata_access_err:
193
+	port_conf_def->iscsi_drive_num = DEFAULT_ISCSI_DRIVE_NUM;
190 194
 	return status;
191 195
 }
192 196
 
@@ -327,6 +331,27 @@ nvdata_access_err:
327 331
 	return status;
328 332
 }
329 333
 
334
+static
335
+mlx_status
336
+nvconfig_get_rom_cap_default_conf( IN void *data,
337
+		IN int status, OUT void *def_struct) {
338
+	union mlx_nvconfig_rom_cap_conf *rom_cap_conf =
339
+			(union mlx_nvconfig_rom_cap_conf *) data;
340
+	struct mlx_nvconfig_conf_defaults *conf_def =
341
+			(struct mlx_nvconfig_conf_defaults *) def_struct;
342
+
343
+	MLX_CHECK_STATUS(NULL, status, nvdata_access_err,
344
+			"TLV not found. Using hard-coded defaults ");
345
+	conf_def->boot_ip_ver_en = rom_cap_conf->boot_ip_ver_en;
346
+
347
+	return MLX_SUCCESS;
348
+
349
+nvdata_access_err:
350
+	rom_cap_conf->boot_ip_ver_en = DEFAULT_BOOT_IP_VERSION_EN;
351
+
352
+	return status;
353
+}
354
+
330 355
 static struct tlv_default tlv_port_defaults[] = {
331 356
 	TlvDefaultEntry(BOOT_SETTINGS_TYPE, union mlx_nvconfig_nic_boot_conf, &nvconfig_get_boot_default_conf),
332 357
 	TlvDefaultEntry(BOOT_SETTINGS_EXT_TYPE, union mlx_nvconfig_nic_boot_ext_conf, &nvconfig_get_boot_ext_default_conf),
@@ -343,6 +368,7 @@ static struct tlv_default tlv_general_defaults[] = {
343 368
 	TlvDefaultEntry(GLOPAL_PCI_CAPS_TYPE, union mlx_nvconfig_virt_caps, &nvconfig_get_nv_virt_caps_default_conf),
344 369
 	TlvDefaultEntry(GLOPAL_PCI_SETTINGS_TYPE, union mlx_nvconfig_virt_conf, &nvconfig_get_nv_virt_default_conf),
345 370
 	TlvDefaultEntry(OCSD_OCBB_TYPE, union mlx_nvconfig_ocsd_ocbb_conf, &nvconfig_get_ocsd_ocbb_default_conf),
371
+	TlvDefaultEntry(NV_ROM_CAP_TYPE, union mlx_nvconfig_rom_cap_conf, &nvconfig_get_rom_cap_default_conf),
346 372
 };
347 373
 
348 374
 static

+ 6
- 0
src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig_defaults.h Visa fil

@@ -32,9 +32,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
32 32
 #define DEFAULT_BOOT_VLAN 1
33 33
 #define DEFAULT_ISCSI_DHCP_PARAM_EN 1
34 34
 #define DEFAULT_ISCSI_IPV4_DHCP_EN 1
35
+#define DEFAULT_ISCSI_DRIVE_NUM 0x80
35 36
 #define DEFAULT_OCSD_OCBB_EN 1
36 37
 #define DEFAULT_BOOT_IP_VER 0
37 38
 #define DEFAULT_BOOT_LINK_UP_TO 0
39
+#define DEFAULT_BOOT_UNDI_NETWORK_WAIT_TO 30
40
+#define DEFAULT_BOOT_IP_VERSION_EN 1
38 41
 
39 42
 struct mlx_nvconfig_port_conf_defaults {
40 43
 	mlx_uint8 pptx;
@@ -56,11 +59,13 @@ struct mlx_nvconfig_port_conf_defaults {
56 59
 	mlx_boolean iscsi_ipv4_dhcp_en;
57 60
 	mlx_uint8 iscsi_lun_busy_retry_count;
58 61
 	mlx_uint8 iscsi_link_up_delay_time;
62
+	mlx_uint8 iscsi_drive_num;
59 63
 	mlx_uint8 client_identifier;
60 64
 	mlx_uint8 mac_admin_bit;
61 65
 	mlx_uint8 default_link_type;
62 66
 	mlx_uint8 linkup_timeout;
63 67
 	mlx_uint8 ip_ver;
68
+	mlx_uint8 undi_network_wait_to;
64 69
 };
65 70
 
66 71
 struct mlx_nvconfig_conf_defaults  {
@@ -71,6 +76,7 @@ struct mlx_nvconfig_conf_defaults  {
71 76
 	mlx_uint8 uar_bar_size;
72 77
 	mlx_uint8 flexboot_menu_to;
73 78
 	mlx_boolean ocsd_ocbb_en;
79
+	mlx_boolean boot_ip_ver_en;
74 80
 };
75 81
 
76 82
 mlx_status

+ 83
- 11
src/drivers/infiniband/mlx_utils/mlx_lib/mlx_nvconfig/mlx_nvconfig_prm.h Visa fil

@@ -33,12 +33,15 @@ enum {
33 33
 	OCSD_OCBB_TYPE 					= 0x2011,
34 34
 	FLOW_CONTROL_TYPE				= 0x2020,
35 35
 	BOOT_SETTINGS_TYPE				= 0x2021,
36
+	NV_ROM_FLEXBOOT_DEBUG				= 0x2004,
37
+
36 38
 	ISCSI_GENERAL_SETTINGS_TYPE		= 0x2100,
37 39
 	IB_BOOT_SETTING_TYPE			= 0x2022,
38 40
 	IB_DHCP_SETTINGS_TYPE			= 0x2023,
39 41
 	GLOPAL_PCI_SETTINGS_TYPE		= 0x80,
40 42
 	GLOPAL_PCI_CAPS_TYPE			= 0x81,
41 43
 	GLOBAL_ROM_INI_TYPE				= 0x100,
44
+	NV_VIRT_NET_ADDR				= 0x110,
42 45
 
43 46
 	// Types for iSCSI strings
44 47
 	DHCP_VEND_ID					= 0x2101,
@@ -59,6 +62,8 @@ enum {
59 62
 	FIRST_TGT_ISCSI_NAME			= 0x2204,
60 63
 	FIRST_TGT_CHAP_ID				= 0x2205,
61 64
 	FIRST_TGT_CHAP_PWD				= 0x2207,
65
+	NV_ROM_DEBUG_LEVEL				= 0x2002,
66
+	NV_ROM_CAP_TYPE					= 0x101,
62 67
 };
63 68
 
64 69
 union mlx_nvconfig_nic_boot_conf {
@@ -78,7 +83,9 @@ union mlx_nvconfig_nic_boot_ext_conf {
78 83
 	struct {
79 84
 		mlx_uint32	linkup_timeout	: 8;
80 85
 		mlx_uint32	ip_ver			: 2;
81
-		mlx_uint32	reserved0		: 22;
86
+		mlx_uint32	reserved0		: 6;
87
+		mlx_uint32	undi_network_wait_to : 8;
88
+		mlx_uint32	reserved1		: 8;
82 89
 	};
83 90
 	mlx_uint32 dword;
84 91
 };
@@ -194,7 +201,8 @@ union mlx_nvconfig_iscsi_general {
194 201
 		/*-------------------*/
195 202
 		mlx_uint32	lun_busy_retry_count:8;
196 203
 		mlx_uint32	link_up_delay_time	:8;
197
-		mlx_uint32	reserved4			:16;
204
+		mlx_uint32	drive_num			:8;
205
+		mlx_uint32	reserved4			:8;
198 206
 	};
199 207
 	mlx_uint32 dword[3];
200 208
 };
@@ -226,34 +234,98 @@ union mlx_nvconfig_vpi_link_conf {
226 234
 };
227 235
 
228 236
 struct  mlx_nvcofnig_romini {
229
-	mlx_uint32 reserved0    :1;
237
+	mlx_uint32 reserved0    		:1;
230 238
 	mlx_uint32 shared_memory_en     :1;
231
-	mlx_uint32 hii_vpi_en   :1;
232
-	mlx_uint32 tech_enum    :1;
233
-	mlx_uint32 reserved1    :4;
239
+	mlx_uint32 hii_vpi_en   		:1;
240
+	mlx_uint32 tech_enum    		:1;
241
+	mlx_uint32 reserved1    		:4;
234 242
 	mlx_uint32 static_component_name_string :1;
235 243
 	mlx_uint32 hii_iscsi_configuration      :1;
236
-	mlx_uint32 hii_ibm_aim  :1;
244
+	mlx_uint32 hii_ibm_aim  		:1;
237 245
 	mlx_uint32 hii_platform_setup   :1;
238 246
 	mlx_uint32 hii_bdf_decimal      :1;
239 247
 	mlx_uint32 hii_read_only        :1;
240
-	mlx_uint32 reserved2    :10;
248
+	mlx_uint32 reserved2    		:10;
241 249
 	mlx_uint32 mac_enum             :1;
242
-	mlx_uint32 port_enum    :1;
250
+	mlx_uint32 port_enum    		:1;
243 251
 	mlx_uint32 flash_en             :1;
244 252
 	mlx_uint32 fmp_en               :1;
245 253
 	mlx_uint32 bofm_en              :1;
246
-	mlx_uint32 platform_to_driver_en                :1;
254
+	mlx_uint32 platform_to_driver_en:1;
247 255
 	mlx_uint32 hii_en               :1;
248 256
 	mlx_uint32 undi_en              :1;
249 257
 	/* -------------- */
250 258
 	mlx_uint64 dhcp_user_class;
251 259
 	/* -------------- */
252
-	mlx_uint32 reserved3    :22;
260
+	mlx_uint32 reserved3    		:10;
261
+	mlx_uint32 ucm_single_port		:1;
262
+	mlx_uint32 tivoli_wa_en			:1;
263
+	mlx_uint32 dhcp_pxe_discovery_control_dis	:1;
264
+	mlx_uint32 hii_flexaddr_override:1;
265
+	mlx_uint32 hii_flexaddr_setting :1;
266
+	mlx_uint32 guided_ops			:1;
267
+	mlx_uint32 hii_type				:4;
268
+	mlx_uint32 hii_mriname2			:1;
269
+	mlx_uint32 hii_aim_ucm_ver2		:1;
253 270
 	mlx_uint32 uri_boot_retry_delay :4;
254 271
 	mlx_uint32 uri_boot_retry       :4;
255 272
 	mlx_uint32 option_rom_debug     :1;
256 273
 	mlx_uint32 promiscuous_vlan     :1;
274
+
275
+} __attribute__ ((packed));
276
+
277
+union mlx_nvconfig_debug_conf {
278
+	struct {
279
+	mlx_uint32	dbg_log_en				:1;
280
+	mlx_uint32	reserved1				:31;
281
+		/***************************************************/
282
+	mlx_uint32	stp_dbg_lvl				:2;
283
+	mlx_uint32	romprefix_dbg_lvl		:2;
284
+	mlx_uint32	dhcp_dbg_lvl			:2;
285
+	mlx_uint32	dhcpv6_dbg_lvl			:2;
286
+	mlx_uint32	arp_dbg_lvl				:2;
287
+	mlx_uint32	neighbor_dbg_lvl		:2;
288
+	mlx_uint32	ndp_dbg_lvl				:2;
289
+	mlx_uint32	uri_dbg_lvl				:2;
290
+	mlx_uint32	driver_dbg_lvl			:2;
291
+	mlx_uint32	nodnic_dbg_lvl			:2;
292
+	mlx_uint32	nodnic_cmd_dbg_lvl		:2;
293
+	mlx_uint32	nodnic_device_dbg_lvl	:2;
294
+	mlx_uint32	nodnic_port_dbg_lvl		:2;
295
+	mlx_uint32	netdevice_dbg_lvl		:2;
296
+	mlx_uint32	tftp_dbg_lvl			:2;
297
+	mlx_uint32	udp_dbg_lvl				:2;
298
+		/***************************************************/
299
+	mlx_uint32	tcp_dbg_lvl				:2;
300
+	mlx_uint32	tcpip_dbg_lvl			:2;
301
+	mlx_uint32	ipv4_dbg_lvl			:2;
302
+	mlx_uint32	ipv6_dbg_lvl			:2;
303
+	mlx_uint32	drv_set_dbg_lvl			:2;
304
+	mlx_uint32	stat_update_dbg_lvl		:2;
305
+	mlx_uint32	pxe_undi_dbg_lvl		:2;
306
+	mlx_uint32	reserved2				:18;
307
+	};
308
+	mlx_uint32 dword[3];
309
+};
310
+
311
+union mlx_nvconfig_flexboot_debug {
312
+	struct {
313
+	mlx_uint32	reserved0				:29;
314
+	mlx_uint32	panic_behavior				:2;
315
+	mlx_uint32	boot_to_shell				:1;
316
+	};
317
+	mlx_uint32 dword;
318
+};
319
+
320
+union mlx_nvconfig_rom_cap_conf {
321
+	struct {
322
+		mlx_uint32	reserved0			:28;
323
+		mlx_uint32	uefi_logs_en		:1;
324
+		mlx_uint32	flexboot_debug_en	:1;
325
+		mlx_uint32	boot_debug_log_en	:1;
326
+		mlx_uint32	boot_ip_ver_en		:1;
327
+	};
328
+	mlx_uint32 dword;
257 329
 };
258 330
 
259 331
 #endif /* MLX_NVCONFIG_PRM_H_ */

+ 1
- 1
src/drivers/infiniband/mlx_utils/src/public/mlx_icmd.c Visa fil

@@ -316,7 +316,7 @@ mlx_icmd_send_command(
316 316
 				)
317 317
 {
318 318
 	mlx_status status = MLX_SUCCESS;
319
-	mlx_uint32 icmd_status = MLX_FAILED;
319
+	mlx_uint32 icmd_status = 0;
320 320
 
321 321
 	if (utils == NULL || data == NULL) {
322 322
 		status = MLX_INVALID_PARAMETER;

+ 16
- 0
src/drivers/infiniband/mlx_utils/src/public/mlx_pci.c Visa fil

@@ -20,6 +20,7 @@
20 20
 FILE_LICENCE ( GPL2_OR_LATER );
21 21
 
22 22
 #include <stddef.h>
23
+
23 24
 #include "../../include/private/mlx_pci_priv.h"
24 25
 #include "../../include/public/mlx_pci.h"
25 26
 
@@ -38,6 +39,21 @@ bail:
38 39
 	return status;
39 40
 }
40 41
 
42
+mlx_status
43
+mlx_pci_teardown(
44
+			IN mlx_utils *utils
45
+			)
46
+{
47
+	mlx_status status = MLX_SUCCESS;
48
+	if( utils == NULL){
49
+		status = MLX_INVALID_PARAMETER;
50
+		goto bail;
51
+	}
52
+	status = mlx_pci_teardown_priv(utils);
53
+bail:
54
+	return status;
55
+}
56
+
41 57
 mlx_status
42 58
 mlx_pci_read(
43 59
 			IN mlx_utils *utils,

+ 3
- 2
src/drivers/infiniband/mlx_utils/src/public/mlx_utils.c Visa fil

@@ -20,10 +20,10 @@
20 20
 FILE_LICENCE ( GPL2_OR_LATER );
21 21
 
22 22
 #include <stddef.h>
23
+
23 24
 #include "../../include/private/mlx_utils_priv.h"
24 25
 #include "../../include/public/mlx_pci.h"
25 26
 #include "../../include/public/mlx_utils.h"
26
-
27 27
 mlx_status
28 28
 mlx_utils_init(
29 29
 				IN mlx_utils *utils,
@@ -44,11 +44,12 @@ bail:
44 44
 
45 45
 mlx_status
46 46
 mlx_utils_teardown(
47
-				IN mlx_utils *utils __attribute__ ((unused))
47
+				IN mlx_utils *utils
48 48
 				)
49 49
 {
50 50
 	mlx_status status = MLX_SUCCESS;
51 51
 	mlx_utils_free_lock(utils);
52
+	mlx_pci_teardown(utils);
52 53
 	return status;
53 54
 }
54 55
 

+ 3
- 2
src/drivers/infiniband/mlx_utils_flexboot/include/mlx_logging_priv.h Visa fil

@@ -12,8 +12,8 @@
12 12
 #include <compiler.h>
13 13
 
14 14
 #define MLX_DEBUG_FATAL_ERROR_PRIVATE(...)		do {				\
15
-		DBG("%s: ",__func__);						\
16
-		DBG(__VA_ARGS__);			\
15
+		printf("%s: ",__func__);						\
16
+		printf(__VA_ARGS__);			\
17 17
 	} while ( 0 )
18 18
 
19 19
 #define MLX_DEBUG_ERROR_PRIVATE(id, ...)		do {				\
@@ -56,6 +56,7 @@
56 56
 		DBG2(__VA_ARGS__);			\
57 57
 	} while ( 0 )
58 58
 
59
+#define MLX_PRINT_PRIVATE(...)				printf(__VA_ARGS__)
59 60
 
60 61
 
61 62
 #endif /* STUB_MLXUTILS_INCLUDE_PRIVATE_FLEXBOOT_DEBUG_H_ */

+ 1
- 1
src/drivers/infiniband/mlx_utils_flexboot/include/mlx_types_priv.h Visa fil

@@ -33,7 +33,7 @@ typedef uint8_t		mlx_uint8;
33 33
 typedef uint16_t	mlx_uint16;
34 34
 typedef uint32_t	mlx_uint32;
35 35
 typedef uint64_t	mlx_uint64;
36
-typedef uint32_t 	mlx_uintn;
36
+typedef unsigned long	mlx_uintn;
37 37
 
38 38
 typedef int8_t		mlx_int8;
39 39
 typedef int16_t		mlx_int16;;

+ 13
- 0
src/drivers/infiniband/mlx_utils_flexboot/src/mlx_pci_priv.c Visa fil

@@ -6,6 +6,7 @@
6 6
  */
7 7
 
8 8
 #include <ipxe/pci.h>
9
+
9 10
 #include "../../mlx_utils/include/private/mlx_pci_priv.h"
10 11
 
11 12
 
@@ -120,6 +121,18 @@ mlx_pci_init_priv(
120 121
 	return status;
121 122
 }
122 123
 
124
+mlx_status
125
+mlx_pci_teardown_priv(
126
+			IN mlx_utils *utils __attribute__ ((unused))
127
+			)
128
+{
129
+	mlx_status status = MLX_SUCCESS;
130
+#ifdef DEVICE_CX3
131
+	iounmap( utils->config );
132
+#endif
133
+	return status;
134
+}
135
+
123 136
 mlx_status
124 137
 mlx_pci_read_priv(
125 138
 			IN mlx_utils *utils,

Laddar…
Avbryt
Spara