Преглед изворни кода

[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 година
родитељ
комит
f747fac3e1

+ 7
- 1
src/drivers/infiniband/hermon.c Прегледај датотеку

@@ -3128,6 +3128,11 @@ static int hermon_eth_transmit ( struct net_device *netdev,
3128 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 3137
  * Handle Hermon Ethernet device send completion
3133 3138
  *
@@ -3225,7 +3230,8 @@ static int hermon_eth_open ( struct net_device *netdev ) {
3225 3230
 	/* Allocate queue pair */
3226 3231
 	port->eth_qp = ib_create_qp ( ibdev, IB_QPT_ETH,
3227 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 3235
 	if ( ! port->eth_qp ) {
3230 3236
 		DBGC ( hermon, "Hermon %p port %d could not create queue "
3231 3237
 		       "pair\n", hermon, ibdev->port );

+ 8
- 3
src/drivers/net/ipoib.c Прегледај датотеку

@@ -534,6 +534,11 @@ static struct ib_completion_queue_operations ipoib_cq_op = {
534 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 543
  * Poll IPoIB network device
539 544
  *
@@ -667,9 +672,9 @@ static int ipoib_open ( struct net_device *netdev ) {
667 672
 	}
668 673
 
669 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 678
 	if ( ! ipoib->qp ) {
674 679
 		DBGC ( ipoib, "IPoIB %p could not allocate queue pair\n",
675 680
 		       ipoib );

+ 14
- 2
src/include/ipxe/infiniband.h Прегледај датотеку

@@ -142,6 +142,16 @@ enum ib_queue_pair_type {
142 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 155
 /** An Infiniband Queue Pair */
146 156
 struct ib_queue_pair {
147 157
 	/** Containing Infiniband device */
@@ -169,6 +179,8 @@ struct ib_queue_pair {
169 179
 	struct list_head mgids;
170 180
 	/** Address vector */
171 181
 	struct ib_address_vector av;
182
+	/** Queue pair operations */
183
+	struct ib_queue_pair_operations *op;
172 184
 	/** Driver private data */
173 185
 	void *drv_priv;
174 186
 	/** Queue owner private data */
@@ -478,8 +490,8 @@ extern void ib_poll_cq ( struct ib_device *ibdev,
478 490
 extern struct ib_queue_pair *
479 491
 ib_create_qp ( struct ib_device *ibdev, enum ib_queue_pair_type type,
480 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 495
 extern int ib_modify_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp );
484 496
 extern void ib_destroy_qp ( struct ib_device *ibdev,
485 497
 			    struct ib_queue_pair *qp );

+ 5
- 2
src/net/infiniband.c Прегледај датотеку

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

+ 7
- 1
src/net/infiniband/ib_cmrc.c Прегледај датотеку

@@ -257,6 +257,11 @@ static struct ib_completion_queue_operations ib_cmrc_completion_ops = {
257 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 266
  * Send data via CMRC
262 267
  *
@@ -410,7 +415,8 @@ int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev,
410 415
 
411 416
 	/* Create queue pair */
412 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 420
 	if ( ! cmrc->qp ) {
415 421
 		DBGC ( cmrc, "CMRC %p could not create queue pair\n", cmrc );
416 422
 		rc = -ENOMEM;

+ 7
- 1
src/net/infiniband/ib_mi.c Прегледај датотеку

@@ -164,6 +164,11 @@ static struct ib_completion_queue_operations ib_mi_completion_ops = {
164 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 173
  * Transmit MAD
169 174
  *
@@ -353,7 +358,8 @@ struct ib_mad_interface * ib_create_mi ( struct ib_device *ibdev,
353 358
 
354 359
 	/* Create queue pair */
355 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 363
 	if ( ! mi->qp ) {
358 364
 		DBGC ( mi, "MI %p could not allocate queue pair\n", mi );
359 365
 		goto err_create_qp;

Loading…
Откажи
Сачувај