]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/linux/etherdevice.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph...
[karo-tx-linux.git] / include / linux / etherdevice.h
index 606563ef8a725e54d27db855c63dad948f3ce815..9012f877520802662fb5f3704c60ef24d09c7136 100644 (file)
@@ -110,7 +110,29 @@ static inline bool is_zero_ether_addr(const u8 *addr)
  */
 static inline bool is_multicast_ether_addr(const u8 *addr)
 {
-       return 0x01 & addr[0];
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+       u32 a = *(const u32 *)addr;
+#else
+       u16 a = *(const u16 *)addr;
+#endif
+#ifdef __BIG_ENDIAN
+       return 0x01 & (a >> ((sizeof(a) * 8) - 8));
+#else
+       return 0x01 & a;
+#endif
+}
+
+static inline bool is_multicast_ether_addr_64bits(const u8 addr[6+2])
+{
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
+#ifdef __BIG_ENDIAN
+       return 0x01 & ((*(const u64 *)addr) >> 56);
+#else
+       return 0x01 & (*(const u64 *)addr);
+#endif
+#else
+       return is_multicast_ether_addr(addr);
+#endif
 }
 
 /**
@@ -168,6 +190,24 @@ static inline bool is_valid_ether_addr(const u8 *addr)
        return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
 }
 
+/**
+ * eth_proto_is_802_3 - Determine if a given Ethertype/length is a protocol
+ * @proto: Ethertype/length value to be tested
+ *
+ * Check that the value from the Ethertype/length field is a valid Ethertype.
+ *
+ * Return true if the valid is an 802.3 supported Ethertype.
+ */
+static inline bool eth_proto_is_802_3(__be16 proto)
+{
+#ifndef __BIG_ENDIAN
+       /* if CPU is little endian mask off bits representing LSB */
+       proto &= htons(0xFF00);
+#endif
+       /* cast both to u16 and compare since LSB can be ignored */
+       return (__force u16)proto >= (__force u16)htons(ETH_P_802_3_MIN);
+}
+
 /**
  * eth_random_addr - Generate software assigned random Ethernet address
  * @addr: Pointer to a six-byte array containing the Ethernet address