浏览代码

[hermon] Make driver 64-bit safe

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 年前
父节点
当前提交
c0778b770c
共有 2 个文件被更改,包括 37 次插入0 次删除
  1. 27
    0
      src/drivers/infiniband/hermon.c
  2. 10
    0
      src/drivers/infiniband/mlx_bitops.h

+ 27
- 0
src/drivers/infiniband/hermon.c 查看文件

@@ -193,6 +193,7 @@ static int hermon_cmd ( struct hermon *hermon, unsigned long command,
193 193
 	if ( in_len && ( command & HERMON_HCR_IN_MBOX ) ) {
194 194
 		memset ( hermon->mailbox_in, 0, HERMON_MBOX_SIZE );
195 195
 		in_buffer = hermon->mailbox_in;
196
+		MLX_FILL_H ( &hcr, 0, in_param_h, virt_to_bus ( in_buffer ) );
196 197
 		MLX_FILL_1 ( &hcr, 1, in_param_l, virt_to_bus ( in_buffer ) );
197 198
 	}
198 199
 	memcpy ( in_buffer, in, in_len );
@@ -200,6 +201,8 @@ static int hermon_cmd ( struct hermon *hermon, unsigned long command,
200 201
 	out_buffer = &hcr.u.dwords[3];
201 202
 	if ( out_len && ( command & HERMON_HCR_OUT_MBOX ) ) {
202 203
 		out_buffer = hermon->mailbox_out;
204
+		MLX_FILL_H ( &hcr, 3, out_param_h,
205
+			     virt_to_bus ( out_buffer ) );
203 206
 		MLX_FILL_1 ( &hcr, 4, out_param_l,
204 207
 			     virt_to_bus ( out_buffer ) );
205 208
 	}
@@ -652,6 +655,7 @@ static int hermon_alloc_mtt ( struct hermon *hermon,
652 655
 		memset ( &write_mtt, 0, sizeof ( write_mtt ) );
653 656
 		MLX_FILL_1 ( &write_mtt.mtt_base_addr, 1,
654 657
 			     value, mtt_base_addr );
658
+		MLX_FILL_H ( &write_mtt.mtt, 0, ptag_h, addr );
655 659
 		MLX_FILL_2 ( &write_mtt.mtt, 1,
656 660
 			     p, 1,
657 661
 			     ptag_l, ( addr >> 3 ) );
@@ -894,8 +898,12 @@ static int hermon_create_cq ( struct ib_device *ibdev,
894 898
 		     usr_page, HERMON_UAR_NON_EQ_PAGE,
895 899
 		     log_cq_size, fls ( cq->num_cqes - 1 ) );
896 900
 	MLX_FILL_1 ( &cqctx, 5, c_eqn, hermon->eq.eqn );
901
+	MLX_FILL_H ( &cqctx, 6, mtt_base_addr_h,
902
+		     hermon_cq->mtt.mtt_base_addr );
897 903
 	MLX_FILL_1 ( &cqctx, 7, mtt_base_addr_l,
898 904
 		     ( hermon_cq->mtt.mtt_base_addr >> 3 ) );
905
+	MLX_FILL_H ( &cqctx, 14, db_record_addr_h,
906
+		     virt_to_phys ( hermon_cq->doorbell ) );
899 907
 	MLX_FILL_1 ( &cqctx, 15, db_record_addr_l,
900 908
 		     ( virt_to_phys ( hermon_cq->doorbell ) >> 3 ) );
901 909
 	if ( ( rc = hermon_cmd_sw2hw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
@@ -1180,8 +1188,12 @@ static int hermon_create_qp ( struct ib_device *ibdev,
1180 1188
 		     qpc_eec_data.page_offset,
1181 1189
 		     ( hermon_qp->mtt.page_offset >> 6 ) );
1182 1190
 	MLX_FILL_1 ( &qpctx, 41, qpc_eec_data.cqn_rcv, qp->recv.cq->cqn );
1191
+	MLX_FILL_H ( &qpctx, 42, qpc_eec_data.db_record_addr_h,
1192
+		     virt_to_phys ( hermon_qp->recv.doorbell ) );
1183 1193
 	MLX_FILL_1 ( &qpctx, 43, qpc_eec_data.db_record_addr_l,
1184 1194
 		     ( virt_to_phys ( hermon_qp->recv.doorbell ) >> 2 ) );
1195
+	MLX_FILL_H ( &qpctx, 52, qpc_eec_data.mtt_base_addr_h,
1196
+		     hermon_qp->mtt.mtt_base_addr );
1185 1197
 	MLX_FILL_1 ( &qpctx, 53, qpc_eec_data.mtt_base_addr_l,
1186 1198
 		     ( hermon_qp->mtt.mtt_base_addr >> 3 ) );
1187 1199
 	if ( ( rc = hermon_cmd_rst2init_qp ( hermon, qp->qpn,
@@ -1403,6 +1415,8 @@ hermon_fill_ud_send_wqe ( struct ib_device *ibdev,
1403 1415
 	MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, av->qkey );
1404 1416
 	MLX_FILL_1 ( &wqe->ud.data[0], 0, byte_count, iob_len ( iobuf ) );
1405 1417
 	MLX_FILL_1 ( &wqe->ud.data[0], 1, l_key, hermon->lkey );
1418
+	MLX_FILL_H ( &wqe->ud.data[0], 2,
1419
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1406 1420
 	MLX_FILL_1 ( &wqe->ud.data[0], 3,
1407 1421
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1408 1422
 	return HERMON_OPCODE_SEND;
@@ -1446,11 +1460,15 @@ hermon_fill_mlx_send_wqe ( struct ib_device *ibdev,
1446 1460
 	MLX_FILL_1 ( &wqe->mlx.data[0], 0,
1447 1461
 		     byte_count, iob_len ( &headers ) );
1448 1462
 	MLX_FILL_1 ( &wqe->mlx.data[0], 1, l_key, hermon->lkey );
1463
+	MLX_FILL_H ( &wqe->mlx.data[0], 2,
1464
+		     local_address_h, virt_to_bus ( headers.data ) );
1449 1465
 	MLX_FILL_1 ( &wqe->mlx.data[0], 3,
1450 1466
 		     local_address_l, virt_to_bus ( headers.data ) );
1451 1467
 	MLX_FILL_1 ( &wqe->mlx.data[1], 0,
1452 1468
 		     byte_count, ( iob_len ( iobuf ) + 4 /* ICRC */ ) );
1453 1469
 	MLX_FILL_1 ( &wqe->mlx.data[1], 1, l_key, hermon->lkey );
1470
+	MLX_FILL_H ( &wqe->mlx.data[1], 2,
1471
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1454 1472
 	MLX_FILL_1 ( &wqe->mlx.data[1], 3,
1455 1473
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1456 1474
 	return HERMON_OPCODE_SEND;
@@ -1479,6 +1497,8 @@ hermon_fill_rc_send_wqe ( struct ib_device *ibdev,
1479 1497
 	MLX_FILL_1 ( &wqe->rc.ctrl, 2, c, 0x03 /* generate completion */ );
1480 1498
 	MLX_FILL_1 ( &wqe->rc.data[0], 0, byte_count, iob_len ( iobuf ) );
1481 1499
 	MLX_FILL_1 ( &wqe->rc.data[0], 1, l_key, hermon->lkey );
1500
+	MLX_FILL_H ( &wqe->rc.data[0], 2,
1501
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1482 1502
 	MLX_FILL_1 ( &wqe->rc.data[0], 3,
1483 1503
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1484 1504
 	return HERMON_OPCODE_SEND;
@@ -1511,6 +1531,8 @@ hermon_fill_eth_send_wqe ( struct ib_device *ibdev,
1511 1531
 	MLX_FILL_1 ( &wqe->eth.data[0], 0,
1512 1532
 		     byte_count, iob_len ( iobuf ) );
1513 1533
 	MLX_FILL_1 ( &wqe->eth.data[0], 1, l_key, hermon->lkey );
1534
+	MLX_FILL_H ( &wqe->eth.data[0], 2,
1535
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1514 1536
 	MLX_FILL_1 ( &wqe->eth.data[0], 3,
1515 1537
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1516 1538
 	return HERMON_OPCODE_SEND;
@@ -1623,6 +1645,8 @@ static int hermon_post_recv ( struct ib_device *ibdev,
1623 1645
 	/* Construct work queue entry */
1624 1646
 	MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_tailroom ( iobuf ) );
1625 1647
 	MLX_FILL_1 ( &wqe->data[0], 1, l_key, hermon->lkey );
1648
+	MLX_FILL_H ( &wqe->data[0], 2,
1649
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1626 1650
 	MLX_FILL_1 ( &wqe->data[0], 3,
1627 1651
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1628 1652
 
@@ -1849,6 +1873,8 @@ static int hermon_create_eq ( struct hermon *hermon ) {
1849 1873
 	MLX_FILL_1 ( &eqctx, 2,
1850 1874
 		     page_offset, ( hermon_eq->mtt.page_offset >> 5 ) );
1851 1875
 	MLX_FILL_1 ( &eqctx, 3, log_eq_size, fls ( HERMON_NUM_EQES - 1 ) );
1876
+	MLX_FILL_H ( &eqctx, 6, mtt_base_addr_h,
1877
+		     hermon_eq->mtt.mtt_base_addr );
1852 1878
 	MLX_FILL_1 ( &eqctx, 7, mtt_base_addr_l,
1853 1879
 		     ( hermon_eq->mtt.mtt_base_addr >> 3 ) );
1854 1880
 	if ( ( rc = hermon_cmd_sw2hw_eq ( hermon, hermon_eq->eqn,
@@ -2812,6 +2838,7 @@ static int hermon_map_vpm ( struct hermon *hermon,
2812 2838
 		memset ( &mapping, 0, sizeof ( mapping ) );
2813 2839
 		MLX_FILL_1 ( &mapping, 0, va_h, ( va >> 32 ) );
2814 2840
 		MLX_FILL_1 ( &mapping, 1, va_l, ( va >> 12 ) );
2841
+		MLX_FILL_H ( &mapping, 2, pa_h, pa );
2815 2842
 		MLX_FILL_2 ( &mapping, 3,
2816 2843
 			     log2size, ( ( fls ( size ) - 1 ) - 12 ),
2817 2844
 			     pa_l, ( pa >> 12 ) );

+ 10
- 0
src/drivers/infiniband/mlx_bitops.h 查看文件

@@ -232,4 +232,14 @@ typedef unsigned char pseudo_bit_t;
232 232
 		__value;						     \
233 233
 	} )
234 234
 
235
+/*
236
+ * Fill high dword of physical address, if necessary
237
+ *
238
+ */
239
+#define MLX_FILL_H( _structure_st, _index, _field, _address ) do {	     \
240
+	if ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) {		     \
241
+		MLX_FILL_1 ( _structure_st, _index, _field,		     \
242
+			     ( ( ( uint64_t ) (_address) ) >> 32 ) );	     \
243
+	} } while ( 0 )
244
+
235 245
 #endif /* _MLX_BITOPS_H */

正在加载...
取消
保存