Bladeren bron

Revert to dev_priv/owner_priv scheme, rather than container_of; it

makes it easier to put the generic allocation code into infiniband.c
tags/v0.9.3
Michael Brown 16 jaren geleden
bovenliggende
commit
b21d4ca21e
4 gewijzigde bestanden met toevoegingen van 222 en 108 verwijderingen
  1. 18
    5
      src/drivers/net/mlx_ipoib/arbel.h
  2. 140
    96
      src/drivers/net/mlx_ipoib/mt25218.c
  3. 13
    7
      src/include/gpxe/infiniband.h
  4. 51
    0
      src/net/infiniband.c

+ 18
- 5
src/drivers/net/mlx_ipoib/arbel.h Bestand weergeven

@@ -107,6 +107,8 @@ struct arbel_dev_limits {
107 107
 	unsigned long reserved_uars;
108 108
 	/** Number of reserved CQs */
109 109
 	unsigned long reserved_cqs;
110
+	/** Number of reserved QPs */
111
+	unsigned long reserved_qps;
110 112
 };
111 113
 
112 114
 /** Alignment of Arbel send work queue entries */
@@ -143,6 +145,15 @@ struct arbel_recv_work_queue {
143 145
 	union arbel_recv_wqe *wqe;
144 146
 };
145 147
 
148
+/** Maximum number of allocatable queue pairs
149
+ *
150
+ * This is a policy decision, not a device limit.
151
+ */
152
+#define ARBEL_MAX_QPS		8
153
+
154
+/** Base queue pair number */
155
+#define ARBEL_QPN_BASE 0x550000
156
+
146 157
 /** An Arbel queue pair */
