Browse Source

[arbel] Make driver 64-bit safe

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
464cd1b3ce
1 changed files with 37 additions and 2 deletions
  1. 37
    2
      src/drivers/infiniband/arbel.c

+ 37
- 2
src/drivers/infiniband/arbel.c View File

162
 	in_buffer = &hcr.u.dwords[0];
162
 	in_buffer = &hcr.u.dwords[0];
163
 	if ( in_len && ( command & ARBEL_HCR_IN_MBOX ) ) {
163
 	if ( in_len && ( command & ARBEL_HCR_IN_MBOX ) ) {
164
 		in_buffer = arbel->mailbox_in;
164
 		in_buffer = arbel->mailbox_in;
165
+		MLX_FILL_H ( &hcr, 0, in_param_h, virt_to_bus ( in_buffer ) );
165
 		MLX_FILL_1 ( &hcr, 1, in_param_l, virt_to_bus ( in_buffer ) );
166
 		MLX_FILL_1 ( &hcr, 1, in_param_l, virt_to_bus ( in_buffer ) );
166
 	}
167
 	}
167
 	memcpy ( in_buffer, in, in_len );
168
 	memcpy ( in_buffer, in, in_len );
169
 	out_buffer = &hcr.u.dwords[3];
170
 	out_buffer = &hcr.u.dwords[3];
170
 	if ( out_len && ( command & ARBEL_HCR_OUT_MBOX ) ) {
171
 	if ( out_len && ( command & ARBEL_HCR_OUT_MBOX ) ) {
171
 		out_buffer = arbel->mailbox_out;
172
 		out_buffer = arbel->mailbox_out;
173
+		MLX_FILL_H ( &hcr, 3, out_param_h,
174
+			     virt_to_bus ( out_buffer ) );
172
 		MLX_FILL_1 ( &hcr, 4, out_param_l,
175
 		MLX_FILL_1 ( &hcr, 4, out_param_l,
173
 			     virt_to_bus ( out_buffer ) );
176
 			     virt_to_bus ( out_buffer ) );
174
 	}
177
 	}
657
 	/* Hand queue over to hardware */
660
 	/* Hand queue over to hardware */
658
 	memset ( &cqctx, 0, sizeof ( cqctx ) );
661
 	memset ( &cqctx, 0, sizeof ( cqctx ) );
659
 	MLX_FILL_1 ( &cqctx, 0, st, 0xa /* "Event fired" */ );
662
 	MLX_FILL_1 ( &cqctx, 0, st, 0xa /* "Event fired" */ );
663
+	MLX_FILL_H ( &cqctx, 1, start_address_h,
664
+		     virt_to_bus ( arbel_cq->cqe ) );
660
 	MLX_FILL_1 ( &cqctx, 2, start_address_l,
665
 	MLX_FILL_1 ( &cqctx, 2, start_address_l,
661
 		     virt_to_bus ( arbel_cq->cqe ) );
666
 		     virt_to_bus ( arbel_cq->cqe ) );
662
 	MLX_FILL_2 ( &cqctx, 3,
667
 	MLX_FILL_2 ( &cqctx, 3,
938
 	struct arbelprm_qp_ee_state_transitions qpctx;
943
 	struct arbelprm_qp_ee_state_transitions qpctx;
939
 	struct arbelprm_qp_db_record *send_db_rec;
944
 	struct arbelprm_qp_db_record *send_db_rec;
940
 	struct arbelprm_qp_db_record *recv_db_rec;
945
 	struct arbelprm_qp_db_record *recv_db_rec;
946
+	physaddr_t send_wqe_base_adr;
947
+	physaddr_t recv_wqe_base_adr;
948
+	physaddr_t wqe_base_adr;
941
 	int rc;
949
 	int rc;
942
 
950
 
943
 	/* Calculate queue pair number */
951
 	/* Calculate queue pair number */
961
 					   qp->recv.num_wqes ) ) != 0 )
969
 					   qp->recv.num_wqes ) ) != 0 )
962
 		goto err_create_recv_wq;
970
 		goto err_create_recv_wq;
963
 
