Преглед на файлове

[ipoib] Mask out non-QPN bits in the IPoIB destination MAC when sending

The first byte of the IPoIB MAC address is used for flags indicating
support for "connected mode".  Strip out the non-QPN bits of the first
dword when constructing the address vector for transmitted IPoIB
packets, so as not to end up passing an invalid QPN in the BTH.
tags/v1.0.0-rc1
Michael Brown преди 14 години
родител
ревизия
c2c77377a6
променени са 3 файла, в които са добавени 13 реда и са изтрити 10 реда
  1. 7
    8
      src/drivers/net/ipoib.c
  2. 3
    0
      src/include/gpxe/infiniband.h
  3. 3
    2
      src/include/gpxe/ipoib.h

+ 7
- 8
src/drivers/net/ipoib.c Целия файл

@@ -71,7 +71,7 @@ struct ipoib_device {
71 71
 
72 72
 /** Broadcast IPoIB address */
73 73
 static struct ipoib_mac ipoib_broadcast = {
74
-	.qpn = htonl ( IB_QPN_BROADCAST ),
74
+	.flags__qpn = htonl ( IB_QPN_BROADCAST ),
75 75
 	.gid.u.bytes = 	{ 0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00,
76 76
 			  0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff },
77 77
 };
@@ -146,8 +146,7 @@ static struct ipoib_peer * ipoib_lookup_peer_by_key ( unsigned int key ) {
146 146
 /**
147 147
  * Store GID and QPN in peer cache
148 148
  *
149
- * @v gid		Peer GID
150
- * @v qpn		Peer QPN
149
+ * @v mac		Peer MAC address
151 150
  * @ret peer		Peer cache entry
152 151
  */
153 152
 static struct ipoib_peer * ipoib_cache_peer ( const struct ipoib_mac *mac ) {
@@ -283,7 +282,7 @@ const char * ipoib_ntoa ( const void *ll_addr ) {
283 282
 	const struct ipoib_mac *mac = ll_addr;
284 283
 
285 284
 	snprintf ( buf, sizeof ( buf ), "%08x:%08x:%08x:%08x:%08x",
286
-		   htonl ( mac->qpn ), htonl ( mac->gid.u.dwords[0] ),
285
+		   htonl ( mac->flags__qpn ), htonl ( mac->gid.u.dwords[0] ),
287 286
 		   htonl ( mac->gid.u.dwords[1] ),
288 287
 		   htonl ( mac->gid.u.dwords[2] ),
289 288
 		   htonl ( mac->gid.u.dwords[3] ) );
@@ -438,7 +437,7 @@ static int ipoib_transmit ( struct net_device *netdev,
438 437
 
439 438
 	/* Construct address vector */
440 439
 	memset ( &av, 0, sizeof ( av ) );
441
-	av.qpn = ntohl ( dest->mac.qpn );
440
+	av.qpn = ( ntohl ( dest->mac.flags__qpn ) & IB_QPN_MASK );
442 441
 	av.gid_present = 1;
443 442
 	memcpy ( &av.gid, &dest->mac.gid, sizeof ( av.gid ) );
444 443
 	if ( ( rc = ib_resolve_path ( ibdev, &av ) ) != 0 ) {
@@ -501,7 +500,7 @@ static void ipoib_complete_recv ( struct ib_device *ibdev __unused,
501 500
 
502 501
 	/* Parse source address */
503 502
 	if ( av->gid_present ) {
504
-		ll_src.qpn = htonl ( av->qpn );
503
+		ll_src.flags__qpn = htonl ( av->qpn );
505 504
 		memcpy ( &ll_src.gid, &av->gid, sizeof ( ll_src.gid ) );
506 505
 		src = ipoib_cache_peer ( &ll_src );
507 506
 		ipoib_hdr->u.peer.src = src->key;
@@ -637,7 +636,7 @@ static int ipoib_open ( struct net_device *netdev ) {
637 636
 	ib_qp_set_ownerdata ( ipoib->qp, ipoib );
638 637
 
639 638
 	/* Update MAC address with QPN */
640
-	mac->qpn = htonl ( ipoib->qp->qpn );
639
+	mac->flags__qpn = htonl ( ipoib->qp->qpn );
641 640
 
642 641
 	/* Fill receive rings */
643 642
 	ib_refill_recv ( ibdev, ipoib->qp );
@@ -670,7 +669,7 @@ static void ipoib_close ( struct net_device *netdev ) {
670 669
 	ipoib_leave_broadcast_group ( ipoib );
671 670
 
672 671
 	/* Remove QPN from MAC address */
673
-	mac->qpn = 0;
672
+	mac->flags__qpn = 0;
674 673
 
675 674
 	/* Tear down the queues */
676 675
 	ib_destroy_qp ( ibdev, ipoib->qp );

+ 3
- 0
src/include/gpxe/infiniband.h Целия файл

@@ -30,6 +30,9 @@ FILE_LICENCE ( GPL2_OR_LATER );
30 30
 /** Broadcast QPN */
31 31
 #define IB_QPN_BROADCAST 0xffffffUL
32 32
 
33
+/** QPN mask */
34
+#define IB_QPN_MASK 0xffffffUL
35
+
33 36
 /** Default Infiniband partition key */
34 37
 #define IB_PKEY_DEFAULT 0xffff
35 38
 

+ 3
- 2
src/include/gpxe/ipoib.h Целия файл

@@ -17,9 +17,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
17 17
 struct ipoib_mac {
18 18
 	/** Queue pair number
19 19
 	 *
20
-	 * MSB must be zero; QPNs are only 24-bit.
20
+	 * MSB indicates support for IPoIB "connected mode".  Lower 24
21
+	 * bits are the QPN.
21 22
 	 */
22
-	uint32_t qpn;
23
+	uint32_t flags__qpn;
23 24
 	/** Port GID */
24 25
 	struct ib_gid gid;
25 26
 } __attribute__ (( packed ));

Loading…
Отказ
Запис