]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ipoib] Avoid unnecessary path record lookup for broadcast address
authorMichael Brown <mcb30@ipxe.org>
Tue, 8 Mar 2016 10:06:24 +0000 (10:06 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 8 Mar 2016 12:23:30 +0000 (12:23 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/net/ipoib.c

index 8bad2b2a2020f43933181361b906727b5a93221a..d8c4efad58948c84eec929069dc13f2eba2fa754 100644 (file)
@@ -503,8 +503,10 @@ static int ipoib_transmit ( struct net_device *netdev,
        struct ethhdr *ethhdr;
        struct iphdr *iphdr;
        struct ipoib_hdr *ipoib_hdr;
+       struct ipoib_remac *remac;
        struct ipoib_mac *mac;
-       struct ib_address_vector dest;
+       struct ib_address_vector *dest;
+       struct ib_address_vector av;
        uint16_t net_proto;
        int rc;
 
@@ -522,12 +524,32 @@ static int ipoib_transmit ( struct net_device *netdev,
 
        /* Strip eIPoIB header */
        ethhdr = iobuf->data;
+       remac = ( ( struct ipoib_remac * ) ethhdr->h_dest );
        net_proto = ethhdr->h_protocol;
        iob_pull ( iobuf, sizeof ( *ethhdr ) );
 
        /* Identify destination address */
-       mac = ipoib_find_remac ( ipoib, ( ( void * ) ethhdr->h_dest ) );
-       if ( ! mac ) {
+       if ( is_multicast_ether_addr ( remac ) ) {
+
+               /* Transmit multicasts as broadcasts, for simplicity */
+               dest = &ipoib->broadcast.av;
+
+       } else if ( ( mac = ipoib_find_remac ( ipoib, remac ) ) ) {
+
+               /* Construct address vector from IPoIB MAC */
+               dest = &av;
+               memset ( dest, 0, sizeof ( *dest ) );
+               dest->qpn = ( ntohl ( mac->flags__qpn ) & IB_QPN_MASK );
+               dest->qkey = ipoib->broadcast.av.qkey;
+               dest->gid_present = 1;
+               memcpy ( &dest->gid, &mac->gid, sizeof ( dest->gid ) );
+               if ( ( rc = ib_resolve_path ( ibdev, dest ) ) != 0 ) {
+                       /* Path not resolved yet */
+                       return rc;
+               }
+
+       } else {
+
                /* Generate a new ARP request (if possible) to trigger
                 * population of the REMAC cache entry.
                 */
@@ -564,18 +586,8 @@ static int ipoib_transmit ( struct net_device *netdev,
        ipoib_hdr->proto = net_proto;
        ipoib_hdr->reserved = 0;
 
-       /* Construct address vector */
-       memset ( &dest, 0, sizeof ( dest ) );
-       dest.qpn = ( ntohl ( mac->flags__qpn ) & IB_QPN_MASK );
-       dest.qkey = ipoib->broadcast.av.qkey;
-       dest.gid_present = 1;
-       memcpy ( &dest.gid, &mac->gid, sizeof ( dest.gid ) );
-       if ( ( rc = ib_resolve_path ( ibdev, &dest ) ) != 0 ) {
-               /* Path not resolved yet */
-               return rc;
-       }
-
-       return ib_post_send ( ibdev, ipoib->qp, &dest, iobuf );
+       /* Transmit packet */
+       return ib_post_send ( ibdev, ipoib->qp, dest, iobuf );
 }
 
 /**