14a2361dfSScott Branden /* SPDX-License-Identifier: BSD-3-Clause 2e6e8f03eSRandy Schacher * Copyright(c) 2014-2023 Broadcom 34a2361dfSScott Branden * All rights reserved. 44a2361dfSScott Branden */ 54a2361dfSScott Branden 64a2361dfSScott Branden #include <inttypes.h> 772aaa312SKalesh AP #include <rte_ether.h> 84a2361dfSScott Branden 94a2361dfSScott Branden #include "bnxt_util.h" 104a2361dfSScott Branden bnxt_check_zero_bytes(const uint8_t * bytes,int len)114a2361dfSScott Brandenint bnxt_check_zero_bytes(const uint8_t *bytes, int len) 124a2361dfSScott Branden { 134a2361dfSScott Branden int i; 144a2361dfSScott Branden 154a2361dfSScott Branden for (i = 0; i < len; i++) 164a2361dfSScott Branden if (bytes[i] != 0x00) 174a2361dfSScott Branden return 0; 184a2361dfSScott Branden return 1; 194a2361dfSScott Branden } 2072aaa312SKalesh AP bnxt_eth_hw_addr_random(uint8_t * mac_addr)2172aaa312SKalesh APvoid bnxt_eth_hw_addr_random(uint8_t *mac_addr) 2272aaa312SKalesh AP { 2372aaa312SKalesh AP rte_eth_random_addr(mac_addr); 2472aaa312SKalesh AP 2572aaa312SKalesh AP /* Set Organizationally Unique Identifier (OUI) prefix */ 2672aaa312SKalesh AP mac_addr[0] = 0x00; 2772aaa312SKalesh AP mac_addr[1] = 0x0a; 2872aaa312SKalesh AP mac_addr[2] = 0xf7; 2972aaa312SKalesh AP } 30*fe2f715cSAjit Khaparde hweight32(uint32_t word32)31*fe2f715cSAjit Khapardeuint8_t hweight32(uint32_t word32) 32*fe2f715cSAjit Khaparde { 33*fe2f715cSAjit Khaparde uint32_t res = word32 - ((word32 >> 1) & 0x55555555); 34*fe2f715cSAjit Khaparde 35*fe2f715cSAjit Khaparde res = (res & 0x33333333) + ((res >> 2) & 0x33333333); 36*fe2f715cSAjit Khaparde res = (res + (res >> 4)) & 0x0F0F0F0F; 37*fe2f715cSAjit Khaparde res = res + (res >> 8); 38*fe2f715cSAjit Khaparde return (res + (res >> 16)) & 0x000000FF; 39*fe2f715cSAjit Khaparde } 40