summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2016-06-03 10:17:19 +0000
committerhselasky <hselasky@FreeBSD.org>2016-06-03 10:17:19 +0000
commit4e2e9d9fb63d3ba974cfdce889ec15bd7f0ba9e5 (patch)
treed22d0533bc4851648817d612dddb44cc4b177875
parentab2c64021c766d04e254fb15013c06ec9bade6d5 (diff)
downloadFreeBSD-src-4e2e9d9fb63d3ba974cfdce889ec15bd7f0ba9e5.zip
FreeBSD-src-4e2e9d9fb63d3ba974cfdce889ec15bd7f0ba9e5.tar.gz
MFC r294832:
Implement ether_addr_equal(), ether_addr_equal_64bits() and random_ether_addr() for the LinuxKPI. Sponsored by: Mellanox Technologies
-rw-r--r--sys/ofed/include/linux/etherdevice.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/sys/ofed/include/linux/etherdevice.h b/sys/ofed/include/linux/etherdevice.h
index c50dc5d..a975bd0 100644
--- a/sys/ofed/include/linux/etherdevice.h
+++ b/sys/ofed/include/linux/etherdevice.h
@@ -37,6 +37,9 @@
#include <linux/types.h>
+#include <sys/random.h>
+#include <sys/libkern.h>
+
#define ETH_MODULE_SFF_8079 1
#define ETH_MODULE_SFF_8079_LEN 256
#define ETH_MODULE_SFF_8472 2
@@ -113,4 +116,31 @@ static inline void ether_addr_copy(u8 *dst, const u8 *src)
memcpy(dst, src, 6);
}
+static inline bool
+ether_addr_equal(const u8 *pa, const u8 *pb)
+{
+ return (memcmp(pa, pb, 6) == 0);
+}
+
+static inline bool
+ether_addr_equal_64bits(const u8 *pa, const u8 *pb)
+{
+ return (memcmp(pa, pb, 6) == 0);
+}
+
+static inline void
+eth_broadcast_addr(u8 *pa)
+{
+ memset(pa, 0xff, 6);
+}
+
+static inline void
+random_ether_addr(u8 * dst)
+{
+ read_random(dst, 6);
+
+ dst[0] &= 0xfe;
+ dst[0] |= 0x02;
+}
+
#endif /* _LINUX_ETHERDEVICE */
OpenPOWER on IntegriCloud