浏览代码

[infiniband] Include destination address vector in ib_complete_recv()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 年前
父节点
当前提交
f54a61e434

+ 8
- 2
src/drivers/infiniband/arbel.c 查看文件

@@ -1525,6 +1525,7 @@ static int arbel_complete ( struct ib_device *ibdev,
1525 1525
 	struct arbel_recv_work_queue *arbel_recv_wq;
1526 1526
 	struct arbelprm_recv_wqe *recv_wqe;
1527 1527
 	struct io_buffer *iobuf;
1528
+	struct ib_address_vector recv_dest;
1528 1529
 	struct ib_address_vector recv_source;
1529 1530
 	struct ib_global_route_header *grh;
1530 1531
 	struct ib_address_vector *source;
@@ -1608,6 +1609,8 @@ static int arbel_complete ( struct ib_device *ibdev,
1608 1609
 			     l_key, ARBEL_INVALID_LKEY );
1609 1610
 		assert ( len <= iob_tailroom ( iobuf ) );
1610 1611
 		iob_put ( iobuf, len );
1612
+		memset ( &recv_dest, 0, sizeof ( recv_dest ) );
1613
+		recv_dest.qpn = qpn;
1611 1614
 		switch ( qp->type ) {
1612 1615
 		case IB_QPT_SMI:
1613 1616
 		case IB_QPT_GSI:
@@ -1621,7 +1624,10 @@ static int arbel_complete ( struct ib_device *ibdev,
1621 1624
 			source->qpn = MLX_GET ( &cqe->normal, rqpn );
1622 1625
 			source->lid = MLX_GET ( &cqe->normal, rlid );
1623 1626
 			source->sl = MLX_GET ( &cqe->normal, sl );
1624
-			source->gid_present = MLX_GET ( &cqe->normal, g );
1627
+			recv_dest.gid_present = source->gid_present =
1628
+				MLX_GET ( &cqe->normal, g );
1629
+			memcpy ( &recv_dest.gid, &grh->dgid,
1630
+				 sizeof ( recv_dest.gid ) );
1625 1631
 			memcpy ( &source->gid, &grh->sgid,
1626 1632
 				 sizeof ( source->gid ) );
1627 1633
 			break;
@@ -1633,7 +1639,7 @@ static int arbel_complete ( struct ib_device *ibdev,
1633 1639
 			return -EINVAL;
1634 1640
 		}
1635 1641
 		/* Hand off to completion handler */
1636
-		ib_complete_recv ( ibdev, qp, source, iobuf, rc );
1642
+		ib_complete_recv ( ibdev, qp, &recv_dest, source, iobuf, rc );
1637 1643
 	}
1638 1644
 
1639 1645
 	return rc;

+ 10
- 2
src/drivers/infiniband/hermon.c 查看文件

@@ -1677,6 +1677,7 @@ static int hermon_complete ( struct ib_device *ibdev,
1677 1677
 	struct ib_work_queue *wq;
1678 1678
 	struct ib_queue_pair *qp;
1679 1679
 	struct io_buffer *iobuf;
1680
+	struct ib_address_vector recv_dest;
1680 1681
 	struct ib_address_vector recv_source;
1681 1682
 	struct ib_global_route_header *grh;
1682 1683
 	struct ib_address_vector *source;
@@ -1737,6 +1738,8 @@ static int hermon_complete ( struct ib_device *ibdev,
1737 1738
 		len = MLX_GET ( &cqe->normal, byte_cnt );
1738 1739
 		assert ( len <= iob_tailroom ( iobuf ) );
1739 1740
 		iob_put ( iobuf, len );
1741
+		memset ( &recv_dest, 0, sizeof ( recv_dest ) );
1742
+		recv_dest.qpn = qpn;
1740 1743
 		memset ( &recv_source, 0, sizeof ( recv_source ) );
1741 1744
 		switch ( qp->type ) {
1742 1745
 		case IB_QPT_SMI:
@@ -1750,7 +1753,10 @@ static int hermon_complete ( struct ib_device *ibdev,
1750 1753
 			source->qpn = MLX_GET ( &cqe->normal, srq_rqpn );
1751 1754
 			source->lid = MLX_GET ( &cqe->normal, slid_smac47_32 );
1752 1755
 			source->sl = MLX_GET ( &cqe->normal, sl );
1753
-			source->gid_present = MLX_GET ( &cqe->normal, g );
1756
+			recv_dest.gid_present = source->gid_present =
1757
+				MLX_GET ( &cqe->normal, g );
1758
+			memcpy ( &recv_dest.gid, &grh->dgid,
1759
+				 sizeof ( recv_dest.gid ) );
1754 1760
 			memcpy ( &source->gid, &grh->sgid,
1755 1761
 				 sizeof ( source->gid ) );
1756 1762
 			break;
@@ -1768,7 +1774,7 @@ static int hermon_complete ( struct ib_device *ibdev,
1768 1774
 			return -EINVAL;
1769 1775
 		}
1770 1776
 		/* Hand off to completion handler */
1771
-		ib_complete_recv ( ibdev, qp, source, iobuf, rc );
1777
+		ib_complete_recv ( ibdev, qp, &recv_dest, source, iobuf, rc );
1772 1778
 	}
1773 1779
 
1774 1780
 	return rc;
@@ -3155,12 +3161,14 @@ static void hermon_eth_complete_send ( struct ib_device *ibdev __unused,
3155 3161
  *
3156 3162
  * @v ibdev		Infiniband device
3157 3163
  * @v qp		Queue pair
3164
+ * @v dest		Destination address vector, or NULL
3158 3165
  * @v source		Source address vector, or NULL
3159 3166
  * @v iobuf		I/O buffer
3160 3167
  * @v rc		Completion status code
3161 3168
  */
3162 3169
 static void hermon_eth_complete_recv ( struct ib_device *ibdev __unused,
3163 3170
 				       struct ib_queue_pair *qp,
3171
+				       struct ib_address_vector *dest __unused,
3164 3172
 				       struct ib_address_vector *source,
3165 3173
 				       struct io_buffer *iobuf, int rc ) {
3166 3174
 	struct net_device *netdev = ib_qp_get_ownerdata ( qp );

+ 4
- 3
src/drivers/infiniband/linda.c 查看文件

@@ -1170,6 +1170,7 @@ static void linda_complete_recv ( struct ib_device *ibdev,
1170 1170
 	struct io_buffer headers;
1171 1171
 	struct io_buffer *iobuf;
1172 1172
 	struct ib_queue_pair *intended_qp;
1173
+	struct ib_address_vector dest;
1173 1174
 	struct ib_address_vector source;
1174 1175
 	unsigned int rcvtype;
1175 1176
 	unsigned int pktlen;
@@ -1238,7 +1239,7 @@ static void linda_complete_recv ( struct ib_device *ibdev,
1238 1239
 	qp0 = ( qp->qpn == 0 );
1239 1240
 	intended_qp = NULL;
1240 1241
 	if ( ( rc = ib_pull ( ibdev, &headers, ( qp0 ? &intended_qp : NULL ),
1241
-			      &payload_len, &source ) ) != 0 ) {
1242
+			      &payload_len, &dest, &source ) ) != 0 ) {
1242 1243
 		DBGC ( linda, "Linda %p could not parse headers: %s\n",
1243 1244
 		       linda, strerror ( rc ) );
1244 1245
 		err = 1;
@@ -1295,11 +1296,11 @@ static void linda_complete_recv ( struct ib_device *ibdev,
1295 1296
 				qp->recv.fill--;
1296 1297
 				intended_qp->recv.fill++;
1297 1298
 			}
1298
-			ib_complete_recv ( ibdev, intended_qp, &source,
1299
+			ib_complete_recv ( ibdev, intended_qp, &dest, &source,
1299 1300
 					   iobuf, rc);
1300 1301
 		} else {
1301 1302
 			/* Completing on a skipped-over eager buffer */
1302
-			ib_complete_recv ( ibdev, qp, &source, iobuf,
1303
+			ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,
1303 1304
 					   -ECANCELED );
1304 1305
 		}
1305 1306
 

+ 4
- 3
src/drivers/infiniband/qib7322.c 查看文件

@@ -1413,6 +1413,7 @@ static void qib7322_complete_recv ( struct ib_device *ibdev,
1413 1413
 	struct io_buffer headers;
1414 1414
 	struct io_buffer *iobuf;
1415 1415
 	struct ib_queue_pair *intended_qp;
1416
+	struct ib_address_vector dest;
1416 1417
 	struct ib_address_vector source;
1417 1418
 	unsigned int rcvtype;
1418 1419
 	unsigned int pktlen;
@@ -1474,7 +1475,7 @@ static void qib7322_complete_recv ( struct ib_device *ibdev,
1474 1475
 	qp0 = ( qp->qpn == 0 );
1475 1476
 	intended_qp = NULL;
1476 1477
 	if ( ( rc = ib_pull ( ibdev, &headers, ( qp0 ? &intended_qp : NULL ),
1477
-			      &payload_len, &source ) ) != 0 ) {
1478
+			      &payload_len, &dest, &source ) ) != 0 ) {
1478 1479
 		DBGC ( qib7322, "QIB7322 %p could not parse headers: %s\n",
1479 1480
 		       qib7322, strerror ( rc ) );
1480 1481
 		err = 1;
@@ -1531,11 +1532,11 @@ static void qib7322_complete_recv ( struct ib_device *ibdev,
1531 1532
 				qp->recv.fill--;
1532 1533
 				intended_qp->recv.fill++;
1533 1534
 			}
1534
-			ib_complete_recv ( ibdev, intended_qp, &source,
1535
+			ib_complete_recv ( ibdev, intended_qp, &dest, &source,
1535 1536
 					   iobuf, rc);
1536 1537
 		} else {
1537 1538
 			/* Completing on a skipped-over eager buffer */
1538
-			ib_complete_recv ( ibdev, qp, &source, iobuf,
1539
+			ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,
1539 1540
 					   -ECANCELED );
1540 1541
 		}
1541 1542
 

+ 2
- 0
src/drivers/net/ipoib.c 查看文件

@@ -480,12 +480,14 @@ static void ipoib_complete_send ( struct ib_device *ibdev __unused,
480 480
  *
481 481
  * @v ibdev		Infiniband device
482 482
  * @v qp		Queue pair
483
+ * @v dest		Destination address vector, or NULL
483 484
  * @v source		Source address vector, or NULL
484 485
  * @v iobuf		I/O buffer
485 486
  * @v rc		Completion status code
486 487
  */
487 488
 static void ipoib_complete_recv ( struct ib_device *ibdev __unused,
488 489
 				  struct ib_queue_pair *qp,
490
+				  struct ib_address_vector *dest __unused,
489 491
 				  struct ib_address_vector *source,
490 492
 				  struct io_buffer *iobuf, int rc ) {
491 493
 	struct ipoib_device *ipoib = ib_qp_get_ownerdata ( qp );

+ 1
- 0
src/include/ipxe/ib_packet.h 查看文件

@@ -155,6 +155,7 @@ extern int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
155 155
 		     const struct ib_address_vector *dest );
156 156
 extern int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
157 157
 		     struct ib_queue_pair **qp, size_t *payload_len,
158
+		     struct ib_address_vector *dest,
158 159
 		     struct ib_address_vector *source );
159 160
 
160 161
 #endif /* _IPXE_IB_PACKET_H */

+ 3
- 0
src/include/ipxe/infiniband.h 查看文件

@@ -205,12 +205,14 @@ struct ib_completion_queue_operations {
205 205
 	 *
206 206
 	 * @v ibdev		Infiniband device
207 207
 	 * @v qp		Queue pair
208
+	 * @v dest		Destination address vector, or NULL
208 209
 	 * @v source		Source address vector, or NULL
209 210
 	 * @v iobuf		I/O buffer
210 211
 	 * @v rc		Completion status code
211 212
 	 */
212 213
 	void ( * complete_recv ) ( struct ib_device *ibdev,
213 214
 				   struct ib_queue_pair *qp,
215
+				   struct ib_address_vector *dest,
214 216
 				   struct ib_address_vector *source,
215 217
 				   struct io_buffer *iobuf, int rc );
216 218
 };
@@ -511,6 +513,7 @@ extern void ib_complete_send ( struct ib_device *ibdev,
511 513
 			       struct io_buffer *iobuf, int rc );
512 514
 extern void ib_complete_recv ( struct ib_device *ibdev,
513 515
 			       struct ib_queue_pair *qp,
516
+			       struct ib_address_vector *dest,
514 517
 			       struct ib_address_vector *source,
515 518
 			       struct io_buffer *iobuf, int rc );
516 519
 extern void ib_refill_recv ( struct ib_device *ibdev,

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

@@ -304,7 +304,7 @@ void ib_destroy_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp ) {
304 304
 	}
305 305
 	for ( i = 0 ; i < qp->recv.num_wqes ; i++ ) {
306 306
 		if ( ( iobuf = qp->recv.iobufs[i] ) != NULL ) {
307
-			ib_complete_recv ( ibdev, qp, NULL, iobuf,
307
+			ib_complete_recv ( ibdev, qp, NULL, NULL, iobuf,
308 308
 					   -ECANCELED );
309 309
 		}
310 310
 	}
@@ -486,16 +486,19 @@ void ib_complete_send ( struct ib_device *ibdev, struct ib_queue_pair *qp,
486 486
  *
487 487
  * @v ibdev		Infiniband device
488 488
  * @v qp		Queue pair
489
+ * @v dest		Destination address vector, or NULL
489 490
  * @v source		Source address vector, or NULL
490 491
  * @v iobuf		I/O buffer
491 492
  * @v rc		Completion status code
492 493
  */
493 494
 void ib_complete_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp,
495
+			struct ib_address_vector *dest,
494 496
 			struct ib_address_vector *source,
495 497
 			struct io_buffer *iobuf, int rc ) {
496 498
 
497 499
 	if ( qp->recv.cq->op->complete_recv ) {
498
-		qp->recv.cq->op->complete_recv ( ibdev, qp, source, iobuf, rc );
500
+		qp->recv.cq->op->complete_recv ( ibdev, qp, dest, source,
501
+						 iobuf, rc );
499 502
 	} else {
500 503
 		free_iob ( iobuf );
501 504
 	}

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

@@ -220,12 +220,14 @@ static void ib_cmrc_complete_send ( struct ib_device *ibdev __unused,
220 220
  *
221 221
  * @v ibdev		Infiniband device
222 222
  * @v qp		Queue pair
223
+ * @v dest		Destination address vector, or NULL
223 224
  * @v source		Source address vector, or NULL
224 225
  * @v iobuf		I/O buffer
225 226
  * @v rc		Completion status code
226 227
  */
227 228
 static void ib_cmrc_complete_recv ( struct ib_device *ibdev __unused,
228 229
 				    struct ib_queue_pair *qp,
230
+				    struct ib_address_vector *dest __unused,
229 231
 				    struct ib_address_vector *source __unused,
230 232
 				    struct io_buffer *iobuf, int rc ) {
231 233
 	struct ib_cmrc_connection *cmrc = ib_qp_get_ownerdata ( qp );

+ 3
- 1
src/net/infiniband/ib_mi.c 查看文件

@@ -112,12 +112,14 @@ static int ib_mi_handle ( struct ib_device *ibdev,
112 112
  *
113 113
  * @v ibdev		Infiniband device
114 114
  * @v qp		Queue pair
115
- * @v source		Address vector
115
+ * @v dest		Destination address vector
116
+ * @v source		Source address vector
116 117
  * @v iobuf		I/O buffer
117 118
  * @v rc		Completion status code
118 119
  */
119 120
 static void ib_mi_complete_recv ( struct ib_device *ibdev,
120 121
 				  struct ib_queue_pair *qp,
122
+				  struct ib_address_vector *dest __unused,
121 123
 				  struct ib_address_vector *source,
122 124
 				  struct io_buffer *iobuf, int rc ) {
123 125
 	struct ib_mad_interface *mi = ib_qp_get_ownerdata ( qp );

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

@@ -122,11 +122,13 @@ int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
122 122
  * @v iobuf		I/O buffer containing headers
123 123
  * @v qp		Queue pair to fill in, or NULL
124 124
  * @v payload_len	Payload length to fill in, or NULL
125
+ * @v dest		Destination address vector to fill in
125 126
  * @v source		Source address vector to fill in
126 127
  * @ret rc		Return status code
127 128
  */
128 129
 int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
129 130
 	      struct ib_queue_pair **qp, size_t *payload_len,
131
+	      struct ib_address_vector *dest,
130 132
 	      struct ib_address_vector *source ) {
131 133
 	struct ib_local_route_header *lrh;
132 134
 	struct ib_global_route_header *grh;
@@ -135,14 +137,13 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
135 137
 	size_t orig_iob_len = iob_len ( iobuf );
136 138
 	unsigned int lnh;
137 139
 	size_t pad_len;
138
-	unsigned long qpn;
139
-	unsigned int lid;
140 140
 
141 141
 	/* Clear return values */
142 142
 	if ( qp )
143 143
 		*qp = NULL;
144 144
 	if ( payload_len )
145 145
 		*payload_len = 0;
146
+	memset ( dest, 0, sizeof ( *dest ) );
146 147
 	memset ( source, 0, sizeof ( *source ) );
147 148
 
148 149
 	/* Extract LRH */
@@ -153,10 +154,11 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
153 154
 	}
154 155
 	lrh = iobuf->data;
155 156
 	iob_pull ( iobuf, sizeof ( *lrh ) );
157
+	dest->lid = ntohs ( lrh->dlid );
158
+	dest->sl = ( lrh->sl__lnh >> 4 );
156 159
 	source->lid = ntohs ( lrh->slid );
157 160
 	source->sl = ( lrh->sl__lnh >> 4 );
158 161
 	lnh = ( lrh->sl__lnh & 0x3 );
159
-	lid = ntohs ( lrh->dlid );
160 162
 
161 163
 	/* Reject unsupported packets */
162 164
 	if ( ! ( ( lnh == IB_LNH_BTH ) || ( lnh == IB_LNH_GRH ) ) ) {
@@ -174,6 +176,8 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
174 176
 		}
175 177
 		grh = iobuf->data;
176 178
 		iob_pull ( iobuf, sizeof ( *grh ) );
179
+		dest->gid_present = 1;
180
+		memcpy ( &dest->gid, &grh->dgid, sizeof ( dest->gid ) );
177 181
 		source->gid_present = 1;
178 182
 		memcpy ( &source->gid, &grh->sgid, sizeof ( source->gid ) );
179 183
 	} else {
@@ -193,7 +197,7 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
193 197
 		       ibdev, bth->opcode );
194 198
 		return -ENOTSUP;
195 199
 	}
196
-	qpn = ntohl ( bth->dest_qp );
200
+	dest->qpn = ntohl ( bth->dest_qp );
197 201
 
198 202
 	/* Extract DETH */
199 203
 	if ( iob_len ( iobuf ) < sizeof ( *deth ) ) {
@@ -216,7 +220,7 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
216 220
 
217 221
 	/* Determine destination QP, if applicable */
218 222
 	if ( qp ) {
219
-		if ( IB_LID_MULTICAST ( lid ) && grh ) {
223
+		if ( IB_LID_MULTICAST ( dest->lid ) && grh ) {
220 224
 			if ( ! ( *qp = ib_find_qp_mgid ( ibdev, &grh->dgid ))){
221 225
 				DBGC ( ibdev, "IBDEV %p RX for unknown MGID "
222 226
 				       IB_GID_FMT "\n",
@@ -224,9 +228,9 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
224 228
 				return -ENODEV;
225 229
 			}
226 230
 		} else {
227
-			if ( ! ( *qp = ib_find_qp_qpn ( ibdev, qpn ) ) ) {
231
+			if ( ! ( *qp = ib_find_qp_qpn ( ibdev, dest->qpn ) ) ) {
228 232
 				DBGC ( ibdev, "IBDEV %p RX for nonexistent "
229
-				       "QPN %lx\n", ibdev, qpn );
233
+				       "QPN %lx\n", ibdev, dest->qpn );
230 234
 				return -ENODEV;
231 235
 			}
232 236
 		}
@@ -234,8 +238,8 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
234 238
 	}
235 239
 
236 240
 	DBGC2 ( ibdev, "IBDEV %p RX %04x:%08lx <= %04x:%08lx (key %08x)\n",
237
-		ibdev, lid, ( IB_LID_MULTICAST( lid ) ?
238
-			      ( qp ? (*qp)->ext_qpn : -1UL ) : qpn ),
241
+		ibdev, dest->lid, ( IB_LID_MULTICAST ( dest->lid ) ?
242
+			      ( qp ? (*qp)->ext_qpn : -1UL ) : dest->qpn ),
239 243
 		source->lid, source->qpn, ntohl ( deth->qkey ) );
240 244
 	DBGCP_HDA ( ibdev, 0,
241 245
 		    ( iobuf->data - ( orig_iob_len - iob_len ( iobuf ) ) ),

正在加载...
取消
保存