Browse Source

[ipoib] Avoid unnecessary path record lookup for broadcast address

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
ffdf8ea757
1 changed files with 27 additions and 15 deletions
  1. 27
    15
      src/drivers/net/ipoib.c

+ 27
- 15
src/drivers/net/ipoib.c View File

503
 	struct ethhdr *ethhdr;
503
 	struct ethhdr *ethhdr;
504
 	struct iphdr *iphdr;
504
 	struct iphdr *iphdr;
505
 	struct ipoib_hdr *ipoib_hdr;
505
 	struct ipoib_hdr *ipoib_hdr;
506
+	struct ipoib_remac *remac;
506
 	struct ipoib_mac *mac;
507
 	struct ipoib_mac *mac;
507
-	struct ib_address_vector dest;
508
+	struct ib_address_vector *dest;
509
+	struct ib_address_vector av;
508
 	uint16_t net_proto;
510
 	uint16_t net_proto;
509
 	int rc;
511
 	int rc;
510
 
512
 
522
 
524
 
523
 	/* Strip eIPoIB header */
525
 	/* Strip eIPoIB header */
524
 	ethhdr = iobuf->data;
526
 	ethhdr = iobuf->data;
527
+	remac = ( ( struct ipoib_remac * ) ethhdr->h_dest );
525
 	net_proto = ethhdr->h_protocol;
528
 	net_proto = ethhdr->h_protocol;
526
 	iob_pull ( iobuf, sizeof ( *ethhdr ) );
529
 	iob_pull ( iobuf, sizeof ( *ethhdr ) );
527
 
530
 
528
 	/* Identify destination address */
531
 	/* Identify destination address */
529
-	mac = ipoib_find_remac ( ipoib, ( ( void * ) ethhdr->h_dest ) );
530
-	if ( ! mac ) {
532
+	if ( is_multicast_ether_addr ( remac ) ) {
533
+
534
+		/* Transmit multicasts as broadcasts, for simplicity */
535
+		dest = &ipoib->broadcast.av;
536
+
537
+	} else if ( ( mac = ipoib_find_remac ( ipoib, remac ) ) ) {
538
+
539
+		/* Construct address vector from IPoIB MAC */
540
+		dest = &av;
541
+		memset ( dest, 0, sizeof ( *dest ) );
542
+		dest->qpn = ( ntohl ( mac->flags__qpn ) & IB_QPN_MASK );
543
+		dest->qkey = ipoib->broadcast.av.qkey;
544
+		dest->gid_present = 1;
545
+		memcpy ( &dest->gid, &mac->gid, sizeof ( dest->gid ) );
546
+		if ( ( rc = ib_resolve_path ( ibdev, dest ) ) != 0 ) {
547
+			/* Path not resolved yet */
548
+			return rc;
549
+		}
550
+
551
+	} else {
552
+
531
 		/* Generate a new ARP request (if possible) to trigger
553
 		/* Generate a new ARP request (if possible) to trigger
532
 		 * population of the REMAC cache entry.
554
 		 * population of the REMAC cache entry.
533
 		 */
555
 		 */
564
 	ipoib_hdr->proto = net_proto;
586
 	ipoib_hdr->proto = net_proto;
565
 	ipoib_hdr->reserved = 0;
587
 	ipoib_hdr->reserved = 0;
566
 
588
 
567
-	/* Construct address vector */
568
-	memset ( &dest, 0, sizeof ( dest ) );
569
-	dest.qpn = ( ntohl ( mac->flags__qpn ) & IB_QPN_MASK );
570
-	dest.qkey = ipoib->broadcast.av.qkey;
571
-	dest.gid_present = 1;
572
-	memcpy ( &dest.gid, &mac->gid, sizeof ( dest.gid ) );
573
-	if ( ( rc = ib_resolve_path ( ibdev, &dest ) ) != 0 ) {
574
-		/* Path not resolved yet */
575
-		return rc;
576
-	}
577
-
578
-	return ib_post_send ( ibdev, ipoib->qp, &dest, iobuf );
589
+	/* Transmit packet */
590
+	return ib_post_send ( ibdev, ipoib->qp, dest, iobuf );
579
 }
591
 }
580
 
592
 
581
 /**
593
 /**

Loading…
Cancel
Save