Browse Source

destroy_cq() now implemented (not tested).

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
e238bb1e43

+ 4
- 0
src/drivers/net/mlx_ipoib/arbel.h View File

28
 /* HCA command register opcodes */
28
 /* HCA command register opcodes */
29
 #define ARBEL_HCR_QUERY_DEV_LIM		0x0003
29
 #define ARBEL_HCR_QUERY_DEV_LIM		0x0003
30
 #define ARBEL_HCR_SW2HW_CQ		0x0016
30
 #define ARBEL_HCR_SW2HW_CQ		0x0016
31
+#define ARBEL_HCR_HW2SW_CQ		0x0017
31
 
32
 
32
 /*
33
 /*
33
  * Wrapper structures for hardware datatypes
34
  * Wrapper structures for hardware datatypes
247
 #define ARBEL_HCR_OUT_CMD( _opcode, _out_mbox, _out_len )		     \
248
 #define ARBEL_HCR_OUT_CMD( _opcode, _out_mbox, _out_len )		     \
248
 	ARBEL_HCR_CMD ( _opcode, 0, 0, _out_mbox, _out_len )
249
 	ARBEL_HCR_CMD ( _opcode, 0, 0, _out_mbox, _out_len )
249
 
250
 
251
+#define ARBEL_HCR_VOID_CMD( _opcode )					     \
252
+	ARBEL_HCR_CMD ( _opcode, 0, 0, 0, 0 )
253
+
250
 /*
254
 /*
251
  * Doorbell record allocation
255
  * Doorbell record allocation
252
  *
256
  *

+ 63
- 2
src/drivers/net/mlx_ipoib/mt25218.c View File

270
 
270
 
271
 
271
 
272
 
272
 
273
+/***************************************************************************
274
+ *
275
+ * Queue number allocation
276
+ *
277
+ ***************************************************************************
278
+ */
279
+
273
 /**
280
 /**
274
  * Allocate queue number
281
  * Allocate queue number
275
  *
282
  *
444
 			   0, cqctx, cqn, NULL );
451
 			   0, cqctx, cqn, NULL );
445
 }
452
 }
446
 
453
 
454
+static inline int
455
+arbel_cmd_hw2sw_cq ( struct arbel *arbel, unsigned long cqn ) {
456
+	return arbel_cmd ( arbel,
457
+			   ARBEL_HCR_VOID_CMD ( ARBEL_HCR_HW2SW_CQ ),
458
+			   1, NULL, cqn, NULL );
459
+}
460
+
447
 /***************************************************************************
461
 /***************************************************************************
448
  *
462
  *
449
  * Completion queue operations
463
  * Completion queue operations
548
 	return 0;
562
 	return 0;
549
 
563
 
550
  err_sw2hw:
564
  err_sw2hw:
551
-	memset ( ci_db_rec, 0, sizeof ( *ci_db_rec ) );
552
-	memset ( arm_db_rec, 0, sizeof ( *arm_db_rec ) );
565
+	MLX_FILL_1 ( ci_db_rec, 1, res, ARBEL_UAR_RES_NONE );
566
+	MLX_FILL_1 ( arm_db_rec, 1, res, ARBEL_UAR_RES_NONE );
567
+	free_dma ( arbel_cq->cqe, cqe_size );
553
  err_cqe:
568
  err_cqe:
554
 	free ( arbel_cq );
569
 	free ( arbel_cq );
555
  err_arbel_cq:
570
  err_arbel_cq:
558
 	return rc;
573
 	return rc;
559
 }
574
 }
560
 
575
 
576
+/**
577
+ * Destroy completion queue
578
+ *
579
+ * @v ibdev		Infiniband device
580
+ * @v cq		Completion queue
581
+ */
582
+static void arbel_destroy_cq ( struct ib_device *ibdev,
583
+			       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 );
587
+	struct arbelprm_cq_ci_db_record *ci_db_rec;
588
+	struct arbelprm_cq_arm_db_record *arm_db_rec;
589
+	int cqn_offset;
590
+	size_t cqe_size;
591
+	unsigned int ci_doorbell_idx;
592
+	unsigned int arm_doorbell_idx;
593
+	int rc;
594
+
595
+	assert ( list_empty ( &cq->work_queues ) );
596
+
597
+	/* Take ownership back from hardware */
598
+	if ( ( rc = arbel_cmd_hw2sw_cq ( arbel, cq->cqn ) ) != 0 ) {
599
+		DBGC ( arbel, "Arbel %p FATAL HW2SW_CQ failed: %s\n",
600
+		       arbel, strerror ( rc ) );
601
+		/* Leak memory and return; at least we avoid corruption */
602
+		return;
603
+	}
604
+
605
+	/* Clear doorbell records */
606
+	cqn_offset = ( cq->cqn - arbel->limits.reserved_cqs );
607
+	ci_doorbell_idx = arbel_cq_ci_doorbell_idx ( cqn_offset );
608
+	arm_doorbell_idx = arbel_cq_arm_doorbell_idx ( cqn_offset );
609
+	ci_db_rec = &arbel->db_rec[ci_doorbell_idx].cq_ci;
610
+	arm_db_rec = &arbel->db_rec[arm_doorbell_idx].cq_arm;
611
+	MLX_FILL_1 ( ci_db_rec, 1, res, ARBEL_UAR_RES_NONE );
612
+	MLX_FILL_1 ( arm_db_rec, 1, res, ARBEL_UAR_RES_NONE );
613
+
614
+	/* Free memory */
615
+	cqe_size = ( cq->num_cqes * sizeof ( arbel_cq->cqe[0] ) );
616
+	free_dma ( arbel_cq->cqe, cqe_size );
617
+	free ( arbel_cq );
618
+	arbel_free_qn_offset ( arbel->cq_inuse, cqn_offset );
619
+}
561
 
