diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2017-09-17 18:58:13 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2017-09-21 15:18:24 +0200 |
commit | 8bfe0960dc2d33f15c6098945d36ebed5e5b5434 (patch) | |
tree | 732d84b54847c107e65ff7c68e1929d660af6d53 | |
parent | 67d44a18bd3143e28f6b2a8038100585a2d596cb (diff) |
header: add ether_addr_to_u64() and u64_to_ether_addr()v4.14-rc2-1
These function were added in commit 5952758101 ("dsa: mv88e6xxx:
Optimise atu_get") and are now used by mwifiex.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | backport/backport-include/linux/etherdevice.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/backport/backport-include/linux/etherdevice.h b/backport/backport-include/linux/etherdevice.h index 92256e00..a00e6660 100644 --- a/backport/backport-include/linux/etherdevice.h +++ b/backport/backport-include/linux/etherdevice.h @@ -193,4 +193,38 @@ static inline int eth_skb_pad(struct sk_buff *skb) } #endif /* LINUX_VERSION_IS_LESS(3,19,0) */ +#if LINUX_VERSION_IS_LESS(4,11,0) +/** + * ether_addr_to_u64 - Convert an Ethernet address into a u64 value. + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Return a u64 value of the address + */ +static inline u64 ether_addr_to_u64(const u8 *addr) +{ + u64 u = 0; + int i; + + for (i = 0; i < ETH_ALEN; i++) + u = u << 8 | addr[i]; + + return u; +} + +/** + * u64_to_ether_addr - Convert a u64 to an Ethernet address. + * @u: u64 to convert to an Ethernet MAC address + * @addr: Pointer to a six-byte array to contain the Ethernet address + */ +static inline void u64_to_ether_addr(u64 u, u8 *addr) +{ + int i; + + for (i = ETH_ALEN - 1; i >= 0; i--) { + addr[i] = u & 0xff; + u = u >> 8; + } +} +#endif /* LINUX_VERSION_IS_LESS(4,11,0) */ + #endif /* _BACKPORT_LINUX_ETHERDEVICE_H */ |