Browse Source

[hermon] Improve debugging output and facilities

Improve the utility of debugging messages by including the relevant
port number, queue number (QPN, CQN, EQN), work queue entry (WQE)
number, and physical addresses wherever applicable.

Add hermon_dump_cqctx() for dumping a completion queue context, and
hermon_fill_nop_send_wqe() for inserting NOPs into send work queues.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
42f451e070
2 changed files with 180 additions and 91 deletions
  1. 179
    91
      src/drivers/infiniband/hermon.c
  2. 1
    0
      src/drivers/infiniband/hermon.h

+ 179
- 91
src/drivers/infiniband/hermon.c View File

369
 
369
 
370
 static inline int
370
 static inline int
371
 hermon_cmd_hw2sw_cq ( struct hermon *hermon, unsigned long cqn,
371
 hermon_cmd_hw2sw_cq ( struct hermon *hermon, unsigned long cqn,
372
-		      struct hermonprm_completion_queue_context *cqctx) {
372
+		      struct hermonprm_completion_queue_context *cqctx ) {
373
 	return hermon_cmd ( hermon,
373
 	return hermon_cmd ( hermon,
374
 			    HERMON_HCR_OUT_CMD ( HERMON_HCR_HW2SW_CQ,
374
 			    HERMON_HCR_OUT_CMD ( HERMON_HCR_HW2SW_CQ,
375
 						 1, sizeof ( *cqctx ) ),
375
 						 1, sizeof ( *cqctx ) ),
376
 			    0, NULL, cqn, cqctx );
376
 			    0, NULL, cqn, cqctx );
377
 }
377
 }
378
 
378
 
379
+static inline int
380
+hermon_cmd_query_cq ( struct hermon *hermon, unsigned long cqn,
381
+		      struct hermonprm_completion_queue_context *cqctx ) {
382
+	return hermon_cmd ( hermon,
383
+			    HERMON_HCR_OUT_CMD ( HERMON_HCR_QUERY_CQ,
384
+						 1, sizeof ( *cqctx ) ),
385
+			    0, NULL, cqn, cqctx );
386
+}
387
+
379
 static inline int
388
 static inline int
380
 hermon_cmd_rst2init_qp ( struct hermon *hermon, unsigned long qpn,
389
 hermon_cmd_rst2init_qp ( struct hermon *hermon, unsigned long qpn,
381
 			 const struct hermonprm_qp_ee_state_transitions *ctx ){
390
 			 const struct hermonprm_qp_ee_state_transitions *ctx ){
573
 			      struct hermon_mtt *mtt ) {
582
 			      struct hermon_mtt *mtt ) {
574
 	struct hermonprm_write_mtt write_mtt;
583
 	struct hermonprm_write_mtt write_mtt;
575
 	physaddr_t start;
584
 	physaddr_t start;
585
+	physaddr_t addr;
576
 	unsigned int page_offset;
586
 	unsigned int page_offset;
577
 	unsigned int num_pages;
587
 	unsigned int num_pages;
578
 	int mtt_offset;
588
 	int mtt_offset;
596
 	}
606
 	}
597
 	mtt_base_addr = ( ( hermon->cap.reserved_mtts + mtt_offset ) *
607
 	mtt_base_addr = ( ( hermon->cap.reserved_mtts + mtt_offset ) *
598
 			  hermon->cap.mtt_entry_size );
608
 			  hermon->cap.mtt_entry_size );
609
+	addr = start;
599
 
610
 
600
 	/* Fill in MTT structure */
611
 	/* Fill in MTT structure */
601
 	mtt->mtt_offset = mtt_offset;
612
 	mtt->mtt_offset = mtt_offset;
610
 			     value, mtt_base_addr );
621
 			     value, mtt_base_addr );
611
 		MLX_FILL_2 ( &write_mtt.mtt, 1,
622
 		MLX_FILL_2 ( &write_mtt.mtt, 1,
612
 			     p, 1,
623
 			     p, 1,
613
-			     ptag_l, ( start >> 3 ) );
624
+			     ptag_l, ( addr >> 3 ) );
614
 		if ( ( rc = hermon_cmd_write_mtt ( hermon,
625
 		if ( ( rc = hermon_cmd_write_mtt ( hermon,
615
 						   &write_mtt ) ) != 0 ) {
626
 						   &write_mtt ) ) != 0 ) {
616
 			DBGC ( hermon, "Hermon %p could not write MTT at %x\n",
627
 			DBGC ( hermon, "Hermon %p could not write MTT at %x\n",
617
 			       hermon, mtt_base_addr );
628
 			       hermon, mtt_base_addr );
618
 			goto err_write_mtt;
629
 			goto err_write_mtt;
619
 		}
630
 		}
620
-		start += HERMON_PAGE_SIZE;
631
+		addr += HERMON_PAGE_SIZE;
621
 		mtt_base_addr += hermon->cap.mtt_entry_size;
632
 		mtt_base_addr += hermon->cap.mtt_entry_size;
622
 	}
633
 	}
623
 
634
 
635
+	DBGC ( hermon, "Hermon %p MTT entries [%#x,%#x] for "
636
+	       "[%08lx,%08lx,%08lx,%08lx)\n", hermon, mtt->mtt_offset,
637
+	       ( mtt->mtt_offset + mtt->num_pages - 1 ), start,
638
+	       ( start + page_offset ), ( start + len ), addr );
639
+
624
 	return 0;
640
 	return 0;
625
 
641
 
626
  err_write_mtt:
642
  err_write_mtt:
637
  */
653
  */
