]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/etherdevice.h
[ETHERNET]: Optimize is_broadcast_ether_addr
[linux-2.6-omap-h63xx.git] / include / linux / etherdevice.h
index 4522c7186bf378de1c4162b042ad8a3b78fc09ac..17460c85df7b843e5b83fe3811bef33cbb45e5cc 100644 (file)
@@ -71,8 +71,7 @@ static inline int is_multicast_ether_addr(const u8 *addr)
 
 static inline int is_broadcast_ether_addr(const u8 *addr)
 {
-        return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&  
-               (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
+       return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) == 0xff;
 }
 
 /**
@@ -104,6 +103,22 @@ static inline void random_ether_addr(u8 *addr)
        addr [0] &= 0xfe;       /* clear multicast bit */
        addr [0] |= 0x02;       /* set local assignment bit (IEEE802) */
 }
+
+/**
+ * compare_ether_addr - Compare two Ethernet addresses
+ * @addr1: Pointer to a six-byte array containing the Ethernet address
+ * @addr2 Pointer other six-byte array containing the Ethernet address
+ *
+ * Compare two ethernet addresses, returns 0 if equal
+ */
+static inline unsigned compare_ether_addr(const u8 *_a, const u8 *_b)
+{
+       const u16 *a = (const u16 *) _a;
+       const u16 *b = (const u16 *) _b;
+
+       BUILD_BUG_ON(ETH_ALEN != 6);
+       return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
+}
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_ETHERDEVICE_H */