From: Viktor Barna <viktor.barna@xxxxxxxxxx> (Part of the split. Please, take a look at the cover letter for more details). Signed-off-by: Viktor Barna <viktor.barna@xxxxxxxxxx> --- drivers/net/wireless/celeno/cl8k/mac_addr.h | 67 +++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 drivers/net/wireless/celeno/cl8k/mac_addr.h diff --git a/drivers/net/wireless/celeno/cl8k/mac_addr.h b/drivers/net/wireless/celeno/cl8k/mac_addr.h new file mode 100644 index 000000000000..6cd264c32f58 --- /dev/null +++ b/drivers/net/wireless/celeno/cl8k/mac_addr.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: MIT */ +/* Copyright(c) 2019-2021, Celeno Communications Ltd. */ + +#ifndef CL_MAC_ADDR_H +#define CL_MAC_ADDR_H + +#include "hw.h" + +int cl_mac_addr_set(struct cl_hw *cl_hw); + +static inline void cl_mac_addr_copy(u8 *dest_addr, const u8 *src_addr) +{ + memcpy(dest_addr, src_addr, ETH_ALEN); +} + +static inline void cl_mac_addr_move(u8 *dest_addr, const u8 *src_addr) +{ + memmove(dest_addr, src_addr, ETH_ALEN); +} + +static inline bool cl_mac_addr_compare(const u8 *addr1, const u8 *addr2) +{ + return !memcmp(addr1, addr2, ETH_ALEN); +} + +static inline bool cl_mac_addr_is_zero(const u8 *addr) +{ + const u8 addr_zero[ETH_ALEN] = {0}; + + return !memcmp(addr, addr_zero, ETH_ALEN); +} + +static inline bool cl_mac_addr_is_broadcast(const u8 *addr) +{ + const u8 addr_bcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + return !memcmp(addr, addr_bcast, ETH_ALEN); +} + +static inline bool cl_mac_addr_parse_str(const u8 *str, u8 *addr) +{ + return (sscanf(str, + "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", + &addr[0], + &addr[1], + &addr[2], + &addr[3], + &addr[4], + &addr[5]) == ETH_ALEN); +} + +static inline void cl_mac_addr_array_to_nxmac(u8 *array, u32 *low, u32 *high) +{ + /* Convert mac address (in a form of array) to a C nxmac form. + * Input: array - MAC address + * Output: low - array[0..3], high - array[4..5] + */ + u8 i; + + for (i = 0; i < 4; i++) + *low |= (u32)(((u32)array[i]) << (i * 8)); + + for (i = 0; i < 2; i++) + *high |= (u32)(((u32)array[i + 4]) << (i * 8)); +} + +#endif /* CL_MAC_ADDR_H */ -- 2.30.0 ________________________________ The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any retransmission, dissemination, copying or other use of, or taking of any action in reliance upon this information is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Nothing contained herein shall be deemed as a representation, warranty or a commitment by Celeno. No warranties are expressed or implied, including, but not limited to, any implied warranties of non-infringement, merchantability and fitness for a particular purpose. ________________________________