638
 static void hermon_free_mtt ( struct hermon *hermon,
654
 static void hermon_free_mtt ( struct hermon *hermon,
639
 			      struct hermon_mtt *mtt ) {
655
 			      struct hermon_mtt *mtt ) {
656
+
657
+	DBGC ( hermon, "Hermon %p MTT entries [%#x,%#x] freed\n",
658
+	       hermon, mtt->mtt_offset,
659
+	       ( mtt->mtt_offset + mtt->num_pages - 1 ) );
640
 	hermon_bitmask_free ( hermon->mtt_inuse, mtt->mtt_offset,
660
 	hermon_bitmask_free ( hermon->mtt_inuse, mtt->mtt_offset,
641
 			      mtt->num_pages );
661
 			      mtt->num_pages );
642
 }
662
 }
669
 	/* Issue MAD */
689
 	/* Issue MAD */
670
 	if ( ( rc = hermon_cmd_mad_ifc ( hermon, ibdev->port,
690
 	if ( ( rc = hermon_cmd_mad_ifc ( hermon, ibdev->port,
671
 					 &mad_ifc ) ) != 0 ) {
691
 					 &mad_ifc ) ) != 0 ) {
672
-		DBGC ( hermon, "Hermon %p could not issue MAD IFC: %s\n",
673
-		       hermon, strerror ( rc ) );
692
+		DBGC ( hermon, "Hermon %p port %d could not issue MAD IFC: "
693
+		       "%s\n", hermon, ibdev->port, strerror ( rc ) );
674
 		return rc;
694
 		return rc;
675
 	}
695
 	}
676
 
696
 
678
 	memcpy ( mad, &mad_ifc.mad, sizeof ( *mad ) );
698
 	memcpy ( mad, &mad_ifc.mad, sizeof ( *mad ) );
679
 
699
 
680
 	if ( mad->hdr.status != 0 ) {
700
 	if ( mad->hdr.status != 0 ) {
681
-		DBGC ( hermon, "Hermon %p MAD IFC status %04x\n",
682
-		       hermon, ntohs ( mad->hdr.status ) );
701
+		DBGC ( hermon, "Hermon %p port %d MAD IFC status %04x\n",
702
+		       hermon, ibdev->port, ntohs ( mad->hdr.status ) );
683
 		return -EIO;
703
 		return -EIO;
684
 	}
704
 	}
685
 	return 0;
705
 	return 0;
692
  ***************************************************************************
712
  ***************************************************************************
693
  */
713
  */
694
 
714
 