971
 
972
+	/* Send and receive work queue entries must be within the same 4GB */
973
+	send_wqe_base_adr = virt_to_bus ( arbel_qp->send.wqe );
974
+	recv_wqe_base_adr = virt_to_bus ( arbel_qp->recv.wqe );
975
+	if ( ( sizeof ( physaddr_t ) > sizeof ( uint32_t ) ) &&
976
+	     ( ( ( ( uint64_t ) send_wqe_base_adr ) >> 32 ) !=
977
+	       ( ( ( uint64_t ) recv_wqe_base_adr ) >> 32 ) ) ) {
978
+		DBGC ( arbel, "Arbel %p QPN %#lx cannot support send %08lx "
979
+		       "recv %08lx\n", arbel, qp->qpn,
980
+		       send_wqe_base_adr, recv_wqe_base_adr );
981
+		rc = -ENOTSUP;
982
+		goto err_unsupported_address_split;
983
+	}
984
+	wqe_base_adr = send_wqe_base_adr;
985
+
964
 	/* Initialise doorbell records */
986
 	/* Initialise doorbell records */
965
 	send_db_rec = &arbel->db_rec[arbel_qp->send.doorbell_idx].qp;
987
 	send_db_rec = &arbel->db_rec[arbel_qp->send.doorbell_idx].qp;
966
 	MLX_FILL_1 ( send_db_rec, 0, counter, 0 );
988
 	MLX_FILL_1 ( send_db_rec, 0, counter, 0 );
991
 	MLX_FILL_1 ( &qpctx, 10, qpc_eec_data.primary_address_path.port_number,
1013
 	MLX_FILL_1 ( &qpctx, 10, qpc_eec_data.primary_address_path.port_number,
992
 		     ibdev->port );
1014
 		     ibdev->port );
993
 	MLX_FILL_1 ( &qpctx, 27, qpc_eec_data.pd, ARBEL_GLOBAL_PD );
1015
 	MLX_FILL_1 ( &qpctx, 27, qpc_eec_data.pd, ARBEL_GLOBAL_PD );
1016
+	MLX_FILL_H ( &qpctx, 28, qpc_eec_data.wqe_base_adr_h, wqe_base_adr );
994
 	MLX_FILL_1 ( &qpctx, 29, qpc_eec_data.wqe_lkey, arbel->lkey );
1017
 	MLX_FILL_1 ( &qpctx, 29, qpc_eec_data.wqe_lkey, arbel->lkey );
995
 	MLX_FILL_1 ( &qpctx, 30, qpc_eec_data.ssc, 1 );
1018
 	MLX_FILL_1 ( &qpctx, 30, qpc_eec_data.ssc, 1 );
996
 	MLX_FILL_1 ( &qpctx, 33, qpc_eec_data.cqn_snd, qp->send.cq->cqn );
1019
 	MLX_FILL_1 ( &qpctx, 33, qpc_eec_data.cqn_snd, qp->send.cq->cqn );
997
 	MLX_FILL_1 ( &qpctx, 34, qpc_eec_data.snd_wqe_base_adr_l,
1020
 	MLX_FILL_1 ( &qpctx, 34, qpc_eec_data.snd_wqe_base_adr_l,
998
-		     ( virt_to_bus ( arbel_qp->send.wqe ) >> 6 ) );
1021
+		     ( send_wqe_base_adr >> 6 ) );
999
 	MLX_FILL_1 ( &qpctx, 35, qpc_eec_data.snd_db_record_index,
1022
 	MLX_FILL_1 ( &qpctx, 35, qpc_eec_data.snd_db_record_index,
1000
 		     arbel_qp->send.doorbell_idx );
1023
 		     arbel_qp->send.doorbell_idx );
1001
 	MLX_FILL_1 ( &qpctx, 38, qpc_eec_data.rsc, 1 );
1024
 	MLX_FILL_1 ( &qpctx, 38, qpc_eec_data.rsc, 1 );
1002
 	MLX_FILL_1 ( &qpctx, 41, qpc_eec_data.cqn_rcv, qp->recv.cq->cqn );
