diff options
author | Joe Perches <joe@perches.com> | 2012-05-09 13:04:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-05-10 23:33:01 -0400 |
commit | baf523c9ba4a69e97b0b5a6fb0e0a9e43550a65b (patch) | |
tree | 9c0a9ba3234ceecf51f292bb2089ce787d993b8b /include/linux/etherdevice.h | |
parent | 2e42e4747ea72943c21551d8a206b51a9893b1e0 (diff) |
etherdevice.h: Add ether_addr_equal_64bits
Add an optimized boolean function to check if
2 ethernet addresses are the same.
This is to avoid any confusion about compare_ether_addr_64bits
returning an unsigned, and not being able to use the
compare_ether_addr_64bits function for sorting ala memcmp.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/etherdevice.h')
-rw-r--r-- | include/linux/etherdevice.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index f3301140d28a..afacf8576d0f 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h | |||
@@ -225,6 +225,26 @@ static inline unsigned compare_ether_addr_64bits(const u8 addr1[6+2], | |||
225 | } | 225 | } |
226 | 226 | ||
227 | /** | 227 | /** |
228 | * ether_addr_equal_64bits - Compare two Ethernet addresses | ||
229 | * @addr1: Pointer to an array of 8 bytes | ||
230 | * @addr2: Pointer to an other array of 8 bytes | ||
231 | * | ||
232 | * Compare two ethernet addresses, returns true if equal, false otherwise. | ||
233 | * | ||
234 | * The function doesn't need any conditional branches and possibly uses | ||
235 | * word memory accesses on CPU allowing cheap unaligned memory reads. | ||
236 | * arrays = { byte1, byte2, byte3, byte4, byte6, byte7, pad1, pad2} | ||
237 | * | ||
238 | * Please note that alignment of addr1 & addr2 is only guaranted to be 16 bits. | ||
239 | */ | ||
240 | |||
241 | static inline bool ether_addr_equal_64bits(const u8 addr1[6+2], | ||
242 | const u8 addr2[6+2]) | ||
243 | { | ||
244 | return !compare_ether_addr_64bits(addr1, addr2); | ||
245 | } | ||
246 | |||
247 | /** | ||
228 | * is_etherdev_addr - Tell if given Ethernet address belongs to the device. | 248 | * is_etherdev_addr - Tell if given Ethernet address belongs to the device. |
229 | * @dev: Pointer to a device structure | 249 | * @dev: Pointer to a device structure |
230 | * @addr: Pointer to a six-byte array containing the Ethernet address | 250 | * @addr: Pointer to a six-byte array containing the Ethernet address |