Browse Source

[infiniband] Allow queue pairs to have a custom allocator for receive iobufs

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
f747fac3e1

+ 7
- 1
src/drivers/infiniband/hermon.c View File

3128
 	return 0;
3128
 	return 0;
3129
 }
3129
 }
3130
 
3130
 
3131
+/** Hermon Ethernet queue pair operations */
3132
+static struct ib_queue_pair_operations hermon_eth_qp_op = {
3133
+	.alloc_iob = alloc_iob,
3134
+};
3135
+
3131
 /**
3136
 /**
3132
  * Handle Hermon Ethernet device send completion
3137
  * Handle Hermon Ethernet device send completion
3133
  *
3138
  *
3225
 	/* Allocate queue pair */
3230
 	/* Allocate queue pair */
3226
 	port->eth_qp = ib_create_qp ( ibdev, IB_QPT_ETH,
3231
 	port->eth_qp = ib_create_qp ( ibdev, IB_QPT_ETH,
3227
 				      HERMON_ETH_NUM_SEND_WQES, port->eth_cq,
3232
 				      HERMON_ETH_NUM_SEND_WQES, port->eth_cq,
3228
-				      HERMON_ETH_NUM_RECV_WQES, port->eth_cq );
3233
+				      HERMON_ETH_NUM_RECV_WQES, port->eth_cq,
3234
+				      &hermon_eth_qp_op );
3229
 	if ( ! port->eth_qp ) {
3235
 	if ( ! port->eth_qp ) {
3230
 		DBGC ( hermon, "Hermon %p port %d could not create queue "
3236
 		DBGC ( hermon, "Hermon %p port %d could not create queue "
3231
 		       "pair\n", hermon, ibdev->port );
3237
 		       "pair\n", hermon, ibdev->port );

+ 8
- 3
src/drivers/net/ipoib.c View File

534
 	.complete_recv = ipoib_complete_recv,
534
 	.complete_recv = ipoib_complete_recv,
535
 };
535
 };
536
 
536
 
537
+/** IPoIB queue pair operations */
538
+static struct ib_queue_pair_operations ipoib_qp_op = {
539
+	.alloc_iob = alloc_iob,
540
+};
541
+
537
 /**
542
 /**
538
  * Poll IPoIB network device
543
  * Poll IPoIB network device
539
  *
544
  *
667
 	}
672
 	}
668
 
673
 
669
 	/* Allocate queue pair */
674
 	/* Allocate queue pair */
670
-	ipoib->qp = ib_create_qp ( ibdev, IB_QPT_UD,
671
-				   IPOIB_NUM_SEND_WQES, ipoib->cq,
672
-				   IPOIB_NUM_RECV_WQES, ipoib->cq );
675
+	ipoib->qp = ib_create_qp ( ibdev, IB_QPT_UD, IPOIB_NUM_SEND_WQES,
676
+				   ipoib->cq, IPOIB_NUM_RECV_WQES, ipoib->cq,
677
+				   &ipoib_qp_op );
673
 	if ( ! ipoib->qp ) {
678
 	if ( ! ipoib->qp ) {
674
 		DBGC ( ipoib, "IPoIB %p could not allocate queue pair\n",
679
 		DBGC ( ipoib, "IPoIB %p could not allocate queue pair\n",
675
 		       ipoib );
680
 		       ipoib );

+ 14
- 2
src/include/ipxe/infiniband.h View File

142
 	IB_QPT_ETH,
142
 	IB_QPT_ETH,
143
 };
143
 };
144
 
144
 
145
+/** Infiniband queue pair operations */
146
+struct ib_queue_pair_operations {
147
+	/** Allocate receive I/O buffer
148
+	 *
149
+	 * @v len		Maximum receive length
150
+	 * @ret iobuf		I/O buffer (or NULL if out of memory)
151
+	 */
152
+	struct io_buffer * ( * alloc_iob ) ( size_t len );
153
+};
154
+
145
 /** An Infiniband Queue Pair */