147 158
 struct arbel_queue_pair {
148 159
 	/** Infiniband queue pair */
@@ -161,10 +172,10 @@ struct arbel_queue_pair {
161 172
 
162 173
 /** An Arbel completion queue */
163 174
 struct arbel_completion_queue {
164
-	/** Infiniband completion queue */
165
-	struct ib_completion_queue cq;
166
-	/** Doorbell record number */
167
-	unsigned int doorbell_idx;
175
+	/** Consumer counter doorbell record number */
176
+	unsigned int ci_doorbell_idx;
177
+	/** Arm queue doorbell record number */
178
+	unsigned int arm_doorbell_idx;
168 179
 	/** Completion queue entries */
169 180
 	union arbelprm_completion_entry *cqe;
170 181
 };
@@ -200,6 +211,8 @@ struct arbel {
200 211
 
201 212
 	/** Completion queue in-use bitmask */
202 213
 	arbel_bitmask_t cq_inuse[ ARBEL_BITMASK_SIZE ( ARBEL_MAX_CQS ) ];
214
+	/** Queue pair in-use bitmask */
215
+	arbel_bitmask_t qp_inuse[ ARBEL_BITMASK_SIZE ( ARBEL_MAX_QPS ) ];
203 216
 	
204 217
 	/** Device limits */
205 218
 	struct arbel_dev_limits limits;
@@ -301,7 +314,7 @@ arbel_recv_doorbell_idx ( unsigned int qpn_offset ) {
301 314
 }
302 315
 
303 316
 /**
304
- * Get commpletion queue consumer counter doorbell index
317
+ * Get completion queue consumer counter doorbell index
305 318
  *
306 319
  * @v cqn_offset	Completion queue number offset
307 320
  * @ret doorbell_idx	Doorbell index

+ 140
- 96
src/drivers/net/mlx_ipoib/mt25218.c Bestand weergeven

@@ -53,28 +53,28 @@ static struct io_buffer *static_ipoib_tx_ring[NUM_IPOIB_SND_WQES];
53 53
 static struct io_buffer *static_ipoib_rx_ring[NUM_IPOIB_RCV_WQES];
54 54
 
55 55
 static struct arbel static_arbel;
56
-static struct arbel_completion_queue static_ipoib_send_cq;
57
-static struct arbel_completion_queue static_ipoib_recv_cq;
58
-
59
-static struct arbel_queue_pair static_ipoib_qp = {
60
-	.qp = {
61
-		.send = {
62
-			.qp = &static_ipoib_qp.qp,
63
-			.is_send = 1,
64
-			.cq = &static_ipoib_send_cq.cq,
65
-			.num_wqes = NUM_IPOIB_SND_WQES,
66
-			.iobufs = static_ipoib_tx_ring,
67
-			.list = LIST_HEAD_INIT (static_ipoib_qp.qp.send.list),
68
-		},
69
-		.recv = {
70
-			.qp = &static_ipoib_qp.qp,
71
-			.is_send = 0,
72
-			.cq = &static_ipoib_recv_cq.cq,
73
-			.num_wqes = NUM_IPOIB_RCV_WQES,
74
-			.iobufs = static_ipoib_rx_ring,
75
-			.list = LIST_HEAD_INIT (static_ipoib_qp.qp.recv.list),
76
-		},
77
-	},
56
+
57
+static struct arbel_completion_queue static_arbel_ipoib_send_cq = {
58
+	.ci_doorbell_idx = IPOIB_SND_CQ_CI_DB_IDX,
59
+};
60
+static struct ib_completion_queue static_ipoib_send_cq = {
61
+	.cqn = 1234, /* Only used for debug messages */
62
+	.num_cqes = NUM_IPOIB_SND_CQES,
63
+	.work_queues = LIST_HEAD_INIT ( static_ipoib_send_cq.work_queues ),
64
+	.dev_priv = &static_arbel_ipoib_send_cq,
65
+};
66
+
67
+static struct arbel_completion_queue static_arbel_ipoib_recv_cq = {
68
+	.ci_doorbell_idx = IPOIB_RCV_CQ_CI_DB_IDX,
69
+};
70
+static struct ib_completion_queue static_ipoib_recv_cq = {
71
+	.cqn = 2345, /* Only used for debug messages */
72
+	.num_cqes = NUM_IPOIB_RCV_CQES,
73
+	.work_queues = LIST_HEAD_INIT ( static_ipoib_recv_cq.work_queues ),
74
+	.dev_priv = &static_arbel_ipoib_recv_cq,
75
+};
76
+
77
+static struct arbel_queue_pair static_arbel_ipoib_qp = {
78 78
 	.send = {
79 79
 		.doorbell_idx = IPOIB_SND_QP_DB_IDX,
80 80
 	},
@@ -82,24 +82,31 @@ static struct arbel_queue_pair static_ipoib_qp = {
82 82
 		.doorbell_idx = IPOIB_RCV_QP_DB_IDX,
83 83
 	},
84 84
 };
85
-static struct arbel_completion_queue static_ipoib_send_cq = {
86
-	.cq = {
87
-		.cqn = 1234, /* Only used for debug messages */
88
-		.num_cqes = NUM_IPOIB_SND_CQES,
89
-		.work_queues = LIST_HEAD_INIT (static_ipoib_send_cq.cq.work_queues),
85
+static struct ib_queue_pair static_ipoib_qp = {
86
+	.send = {
87
+		.qp = &static_ipoib_qp,
88
+		.is_send = 1,
89
+		.cq = &static_ipoib_send_cq,
90
+		.num_wqes = NUM_IPOIB_SND_WQES,
91
+		.iobufs = static_ipoib_tx_ring,
92
+		.list = LIST_HEAD_INIT (static_ipoib_qp.send.list),
93
+		.dev_priv = &static_arbel_ipoib_qp.send,
90 94
 	},
91
-	.doorbell_idx = IPOIB_SND_CQ_CI_DB_IDX,
92
-};
93
-static struct arbel_completion_queue static_ipoib_recv_cq = {
94
-	.cq = {
95
-		.cqn = 2345, /* Only used for debug messages */
96
-		.num_cqes = NUM_IPOIB_RCV_CQES,
97
-		.work_queues = LIST_HEAD_INIT (static_ipoib_recv_cq.cq.work_queues),
95
+	.recv = {
96
+		.qp = &static_ipoib_qp,
97
+		.is_send = 0,
98
+		.cq = &static_ipoib_recv_cq,
99
+		.num_wqes = NUM_IPOIB_RCV_WQES,
100
+		.iobufs = static_ipoib_rx_ring,
101
+		.list = LIST_HEAD_INIT (static_ipoib_qp.recv.list),
102
+		.dev_priv = &static_arbel_ipoib_qp.recv,
98 103
 	},
99
-	.doorbell_idx = IPOIB_RCV_CQ_CI_DB_IDX,
104
+	.dev_priv = &static_arbel_ipoib_qp,
100 105
 };
106
+
107
+
101 108
 static struct ib_device static_ibdev = {
102
-	.priv = &static_arbel,
109
+	.dev_priv = &static_arbel,
103 110
 };
104 111
 
105 112
 
@@ -150,7 +157,7 @@ static int mlx_transmit_direct ( struct net_device *netdev,
150 157
 	};
151 158
 	memcpy ( &av.gid, ( ( void * ) bav ) + 16, 16 );
152 159
 
153
-	rc = arbel_post_send ( &static_ibdev, &static_ipoib_qp.qp, &av, iobuf );
160
+	rc = arbel_post_send ( &static_ibdev, &static_ipoib_qp, &av, iobuf );
154 161
 
155 162
 	return rc;
156 163
 }
@@ -164,7 +171,7 @@ static void temp_complete_send ( struct ib_device *ibdev __unused,
164 171
 				 struct ib_queue_pair *qp,
165 172
 				 struct ib_completion *completion,
166 173
 				 struct io_buffer *iobuf ) {
167
-	struct net_device *netdev = qp->priv;
174
+	struct net_device *netdev = qp->owner_priv;
168 175
 
169 176
 	DBG ( "Wahey! TX completion\n" );
170 177
 	netdev_tx_complete_err ( netdev, iobuf,
@@ -175,7 +182,7 @@ static void temp_complete_recv ( struct ib_device *ibdev __unused,
175 182
 				 struct ib_queue_pair *qp,
176 183
 				 struct ib_completion *completion,
177 184
 				 struct io_buffer *iobuf ) {
178
-	struct net_device *netdev = qp->priv;
185
+	struct net_device *netdev = qp->owner_priv;
179 186
 	struct mlx_nic *mlx = netdev->priv;
180 187
 
181 188
 	DBG ( "Yay! RX completion on %p len %zx:\n", iobuf, completion->len );
@@ -205,7 +212,7 @@ static void mlx_refill_rx ( struct net_device *netdev ) {
205 212
 			break;
206 213
 		DBG ( "Posting RX buffer %p:\n", iobuf );
207 214
 		if ( ( rc = arbel_post_recv ( &static_ibdev,
208
-					      &static_ipoib_qp.qp,
215
+					      &static_ipoib_qp,
209 216
 					      iobuf ) ) != 0 ) {
210 217
 			free_iob ( iobuf );
211 218
 			break;
@@ -237,11 +244,10 @@ static void mlx_poll ( struct net_device *netdev ) {
237 244
 	}
238 245
 
239 246
 	/* Poll completion queues */
240
-	arbel_poll_cq ( &static_ibdev, &static_ipoib_send_cq.cq,
247
+	arbel_poll_cq ( &static_ibdev, &static_ipoib_send_cq,
241 248
 			temp_complete_send, temp_complete_recv );
242
-	arbel_poll_cq ( &static_ibdev, &static_ipoib_recv_cq.cq,
249
+	arbel_poll_cq ( &static_ibdev, &static_ipoib_recv_cq,
243 250
 			temp_complete_send, temp_complete_recv );
244
-	//	mlx_poll_cq ( netdev, mlx->rcv_cqh, mlx_rx_complete );
245 251
 
246 252
 	mlx_refill_rx ( netdev );
247 253
 }
@@ -469,24 +475,18 @@ arbel_cmd_hw2sw_cq ( struct arbel *arbel, unsigned long cqn ) {
469 475
  * Create completion queue
470 476
  *
471 477
  * @v ibdev		Infiniband device
472
- * @v log2_num_cqes	Log2 of the number of completion queue entries
473
- * @ret new_cq		New completion queue
478
+ * @v cq		Completion queue
474 479
  * @ret rc		Return status code
475 480
  */
476 481
 static int arbel_create_cq ( struct ib_device *ibdev,
477
-			     unsigned int log2_num_cqes,
478
-			     struct ib_completion_queue **new_cq ) {
479
-	struct arbel *arbel = ibdev->priv;
482
+			     struct ib_completion_queue *cq ) {
483
+	struct arbel *arbel = ibdev->dev_priv;
480 484
 	struct arbel_completion_queue *arbel_cq;
481 485
 	struct arbelprm_completion_queue_context cqctx;
482 486
 	struct arbelprm_cq_ci_db_record *ci_db_rec;
483 487
 	struct arbelprm_cq_arm_db_record *arm_db_rec;
484 488
 	int cqn_offset;
485
-	unsigned int cqn;
486
-	unsigned int num_cqes;
487 489
 	size_t cqe_size;
488
-	unsigned int ci_doorbell_idx;
489
-	unsigned int arm_doorbell_idx;
490 490
 	unsigned int i;
491 491
 	int rc;
492 492
 
@@ -497,9 +497,7 @@ static int arbel_create_cq ( struct ib_device *ibdev,
497 497
 		rc = cqn_offset;
498 498
 		goto err_cqn_offset;
499 499
 	}
500
-	cqn = ( arbel->limits.reserved_cqs + cqn_offset );
501
-	ci_doorbell_idx = arbel_cq_ci_doorbell_idx ( cqn_offset );
502
-	arm_doorbell_idx = arbel_cq_arm_doorbell_idx ( cqn_offset );
500
+	cq->cqn = ( arbel->limits.reserved_cqs + cqn_offset );
503 501
 
504 502
 	/* Allocate control structures */
505 503
 	arbel_cq = zalloc ( sizeof ( *arbel_cq ) );
@@ -507,58 +505,59 @@ static int arbel_create_cq ( struct ib_device *ibdev,
507 505
 		rc = -ENOMEM;
508 506
 		goto err_arbel_cq;
509 507
 	}
510
-	arbel_cq->cq.cqn = cqn;
511
-	arbel_cq->cq.num_cqes = num_cqes;
512
-	INIT_LIST_HEAD ( &arbel_cq->cq.work_queues );
513
-	arbel_cq->doorbell_idx = ci_doorbell_idx;
508
+	arbel_cq->ci_doorbell_idx = arbel_cq_ci_doorbell_idx ( cqn_offset );
509
+	arbel_cq->arm_doorbell_idx = arbel_cq_arm_doorbell_idx ( cqn_offset );
514 510
 
515 511
 	/* Allocate completion queue itself */
516
-	num_cqes = ( 1 << log2_num_cqes );
517
-	cqe_size = ( num_cqes * sizeof ( arbel_cq->cqe[0] ) );
512
+	cqe_size = ( cq->num_cqes * sizeof ( arbel_cq->cqe[0] ) );
518 513
 	arbel_cq->cqe = malloc_dma ( cqe_size, sizeof ( arbel_cq->cqe[0] ) );
519 514
 	if ( ! arbel_cq->cqe ) {
520 515
 		rc = -ENOMEM;
521 516
 		goto err_cqe;
522 517
 	}
523 518
 	memset ( arbel_cq->cqe, 0, cqe_size );
524
-	for ( i = 0 ; i < num_cqes ; i++ ) {
519
+	for ( i = 0 ; i < cq->num_cqes ; i++ ) {
525 520
 		MLX_FILL_1 ( &arbel_cq->cqe[i].normal, 7, owner, 1 );
526 521
 	}
527 522
 	barrier();
528 523
 
529 524
 	/* Initialise doorbell records */
530
-	ci_db_rec = &arbel->db_rec[ci_doorbell_idx].cq_ci;
525
+	ci_db_rec = &arbel->db_rec[arbel_cq->ci_doorbell_idx].cq_ci;
531 526
 	MLX_FILL_1 ( ci_db_rec, 0, counter, 0 );
532 527
 	MLX_FILL_2 ( ci_db_rec, 1,
533 528
 		     res, ARBEL_UAR_RES_CQ_CI,
534
-		     cq_number, cqn );
535
-	arm_db_rec = &arbel->db_rec[arm_doorbell_idx].cq_arm;
529
+		     cq_number, cq->cqn );
530
+	arm_db_rec = &arbel->db_rec[arbel_cq->arm_doorbell_idx].cq_arm;
536 531
 	MLX_FILL_1 ( arm_db_rec, 0, counter, 0 );
537 532
 	MLX_FILL_2 ( arm_db_rec, 1,
538 533
 		     res, ARBEL_UAR_RES_CQ_ARM,
539
-		     cq_number, cqn );
534
+		     cq_number, cq->cqn );
540 535
 
541 536
 	/* Hand queue over to hardware */
542 537
 	memset ( &cqctx, 0, sizeof ( cqctx ) );
543 538
 	MLX_FILL_1 ( &cqctx, 0, st, 0xa /* "Event fired" */ );
544 539
 	MLX_FILL_1 ( &cqctx, 2, start_address_l,
545 540
 		     virt_to_bus ( arbel_cq->cqe ) );
541
+#if 0
546 542
 	MLX_FILL_2 ( &cqctx, 3,
547 543
 		     usr_page, arbel->limits.reserved_uars,
548 544
 		     log_cq_size, log2_num_cqes );
545
+#endif
549 546
 	MLX_FILL_1 ( &cqctx, 5, c_eqn, arbel->eqn );
550 547
 	MLX_FILL_1 ( &cqctx, 6, pd, ARBEL_GLOBAL_PD );
551 548
 	MLX_FILL_1 ( &cqctx, 7, l_key, arbel->reserved_lkey );
552
-	MLX_FILL_1 ( &cqctx, 12, cqn, cqn );
553
-	MLX_FILL_1 ( &cqctx, 13, cq_ci_db_record, ci_doorbell_idx );
554
-	MLX_FILL_1 ( &cqctx, 14, cq_state_db_record, arm_doorbell_idx );
555
-	if ( ( rc = arbel_cmd_sw2hw_cq ( arbel, cqn, &cqctx ) ) != 0 ) {
549
+	MLX_FILL_1 ( &cqctx, 12, cqn, cq->cqn );
550
+	MLX_FILL_1 ( &cqctx, 13,
551
+		     cq_ci_db_record, arbel_cq->ci_doorbell_idx );
552
+	MLX_FILL_1 ( &cqctx, 14,
553
+		     cq_state_db_record, arbel_cq->arm_doorbell_idx );
554
+	if ( ( rc = arbel_cmd_sw2hw_cq ( arbel, cq->cqn, &cqctx ) ) != 0 ) {
556 555
 		DBGC ( arbel, "Arbel %p SW2HW_CQ failed: %s\n",
557 556
 		       arbel, strerror ( rc ) );
558 557
 		goto err_sw2hw;
559 558
 	}
560 559
 
561
-	*new_cq = &arbel_cq->cq;
560
+	cq->dev_priv = arbel_cq;
562 561
 	return 0;
563 562
 
564 563
  err_sw2hw:
@@ -581,9 +580,8 @@ static int arbel_create_cq ( struct ib_device *ibdev,
581 580
  */
582 581
 static void arbel_destroy_cq ( struct ib_device *ibdev,
583 582
 			       struct ib_completion_queue *cq ) {
584
-	struct arbel *arbel = ibdev->priv;
585
-	struct arbel_completion_queue *arbel_cq =
586
-		container_of ( cq, struct arbel_completion_queue, cq );
583
+	struct arbel *arbel = ibdev->dev_priv;
584
+	struct arbel_completion_queue *arbel_cq = cq->dev_priv;
587 585
 	struct arbelprm_cq_ci_db_record *ci_db_rec;
588 586
 	struct arbelprm_cq_arm_db_record *arm_db_rec;
589 587
 	int cqn_offset;
@@ -618,6 +616,53 @@ static void arbel_destroy_cq ( struct ib_device *ibdev,
618 616
 	arbel_free_qn_offset ( arbel->cq_inuse, cqn_offset );
619 617
 }
620 618
 
619
+/***************************************************************************
620
+ *
621
+ * Queue pair operations
622
+ *
623
+ ***************************************************************************
624
+ */
625
+
626
+static int arbel_create_qp ( struct ib_device *ibdev,
627
+			     unsigned int log2_num_send_wqes,
628
+			     struct ib_completion_queue *send_cq,
629
+			     unsigned int log2_num_recv_wqes,
630
+			     struct ib_completion_queue *recv_cq,
631
+			     struct ib_queue_pair **new_qp ) {
632
+	struct arbel *arbel = ibdev->dev_priv;
633
+	struct arbel_queue_pair *arbel_qp;
634
+	struct arbelprm_qp_db_record *send_db_rec;
635
+	struct arbelprm_qp_db_record *recv_db_rec;
636
+	int qpn_offset;
637
+	unsigned int qpn;
638
+	unsigned int num_send_wqes;
639
+	unsigned int num_recv_wqes;
640
+	unsigned int send_doorbell_idx;
641
+	unsigned int recv_doorbell_idx;
642
+	int rc;
643
+
644
+	/* Find a free queue pair number */
645
+	qpn_offset = arbel_alloc_qn_offset ( arbel->qp_inuse, ARBEL_MAX_QPS );
646
+	if ( qpn_offset < 0 ) {
647
+		DBGC ( arbel, "Arbel %p out of queue pairs\n", arbel );
648
+		rc = qpn_offset;
649
+		goto err_qpn_offset;
650
+	}
651
+	qpn = ( ARBEL_QPN_BASE + arbel->limits.reserved_qps + qpn_offset );
652
+	send_doorbell_idx = arbel_send_doorbell_idx ( qpn_offset );
653
+	recv_doorbell_idx = arbel_recv_doorbell_idx ( qpn_offset );
654
+
655
+	/* Allocate control structures */
656
+	num_send_wqes = ( 1 << log2_num_send_wqes );
657
+	num_recv_wqes = ( 1 << log2_num_recv_wqes );
658
+	arbel_qp = zalloc ( sizeof ( *arbel_qp ) );
659
+
660
+	return 0;
661
+
662
+ err_qpn_offset:
663
+	return rc;
664
+}
665
+
621 666
 /***************************************************************************
622 667
  *
623 668
  * Work request operations
@@ -659,9 +704,8 @@ static int arbel_post_send ( struct ib_device *ibdev,
659 704
 			     struct ib_queue_pair *qp,
660 705
 			     struct ib_address_vector *av,
661 706
 			     struct io_buffer *iobuf ) {
662
-	struct arbel *arbel = ibdev->priv;
663
-	struct arbel_queue_pair *arbel_qp
664
-		= container_of ( qp, struct arbel_queue_pair, qp );
707
+	struct arbel *arbel = ibdev->dev_priv;
708
+	struct arbel_queue_pair *arbel_qp = qp->dev_priv;
665 709
 	struct ib_work_queue *wq = &qp->send;
666 710
 	struct arbel_send_work_queue *arbel_send_wq = &arbel_qp->send;
667 711
 	struct arbelprm_ud_send_wqe *prev_wqe;
@@ -749,9 +793,8 @@ static int arbel_post_send ( struct ib_device *ibdev,
749 793
 static int arbel_post_recv ( struct ib_device *ibdev,
750 794
 			     struct ib_queue_pair *qp,
751 795
 			     struct io_buffer *iobuf ) {
752
-	struct arbel *arbel = ibdev->priv;
753
-	struct arbel_queue_pair *arbel_qp
754
-		= container_of ( qp, struct arbel_queue_pair, qp );
796
+	struct arbel *arbel = ibdev->dev_priv;
797
+	struct arbel_queue_pair *arbel_qp = qp->dev_priv;
755 798
 	struct ib_work_queue *wq = &qp->recv;
756 799
 	struct arbel_recv_work_queue *arbel_recv_wq = &arbel_qp->recv;
757 800
 	struct arbelprm_recv_wqe *wqe;
@@ -800,7 +843,7 @@ static int arbel_complete ( struct ib_device *ibdev,
800 843
 			    union arbelprm_completion_entry *cqe,
801 844
 			    ib_completer_t complete_send,
802 845
 			    ib_completer_t complete_recv ) {
803
-	struct arbel *arbel = ibdev->priv;
846
+	struct arbel *arbel = ibdev->dev_priv;
804 847
 	struct ib_completion completion;
805 848
 	struct ib_work_queue *wq;
806 849
 	struct ib_queue_pair *qp;
@@ -842,7 +885,7 @@ static int arbel_complete ( struct ib_device *ibdev,
842 885
 		return -EIO;
843 886
 	}
844 887
 	qp = wq->qp;
845
-	arbel_qp = container_of ( qp, struct arbel_queue_pair, qp );
888
+	arbel_qp = qp->dev_priv;
846 889
 
847 890
 	/* Identify work queue entry index */
848 891
 	if ( is_send ) {
@@ -883,9 +926,8 @@ static void arbel_poll_cq ( struct ib_device *ibdev,
883 926
 			    struct ib_completion_queue *cq,
884 927
 			    ib_completer_t complete_send,
885 928
 			    ib_completer_t complete_recv ) {
886
-	struct arbel *arbel = ibdev->priv;
887
-	struct arbel_completion_queue *arbel_cq
888
-		= container_of ( cq, struct arbel_completion_queue, cq );
929
+	struct arbel *arbel = ibdev->dev_priv;
930
+	struct arbel_completion_queue *arbel_cq = cq->dev_priv;
889 931
 	struct arbelprm_cq_ci_db_record *ci_db_rec;
890 932
 	union arbelprm_completion_entry *cqe;
891 933
 	unsigned int cqe_idx_mask;
@@ -914,7 +956,7 @@ static void arbel_poll_cq ( struct ib_device *ibdev,
914 956
 		/* Update completion queue's index */
915 957
 		cq->next_idx++;
916 958
 		/* Update doorbell record */
917
-		ci_db_rec = &arbel->db_rec[arbel_cq->doorbell_idx].cq_ci;
959
+		ci_db_rec = &arbel->db_rec[arbel_cq->ci_doorbell_idx].cq_ci;
918 960
 		MLX_FILL_1 ( ci_db_rec, 0,
919 961
 			     counter, ( cq->next_idx & 0xffffffffUL ) );
920 962
 	}
@@ -992,20 +1034,20 @@ static int arbel_probe ( struct pci_device *pci,
992 1034
 	arbel->db_rec = dev_ib_data.uar_context_base;
993 1035
 	arbel->reserved_lkey = dev_ib_data.mkey;
994 1036
 	arbel->eqn = dev_ib_data.eq.eqn;
995
-	static_ipoib_qp.send.wqe =
1037
+	static_arbel_ipoib_qp.send.wqe =
996 1038
 		( ( struct udqp_st * ) qph )->snd_wq;
997
-	static_ipoib_qp.recv.wqe =
1039
+	static_arbel_ipoib_qp.recv.wqe =
998 1040
 		( ( struct udqp_st * ) qph )->rcv_wq;
999
-	static_ipoib_send_cq.cqe =
1041
+	static_arbel_ipoib_send_cq.cqe =
1000 1042
 		( ( struct cq_st * ) ib_data.ipoib_snd_cq )->cq_buf;
1001
-	static_ipoib_recv_cq.cqe =
1043
+	static_arbel_ipoib_recv_cq.cqe =
1002 1044
 		( ( struct cq_st * ) ib_data.ipoib_rcv_cq )->cq_buf;
1003
-	static_ipoib_qp.qp.qpn = ib_get_qpn ( qph );
1004
-	static_ipoib_qp.qp.priv = netdev;
1005
-	list_add ( &static_ipoib_qp.qp.send.list,
1006
-		   &static_ipoib_send_cq.cq.work_queues );
1007
-	list_add ( &static_ipoib_qp.qp.recv.list,
1008
-		   &static_ipoib_recv_cq.cq.work_queues );
1045
+	static_ipoib_qp.qpn = ib_get_qpn ( qph );
1046
+	static_ipoib_qp.owner_priv = netdev;
1047
+	list_add ( &static_ipoib_qp.send.list,
1048
+		   &static_ipoib_send_cq.work_queues );
1049
+	list_add ( &static_ipoib_qp.recv.list,
1050
+		   &static_ipoib_recv_cq.work_queues );
1009 1051
 
1010 1052
 	/* Get device limits */
1011 1053
 	if ( ( rc = arbel_cmd_query_dev_lim ( arbel, &dev_lim ) ) != 0 ) {
@@ -1016,6 +1058,8 @@ static int arbel_probe ( struct pci_device *pci,
1016 1058
 	arbel->limits.reserved_uars = MLX_GET ( &dev_lim, num_rsvd_uars );
1017 1059
 	arbel->limits.reserved_cqs =
1018 1060
 		( 1 << MLX_GET ( &dev_lim, log2_rsvd_cqs ) );
1061
+	arbel->limits.reserved_qps =
1062
+		( 1 << MLX_GET ( &dev_lim, log2_rsvd_qps ) );
1019 1063
 	DBG ( "Device limits:\n ");
1020 1064
 	DBG_HD ( &dev_lim, sizeof ( dev_lim ) );
1021 1065
 

+ 13
- 7
src/include/gpxe/infiniband.h Bestand weergeven

@@ -89,6 +89,8 @@ struct ib_work_queue {
89 89
 	unsigned long next_idx;
90 90
 	/** I/O buffers assigned to work queue */
91 91
 	struct io_buffer **iobufs;
92
+	/** Device private data */
93
+	void *dev_priv;
92 94
 };
93 95
 
94 96
 /** An Infiniband Queue Pair */
@@ -99,8 +101,10 @@ struct ib_queue_pair {
99 101
 	struct ib_work_queue send;
100 102
 	/** Receive queue */
101 103
 	struct ib_work_queue recv;
104
+	/** Device private data */
105
+	void *dev_priv;
102 106
 	/** Queue owner private data */
103
-	void *priv;
107
+	void *owner_priv;
104 108
 };
105 109
 
106 110
 /** An Infiniband Completion Queue */
@@ -119,6 +123,8 @@ struct ib_completion_queue {
119 123
 	unsigned long next_idx;
120 124
 	/** List of work queues completing to this queue */
121 125
 	struct list_head work_queues;
126
+	/** Device private data */
127
+	void *dev_priv;
122 128
 };
123 129
 
124 130
 /** An Infiniband completion */
@@ -172,13 +178,11 @@ struct ib_device_operations {
172 178
 	 * Create completion queue
173 179
 	 *
174 180
 	 * @v ibdev		Infiniband device
175
-	 * @v log2_num_cqes	Log2 of the number of completion queue entries
176
-	 * @ret new_cq		New completion queue
181
+	 * @v cq		Completion queue
177 182
 	 * @ret rc		Return status code
178 183
 	 */
179 184
 	int ( * create_cq ) ( struct ib_device *ibdev,
180
-			      unsigned int log2_num_cqes,
181
-			      struct ib_completion_queue **new_cq );
185
+			      struct ib_completion_queue *cq );
182 186
 	/**
183 187
 	 * Destroy completion queue
184 188
 	 *
@@ -237,8 +241,10 @@ struct ib_device_operations {
237 241
 
238 242
 /** An Infiniband device */
239 243
 struct ib_device {	
240
-	/** Driver private data */
241
-	void *priv;
244
+	/** Infiniband operations */
245
+	struct ib_device_operations *op;
246
+	/** Device private data */
247
+	void *dev_priv;
242 248
 };
243 249
 
244 250
 

+ 51
- 0
src/net/infiniband.c Bestand weergeven

@@ -17,11 +17,13 @@
17 17
  */
18 18
 
19 19
 #include <stdint.h>
20
+#include <stdlib.h>
20 21
 #include <stdio.h>
21 22
 #include <string.h>
22 23
 #include <byteswap.h>
23 24
 #include <errno.h>
24 25
 #include <assert.h>
26
+#include <gpxe/list.h>
25 27
 #include <gpxe/if_arp.h>
26 28
 #include <gpxe/netdevice.h>
27 29
 #include <gpxe/iobuf.h>
@@ -33,6 +35,55 @@
33 35
  *
34 36
  */
35 37
 
38
+/**
39
+ * Create completion queue
40
+ *
41
+ * @v ibdev		Infiniband device
42
+ * @v num_cqes		Number of completion queue entries
43
+ * @ret cq		New completion queue
44
+ */
45
+struct ib_completion_queue * ib_create_cq ( struct ib_device *ibdev,
46
+					    unsigned int num_cqes ) {
47
+	struct ib_completion_queue *cq;
48
+	int rc;
49
+
50
+	DBGC ( ibdev, "IBDEV %p creating completion queue\n", ibdev );
51
+
52
+	/* Allocate and initialise data structure */
53
+	cq = zalloc ( sizeof ( *cq ) );
54
+	if ( ! cq )
55
+		return NULL;
56
+	cq->num_cqes = num_cqes;
57
+	INIT_LIST_HEAD ( &cq->work_queues );
58
+
59
+	/* Perform device-specific initialisation and get CQN */
60
+	if ( ( rc = ibdev->op->create_cq ( ibdev, cq ) ) != 0 ) {
61
+		DBGC ( ibdev, "IBDEV %p could not initialise CQ: %s\n",
62
+		       ibdev, strerror ( rc ) );
63
+		free ( cq );
64
+		return NULL;
65
+	}
66
+
67
+	DBGC ( ibdev, "IBDEV %p created completion queue %#lx\n",
68
+	       ibdev, cq->cqn );
69
+	return cq;
70
+}
71
+
72
+/**
73
+ * Destroy completion queue
74
+ *
75
+ * @v ibdev		Infiniband device
76
+ * @v cq		Completion queue
77
+ */
78
+void ib_destroy_cq ( struct ib_device *ibdev,
79
+		     struct ib_completion_queue *cq ) {
80
+	DBGC ( ibdev, "IBDEV %p destroying completion queue %#lx\n",
81
+	       ibdev, cq->cqn );
82
+	assert ( list_empty ( &cq->work_queues ) );
83
+	ibdev->op->destroy_cq ( ibdev, cq );
84
+	free ( cq );
85
+}
86
+
36 87
 /**
37 88
  * Find work queue belonging to completion queue
38 89
  *

Laden…
Annuleren
Opslaan