1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2014-2023 Broadcom 3 * All rights reserved. 4 */ 5 6 #include <inttypes.h> 7 #include <rte_ether.h> 8 9 #include "bnxt_util.h" 10 bnxt_check_zero_bytes(const uint8_t * bytes,int len)11int bnxt_check_zero_bytes(const uint8_t *bytes, int len) 12 { 13 int i; 14 15 for (i = 0; i < len; i++) 16 if (bytes[i] != 0x00) 17 return 0; 18 return 1; 19 } 20 bnxt_eth_hw_addr_random(uint8_t * mac_addr)21void bnxt_eth_hw_addr_random(uint8_t *mac_addr) 22 { 23 rte_eth_random_addr(mac_addr); 24 25 /* Set Organizationally Unique Identifier (OUI) prefix */ 26 mac_addr[0] = 0x00; 27 mac_addr[1] = 0x0a; 28 mac_addr[2] = 0xf7; 29 } 30 hweight32(uint32_t word32)31uint8_t hweight32(uint32_t word32) 32 { 33 uint32_t res = word32 - ((word32 >> 1) & 0x55555555); 34 35 res = (res & 0x33333333) + ((res >> 2) & 0x33333333); 36 res = (res + (res >> 4)) & 0x0F0F0F0F; 37 res = res + (res >> 8); 38 return (res + (res >> 16)) & 0x000000FF; 39 } 40