155
 /** An Infiniband Queue Pair */
146
 struct ib_queue_pair {
156
 struct ib_queue_pair {
147
 	/** Containing Infiniband device */
157
 	/** Containing Infiniband device */
169
 	struct list_head mgids;
179
 	struct list_head mgids;
170
 	/** Address vector */
180
 	/** Address vector */
171
 	struct ib_address_vector av;
181
 	struct ib_address_vector av;
182
+	/** Queue pair operations */
183
+	struct ib_queue_pair_operations *op;
172
 	/** Driver private data */
184
 	/** Driver private data */
173
 	void *drv_priv;
185
 	void *drv_priv;
174
 	/** Queue owner private data */
186
 	/** Queue owner private data */
478
 extern struct ib_queue_pair *
490
 extern struct ib_queue_pair *
479
 ib_create_qp ( struct ib_device *ibdev, enum ib_queue_pair_type type,
491
 ib_create_qp ( struct ib_device *ibdev, enum ib_queue_pair_type type,
480
 	       unsigned int num_send_wqes, struct ib_completion_queue *send_cq,
492
 	       unsigned int num_send_wqes, struct ib_completion_queue *send_cq,
481
-	       unsigned int num_recv_wqes,
482
-	       struct ib_completion_queue *recv_cq );
493
+	       unsigned int num_recv_wqes, struct ib_completion_queue *recv_cq,
494
+	       struct ib_queue_pair_operations *op );
483
 extern int ib_modify_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp );
495
 extern int ib_modify_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp );
484
 extern void ib_destroy_qp ( struct ib_device *ibdev,
496
 extern void ib_destroy_qp ( struct ib_device *ibdev,
485
 			    struct ib_queue_pair *qp );
497
 			    struct ib_queue_pair *qp );

+ 5
- 2
src/net/infiniband.c View File

168
  * @v send_cq		Send completion queue
168
  * @v send_cq		Send completion queue
169
  * @v num_recv_wqes	Number of receive work queue entries
169
  * @v num_recv_wqes	Number of receive work queue entries
170
  * @v recv_cq		Receive completion queue
170
  * @v recv_cq		Receive completion queue
171
+ * @v op		Queue pair operations
171
  * @ret qp		Queue pair
172
  * @ret qp		Queue pair
172
  *
173
  *
173
  * The queue pair will be left in the INIT state; you must call
174
  * The queue pair will be left in the INIT state; you must call
178
 				      unsigned int num_send_wqes,
179
 				      unsigned int num_send_wqes,
179
 				      struct ib_completion_queue *send_cq,
180
 				      struct ib_completion_queue *send_cq,
180
 				      unsigned int num_recv_wqes,
181
 				      unsigned int num_recv_wqes,