715
+/**
716
+ * Dump completion queue context (for debugging only)
717
+ *
718
+ * @v hermon		Hermon device
719
+ * @v cq		Completion queue
720
+ * @ret rc		Return status code
721
+ */
722
+static __attribute__ (( unused )) int
723
+hermon_dump_cqctx ( struct hermon *hermon, struct ib_completion_queue *cq ) {
724
+	struct hermonprm_completion_queue_context cqctx;
725
+	int rc;
726
+
727
+	memset ( &cqctx, 0, sizeof ( cqctx ) );
728
+	if ( ( rc = hermon_cmd_query_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
729
+		DBGC ( hermon, "Hermon %p CQN %#lx QUERY_CQ failed: %s\n",
730
+		       hermon, cq->cqn, strerror ( rc ) );
731
+		return rc;
732
+	}
733
+	DBGC ( hermon, "Hermon %p CQN %#lx context:\n", hermon, cq->cqn );
734
+	DBGC_HDA ( hermon, 0, &cqctx, sizeof ( cqctx ) );
735
+
736
+	return 0;
737
+}
738
+
695
 /**
739
 /**
696
  * Create completion queue
740
  * Create completion queue
697
  *
741
  *
759
 	MLX_FILL_1 ( &cqctx, 15, db_record_addr_l,
803
 	MLX_FILL_1 ( &cqctx, 15, db_record_addr_l,
760
 		     ( virt_to_phys ( &hermon_cq->doorbell ) >> 3 ) );
804
 		     ( virt_to_phys ( &hermon_cq->doorbell ) >> 3 ) );
761
 	if ( ( rc = hermon_cmd_sw2hw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
805
 	if ( ( rc = hermon_cmd_sw2hw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
762
-		DBGC ( hermon, "Hermon %p SW2HW_CQ failed: %s\n",
763
-		       hermon, strerror ( rc ) );
806
+		DBGC ( hermon, "Hermon %p CQN %#lx SW2HW_CQ failed: %s\n",
807
+		       hermon, cq->cqn, strerror ( rc ) );
764
 		goto err_sw2hw_cq;
808
 		goto err_sw2hw_cq;
765
 	}
809
 	}
766
 
810
 
767
-	DBGC ( hermon, "Hermon %p CQN %#lx ring at [%p,%p)\n",
768
-	       hermon, cq->cqn, hermon_cq->cqe,
769
-	       ( ( ( void * ) hermon_cq->cqe ) + hermon_cq->cqe_size ) );
811
+	DBGC ( hermon, "Hermon %p CQN %#lx ring [%08lx,%08lx), doorbell "
812
+	       "%08lx\n", hermon, cq->cqn, virt_to_phys ( hermon_cq->cqe ),
813
+	       ( virt_to_phys ( hermon_cq->cqe ) + hermon_cq->cqe_size ),
814
+	       virt_to_phys ( &hermon_cq->doorbell ) );
770
 	ib_cq_set_drvdata ( cq, hermon_cq );
815
 	ib_cq_set_drvdata ( cq, hermon_cq );
771
 	return 0;
816
 	return 0;
772
 
817
 
798
 
843
 
799
 	/* Take ownership back from hardware */
844
 	/* Take ownership back from hardware */
800
 	if ( ( rc = hermon_cmd_hw2sw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
845
 	if ( ( rc = hermon_cmd_hw2sw_cq ( hermon, cq->cqn, &cqctx ) ) != 0 ) {
801
-		DBGC ( hermon, "Hermon %p FATAL HW2SW_CQ failed on CQN %#lx: "
846
+		DBGC ( hermon, "Hermon %p CQN %#lx FATAL HW2SW_CQ failed: "
802
 		       "%s\n", hermon, cq->cqn, strerror ( rc ) );
847
 		       "%s\n", hermon, cq->cqn, strerror ( rc ) );
803
 		/* Leak memory and return; at least we avoid corruption */
848
 		/* Leak memory and return; at least we avoid corruption */
804
 		return;
849
 		return;
925
  * @v qp		Queue pair
970
  * @v qp		Queue pair
926
  * @ret rc		Return status code
971
  * @ret rc		Return status code
927
  */
972
  */
928
-static inline int hermon_dump_qpctx ( struct hermon *hermon,
929
-				      struct ib_queue_pair *qp ) {
973
+static __attribute__ (( unused )) int
974
+hermon_dump_qpctx ( struct hermon *hermon, struct ib_queue_pair *qp ) {
930
 	struct hermonprm_qp_ee_state_transitions qpctx;
975
 	struct hermonprm_qp_ee_state_transitions qpctx;
931
 	int rc;
976
 	int rc;
932
 
977
 
933
 	memset ( &qpctx, 0, sizeof ( qpctx ) );
978
 	memset ( &qpctx, 0, sizeof ( qpctx ) );
934
 	if ( ( rc = hermon_cmd_query_qp ( hermon, qp->qpn, &qpctx ) ) != 0 ) {
979
 	if ( ( rc = hermon_cmd_query_qp ( hermon, qp->qpn, &qpctx ) ) != 0 ) {
935
-		DBGC ( hermon, "Hermon %p QUERY_QP failed: %s\n",
936
-		       hermon, strerror ( rc ) );
980
+		DBGC ( hermon, "Hermon %p QPN %#lx QUERY_QP failed: %s\n",
981
+		       hermon, qp->qpn, strerror ( rc ) );
937
 		return rc;
982
 		return rc;
938
 	}
983
 	}
939
-	DBGC ( hermon, "Hermon %p QPN %lx context:\n", hermon, qp->qpn );
940
-	DBGC_HDA ( hermon, 0, &qpctx.u.dwords[2],
941
-		   ( sizeof ( qpctx ) - 8 ) );
984
+	DBGC ( hermon, "Hermon %p QPN %#lx context:\n", hermon, qp->qpn );
985
+	DBGC_HDA ( hermon, 0, &qpctx.u.dwords[2], ( sizeof ( qpctx ) - 8 ) );
942
 
986
 
943
 	return 0;
987
 	return 0;
944
 }
988
 }
1032
 		     ( hermon_qp->mtt.mtt_base_addr >> 3 ) );
1076
 		     ( hermon_qp->mtt.mtt_base_addr >> 3 ) );
1033
 	if ( ( rc = hermon_cmd_rst2init_qp ( hermon, qp->qpn,
1077
 	if ( ( rc = hermon_cmd_rst2init_qp ( hermon, qp->qpn,
1034
 					     &qpctx ) ) != 0 ) {
1078
 					     &qpctx ) ) != 0 ) {
1035
-		DBGC ( hermon, "Hermon %p RST2INIT_QP failed: %s\n",
1036
-		       hermon, strerror ( rc ) );
1079
+		DBGC ( hermon, "Hermon %p QPN %#lx RST2INIT_QP failed: %s\n",
1080
+		       hermon, qp->qpn, strerror ( rc ) );
1037
 		goto err_rst2init_qp;
1081
 		goto err_rst2init_qp;
1038
 	}
1082
 	}
1039
 	hermon_qp->state = HERMON_QP_ST_INIT;
1083
 	hermon_qp->state = HERMON_QP_ST_INIT;
1040
 
1084
 
1041
-	DBGC ( hermon, "Hermon %p QPN %#lx send ring at [%p,%p)\n",
1042
-	       hermon, qp->qpn, hermon_qp->send.wqe,
1043
-	       ( ((void *)hermon_qp->send.wqe ) + hermon_qp->send.wqe_size ) );
1044
-	DBGC ( hermon, "Hermon %p QPN %#lx receive ring at [%p,%p)\n",
1045
-	       hermon, qp->qpn, hermon_qp->recv.wqe,
1046
-	       ( ((void *)hermon_qp->recv.wqe ) + hermon_qp->recv.wqe_size ) );
1085
+	DBGC ( hermon, "Hermon %p QPN %#lx send ring [%08lx,%08lx), doorbell "
1086
+	       "%08lx\n", hermon, qp->qpn,
1087
+	       virt_to_phys ( hermon_qp->send.wqe ),
1088
+	       ( virt_to_phys ( hermon_qp->send.wqe ) +
1089
+		 hermon_qp->send.wqe_size ),
1090
+	       virt_to_phys ( hermon_qp->send.doorbell ) );
1091
+	DBGC ( hermon, "Hermon %p QPN %#lx receive ring [%08lx,%08lx), "
1092
+	       "doorbell %08lx\n", hermon, qp->qpn,
1093
+	       virt_to_phys ( hermon_qp->recv.wqe ),
1094
+	       ( virt_to_phys ( hermon_qp->recv.wqe ) +
1095
+		 hermon_qp->recv.wqe_size ),
1096
+	       virt_to_phys ( &hermon_qp->recv.doorbell ) );
1097
+	DBGC ( hermon, "Hermon %p QPN %#lx send CQN %#lx receive CQN %#lx\n",
1098
+	       hermon, qp->qpn, qp->send.cq->cqn, qp->recv.cq->cqn );
1047
 	ib_qp_set_drvdata ( qp, hermon_qp );
1099
 	ib_qp_set_drvdata ( qp, hermon_qp );
1048
 	return 0;
1100
 	return 0;
1049
 
1101
 
1097
 			     qpc_eec_data.next_rcv_psn, qp->recv.psn );
1149
 			     qpc_eec_data.next_rcv_psn, qp->recv.psn );