1025
 	MLX_FILL_1 ( &qpctx, 41, qpc_eec_data.cqn_rcv, qp->recv.cq->cqn );
1003
 	MLX_FILL_1 ( &qpctx, 42, qpc_eec_data.rcv_wqe_base_adr_l,
1026
 	MLX_FILL_1 ( &qpctx, 42, qpc_eec_data.rcv_wqe_base_adr_l,
1004
-		     ( virt_to_bus ( arbel_qp->recv.wqe ) >> 6 ) );
1027
+		     ( recv_wqe_base_adr >> 6 ) );
1005
 	MLX_FILL_1 ( &qpctx, 43, qpc_eec_data.rcv_db_record_index,
1028
 	MLX_FILL_1 ( &qpctx, 43, qpc_eec_data.rcv_db_record_index,
1006
 		     arbel_qp->recv.doorbell_idx );
1029
 		     arbel_qp->recv.doorbell_idx );
1007
 	if ( ( rc = arbel_cmd_rst2init_qpee ( arbel, qp->qpn, &qpctx )) != 0 ){
1030
 	if ( ( rc = arbel_cmd_rst2init_qpee ( arbel, qp->qpn, &qpctx )) != 0 ){
1030
  err_rst2init_qpee:
1053
  err_rst2init_qpee:
1031
 	MLX_FILL_1 ( send_db_rec, 1, res, ARBEL_UAR_RES_NONE );
1054
 	MLX_FILL_1 ( send_db_rec, 1, res, ARBEL_UAR_RES_NONE );
1032
 	MLX_FILL_1 ( recv_db_rec, 1, res, ARBEL_UAR_RES_NONE );
1055
 	MLX_FILL_1 ( recv_db_rec, 1, res, ARBEL_UAR_RES_NONE );
1056
+ err_unsupported_address_split:
1033
 	free_dma ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size );
1057
 	free_dma ( arbel_qp->recv.wqe, arbel_qp->recv.wqe_size );
1034
  err_create_recv_wq:
1058
  err_create_recv_wq:
1035
 	free_dma ( arbel_qp->send.wqe, arbel_qp->send.wqe_size );
1059
 	free_dma ( arbel_qp->send.wqe, arbel_qp->send.wqe_size );
1205
 	MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, av->qkey );
1229
 	MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, av->qkey );
1206
 	MLX_FILL_1 ( &wqe->ud.data[0], 0, byte_count, iob_len ( iobuf ) );
1230
 	MLX_FILL_1 ( &wqe->ud.data[0], 0, byte_count, iob_len ( iobuf ) );
1207
 	MLX_FILL_1 ( &wqe->ud.data[0], 1, l_key, arbel->lkey );
1231
 	MLX_FILL_1 ( &wqe->ud.data[0], 1, l_key, arbel->lkey );
