Browse Source

[hermon] Make driver 64-bit safe

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

+ 27
- 0
src/drivers/infiniband/hermon.c View File

193
 	if ( in_len && ( command & HERMON_HCR_IN_MBOX ) ) {
193
 	if ( in_len && ( command & HERMON_HCR_IN_MBOX ) ) {
194
 		memset ( hermon->mailbox_in, 0, HERMON_MBOX_SIZE );
194
 		memset ( hermon->mailbox_in, 0, HERMON_MBOX_SIZE );
195
 		in_buffer = hermon->mailbox_in;
195
 		in_buffer = hermon->mailbox_in;
196
+		MLX_FILL_H ( &hcr, 0, in_param_h, virt_to_bus ( in_buffer ) );
196
 		MLX_FILL_1 ( &hcr, 1, in_param_l, virt_to_bus ( in_buffer ) );
197
 		MLX_FILL_1 ( &hcr, 1, in_param_l, virt_to_bus ( in_buffer ) );
197
 	}
198
 	}
198
 	memcpy ( in_buffer, in, in_len );
199
 	memcpy ( in_buffer, in, in_len );
200
 	out_buffer = &hcr.u.dwords[3];
201
 	out_buffer = &hcr.u.dwords[3];
201
 	if ( out_len && ( command & HERMON_HCR_OUT_MBOX ) ) {
202
 	if ( out_len && ( command & HERMON_HCR_OUT_MBOX ) ) {
202
 		out_buffer = hermon->mailbox_out;
203
 		out_buffer = hermon->mailbox_out;
204
+		MLX_FILL_H ( &hcr, 3, out_param_h,
205
+			     virt_to_bus ( out_buffer ) );
203
 		MLX_FILL_1 ( &hcr, 4, out_param_l,
206
 		MLX_FILL_1 ( &hcr, 4, out_param_l,
204
 			     virt_to_bus ( out_buffer ) );
207
 			     virt_to_bus ( out_buffer ) );
205
 	}
208
 	}
652
 		memset ( &write_mtt, 0, sizeof ( write_mtt ) );
655
 		memset ( &write_mtt, 0, sizeof ( write_mtt ) );
653
 		MLX_FILL_1 ( &write_mtt.mtt_base_addr, 1,
656
 		MLX_FILL_1 ( &write_mtt.mtt_base_addr, 1,
654
 			     value, mtt_base_addr );
657
 			     value, mtt_base_addr );
658
+		MLX_FILL_H ( &write_mtt.mtt, 0, ptag_h, addr );
655
 		MLX_FILL_2 ( &write_mtt.mtt, 1,
659
 		MLX_FILL_2 ( &write_mtt.mtt, 1,
656
 			     p, 1,
660
 			     p, 1,
657
 			     ptag_l, ( addr >> 3 ) );
661
 			     ptag_l, ( addr >> 3 ) );
894
 		     usr_page, HERMON_UAR_NON_EQ_PAGE,
898
 		     usr_page, HERMON_UAR_NON_EQ_PAGE,
895
 		     log_cq_size, fls ( cq->num_cqes - 1 ) );
899
 		     log_cq_size, fls ( cq->num_cqes - 1 ) );