1098
 		if ( ( rc = hermon_cmd_init2rtr_qp ( hermon, qp->qpn,
1150
 		if ( ( rc = hermon_cmd_init2rtr_qp ( hermon, qp->qpn,
1099
 						     &qpctx ) ) != 0 ) {
1151
 						     &qpctx ) ) != 0 ) {
1100
-			DBGC ( hermon, "Hermon %p INIT2RTR_QP failed: %s\n",
1101
-			       hermon, strerror ( rc ) );
1152
+			DBGC ( hermon, "Hermon %p QPN %#lx INIT2RTR_QP failed:"
1153
+			       " %s\n", hermon, qp->qpn, strerror ( rc ) );
1102
 			return rc;
1154
 			return rc;
1103
 		}
1155
 		}
1104
 		hermon_qp->state = HERMON_QP_ST_RTR;
1156
 		hermon_qp->state = HERMON_QP_ST_RTR;
1117
 			     qpc_eec_data.next_send_psn, qp->send.psn );
1169
 			     qpc_eec_data.next_send_psn, qp->send.psn );
1118
 		if ( ( rc = hermon_cmd_rtr2rts_qp ( hermon, qp->qpn,
1170
 		if ( ( rc = hermon_cmd_rtr2rts_qp ( hermon, qp->qpn,
1119
 						    &qpctx ) ) != 0 ) {
1171
 						    &qpctx ) ) != 0 ) {
1120
-			DBGC ( hermon, "Hermon %p RTR2RTS_QP failed: %s\n",
1121
-			       hermon, strerror ( rc ) );
1172
+			DBGC ( hermon, "Hermon %p QPN %#lx RTR2RTS_QP failed: "
1173
+			       "%s\n", hermon, qp->qpn, strerror ( rc ) );
1122
 			return rc;
1174
 			return rc;
1123
 		}
1175
 		}
1124
 		hermon_qp->state = HERMON_QP_ST_RTS;
1176
 		hermon_qp->state = HERMON_QP_ST_RTS;
1129
 	MLX_FILL_1 ( &qpctx, 0, opt_param_mask, HERMON_QP_OPT_PARAM_QKEY );
1181
 	MLX_FILL_1 ( &qpctx, 0, opt_param_mask, HERMON_QP_OPT_PARAM_QKEY );
1130
 	MLX_FILL_1 ( &qpctx, 44, qpc_eec_data.q_key, qp->qkey );
1182
 	MLX_FILL_1 ( &qpctx, 44, qpc_eec_data.q_key, qp->qkey );
1131
 	if ( ( rc = hermon_cmd_rts2rts_qp ( hermon, qp->qpn, &qpctx ) ) != 0 ){
1183
 	if ( ( rc = hermon_cmd_rts2rts_qp ( hermon, qp->qpn, &qpctx ) ) != 0 ){
1132
-		DBGC ( hermon, "Hermon %p RTS2RTS_QP failed: %s\n",
1133
-		       hermon, strerror ( rc ) );
1184
+		DBGC ( hermon, "Hermon %p QPN %#lx RTS2RTS_QP failed: %s\n",
1185
+		       hermon, qp->qpn, strerror ( rc ) );
1134
 		return rc;
1186
 		return rc;
1135
 	}
1187
 	}
1136
 
1188
 
1151
 
1203
 
1152
 	/* Take ownership back from hardware */
1204
 	/* Take ownership back from hardware */
1153
 	if ( ( rc = hermon_cmd_2rst_qp ( hermon, qp->qpn ) ) != 0 ) {
1205
 	if ( ( rc = hermon_cmd_2rst_qp ( hermon, qp->qpn ) ) != 0 ) {
1154
-		DBGC ( hermon, "Hermon %p FATAL 2RST_QP failed on QPN %#lx: "
1155
-		       "%s\n", hermon, qp->qpn, strerror ( rc ) );
1206
+		DBGC ( hermon, "Hermon %p QPN %#lx FATAL 2RST_QP failed: %s\n",
1207
+		       hermon, qp->qpn, strerror ( rc ) );
1156
 		/* Leak memory and return; at least we avoid corruption */
1208
 		/* Leak memory and return; at least we avoid corruption */
1157
 		return;
1209
 		return;
1158
 	}
1210
 	}
1177
  ***************************************************************************
1229
  ***************************************************************************
1178
  */
1230
  */
1179
 
1231
 
1232
+/**
1233
+ * Construct UD send work queue entry
1234
+ *
1235
+ * @v ibdev		Infiniband device
1236
+ * @v qp		Queue pair
1237
+ * @v av		Address vector
1238
+ * @v iobuf		I/O buffer
1239
+ * @v wqe		Send work queue entry
1240
+ * @ret opcode		Control opcode
1241
+ */
1242
+static __attribute__ (( unused )) unsigned int
1243
+hermon_fill_nop_send_wqe ( struct ib_device *ibdev __unused,
1244
+			   struct ib_queue_pair *qp __unused,
1245
+			   struct ib_address_vector *av __unused,
1246
+			   struct io_buffer *iobuf __unused,
1247
+			   union hermon_send_wqe *wqe ) {
1248
+
1249
+	MLX_FILL_1 ( &wqe->ctrl, 1, ds, ( sizeof ( wqe->ctrl ) / 16 ) );
1250
+	MLX_FILL_1 ( &wqe->ctrl, 2, c, 0x03 /* generate completion */ );
1251
+	return HERMON_OPCODE_NOP;
1252
+}
1253
+
1180
 /**
1254
 /**
1181
  * Construct UD send work queue entry
1255
  * Construct UD send work queue entry
1182
  *
1256
  *
1325
 	struct hermon_send_work_queue *hermon_send_wq = &hermon_qp->send;
1399
 	struct hermon_send_work_queue *hermon_send_wq = &hermon_qp->send;
1326
 	union hermon_send_wqe *wqe;
1400
 	union hermon_send_wqe *wqe;
1327
 	union hermonprm_doorbell_register db_reg;
1401
 	union hermonprm_doorbell_register db_reg;
1328
-	unsigned int wqe_idx_mask;
1402
+	unsigned long wqe_idx_mask;
1403
+	unsigned long wqe_idx;
1404
+	unsigned int owner;
1329
 	unsigned int opcode;
1405
 	unsigned int opcode;
1330
 
1406
 
1331
 	/* Allocate work queue entry */