181
-				      struct ib_completion_queue *recv_cq ) {
182
+				      struct ib_completion_queue *recv_cq,
183
+				      struct ib_queue_pair_operations *op ) {
182
 	struct ib_queue_pair *qp;
184
 	struct ib_queue_pair *qp;
183
 	size_t total_size;
185
 	size_t total_size;
184
 	int rc;
186
 	int rc;
210
 	qp->recv.iobufs = ( ( ( void * ) qp ) + sizeof ( *qp ) +
212
 	qp->recv.iobufs = ( ( ( void * ) qp ) + sizeof ( *qp ) +
211
 			    ( num_send_wqes * sizeof ( qp->send.iobufs[0] ) ));
213
 			    ( num_send_wqes * sizeof ( qp->send.iobufs[0] ) ));
212
 	INIT_LIST_HEAD ( &qp->mgids );
214
 	INIT_LIST_HEAD ( &qp->mgids );
215
+	qp->op = op;
213
 
216
 
214
 	/* Perform device-specific initialisation and get QPN */
217
 	/* Perform device-specific initialisation and get QPN */
215
 	if ( ( rc = ibdev->op->create_qp ( ibdev, qp ) ) != 0 ) {
218
 	if ( ( rc = ibdev->op->create_qp ( ibdev, qp ) ) != 0 ) {
514
 	while ( qp->recv.fill < qp->recv.num_wqes ) {
517
 	while ( qp->recv.fill < qp->recv.num_wqes ) {
515
 
518
 
516
 		/* Allocate I/O buffer */
519
 		/* Allocate I/O buffer */
517
-		iobuf = alloc_iob ( IB_MAX_PAYLOAD_SIZE );
520
+		iobuf = qp->op->alloc_iob ( IB_MAX_PAYLOAD_SIZE );
518
 		if ( ! iobuf ) {
521
 		if ( ! iobuf ) {
519
 			/* Non-fatal; we will refill on next attempt */
522
 			/* Non-fatal; we will refill on next attempt */
520
 			return;
523
 			return;

+ 7
- 1
src/net/infiniband/ib_cmrc.c View File

257
 	.complete_recv = ib_cmrc_complete_recv,
257
 	.complete_recv = ib_cmrc_complete_recv,
258
 };
258
 };
259
 
259
 
260
+/** Infiniband CMRC queue pair operations */
261
+static struct ib_queue_pair_operations ib_cmrc_queue_pair_ops = {
262
+	.alloc_iob = alloc_iob,
263
+};
264
+
260
 /**
265
 /**
261
  * Send data via CMRC
266
  * Send data via CMRC
262
  *
267
  *
410
 
415
 
411
 	/* Create queue pair */
416
 	/* Create queue pair */
412
 	cmrc->qp = ib_create_qp ( ibdev, IB_QPT_RC, IB_CMRC_NUM_SEND_WQES,
417
 	cmrc->qp = ib_create_qp ( ibdev, IB_QPT_RC, IB_CMRC_NUM_SEND_WQES,
413
-				  cmrc->cq, IB_CMRC_NUM_RECV_WQES, cmrc->cq );
418
+				  cmrc->cq, IB_CMRC_NUM_RECV_WQES, cmrc->cq,
419
+				  &ib_cmrc_queue_pair_ops );
414
 	if ( ! cmrc->qp ) {
420
 	if ( ! cmrc->qp ) {
415
 		DBGC ( cmrc, "CMRC %p could not create queue pair\n", cmrc );
421
 		DBGC ( cmrc, "CMRC %p could not create queue pair\n", cmrc );
416
 		rc = -ENOMEM;
422
 		rc = -ENOMEM;

+ 7
- 1
src/net/infiniband/ib_mi.c View File

164
 	.complete_recv = ib_mi_complete_recv,
164
 	.complete_recv = ib_mi_complete_recv,
165
 };
165
 };
166
 
166
 
167
+/** Management interface queue pair operations */
168
+static struct ib_queue_pair_operations ib_mi_queue_pair_ops = {
169
+	.alloc_iob = alloc_iob,
170
+};
171
+
167
 /**
172
 /**
168
  * Transmit MAD
173
  * Transmit MAD
169
  *
174
  *
353
 
358
 
354
 	/* Create queue pair */
359
 	/* Create queue pair */
355
 	mi->qp = ib_create_qp ( ibdev, type, IB_MI_NUM_SEND_WQES, mi->cq,
360
 	mi->qp = ib_create_qp ( ibdev, type, IB_MI_NUM_SEND_WQES, mi->cq,
356
-				IB_MI_NUM_RECV_WQES, mi->cq );
361
+				IB_MI_NUM_RECV_WQES, mi->cq,
362
+				&ib_mi_queue_pair_ops );
357
 	if ( ! mi->qp ) {
363
 	if ( ! mi->qp ) {
358
 		DBGC ( mi, "MI %p could not allocate queue pair\n", mi );
364
 		DBGC ( mi, "MI %p could not allocate queue pair\n", mi );
359
 		goto err_create_qp;
365
 		goto err_create_qp;

Loading…
Cancel
Save