ソースを参照

[ipoib] Expose the real broadcast MAC

The IPoIB broadcast MAC address varies according to the partition key.
Now that the broadcast MAC address is a property of the network device
rather than of the link layer, we can expose this real MAC address
directly.

The broadcast LID is now identified via a path record lookup; this is
marginally inefficient (since it was present in the MCMemberRecord
GetResponse), but avoids the need to special-case broadcasts when
constructing the address vector in ipoib_transmit().
tags/v0.9.8
Michael Brown 15年前
コミット
06ad481904
1個のファイルの変更37行の追加46行の削除
  1. 37
    46
      src/drivers/net/ipoib.c

+ 37
- 46
src/drivers/net/ipoib.c ファイルの表示

@@ -65,10 +65,8 @@ struct ipoib_device {
65 65
 	struct ib_queue_set data;
66 66
 	/** Data queue set */
67 67
 	struct ib_queue_set meta;
68
-	/** Broadcast GID */
69
-	struct ib_gid broadcast_gid;
70
-	/** Broadcast LID */
71
-	unsigned int broadcast_lid;
68
+	/** Broadcast MAC */
69
+	struct ipoib_mac broadcast;
72 70
 	/** Data queue key */
73 71
 	unsigned long data_qkey;
74 72
 	/** Attached to multicast group
@@ -254,9 +252,10 @@ static int ipoib_push ( struct net_device *netdev __unused,
254 252
  * @ret net_proto	Network-layer protocol, in network-byte order
255 253
  * @ret rc		Return status code
256 254
  */
257
-static int ipoib_pull ( struct net_device *netdev __unused,
255
+static int ipoib_pull ( struct net_device *netdev,
258 256
 			struct io_buffer *iobuf, const void **ll_dest,
259 257
 			const void **ll_source, uint16_t *net_proto ) {
258
+	struct ipoib_device *ipoib = netdev->priv;
260 259
 	struct ipoib_hdr *ipoib_hdr = iobuf->data;
261 260
 	struct ipoib_peer *dest;
262 261
 	struct ipoib_peer *source;
@@ -279,8 +278,8 @@ static int ipoib_pull ( struct net_device *netdev __unused,
279 278
 	ipoib_hdr->u.reserved = 0;
280 279
 
281 280
 	/* Fill in required fields */
282
-	*ll_dest = ( dest ? &dest->mac : &ipoib_broadcast );
283
-	*ll_source = ( source ? &source->mac : &ipoib_broadcast );
281
+	*ll_dest = ( dest ? &dest->mac : &ipoib->broadcast );
282
+	*ll_source = ( source ? &source->mac : &ipoib->broadcast );
284 283
 	*net_proto = ipoib_hdr->proto;
285 284
 
286 285
 	return 0;
@@ -331,6 +330,24 @@ struct ll_protocol ipoib_protocol __ll_protocol = {
331 330
 	.mc_hash	= ipoib_mc_hash,
332 331
 };
333 332
 
333
+/**
334
+ * Allocate IPoIB device
335
+ *
336
+ * @v priv_size		Size of driver private data
337
+ * @ret netdev		Network device, or NULL
338
+ */
339
+struct net_device * alloc_ipoibdev ( size_t priv_size ) {
340
+	struct net_device *netdev;
341
+
342
+	netdev = alloc_netdev ( priv_size );
343
+	if ( netdev ) {
344
+		netdev->ll_protocol = &ipoib_protocol;
345
+		netdev->ll_broadcast = ( uint8_t * ) &ipoib_broadcast;
346
+		netdev->max_pkt_len = IB_MAX_PAYLOAD_SIZE;
347
+	}
348
+	return netdev;
349
+}
350
+
334 351
 /****************************************************************************
335 352
  *
336 353
  * IPoIB network device
@@ -439,17 +456,10 @@ static int ipoib_transmit ( struct net_device *netdev,
439 456
 	av.qpn = ntohl ( dest->mac.qpn );
440 457
 	av.qkey = ipoib->data_qkey;
441 458
 	av.gid_present = 1;
442
-	if ( av.qpn == IB_QPN_BROADCAST ) {
443
-		/* Broadcast */
444
-		av.lid = ipoib->broadcast_lid;
445
-		memcpy ( &av.gid, &ipoib->broadcast_gid, sizeof ( av.gid ) );
446
-	} else {
447
-		/* Unicast */
448
-		memcpy ( &av.gid, &dest->mac.gid, sizeof ( av.gid ) );
449
-		if ( ( rc = ib_resolve_path ( ibdev, &av ) ) != 0 ) {
450
-			/* Path not resolved yet */
451
-			return rc;
452
-		}
459
+	memcpy ( &av.gid, &dest->mac.gid, sizeof ( av.gid ) );
460
+	if ( ( rc = ib_resolve_path ( ibdev, &av ) ) != 0 ) {
461
+		/* Path not resolved yet */
462
+		return rc;
453 463
 	}
454 464
 
455 465
 	return ib_post_send ( ibdev, ipoib->data.qp, &av, iobuf );
@@ -554,10 +564,8 @@ static void ipoib_recv_mc_member_record ( struct ipoib_device *ipoib,
554 564
 	/* Record parameters */
555 565
 	joined = ( mc_member_record->scope__join_state & 0x0f );
556 566
 	ipoib->data_qkey = ntohl ( mc_member_record->qkey );
557
-	ipoib->broadcast_lid = ntohs ( mc_member_record->mlid );
558
-	DBGC ( ipoib, "IPoIB %p %s broadcast group: qkey %lx mlid %x\n",
559
-	       ipoib, ( joined ? "joined" : "left" ), ipoib->data_qkey,
560
-	       ipoib->broadcast_lid );
567
+	DBGC ( ipoib, "IPoIB %p %s broadcast group: qkey %lx\n",
568
+	       ipoib, ( joined ? "joined" : "left" ), ipoib->data_qkey );
561 569
 
562 570
 	/* Update data queue pair qkey */
563 571
 	if ( ( rc = ib_modify_qp ( ipoib->ibdev, ipoib->data.qp,
@@ -666,7 +674,7 @@ static int ipoib_join_broadcast_group ( struct ipoib_device *ipoib ) {
666 674
 	/* Attach data queue to broadcast multicast GID */
667 675
 	assert ( ipoib->broadcast_attached == 0 );
668 676
 	if ( ( rc = ib_mcast_attach ( ipoib->ibdev, ipoib->data.qp,
669
-				      &ipoib->broadcast_gid ) ) != 0 ){
677
+				      &ipoib->broadcast.gid ) ) != 0 ){
670 678
 		DBGC ( ipoib, "IPoIB %p could not attach to broadcast GID: "
671 679
 		       "%s\n", ipoib, strerror ( rc ) );
672 680
 		return rc;
@@ -674,7 +682,7 @@ static int ipoib_join_broadcast_group ( struct ipoib_device *ipoib ) {
674 682
 	ipoib->broadcast_attached = 1;
675 683
 
676 684
 	/* Initiate broadcast group join */
677
-	if ( ( rc = ipoib_mc_member_record ( ipoib, &ipoib->broadcast_gid,
685
+	if ( ( rc = ipoib_mc_member_record ( ipoib, &ipoib->broadcast.gid,
678 686
 					     1 ) ) != 0 ) {
679 687
 		DBGC ( ipoib, "IPoIB %p could not send broadcast join: %s\n",
680 688
 		       ipoib, strerror ( rc ) );
@@ -699,7 +707,7 @@ static void ipoib_leave_broadcast_group ( struct ipoib_device *ipoib ) {
699 707
 	if ( ipoib->broadcast_attached ) {
700 708
 		assert ( ipoib->data.qp != NULL );
701 709
 		ib_mcast_detach ( ipoib->ibdev, ipoib->data.qp,
702
-				  &ipoib->broadcast_gid );
710
+				  &ipoib->broadcast.gid );
703 711
 		ipoib->broadcast_attached = 0;
704 712
 	}
705 713
 }
@@ -825,9 +833,9 @@ static void ipoib_set_ib_params ( struct ipoib_device *ipoib ) {
825 833
 	memcpy ( &mac->gid, &ibdev->gid, sizeof ( mac->gid ) );
826 834
 
827 835
 	/* Calculate broadcast GID based on partition key */
828
-	memcpy ( &ipoib->broadcast_gid, &ipoib_broadcast.gid,
829
-		 sizeof ( ipoib->broadcast_gid ) );
830
-	ipoib->broadcast_gid.u.words[2] = htons ( ibdev->pkey );
836
+	memcpy ( &ipoib->broadcast, &ipoib_broadcast,
837
+		 sizeof ( ipoib->broadcast ) );
838
+	ipoib->broadcast.gid.u.words[2] = htons ( ibdev->pkey );
831 839
 
832 840
 	/* Set net device link state to reflect Infiniband link state */
833 841
 	if ( ib_link_ok ( ibdev ) ) {
@@ -882,6 +890,7 @@ int ipoib_probe ( struct ib_device *ibdev ) {
882 890
 	ipoib = netdev->priv;
883 891
 	ib_set_ownerdata ( ibdev, netdev );
884 892
 	netdev->dev = ibdev->dev;
893
+	netdev->ll_broadcast = ( ( uint8_t * ) &ipoib->broadcast );
885 894
 	memset ( ipoib, 0, sizeof ( *ipoib ) );
886 895
 	ipoib->netdev = netdev;
887 896
 	ipoib->ibdev = ibdev;
@@ -916,21 +925,3 @@ void ipoib_remove ( struct ib_device *ibdev ) {
916 925
 	netdev_nullify ( netdev );
917 926
 	netdev_put ( netdev );
918 927
 }
919
-
920
-/**
921
- * Allocate IPoIB device
922
- *
923
- * @v priv_size		Size of driver private data
924
- * @ret netdev		Network device, or NULL
925
- */
926
-struct net_device * alloc_ipoibdev ( size_t priv_size ) {
927
-	struct net_device *netdev;
928
-
929
-	netdev = alloc_netdev ( priv_size );
930
-	if ( netdev ) {
931
-		netdev->ll_protocol = &ipoib_protocol;
932
-		netdev->ll_broadcast = ( uint8_t * ) &ipoib_broadcast;
933
-		netdev->max_pkt_len = IB_MAX_PAYLOAD_SIZE;
934
-	}
935
-	return netdev;
936
-}

読み込み中…
キャンセル
保存