net/ice/base: support 32-bit hamming weight
authorLeyi Rong <leyi.rong@intel.com>
Wed, 19 Jun 2019 15:18:01 +0000 (23:18 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 28 Jun 2019 18:31:48 +0000 (20:31 +0200)
Add function support for hweight32.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Signed-off-by: Leyi Rong <leyi.rong@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/ice/base/ice_osdep.h

index d2d9238..ede893f 100644 (file)
@@ -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)