896
 	MLX_FILL_1 ( &cqctx, 5, c_eqn, hermon->eq.eqn );
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
 	MLX_FILL_1 ( &cqctx, 7, mtt_base_addr_l,
903
 	MLX_FILL_1 ( &cqctx, 7, mtt_base_addr_l,
898
 		     ( hermon_cq->mtt.mtt_base_addr >> 3 ) );
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
 	MLX_FILL_1 ( &cqctx, 15, db_record_addr_l,
907
 	MLX_FILL_1 ( &cqctx, 15, db_record_addr_l,
900
 		     ( virt_to_phys ( hermon_cq->doorbell ) >> 3 ) );
908
 		     ( virt_to_phys ( hermon_cq->doorbell ) >> 3 ) );
901
 	if ( ( rc = hermon_cmd_sw2hw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
909
 	if ( ( rc = hermon_cmd_sw2hw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
1180
 		     qpc_eec_data.page_offset,
1188
 		     qpc_eec_data.page_offset,
1181
 		     ( hermon_qp->mtt.page_offset >> 6 ) );
1189
 		     ( hermon_qp->mtt.page_offset >> 6 ) );
1182
 	MLX_FILL_1 ( &qpctx, 41, qpc_eec_data.cqn_rcv, qp->recv.cq->cqn );
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
 	MLX_FILL_1 ( &qpctx, 43, qpc_eec_data.db_record_addr_l,
1193
 	MLX_FILL_1 ( &qpctx, 43, qpc_eec_data.db_record_addr_l,
1184
 		     ( virt_to_phys ( hermon_qp->recv.doorbell ) >> 2 ) );
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
 	MLX_FILL_1 ( &qpctx, 53, qpc_eec_data.mtt_base_addr_l,
1197
 	MLX_FILL_1 ( &qpctx, 53, qpc_eec_data.mtt_base_addr_l,
1186
 		     ( hermon_qp->mtt.mtt_base_addr >> 3 ) );
1198
 		     ( hermon_qp->mtt.mtt_base_addr >> 3 ) );
1187
 	if ( ( rc = hermon_cmd_rst2init_qp ( hermon, qp->qpn,
1199
 	if ( ( rc = hermon_cmd_rst2init_qp ( hermon, qp->qpn,
1403
 	MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, av->qkey );
1415
 	MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, av->qkey );
1404
 	MLX_FILL_1 ( &wqe->ud.data[0], 0, byte_count, iob_len ( iobuf ) );
1416
 	MLX_FILL_1 ( &wqe->ud.data[0], 0, byte_count, iob_len ( iobuf ) );
1405
 	MLX_FILL_1 ( &wqe->ud.data[0], 1, l_key, hermon->lkey );
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
 	MLX_FILL_1 ( &wqe->ud.data[0], 3,
1420
 	MLX_FILL_1 ( &wqe->ud.data[0], 3,
1407
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1421
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1408
 	return HERMON_OPCODE_SEND;
1422
 	return HERMON_OPCODE_SEND;
1446
 	MLX_FILL_1 ( &wqe->mlx.data[0], 0,
1460
 	MLX_FILL_1 ( &wqe->mlx.data[0], 0,
1447
 		     byte_count, iob_len ( &headers ) );
1461
 		     byte_count, iob_len ( &headers ) );
1448
 	MLX_FILL_1 ( &wqe->mlx.data[0], 1, l_key, hermon->lkey );
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
 	MLX_FILL_1 ( &wqe->mlx.data[0], 3,
1465
 	MLX_FILL_1 ( &wqe->mlx.data[0], 3,
1450
 		     local_address_l, virt_to_bus ( headers.data ) );
1466
 		     local_address_l, virt_to_bus ( headers.data ) );
1451
 	MLX_FILL_1 ( &wqe->mlx.data[1], 0,
1467
 	MLX_FILL_1 ( &wqe->mlx.data[1], 0,
1452
 		     byte_count, ( iob_len ( iobuf ) + 4 /* ICRC */ ) );
1468
 		     byte_count, ( iob_len ( iobuf ) + 4 /* ICRC */ ) );
1453
 	MLX_FILL_1 ( &wqe->mlx.data[1], 1, l_key, hermon->lkey );
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
 	MLX_FILL_1 ( &wqe->mlx.data[1], 3,
1472
 	MLX_FILL_1 ( &wqe->mlx.data[1], 3,
1455
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1473
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1456
 	return HERMON_OPCODE_SEND;
1474
 	return HERMON_OPCODE_SEND;
1479
 	MLX_FILL_1 ( &wqe->rc.ctrl, 2, c, 0x03 /* generate completion */ );
1497
 	MLX_FILL_1 ( &wqe->rc.ctrl, 2, c, 0x03 /* generate completion */ );
1480
 	MLX_FILL_1 ( &wqe->rc.data[0], 0, byte_count, iob_len ( iobuf ) );
1498
 	MLX_FILL_1 ( &wqe->rc.data[0], 0, byte_count, iob_len ( iobuf ) );
1481
 	MLX_FILL_1 ( &wqe->rc.data[0], 1, l_key, hermon->lkey );
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
 	MLX_FILL_1 ( &wqe->rc.data[0], 3,
1502
 	MLX_FILL_1 ( &wqe->rc.data[0], 3,
1483
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1503
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1484
 	return HERMON_OPCODE_SEND;
1504
 	return HERMON_OPCODE_SEND;
1511
 	MLX_FILL_1 ( &wqe->eth.data[0], 0,
1531
 	MLX_FILL_1 ( &wqe->eth.data[0], 0,
1512
 		     byte_count, iob_len ( iobuf ) );
1532
 		     byte_count, iob_len ( iobuf ) );
1513
 	MLX_FILL_1 ( &wqe->eth.data[0], 1, l_key, hermon->lkey );
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
 	MLX_FILL_1 ( &wqe->eth.data[0], 3,
1536
 	MLX_FILL_1 ( &wqe->eth.data[0], 3,
1515
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1537
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1516
 	return HERMON_OPCODE_SEND;
1538
 	return HERMON_OPCODE_SEND;
1623
 	/* Construct work queue entry */
1645
 	/* Construct work queue entry */
1624
 	MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_tailroom ( iobuf ) );
1646
 	MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_tailroom ( iobuf ) );
1625
 	MLX_FILL_1 ( &wqe->data[0], 1, l_key, hermon->lkey );
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
 	MLX_FILL_1 ( &wqe->data[0], 3,
1650
 	MLX_FILL_1 ( &wqe->data[0], 3,
1627
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1651
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1628
 
1652
 
1849
 	MLX_FILL_1 ( &eqctx, 2,
1873
 	MLX_FILL_1 ( &eqctx, 2,
1850
 		     page_offset, ( hermon_eq->mtt.page_offset >> 5 ) );
1874
 		     page_offset, ( hermon_eq->mtt.page_offset >> 5 ) );
1851
 	MLX_FILL_1 ( &eqctx, 3, log_eq_size, fls ( HERMON_NUM_EQES - 1 ) );
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
 	MLX_FILL_1 ( &eqctx, 7, mtt_base_addr_l,
1878
 	MLX_FILL_1 ( &eqctx, 7, mtt_base_addr_l,
1853
 		     ( hermon_eq->mtt.mtt_base_addr >> 3 ) );
1879
 		     ( hermon_eq->mtt.mtt_base_addr >> 3 ) );
1854
 	if ( ( rc = hermon_cmd_sw2hw_eq ( hermon, hermon_eq->eqn,
1880
 	if ( ( rc = hermon_cmd_sw2hw_eq ( hermon, hermon_eq->eqn,
2812
 		memset ( &mapping, 0, sizeof ( mapping ) );
2838
 		memset ( &mapping, 0, sizeof ( mapping ) );
2813
 		MLX_FILL_1 ( &mapping, 0, va_h, ( va >> 32 ) );
2839
 		MLX_FILL_1 ( &mapping, 0, va_h, ( va >> 32 ) );
2814
 		MLX_FILL_1 ( &mapping, 1, va_l, ( va >> 12 ) );
2840
 		MLX_FILL_1 ( &mapping, 1, va_l, ( va >> 12 ) );
2841
+		MLX_FILL_H ( &mapping, 2, pa_h, pa );
2815
 		MLX_FILL_2 ( &mapping, 3,
2842
 		MLX_FILL_2 ( &mapping, 3,
2816
 			     log2size, ( ( fls ( size ) - 1 ) - 12 ),
2843
 			     log2size, ( ( fls ( size ) - 1 ) - 12 ),
2817
 			     pa_l, ( pa >> 12 ) );
2844
 			     pa_l, ( pa >> 12 ) );

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

232
 		__value;						     \
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
 #endif /* _MLX_BITOPS_H */
245
 #endif /* _MLX_BITOPS_H */

Loading…
Cancel
Save