Browse Source

[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 15 years ago
parent
commit
c2c77377a6
3 changed files with 13 additions and 10 deletions
  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 View File

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

+ 3
- 0
src/include/gpxe/infiniband.h View File

30
 /** Broadcast QPN */
30
 /** Broadcast QPN */
31
 #define IB_QPN_BROADCAST 0xffffffUL
31
 #define IB_QPN_BROADCAST 0xffffffUL
32
 
32
 
33
+/** QPN mask */
34
+#define IB_QPN_MASK 0xffffffUL
35
+
33
 /** Default Infiniband partition key */
36
 /** Default Infiniband partition key */
34
 #define IB_PKEY_DEFAULT 0xffff
37
 #define IB_PKEY_DEFAULT 0xffff
35
 
38
 

+ 3
- 2
src/include/gpxe/ipoib.h View File

17
 struct ipoib_mac {
17
 struct ipoib_mac {
18
 	/** Queue pair number
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
 	/** Port GID */
24
 	/** Port GID */
24
 	struct ib_gid gid;
25
 	struct ib_gid gid;
25
 } __attribute__ (( packed ));
26
 } __attribute__ (( packed ));

Loading…
Cancel
Save