1232
+	MLX_FILL_H ( &wqe->ud.data[0], 2,
1233
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1208
 	MLX_FILL_1 ( &wqe->ud.data[0], 3,
1234
 	MLX_FILL_1 ( &wqe->ud.data[0], 3,
1209
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1235
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1210
 
1236
 
1247
 	MLX_FILL_1 ( &wqe->mlx.data[0], 0,
1273
 	MLX_FILL_1 ( &wqe->mlx.data[0], 0,
1248
 		     byte_count, iob_len ( &headers ) );
1274
 		     byte_count, iob_len ( &headers ) );
1249
 	MLX_FILL_1 ( &wqe->mlx.data[0], 1, l_key, arbel->lkey );
1275
 	MLX_FILL_1 ( &wqe->mlx.data[0], 1, l_key, arbel->lkey );
1276
+	MLX_FILL_H ( &wqe->mlx.data[0], 2,
1277
+		     local_address_h, virt_to_bus ( headers.data ) );
1250
 	MLX_FILL_1 ( &wqe->mlx.data[0], 3,
1278
 	MLX_FILL_1 ( &wqe->mlx.data[0], 3,
1251
 		     local_address_l, virt_to_bus ( headers.data ) );
1279
 		     local_address_l, virt_to_bus ( headers.data ) );
1252
 	MLX_FILL_1 ( &wqe->mlx.data[1], 0,
1280
 	MLX_FILL_1 ( &wqe->mlx.data[1], 0,
1253
 		     byte_count, ( iob_len ( iobuf ) + 4 /* ICRC */ ) );
1281
 		     byte_count, ( iob_len ( iobuf ) + 4 /* ICRC */ ) );
1254
 	MLX_FILL_1 ( &wqe->mlx.data[1], 1, l_key, arbel->lkey );
1282
 	MLX_FILL_1 ( &wqe->mlx.data[1], 1, l_key, arbel->lkey );
1283
+	MLX_FILL_H ( &wqe->mlx.data[1], 2,
1284
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1255
 	MLX_FILL_1 ( &wqe->mlx.data[1], 3,
1285
 	MLX_FILL_1 ( &wqe->mlx.data[1], 3,
1256
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1286
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1257
 
1287
 
1378
 	/* Construct work queue entry */
1408
 	/* Construct work queue entry */
1379
 	MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_tailroom ( iobuf ) );
1409
 	MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_tailroom ( iobuf ) );
1380
 	MLX_FILL_1 ( &wqe->data[0], 1, l_key, arbel->lkey );
1410
 	MLX_FILL_1 ( &wqe->data[0], 1, l_key, arbel->lkey );
1411
+	MLX_FILL_H ( &wqe->data[0], 2,
1412
+		     local_address_h, virt_to_bus ( iobuf->data ) );
1381
 	MLX_FILL_1 ( &wqe->data[0], 3,
1413
 	MLX_FILL_1 ( &wqe->data[0], 3,
1382
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1414
 		     local_address_l, virt_to_bus ( iobuf->data ) );
1383
 
1415
 
1609
 	/* Hand queue over to hardware */
1641
 	/* Hand queue over to hardware */
1610
 	memset ( &eqctx, 0, sizeof ( eqctx ) );
1642
 	memset ( &eqctx, 0, sizeof ( eqctx ) );
1611
 	MLX_FILL_1 ( &eqctx, 0, st, 0xa /* "Fired" */ );
1643
 	MLX_FILL_1 ( &eqctx, 0, st, 0xa /* "Fired" */ );
1644
+	MLX_FILL_H ( &eqctx, 1,
1645
+		     start_address_h, virt_to_phys ( arbel_eq->eqe ) );
1612
 	MLX_FILL_1 ( &eqctx, 2,
1646
 	MLX_FILL_1 ( &eqctx, 2,
1613
 		     start_address_l, virt_to_phys ( arbel_eq->eqe ) );
1647
 		     start_address_l, virt_to_phys ( arbel_eq->eqe ) );
1614
 	MLX_FILL_1 ( &eqctx, 3, log_eq_size, fls ( ARBEL_NUM_EQES - 1 ) );
1648
 	MLX_FILL_1 ( &eqctx, 3, log_eq_size, fls ( ARBEL_NUM_EQES - 1 ) );
2031
 		memset ( &mapping, 0, sizeof ( mapping ) );
2065
 		memset ( &mapping, 0, sizeof ( mapping ) );
2032
 		MLX_FILL_1 ( &mapping, 0, va_h, ( va >> 32 ) );
2066
 		MLX_FILL_1 ( &mapping, 0, va_h, ( va >> 32 ) );
2033
 		MLX_FILL_1 ( &mapping, 1, va_l, ( va >> 12 ) );
2067
 		MLX_FILL_1 ( &mapping, 1, va_l, ( va >> 12 ) );
2068
+		MLX_FILL_H ( &mapping, 2, pa_h, pa );
2034
 		MLX_FILL_2 ( &mapping, 3,
2069
 		MLX_FILL_2 ( &mapping, 3,
2035
 			     log2size, ( ( fls ( size ) - 1 ) - 12 ),
2070
 			     log2size, ( ( fls ( size ) - 1 ) - 12 ),
2036
 			     pa_l, ( pa >> 12 ) );
2071
 			     pa_l, ( pa >> 12 ) );

Loading…
Cancel
Save