1407
 	/* Allocate work queue entry */
1408
+	wqe_idx = ( wq->next_idx & ( hermon_send_wq->num_wqes - 1 ) );
1409
+	owner = ( ( wq->next_idx & hermon_send_wq->num_wqes ) ? 1 : 0 );
1332
 	wqe_idx_mask = ( wq->num_wqes - 1 );
1410
 	wqe_idx_mask = ( wq->num_wqes - 1 );
1333
-	if ( wq->iobufs[wq->next_idx & wqe_idx_mask] ) {
1334
-		DBGC ( hermon, "Hermon %p send queue full", hermon );
1411
+	if ( wq->iobufs[ wqe_idx & wqe_idx_mask ] ) {
1412
+		DBGC ( hermon, "Hermon %p QPN %#lx send queue full",
1413
+		       hermon, qp->qpn );
1335
 		return -ENOBUFS;
1414
 		return -ENOBUFS;
1336
 	}
1415
 	}
1337
-	wq->iobufs[wq->next_idx & wqe_idx_mask] = iobuf;
1338
-	wqe = &hermon_send_wq->wqe[ wq->next_idx &
1339
-				    ( hermon_send_wq->num_wqes - 1 ) ];
1416
+	wq->iobufs[ wqe_idx & wqe_idx_mask ] = iobuf;
1417
+	wqe = &hermon_send_wq->wqe[wqe_idx];
1340
 
1418
 
1341
 	/* Construct work queue entry */
1419
 	/* Construct work queue entry */
