瀏覽代碼

[infiniband] Allow external QPN to differ from real QPN

Most IB hardware seems not to allow allocation of the genuine QPNs 0
and 1, so allow for the externally-visible QPN (as constructed and
parsed by ib_packet, where used) to differ from the real
hardware-allocated QPN.
tags/v0.9.8
Michael Brown 15 年之前
父節點
當前提交
f1d92fa886
共有 3 個文件被更改,包括 32 次插入8 次删除
  1. 8
    1
      src/include/gpxe/infiniband.h
  2. 19
    2
      src/net/infiniband.c
  3. 5
    5
      src/net/infiniband/ib_packet.c

+ 8
- 1
src/include/gpxe/infiniband.h 查看文件

@@ -96,8 +96,15 @@ struct ib_queue_pair {
96 96
 	struct ib_device *ibdev;
97 97
 	/** List of queue pairs on this Infiniband device */
98 98
 	struct list_head list;
99
-	/** Queue Pair Number */
99
+	/** Queue pair number */
100 100
 	unsigned long qpn;
101
+	/** Externally-visible queue pair number
102
+	 *
103
+	 * This may differ from the real queue pair number (e.g. when
104
+	 * the HCA cannot use the management QPNs 0 and 1 as hardware
105
+	 * QPNs and needs to remap them).
106
+	 */
107
+	unsigned long ext_qpn;
101 108
 	/** Queue pair type */
102 109
 	enum ib_queue_pair_type type;
103 110
 	/** Queue key */

+ 19
- 2
src/net/infiniband.c 查看文件

@@ -196,7 +196,6 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev,
196 196
 		       "%s\n", ibdev, strerror ( rc ) );
197 197
 		goto err_dev_create_qp;
198 198
 	}
199
-
200 199
 	DBGC ( ibdev, "IBDEV %p created queue pair %p (%p) with QPN %#lx\n",
201 200
 	       ibdev, qp, ib_qp_get_drvdata ( qp ), qp->qpn );
202 201
 	DBGC ( ibdev, "IBDEV %p QPN %#lx has %d send entries at [%p,%p)\n",
@@ -205,6 +204,24 @@ struct ib_queue_pair * ib_create_qp ( struct ib_device *ibdev,
205 204
 	DBGC ( ibdev, "IBDEV %p QPN %#lx has %d receive entries at [%p,%p)\n",
206 205
 	       ibdev, qp->qpn, num_recv_wqes, qp->recv.iobufs,
207 206
 	       ( ( ( void * ) qp ) + total_size ) );
207
+
208
+	/* Calculate externally-visible QPN */
209
+	switch ( type ) {
210
+	case IB_QPT_SMA:
211
+		qp->ext_qpn = IB_QPN_SMA;
212
+		break;
213
+	case IB_QPT_GMA:
214
+		qp->ext_qpn = IB_QPN_GMA;
215
+		break;
216
+	default:
217
+		qp->ext_qpn = qp->qpn;
218
+		break;
219
+	}
220
+	if ( qp->ext_qpn != qp->qpn ) {
221
+		DBGC ( ibdev, "IBDEV %p QPN %#lx has external QPN %#lx\n",
222
+		       ibdev, qp->qpn, qp->ext_qpn );
223
+	}
224
+
208 225
 	return qp;
209 226
 
210 227
 	ibdev->op->destroy_qp ( ibdev, qp );
@@ -295,7 +312,7 @@ struct ib_queue_pair * ib_find_qp_qpn ( struct ib_device *ibdev,
295 312
 	struct ib_queue_pair *qp;
296 313
 
297 314
 	list_for_each_entry ( qp, &ibdev->qps, list ) {
298
-		if ( qp->qpn == qpn )
315
+		if ( ( qpn == qp->qpn ) || ( qpn == qp->ext_qpn ) )
299 316
 			return qp;
300 317
 	}
301 318
 	return NULL;

+ 5
- 5
src/net/infiniband/ib_packet.c 查看文件

@@ -58,7 +58,7 @@ int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
58 58
 	unsigned int lnh;
59 59
 
60 60
 	DBGC2 ( ibdev, "IBDEV %p TX %04x:%08lx => %04x:%08lx (key %08lx)\n",
61
-		ibdev, ibdev->lid, qp->qpn, av->lid, av->qpn, av->qkey );
61
+		ibdev, ibdev->lid, qp->ext_qpn, av->lid, av->qpn, av->qkey );
62 62
 
63 63
 	/* Calculate packet length */
64 64
 	pad_len = ( (-payload_len) & 0x3 );
@@ -76,7 +76,7 @@ int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
76 76
 	lrh_len = ( payload_len + iob_len ( iobuf ) - orig_iob_len );
77 77
 
78 78
 	/* Construct LRH */
79
-	vl = ( ( av->qpn == IB_QPN_SMA ) ? IB_VL_SMP : IB_VL_DEFAULT );
79
+	vl = ( ( qp->ext_qpn == IB_QPN_SMA ) ? IB_VL_SMP : IB_VL_DEFAULT );
80 80
 	lrh->vl__lver = ( vl << 4 );
81 81
 	lnh = ( grh ? IB_LNH_GRH : IB_LNH_BTH );
82 82
 	lrh->sl__lnh = ( ( av->sl << 4 ) | lnh );
@@ -104,7 +104,7 @@ int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
104 104
 
105 105
 	/* Construct DETH */
106 106
 	deth->qkey = htonl ( av->qkey );
107
-	deth->src_qp = htonl ( qp->qpn );
107
+	deth->src_qp = htonl ( qp->ext_qpn );
108 108
 
109 109
 	DBGCP_HDA ( ibdev, 0, iobuf->data,
110 110
 		    ( iob_len ( iobuf ) - orig_iob_len ) );
@@ -233,8 +233,8 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
233 233
 	}
234 234
 
235 235
 	DBGC2 ( ibdev, "IBDEV %p RX %04x:%08lx <= %04x:%08lx (key %08x)\n",
236
-		ibdev, lid,
237
-		( IB_LID_MULTICAST( lid ) ? ( qp ? (*qp)->qpn : -1UL ) : qpn ),
236
+		ibdev, lid, ( IB_LID_MULTICAST( lid ) ?
237
+			      ( qp ? (*qp)->ext_qpn : -1UL ) : qpn ),
238 238
 		av->lid, av->qpn, ntohl ( deth->qkey ) );
239 239
 	DBGCP_HDA ( ibdev, 0,
240 240
 		    ( iobuf->data - ( orig_iob_len - iob_len ( iobuf ) ) ),

Loading…
取消
儲存