620
 
562
 /***************************************************************************
621
 /***************************************************************************
563
  *
622
  *
863
 
922
 
864
 /** Arbel Infiniband operations */
923
 /** Arbel Infiniband operations */
865
 static struct ib_device_operations arbel_ib_operations = {
924
 static struct ib_device_operations arbel_ib_operations = {
925
+	.create_cq	= arbel_create_cq,
926
+	.destroy_cq	= arbel_destroy_cq,
866
 	.post_send	= arbel_post_send,
927
 	.post_send	= arbel_post_send,
867
 	.post_recv	= arbel_post_recv,
928
 	.post_recv	= arbel_post_recv,
868
 	.poll_cq	= arbel_poll_cq,
929
 	.poll_cq	= arbel_poll_cq,

+ 19
- 0
src/include/gpxe/infiniband.h View File

168
  * These represent a subset of the Infiniband Verbs.
168
  * These represent a subset of the Infiniband Verbs.
169
  */
169
  */
170
 struct ib_device_operations {
170
 struct ib_device_operations {
171
+	/**
172
+	 * Create completion queue
173
+	 *
174
+	 * @v ibdev		Infiniband device
175
+	 * @v log2_num_cqes	Log2 of the number of completion queue entries
176
+	 * @ret new_cq		New completion queue
177
+	 * @ret rc		Return status code
178
+	 */
179
+	int ( * create_cq ) ( struct ib_device *ibdev,
180
+			      unsigned int log2_num_cqes,
181
+			      struct ib_completion_queue **new_cq );
182
+	/**
183
+	 * Destroy completion queue
184
+	 *
185
+	 * @v ibdev		Infiniband device
186
+	 * @v cq		Completion queue
187
+	 */
188
+	void ( * destroy_cq ) ( struct ib_device *ibdev,
189
+				struct ib_completion_queue *cq );
171
 	/** Post send work queue entry
190
 	/** Post send work queue entry
172
 	 *
191
 	 *
173
 	 * @v ibdev		Infiniband device
192
 	 * @v ibdev		Infiniband device

Loading…
Cancel
Save