From: Leyi Rong Date: Wed, 19 Jun 2019 15:18:01 +0000 (+0800) Subject: net/ice/base: support 32-bit hamming weight X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8c98bf7e45286d52c44f7e02274d56f4b3398a68;p=dpdk.git net/ice/base: support 32-bit hamming weight Add function support for hweight32. Signed-off-by: Qi Zhang Signed-off-by: Leyi Rong Acked-by: Qi Zhang --- diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h index d2d9238c7c..ede893fc93 100644 --- a/drivers/net/ice/base/ice_osdep.h +++ b/drivers/net/ice/base/ice_osdep.h @@ -267,6 +267,20 @@ ice_hweight8(u32 num) return bits; } +static inline u8 +ice_hweight32(u32 num) +{ + u8 bits = 0; + u32 i; + + for (i = 0; i < 32; i++) { + bits += (u8)(num & 0x1); + num >>= 1; + } + + return bits; +} + #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) #define DELAY(x) rte_delay_us(x) #define ice_usec_delay(x) rte_delay_us(x)