1342
 	memset ( ( ( ( void * ) wqe ) + 4 /* avoid ctrl.owner */ ), 0,
1420
 	memset ( ( ( ( void * ) wqe ) + 4 /* avoid ctrl.owner */ ), 0,
1348
 	barrier();
1426
 	barrier();
1349
 	MLX_FILL_2 ( &wqe->ctrl, 0,
1427
 	MLX_FILL_2 ( &wqe->ctrl, 0,
1350
 		     opcode, opcode,
1428
 		     opcode, opcode,
1351
-		     owner,
1352
-		     ( ( wq->next_idx & hermon_send_wq->num_wqes ) ? 1 : 0 ) );
1353
-	DBGCP ( hermon, "Hermon %p posting send WQE:\n", hermon );
1354
-	DBGCP_HD ( hermon, wqe, sizeof ( *wqe ) );
1355
-	barrier();
1429
+		     owner, owner );
1430
+	DBGCP ( hermon, "Hermon %p QPN %#lx posting send WQE %#lx:\n",
1431
+		hermon, qp->qpn, wqe_idx );
1432
+	DBGCP_HDA ( hermon, virt_to_phys ( wqe ), wqe, sizeof ( *wqe ) );
1356
 
1433
 
1357
 	/* Ring doorbell register */
1434
 	/* Ring doorbell register */
1358
 	MLX_FILL_1 ( &db_reg.send, 0, qn, qp->qpn );
1435
 	MLX_FILL_1 ( &db_reg.send, 0, qn, qp->qpn );
1359
-	DBGCP ( hermon, "Ringing doorbell %08lx with %08x\n",
1360
-		virt_to_phys ( hermon_send_wq->doorbell ), db_reg.dword[0] );
1361
-	writel ( db_reg.dword[0], ( hermon_send_wq->doorbell ) );
1436
+	barrier();
1437
+	writel ( db_reg.dword[0], hermon_send_wq->doorbell );
1362
 
1438
 
1363
 	/* Update work queue's index */
1439
 	/* Update work queue's index */
1364
 	wq->next_idx++;
1440
 	wq->next_idx++;
1387
 	/* Allocate work queue entry */
1463
 	/* Allocate work queue entry */
1388
 	wqe_idx_mask = ( wq->num_wqes - 1 );
1464
 	wqe_idx_mask = ( wq->num_wqes - 1 );
1389
 	if ( wq->iobufs[wq->next_idx & wqe_idx_mask] ) {
1465
 	if ( wq->iobufs[wq->next_idx & wqe_idx_mask] ) {
1390
-		DBGC ( hermon, "Hermon %p receive queue full", hermon );
1466
+		DBGC ( hermon, "Hermon %p QPN %#lx receive queue full",
1467
+		       hermon, qp->qpn );
1391
 		return -ENOBUFS;
1468
 		return -ENOBUFS;
1392
 	}
1469
 	}
1393
 	wq->iobufs[wq->next_idx & wqe_idx_mask] = iobuf;
1470
 	wq->iobufs[wq->next_idx & wqe_idx_mask] = iobuf;
1432
 	unsigned int opcode;
1509
 	unsigned int opcode;
1433
 	unsigned long qpn;
1510
 	unsigned long qpn;
1434
 	int is_send;
1511
 	int is_send;
1435
-	unsigned int wqe_idx;
1512
+	unsigned long wqe_idx;
1513
+	unsigned long wqe_idx_mask;
1436
 	size_t len;
1514
 	size_t len;
1437
 	int rc = 0;
1515
 	int rc = 0;
1438
 
1516
 
1443
 	if ( opcode >= HERMON_OPCODE_RECV_ERROR ) {
1521
 	if ( opcode >= HERMON_OPCODE_RECV_ERROR ) {
1444
 		/* "s" field is not valid for error opcodes */
1522
 		/* "s" field is not valid for error opcodes */
1445
 		is_send = ( opcode == HERMON_OPCODE_SEND_ERROR );
1523
 		is_send = ( opcode == HERMON_OPCODE_SEND_ERROR );
1446
-		DBGC ( hermon, "Hermon %p CQN %lx syndrome %x vendor %x\n",
1524
+		DBGC ( hermon, "Hermon %p CQN %#lx syndrome %x vendor %x\n",
1447
 		       hermon, cq->cqn, MLX_GET ( &cqe->error, syndrome ),
1525
 		       hermon, cq->cqn, MLX_GET ( &cqe->error, syndrome ),
1448
 		       MLX_GET ( &cqe->error, vendor_error_syndrome ) );
1526
 		       MLX_GET ( &cqe->error, vendor_error_syndrome ) );
1449
 		rc = -EIO;
1527
 		rc = -EIO;
1453
 	/* Identify work queue */
1531
 	/* Identify work queue */
1454
 	wq = ib_find_wq ( cq, qpn, is_send );
1532
 	wq = ib_find_wq ( cq, qpn, is_send );
1455
 	if ( ! wq ) {
1533
 	if ( ! wq ) {
1456
-		DBGC ( hermon, "Hermon %p CQN %lx unknown %s QPN %lx\n",
1534
+		DBGC ( hermon, "Hermon %p CQN %#lx unknown %s QPN %#lx\n",
1457
 		       hermon, cq->cqn, ( is_send ? "send" : "recv" ), qpn );
1535
 		       hermon, cq->cqn, ( is_send ? "send" : "recv" ), qpn );
1458
 		return -EIO;
1536
 		return -EIO;
1459
 	}
1537
 	}
1460
 	qp = wq->qp;
1538
 	qp = wq->qp;
1461
 	hermon_qp = ib_qp_get_drvdata ( qp );
1539
 	hermon_qp = ib_qp_get_drvdata ( qp );
1462
 
1540
 
1541
+	/* Identify work queue entry */
1542
+	wqe_idx = MLX_GET ( &cqe->normal, wqe_counter );
1543
+	wqe_idx_mask = ( wq->num_wqes - 1 );
1544
+	DBGCP ( hermon, "Hermon %p CQN %#lx QPN %#lx %s WQE %#lx completed:\n",
1545
+		hermon, cq->cqn, qp->qpn, ( is_send ? "send" : "recv" ),
1546
+		wqe_idx );
1547
+	DBGCP_HDA ( hermon, virt_to_phys ( cqe ), cqe, sizeof ( *cqe ) );
1548
+
1463
 	/* Identify I/O buffer */
1549
 	/* Identify I/O buffer */
1464
-	wqe_idx = ( MLX_GET ( &cqe->normal, wqe_counter ) &
1465
-		    ( wq->num_wqes - 1 ) );
1466
-	iobuf = wq->iobufs[wqe_idx];
1550
+	iobuf = wq->iobufs[ wqe_idx & wqe_idx_mask ];
1467
 	if ( ! iobuf ) {
1551
 	if ( ! iobuf ) {
1468
-		DBGC ( hermon, "Hermon %p CQN %lx QPN %lx empty WQE %x\n",
1469
-		       hermon, cq->cqn, qp->qpn, wqe_idx );
1552
+		DBGC ( hermon, "Hermon %p CQN %#lx QPN %#lx empty %s WQE "
1553
+		       "%#lx\n", hermon, cq->cqn, qp->qpn,
1554
+		       ( is_send ? "send" : "recv" ), wqe_idx );
1470
 		return -EIO;
1555
 		return -EIO;
1471
 	}
1556
 	}
1472
-	wq->iobufs[wqe_idx] = NULL;
1557
+	wq->iobufs[ wqe_idx & wqe_idx_mask ] = NULL;
1473
 
1558
 
1474
 	if ( is_send ) {
1559
 	if ( is_send ) {
1475
 		/* Hand off to completion handler */
1560
 		/* Hand off to completion handler */
1532
 			/* Entry still owned by hardware; end of poll */
1617
 			/* Entry still owned by hardware; end of poll */
1533
 			break;
1618
 			break;
1534
 		}
1619
 		}
1535
-		DBGCP ( hermon, "Hermon %p completion:\n", hermon );
1536
-		DBGCP_HD ( hermon, cqe, sizeof ( *cqe ) );
1537
 
1620
 
1538
 		/* Handle completion */
1621
 		/* Handle completion */
1539
 		if ( ( rc = hermon_complete ( ibdev, cq, cqe ) ) != 0 ) {
1622
 		if ( ( rc = hermon_complete ( ibdev, cq, cqe ) ) != 0 ) {
1540
-			DBGC ( hermon, "Hermon %p failed to complete: %s\n",
1541
-			       hermon, strerror ( rc ) );
1542
-			DBGC_HD ( hermon, cqe, sizeof ( *cqe ) );
1623
+			DBGC ( hermon, "Hermon %p CQN %#lx failed to complete:"
1624
+			       " %s\n", hermon, cq->cqn, strerror ( rc ) );
1625
+			DBGC_HDA ( hermon, virt_to_phys ( cqe ),
1626
+				   cqe, sizeof ( *cqe ) );
1543
 		}
1627
 		}
1544
 
1628
 
1545
 		/* Update completion queue's index */
1629
 		/* Update completion queue's index */
1611
 		     ( hermon_eq->mtt.mtt_base_addr >> 3 ) );
1695
 		     ( hermon_eq->mtt.mtt_base_addr >> 3 ) );
1612
 	if ( ( rc = hermon_cmd_sw2hw_eq ( hermon, hermon_eq->eqn,
1696
 	if ( ( rc = hermon_cmd_sw2hw_eq ( hermon, hermon_eq->eqn,
1613
 					  &eqctx ) ) != 0 ) {
1697
 					  &eqctx ) ) != 0 ) {
1614
-		DBGC ( hermon, "Hermon %p SW2HW_EQ failed: %s\n",
1615
-		       hermon, strerror ( rc ) );
1698
+		DBGC ( hermon, "Hermon %p EQN %#lx SW2HW_EQ failed: %s\n",
1699
+		       hermon, hermon_eq->eqn, strerror ( rc ) );
1616
 		goto err_sw2hw_eq;
1700
 		goto err_sw2hw_eq;
1617
 	}
1701
 	}
1618
 
1702
 
1622
 	if ( ( rc = hermon_cmd_map_eq ( hermon,
1706
 	if ( ( rc = hermon_cmd_map_eq ( hermon,
1623
 					( HERMON_MAP_EQ | hermon_eq->eqn ),
1707
 					( HERMON_MAP_EQ | hermon_eq->eqn ),
1624
 					&mask ) ) != 0 ) {
1708
 					&mask ) ) != 0 ) {
1625
-		DBGC ( hermon, "Hermon %p MAP_EQ failed: %s\n",
1626
-		       hermon, strerror ( rc )  );
1709
+		DBGC ( hermon, "Hermon %p EQN %#lx MAP_EQ failed: %s\n",
1710
+		       hermon, hermon_eq->eqn, strerror ( rc )  );
1627
 		goto err_map_eq;
1711
 		goto err_map_eq;
1628
 	}
1712
 	}
1629
 
1713
 
1630
-	DBGC ( hermon, "Hermon %p EQN %#lx ring at [%p,%p])\n",
1631
-	       hermon, hermon_eq->eqn, hermon_eq->eqe,
1632
-	       ( ( ( void * ) hermon_eq->eqe ) + hermon_eq->eqe_size ) );
1714
+	DBGC ( hermon, "Hermon %p EQN %#lx ring [%08lx,%08lx), doorbell "
1715
+	       "%08lx\n", hermon, hermon_eq->eqn,
1716
+	       virt_to_phys ( hermon_eq->eqe ),
1717
+	       ( virt_to_phys ( hermon_eq->eqe ) + hermon_eq->eqe_size ),
1718
+	       virt_to_phys ( hermon_eq->doorbell ) );
1633
 	return 0;
1719
 	return 0;
1634
 
1720
 
1635
  err_map_eq:
1721
  err_map_eq:
1660
 	if ( ( rc = hermon_cmd_map_eq ( hermon,
1746
 	if ( ( rc = hermon_cmd_map_eq ( hermon,
1661
 					( HERMON_UNMAP_EQ | hermon_eq->eqn ),
1747
 					( HERMON_UNMAP_EQ | hermon_eq->eqn ),
1662
 					&mask ) ) != 0 ) {
1748
 					&mask ) ) != 0 ) {
1663
-		DBGC ( hermon, "Hermon %p FATAL MAP_EQ failed to unmap: %s\n",
1664
-		       hermon, strerror ( rc ) );
1749
+		DBGC ( hermon, "Hermon %p EQN %#lx FATAL MAP_EQ failed to "
1750
+		       "unmap: %s\n", hermon, hermon_eq->eqn, strerror ( rc ) );
1665
 		/* Continue; HCA may die but system should survive */
1751
 		/* Continue; HCA may die but system should survive */
1666
 	}
1752
 	}
1667
 
1753
 
1668
 	/* Take ownership back from hardware */
1754
 	/* Take ownership back from hardware */
1669
 	if ( ( rc = hermon_cmd_hw2sw_eq ( hermon, hermon_eq->eqn,
1755
 	if ( ( rc = hermon_cmd_hw2sw_eq ( hermon, hermon_eq->eqn,
1670
 					  &eqctx ) ) != 0 ) {
1756
 					  &eqctx ) ) != 0 ) {
1671
-		DBGC ( hermon, "Hermon %p FATAL HW2SW_EQ failed: %s\n",
1672
-		       hermon, strerror ( rc ) );
1757
+		DBGC ( hermon, "Hermon %p EQN %#lx FATAL HW2SW_EQ failed: %s\n",
1758
+		       hermon, hermon_eq->eqn, strerror ( rc ) );
1673
 		/* Leak memory and return; at least we avoid corruption */
1759
 		/* Leak memory and return; at least we avoid corruption */
1674
 		return;
1760
 		return;
1675
 	}
1761
 	}
1735
 			/* Entry still owned by hardware; end of poll */
1821
 			/* Entry still owned by hardware; end of poll */
1736
 			break;
1822
 			break;
1737
 		}
1823
 		}
