--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef __LINUX_COMPAT_H_
+#define __LINUX_COMPAT_H_
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <endian.h>
+#include <linux/types.h>
+
+#include "kernel.h"
+
+#define be16_to_cpu(x) be16toh(x)
+#define cpu_to_be16(x) htobe16(x)
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+typedef unsigned long ulong;
+
+#define simple_strtoul strtoul
+
+void log_err(const char *format, ...);
+void log_fail(const char *format, ...);
+#define log_debug printf
+
+static inline ulong hextoul(const char *cp, char **endp)
+{
+ return strtoul(cp, endp, 16);
+}
+
+/* From U-Boot net-common.h */
+
+/**
+ * is_zero_ethaddr - Determine if give Ethernet address is all zeros.
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Return true if the address is all zeroes.
+ */
+static inline int is_zero_ethaddr(const u8 *addr)
+{
+ return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
+}
+
+/**
+ * is_multicast_ethaddr - Determine if the Ethernet address is a multicast.
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Return true if the address is a multicast address.
+ * By definition the broadcast address is also a multicast address.
+ */
+static inline int is_multicast_ethaddr(const u8 *addr)
+{
+ return 0x01 & addr[0];
+}
+
+/*
+ * is_valid_ethaddr - Determine if the given Ethernet address is valid
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not
+ * a multicast address, and is not FF:FF:FF:FF:FF:FF.
+ *
+ * Return true if the address is valid.
+ */
+static inline int is_valid_ethaddr(const u8 *addr)
+{
+ /* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to
+ * explicitly check for it here. */
+ return !is_multicast_ethaddr(addr) && !is_zero_ethaddr(addr);
+}
+
+#endif /* __LINUX_COMPAT_H_ */