Переглянути джерело

[ipoib] Avoid unnecessary path record lookup for broadcast address

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 роки тому
джерело
коміт
ffdf8ea757
1 змінених файлів з 27 додано та 15 видалено
  1. 27
    15
      src/drivers/net/ipoib.c

+ 27
- 15
src/drivers/net/ipoib.c Переглянути файл

@@ -503,8 +503,10 @@ static int ipoib_transmit ( struct net_device *netdev,
503 503
 	struct ethhdr *ethhdr;
504 504
 	struct iphdr *iphdr;
505 505
 	struct ipoib_hdr *ipoib_hdr;
506
+	struct ipoib_remac *remac;
506 507
 	struct ipoib_mac *mac;
507
-	struct ib_address_vector dest;
508
+	struct ib_address_vector *dest;
509
+	struct ib_address_vector av;
508 510
 	uint16_t net_proto;
509 511
 	int rc;
510 512
 
@@ -522,12 +524,32 @@ static int ipoib_transmit ( struct net_device *netdev,
522 524
 
523 525
 	/* Strip eIPoIB header */
524 526
 	ethhdr = iobuf->data;
527
+	remac = ( ( struct ipoib_remac * ) ethhdr->h_dest );
525 528
 	net_proto = ethhdr->h_protocol;
526 529
 	iob_pull ( iobuf, sizeof ( *ethhdr ) );
527 530
 
528 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 553
 		/* Generate a new ARP request (if possible) to trigger
532 554
 		 * population of the REMAC cache entry.
533 555
 		 */
@@ -564,18 +586,8 @@ static int ipoib_transmit ( struct net_device *netdev,
564 586
 	ipoib_hdr->proto = net_proto;
565 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
 /**

Завантаження…
Відмінити
Зберегти