1738
-		DBGCP ( hermon, "Hermon %p event:\n", hermon );
1739
-		DBGCP_HD ( hermon, eqe, sizeof ( *eqe ) );
1824
+		DBGCP ( hermon, "Hermon %p EQN %#lx event:\n",
1825
+			hermon, hermon_eq->eqn );
1826
+		DBGCP_HDA ( hermon, virt_to_phys ( eqe ),
1827
+			    eqe, sizeof ( *eqe ) );
1740
 
1828
 
1741
 		/* Handle event */
1829
 		/* Handle event */
1742
 		event_type = MLX_GET ( &eqe->generic, event_type );
1830
 		event_type = MLX_GET ( &eqe->generic, event_type );
1745
 			hermon_event_port_state_change ( hermon, eqe );
1833
 			hermon_event_port_state_change ( hermon, eqe );
1746
 			break;
1834
 			break;
1747
 		default:
1835
 		default:
1748
-			DBGC ( hermon, "Hermon %p unrecognised event type "
1749
-			       "%#x:\n", hermon, event_type );
1750
-			DBGC_HD ( hermon, eqe, sizeof ( *eqe ) );
1836
+			DBGC ( hermon, "Hermon %p EQN %#lx unrecognised event "
1837
+			       "type %#x:\n",
1838
+			       hermon, hermon_eq->eqn, event_type );
1839
+			DBGC_HDA ( hermon, virt_to_phys ( eqe ),
1840
+				   eqe, sizeof ( *eqe ) );
1751
 			break;
