aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/etherdevice.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/etherdevice.h')
-rw-r--r--include/linux/etherdevice.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index 2308fbb4523..f16a01081e1 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -71,7 +71,7 @@ static inline int is_zero_ether_addr(const u8 *addr)
71 */ 71 */
72static inline int is_multicast_ether_addr(const u8 *addr) 72static inline int is_multicast_ether_addr(const u8 *addr)
73{ 73{
74 return (0x01 & addr[0]); 74 return 0x01 & addr[0];
75} 75}
76 76
77/** 77/**
@@ -82,7 +82,7 @@ static inline int is_multicast_ether_addr(const u8 *addr)
82 */ 82 */
83static inline int is_local_ether_addr(const u8 *addr) 83static inline int is_local_ether_addr(const u8 *addr)
84{ 84{
85 return (0x02 & addr[0]); 85 return 0x02 & addr[0];
86} 86}
87 87
88/** 88/**
@@ -237,13 +237,29 @@ static inline bool is_etherdev_addr(const struct net_device *dev,
237 * entry points. 237 * entry points.
238 */ 238 */
239 239
240static inline int compare_ether_header(const void *a, const void *b) 240static inline unsigned long compare_ether_header(const void *a, const void *b)
241{ 241{
242#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
243 unsigned long fold;
244
245 /*
246 * We want to compare 14 bytes:
247 * [a0 ... a13] ^ [b0 ... b13]
248 * Use two long XOR, ORed together, with an overlap of two bytes.
249 * [a0 a1 a2 a3 a4 a5 a6 a7 ] ^ [b0 b1 b2 b3 b4 b5 b6 b7 ] |
250 * [a6 a7 a8 a9 a10 a11 a12 a13] ^ [b6 b7 b8 b9 b10 b11 b12 b13]
251 * This means the [a6 a7] ^ [b6 b7] part is done two times.
252 */
253 fold = *(unsigned long *)a ^ *(unsigned long *)b;
254 fold |= *(unsigned long *)(a + 6) ^ *(unsigned long *)(b + 6);
255 return fold;
256#else
242 u32 *a32 = (u32 *)((u8 *)a + 2); 257 u32 *a32 = (u32 *)((u8 *)a + 2);
243 u32 *b32 = (u32 *)((u8 *)b + 2); 258 u32 *b32 = (u32 *)((u8 *)b + 2);
244 259
245 return (*(u16 *)a ^ *(u16 *)b) | (a32[0] ^ b32[0]) | 260 return (*(u16 *)a ^ *(u16 *)b) | (a32[0] ^ b32[0]) |
246 (a32[1] ^ b32[1]) | (a32[2] ^ b32[2]); 261 (a32[1] ^ b32[1]) | (a32[2] ^ b32[2]);
262#endif
247} 263}
248 264
249#endif /* _LINUX_ETHERDEVICE_H */ 265#endif /* _LINUX_ETHERDEVICE_H */