1841
 			break;
1752
 		}
1842
 		}
1753
 
1843
 
1757
 		/* Ring doorbell */
1847
 		/* Ring doorbell */
1758
 		MLX_FILL_1 ( &db_reg.event, 0,
1848
 		MLX_FILL_1 ( &db_reg.event, 0,
1759
 			     ci, ( hermon_eq->next_idx & 0x00ffffffUL ) );
1849
 			     ci, ( hermon_eq->next_idx & 0x00ffffffUL ) );
1760
-		DBGCP ( hermon, "Ringing doorbell %08lx with %08x\n",
1761
-			virt_to_phys ( hermon_eq->doorbell ),
1762
-			db_reg.dword[0] );
1763
 		writel ( db_reg.dword[0], hermon_eq->doorbell );
1850
 		writel ( db_reg.dword[0], hermon_eq->doorbell );
1764
 	}
1851
 	}
1765
 }
1852
 }
1833
 	MLX_FILL_1 ( &init_port, 2, max_pkey, 64 );
1920
 	MLX_FILL_1 ( &init_port, 2, max_pkey, 64 );
1834
 	if ( ( rc = hermon_cmd_init_port ( hermon, ibdev->port,
1921
 	if ( ( rc = hermon_cmd_init_port ( hermon, ibdev->port,
1835
 					   &init_port ) ) != 0 ) {
1922
 					   &init_port ) ) != 0 ) {
1836
-		DBGC ( hermon, "Hermon %p could not intialise port: %s\n",
1837
-		       hermon, strerror ( rc ) );
1923
+		DBGC ( hermon, "Hermon %p port %d could not intialise port: "
1924
+		       "%s\n", hermon, ibdev->port, strerror ( rc ) );
1838
 		return rc;
1925
 		return rc;
1839
 	}
1926
 	}
1840
 
1927
 
1854
 	int rc;
1941
 	int rc;
1855
 
1942
 
1856
 	if ( ( rc = hermon_cmd_close_port ( hermon, ibdev->port ) ) != 0 ) {
1943
 	if ( ( rc = hermon_cmd_close_port ( hermon, ibdev->port ) ) != 0 ) {
1857
-		DBGC ( hermon, "Hermon %p could not close port: %s\n",
1858
-		       hermon, strerror ( rc ) );
1944
+		DBGC ( hermon, "Hermon %p port %d could not close port: %s\n",
1945
+		       hermon, ibdev->port, strerror ( rc ) );
1859
 		/* Nothing we can do about this */
1946
 		/* Nothing we can do about this */
1860
 	}
1947
 	}
1861
 }
1948
 }
2085
 		goto err_alloc_fa;
2172
 		goto err_alloc_fa;
2086
 	}
2173
 	}
2087
 	fw_base = user_to_phys ( hermon->firmware_area, 0 );
2174
 	fw_base = user_to_phys ( hermon->firmware_area, 0 );
2088
-	DBGC ( hermon, "Hermon %p firmware area at physical [%lx,%lx)\n",
2175
+	DBGC ( hermon, "Hermon %p firmware area at physical [%08lx,%08lx)\n",
2089
 	       hermon, fw_base, ( fw_base + fw_size ) );
2176
 	       hermon, fw_base, ( fw_base + fw_size ) );
2090
 	if ( ( rc = hermon_map_vpm ( hermon, hermon_cmd_map_fa,
2177
 	if ( ( rc = hermon_map_vpm ( hermon, hermon_cmd_map_fa,
2091
 				     0, fw_base, fw_size ) ) != 0 ) {
2178
 				     0, fw_base, fw_size ) ) != 0 ) {
2720
 	/* Register Infiniband devices */
2807
 	/* Register Infiniband devices */
2721
 	for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
2808
 	for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
2722
 		if ( ( rc = register_ibdev ( hermon->ibdev[i] ) ) != 0 ) {
2809
 		if ( ( rc = register_ibdev ( hermon->ibdev[i] ) ) != 0 ) {
2723
-			DBGC ( hermon, "Hermon %p could not register IB "
2724
-			       "device: %s\n", hermon, strerror ( rc ) );
2810
+			DBGC ( hermon, "Hermon %p port %d could not register "
2811
+			       "IB device: %s\n", hermon,
2812
+			       hermon->ibdev[i]->port, strerror ( rc ) );
2725
 			goto err_register_ibdev;
2813
 			goto err_register_ibdev;
2726
 		}
2814
 		}
2727
 	}
2815
 	}

+ 1
- 0
src/drivers/infiniband/hermon.h View File

55
 #define HERMON_HCR_QUERY_EQ		0x0015
55
 #define HERMON_HCR_QUERY_EQ		0x0015
56
 #define HERMON_HCR_SW2HW_CQ		0x0016
56
 #define HERMON_HCR_SW2HW_CQ		0x0016
57
 #define HERMON_HCR_HW2SW_CQ		0x0017
57
 #define HERMON_HCR_HW2SW_CQ		0x0017
58
+#define HERMON_HCR_QUERY_CQ		0x0018
58
 #define HERMON_HCR_RST2INIT_QP		0x0019
59
 #define HERMON_HCR_RST2INIT_QP		0x0019
59
 #define HERMON_HCR_INIT2RTR_QP		0x001a
60
 #define HERMON_HCR_INIT2RTR_QP		0x001a
60
 #define HERMON_HCR_RTR2RTS_QP		0x001b
61
 #define HERMON_HCR_RTR2RTS_QP		0x001b

Loading…
Cancel
Save